<%@ 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">
    <c:if test="${fnx:hasPrivilegeCode(role_privilege_codes, 'exam_mark-mark')}">
		<li><a href="${ctx}/admin/exam/mark?subjectCode=${subject.code}">评卷进度</a></li>
		</c:if>
		<c:if test="${fnx:hasPrivilegeCode(role_privilege_codes, 'exam_mark-group')}">
        <li><a href="${ctx}/admin/exam/group?subjectCode=${query.subjectCode}">分组管理</a></li>
        </c:if>
        <c:if test="${fnx:hasPrivilegeCode(role_privilege_codes, 'exam_mark-marker')}">
        <li><a href="${ctx}/admin/exam/marker?subjectCode=${query.subjectCode}">评卷员管理</a></li>
        </c:if>
        <c:if test="${fnx:hasPrivilegeCode(role_privilege_codes, 'exam_mark-trial')}">
        <li><a href="${ctx}/admin/exam/trial?subjectCode=${query.subjectCode}">试评管理</a></li>
        </c:if>
        <c:if test="${fnx:hasPrivilegeCode(role_privilege_codes, 'exam_mark-library')}">
        <li><a href="${ctx}/admin/exam/library?subjectCode=${query.subjectCode}">任务管理</a></li>
        </c:if>
        <c:if test="${fnx:hasPrivilegeCode(role_privilege_codes, 'exam_mark-arbitrate')}">
        <li><a href="${ctx}/admin/exam/arbitrate?subjectCode=${query.subjectCode}">仲裁管理</a></li>
        </c:if>
        <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">
            <option  value="" <c:if test="${query.groupNumber==null}">selected</c:if>>不限</option>
            </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>
				<th>标准差</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${query.result}" var="marker">
			<tr>
				<td><c:if test="${marker.group!=null}">
                    ${marker.group.number}-${marker.group.title}
                	</c:if>
                </td>
				<td>${marker.user.loginName}</td>
				<td>${marker.user.name}</td>
				<td>${marker.finishCount}</td>
				<td>${marker.rejectCount}</td>
				<td>
				<c:choose>
		        <c:when test="${marker.finishCount!=null && marker.rejectCount!=null && marker.finishCount>0 && (marker.finishCount-marker.rejectCount)>0}">
		        	<fmt:formatNumber type="percent" maxIntegerDigits="3" value="${(marker.finishCount-marker.rejectCount)/marker.finishCount}" />
		        </c:when>
		        <c:when test="${(marker.rejectCount==null||marker.rejectCount==0) && marker.finishCount!=null}">
		        	100%
		        </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');
        $('<option value="">不限</option>').appendTo(parent);
        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>