<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>评卷质量监控</title>
	<meta name="decorator" content="default"/>
	<%@include file="/WEB-INF/views/include/head.jsp" %>
	<style type="text/css">.sort{color:#0663A2;cursor:pointer;}</style>
</head>
<body>
    <ul class="nav nav-tabs">
        <li><a href="${ctx}/admin/exam/group?subjectCode=${query.subjectCode}">大题管理</a></li>
        <li><a href="${ctx}/admin/exam/marker?subjectCode=${query.subjectCode}">评卷员管理</a></li>
        <li><a href="${ctx}/admin/exam/trial?subjectCode=${query.subjectCode}">试评管理</a></li>
        <li><a href="${ctx}/admin/exam/library?subjectCode=${query.subjectCode}">任务管理</a></li>
        <li><a href="${ctx}/admin/exam/arbitrate?subjectCode=${query.subjectCode}">仲裁管理</a></li>
        <li class="active"><a href="##">质量监控</a></li>
    </ul>
    
	<form id="searchForm"  action="${ctx}/admin/exam/quality" method="post" class="breadcrumb form-search">
		<input type="hidden" id="pageNumber" name="pageNumber" value="${query.pageNumber}"/>
		<input type="hidden" id="pageSize" name="pageSize" value="${query.pageSize}"/>
		<div>
			<label>科目</label>
			<select class="input-large" id="subject-select" name="subjectCode">
				<c:forEach items="${subjectList}" var="subject">
				<option value="${subject.code}" <c:if test="${subject.code==query.subjectCode}">selected</c:if>>${subject.code}-${subject.name}</option>
				</c:forEach>
			</select>
			<label>大题</label>
            <select class="input-medium" id="group-select" name="groupNumber">
            </select>
			&nbsp;
			<input id="btnSubmit" class="btn btn-primary" type="button" value="查询" onclick="goSearch()"/>
			<c:if test="${running!=null}">
            &nbsp;
            <c:if test="${running==true}">
            <a href="##" class="btn disabled">正在计算</a>
            </c:if>
            <c:if test="${running==false}">
            <a href="##" class="btn" id="update-button">重新计算</a>
            <a href="##" class="btn" id="chart-button">给分曲线</a>
            </c:if>
            </c:if>
		</div>
	</form>
	<tags:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>评卷员</th>
				<th>姓名</th>
				<th>完成任务数</th>
				<th>有效评卷数</th>
				<th>评卷采用率</th>
				<th>评卷速度(秒)</th>
				<th>平均分</th>
				<th>标准差</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${query.result}" var="marker">
			<tr>
				<td>${marker.loginName}</td>
				<td>${marker.name}</td>
				<td>${marker.finishCount}</td>
				<td>${marker.validCount}</td>
				<td>
				<c:choose>
		        <c:when test="${marker.finishCount!=null && marker.validCount!=null && marker.finishCount>0}">
		        <fmt:formatNumber type="percent" maxIntegerDigits="3" value="${marker.validCount/marker.finishCount}" />
		        </c:when>
		        <c:otherwise>0%</c:otherwise>
		        </c:choose>
				</td>
				<td><fmt:formatNumber pattern="###.##" value="${marker.avgSpeed}"/></td>
				<td><fmt:formatNumber pattern="###.##" value="${marker.avgScore}"/></td>
				<td><fmt:formatNumber pattern="###.##" value="${marker.stdevScore}"/></td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${query}</div>
<script type="text/javascript">
var searchSubjectCode = '${query.subjectCode}';
var searchGroupNumber = '${query.groupNumber}';
$('#subject-select').change(function(){
    var code = $(this).val();
    $('#group-select').empty();
    $.post('${ctx}/admin/exam/group/query', {subjectCode: code}, function(result){
        var parent = $('#group-select');
        for(var i=0;i<result.length;i++){
            var group = result[i];
            var dom = $('<option value="'+group.number+'">'+group.number+'-'+group.title+'</option>').appendTo(parent);
        }
        if(searchSubjectCode==code) {
            parent.val(searchGroupNumber);
            parent.trigger('change');
        }
    });
});
$('#update-button').click(function(){
    var subjectCode = $('#subject-select').val();
    var groupNumber = $('#group-select').val();
    if(subjectCode=='') {
        alert('请选择科目');
        return false;
    }
    if(groupNumber=='') {
        alert('请选择大题');
        return false;
    }
    $(this).attr('href','${ctx}/admin/exam/quality/update?subjectCode='+subjectCode+'&groupNumber='+groupNumber);
    return true;
});
$('#chart-button').click(function(){
    var subjectCode = $('#subject-select').val();
    var groupNumber = $('#group-select').val();
    if(subjectCode=='') {
        alert('请选择科目');
        return false;
    }
    if(groupNumber=='') {
        alert('请选择大题');
        return false;
    }
    $(this).attr('href','${ctx}/admin/exam/quality/chart?subjectCode='+subjectCode+'&groupNumber='+groupNumber);
    return true;
});
function page(n,s){
	$("#pageNumber").val(n);
	$("#pageSize").val(s);
	$("#searchForm").submit();
	return false;
}
function goSearch(){
	$("#pageNumber").val(1);
	$("#pageSize").val('${query.pageSize}');
	$("#searchForm").submit();
	return false;
}    
$('#subject-select').trigger('change');
</script>	
</body>
</html>