<%@ 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>
	<form id="searchForm" action="${ctx}/admin/exam/tag" 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">
				<option value="">请选择</option>
				<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="0">请选择</option>
			</select>
			<label>标记类型</label>
			<select class="input-medium" name="tagId">
				<c:forEach items="${tagList}" var="tag">
				<option value="${tag.id}" <c:if test="${tag.id==query.tagId}">selected</c:if>>${tag.name}</option>
				</c:forEach>
			</select>
			<br/><br/>
			<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>
			</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.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" %>
	<%@include file="/WEB-INF/views/include/imageView.jsp" %>
<script type="text/javascript">
var searchSubjectCode = '${query.subjectCode}';
var searchGroupNumber = '${query.groupNumber}';
$(document).ready(function() {
    $('.sheet-link').click(function(){
    	initImagePopover($(this).attr('data-title'), '${imageServer}', $(this).attr('data-sheet-url'), $(this).attr('data-answer-url'));
    	return false;
    });
    $('.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();
        if(code==''){
            $('#group-select').empty();
            return;
        }
        $.post('${ctx}/admin/exam/group/query', {subjectCode: code}, function(result){
            var parent = $('#group-select');
            parent.empty();
            for(var i=0;i<result.length;i++){
                var group = result[i];
                $('<option value="'+group.number+'">'+group.number+'-'+group.title+'</option>').appendTo(parent);
            }
            if(searchSubjectCode==code && searchGroupNumber!=''){
                parent.val(searchGroupNumber);
            }
            parent.trigger('change');
        });
    });
    $('#subject-select').trigger('change');
});
function page(n,s){
	$("#pageNumber").val(n);
	$("#searchForm").attr('action', '${ctx}/admin/exam/tag');
	$("#searchForm").submit();
	return false;
}
function goSearch(){
	$("#pageNumber").val(1);
	$("#searchForm").attr('action', '${ctx}/admin/exam/tag');
	$("#searchForm").submit();
	return false;
}
function goExport(){
	$("#searchForm").attr('action', '${ctx}/admin/exam/tag/export');
	$("#searchForm").submit();
	return false;
}
</script>	
</body>
</html>