<%@ 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 class="active"><a href="##">任务管理</a></li>
        <li><a href="${ctx}/admin/exam/arbitrate?subjectCode=${query.subjectCode}">仲裁管理</a></li>
        <li><a href="${ctx}/admin/exam/quality?subjectCode=${query.subjectCode}">质量监控</a></li>
    </ul>
	<form id="searchForm" action="${ctx}/admin/exam/library" 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="item">
				<option value="${item.code}" <c:if test="${item.code==query.subjectCode}">selected</c:if>>${item.code}-${item.name}</option>
				</c:forEach>
			</select>
			<label>大题</label>
            <select class="input-medium" id="group-select" name="groupNumber">
                <c:forEach items="${groupList}" var="item">
                <option value="${item.number}" <c:if test="${item.number==query.groupNumber}">selected</c:if>>${item.number}-${item.title}</option>
                </c:forEach>
            </select>
            <label>状态</label>
            <select class="input-small" id="status-select" name="status">
                <option value="">不限</option>
                <c:forEach items="${statusList}" var="item">
                	 <option value="${item.value}" <c:if test="${item.value==status.value}">selected</c:if>>${item.name}</option>
                </c:forEach>
            </select>
            <label>评卷员</label>
            <select class="input-medium" id="marker-select" name="markerId">
                <option value="0">不限</option>
                <c:forEach items="${markerList}" var="item">
                <option value="${item.id}" <c:if test="${item.id==query.markerId}">selected</c:if>>${item.loginName}</option>
                </c:forEach>
            </select>
            <br/><br/>
            <label>准考证号</label>
            <input type="text" name="examNumber" value="${query.examNumber}" maxlength="20" class="input-medium"/>
			&nbsp;
			<label>考生编号</label>
            <input type="text" name="studentId" id="studentId" value="${query.studentId}" maxlength="10" class="input-medium"onkeyup="this.value=this.value.replace(/\D/g,'')"/>
            &nbsp;
			<input id="btnSubmit" class="btn btn-primary" type="button" value="查询" onclick="goSearch()"/>
		</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>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${query.result}" var="result">
			<tr>
				<td>${result.subjectCode}</td>
				<td>${result.groupNumber}</td>
				<td>${result.examNumber}</td>
				<td>${result.studentId}</td>
				<td>${result.status.name}</td>
                <td>
                    <c:if test="${result.marker!=null}">
                    ${result.marker.loginName}
                    </c:if>
                    <c:if test="${result.marker==null}">
                    &nbsp;
                    </c:if>
                </td>
				<td>
				    <c:if test="${result.markerScore!=null}">
				    <fmt:formatNumber pattern="###.#" value="${result.markerScore}"/>
				    </c:if>
				    <c:if test="${result.markerScore==null}">
				    &nbsp;
				    </c:if>
				</td>
				<td>
				    <c:if test="${result.markerScoreList!=null}">
                    ${result.markerScoreList}
                    </c:if>
                    <c:if test="${result.markerScoreList==null}">
                    &nbsp;
                    </c:if>
				</td>
				<td>
				    <c:if test="${result.markerTime!=null}">
                    <fmt:formatDate value="${result.markerTime}" pattern="yyyy-MM-dd HH:mm:ss" />
                    </c:if>
                    <c:if test="${result.markerTime==null}">
                    &nbsp;
                    </c:if>
				</td>
				<td>
				    <c:if test="${result.status.value==1 || result.status.value==3}">
				    <a class="track-link" href="##" data-image-url="${ctx}/admin/exam/track/byLibrary?libraryId=${result.id}" data-title="${result.examNumber}">阅卷轨迹</a>
				    </c:if>
				    <c:if test="${result.status.value==1}">
				    &nbsp;
                    <a href="##" data-id="${result.id}" class="back-link">打回</a>
					</c:if>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${query}</div>
	<%@include file="/WEB-INF/views/include/trackView.jsp" %>
<script type="text/javascript">
$('.back-link').click(function(){
	if(!confirm('确定要打回该评卷任务吗?')){
	    return;
	}
	$.post('${ctx}/admin/exam/library/back', {id: $(this).attr('data-id')}, function(result){
	    if(result.success==true){
            alert('打回成功');
            $("#searchForm").submit();
        }else{
            alert(result.message);
        }
	});
});
$('.track-link').click(function(){
    initTrackPopover($(this).attr('data-title'),$(this).attr('data-image-url'));
    return false;
});
$('#subject-select').change(function(){
    var code = $(this).val();
    $('#group-select').empty();
    if(code==''){
        $('#group-select').val('').trigger('change');
        return;
    }
    $.post('${ctx}/admin/exam/group/query', {subjectCode: code, status: 'FORMAL'}, function(result){
        var parent = $('#group-select');
        var first = '';
        for(var i=0;i<result.length;i++){
            var group = result[i];
            $('<option value="'+group.number+'">'+group.number+'-'+group.title+'</option>').appendTo(parent);
            if(i==0){
                first = group.number;
            }
        }
        parent.val(first).trigger('change');
    });
});
$('#group-select').change(function(){
    var subjectCode = $('#subject-select').val();
    var groupNumber = $('#group-select').val();
    $('#marker-select').empty();
    $('#marker-select').append('<option value="0">不限</option>');
    $('#marker-select').val('0').trigger('change');
    if(subjectCode=='' || groupNumber==''||groupNumber==null){
        return;
    }
    $.post('${ctx}/admin/exam/marker/query', {subjectCode: subjectCode, groupNumber: groupNumber}, function(result){
        var parent = $('#marker-select');
        var first = '';
        for(var i=0;i<result.length;i++){
            var marker = result[i];
            $('<option value="'+marker.id+'">'+marker.loginName+'</option>').appendTo(parent);
            if(i==0){
                first = marker.id;
            }
        }
        //parent.val(first).trigger('change');
    });
});
function page(n,s){
    $("#pageNumber").val(n);
    $("#pageSize").val(s);
    $("#searchForm").submit();
    return false;
}
function goSearch(){
    $("#pageNumber").val(1);
    var studentId = parseInt($("#studentId").val());
    if( $("#studentId").val()!="" && studentId>2147483647 ){
    	alert("考生编号不合法");
    }else{
	    $("#searchForm").submit();
    }
    return false;
}
</script>	
</body>
</html>