<%@ 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/score" 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>
			<input type="text" name="name" value="${query.name}"  maxlength="10" class="input-mini"/>
			<label>准考证号</label>
			<input type="text" name="examNumber" value="${query.examNumber}" maxlength="50" class="input-small"/>
			<label>学号</label>
			<input type="text" name="studentCode" value="${query.studentCode}" maxlength="30" class="input-small"/>
			<label>科目</label>
			<select class="input-large" name="subjectCode">
				<c:if test="${web_user.type.value==5}">
					<c:forEach items="${subjectList}" var="subject">
						<c:if test="${subject.code==subjectCode}">
						<option value="${subject.code}" >${subject.code}-${subject.name}</option>
						</c:if>
						</c:forEach>
					</c:if>
				<c:if test="${web_user.type.value==0 || web_user.type.value==6}">
					<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>
				</c:if>
			</select>
			<label>评卷账号</label>
			<input type="text" name="markLogin" value="${query.markLogin}"  maxlength="20" class="input-mini"/>
			<label>评卷姓名</label>
			<input type="text" name="markName" value="${query.markName}"  maxlength="20" class="input-mini"/>
			<br/><br/>
			<label>筛选</label>
			<select class="input-medium" name="filter">
				<option value="0">无</option>
				<option value="1" <c:if test="${filter==1}">selected</c:if>>客观0分，主观有分</option>
				<option value="2" <c:if test="${filter==2}">selected</c:if>>客观有分，主观0分</option>
			</select>
			<label>总分：从</label>
			<input  type="text" number="true" name="startScroe"value="${query.startScroe}" class="input-mini"/>
			<label> 到&nbsp;&nbsp;&nbsp;</label>
			<input type="text"  number="true" name="endScroe" value="${query.endScroe}"  class="input-mini"/>
			 
			<br/><br/>
			<input id="btnSubmit" class="btn btn-primary" type="button" value="查询" onclick="goSearch()"/>
			&nbsp;
			<c:if test="${web_user.type.value==0 || web_user.type.value==5}">
			<div class="btn-group">
				<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
					导出<span class="caret"></span>
				</a>
				<ul class="dropdown-menu">
					<li><a href="##" onclick="goExport()">列表导出</a></li>
					<li><a href="##" onclick="goExportScore()">成绩导出</a></li>
				</ul>
			</div>
			</c:if>
			&nbsp;
			<c:if test="${exam.status.value==0 && web_user.type.value==0}">
			<a href="${ctx}/admin/exam/score/calculate" class="btn">重新统分</a>
			</c:if>
			<c:if test="${exam.status.value==1}">
			<a href="javascript:void(0)" class="btn" disabled>${exam.status.name}</a>
			</c:if>
		</div>
	</form>
	<tags:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
	<caption align="top">${exam.name}</caption> 
		<thead>
			<tr>
				<th>准考证号</th>
				<th>姓名</th>
				<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="student">
			<tr>
				<td>
				<a href="##" class="detail-link" data-exam-number="${student.examNumber}">${student.examNumber}</a>
				</td>
				<td>${student.name}</td>
				<td>${student.studentCode}</td>
				<td>${student.subjectCode}-${student.subjectName}&nbsp;${student.subjectRemark}</td>
				<td>${student.subjectLevel}</td>
				<td>${student.subjectCategory}</td>
				<td>${student.objectiveScoreString}</td>
				<td>${student.subjectiveScoreString}</td>
				<td>${student.totalScoreString}</td>
				<td>${student.markLogin}</td>
				<td>${student.markName}</td>
				<td>
					<a class="sheet-link" href="##" data-sheet-url="${student.sheetUrlString}" data-answer-url="<c:if test="${student.answerUrl!=null}">${cardServer}${student.answerUrl}</c:if>" data-title="${student.examNumber}&nbsp;&nbsp;${student.name}&nbsp;&nbsp;客观总分${student.objectiveScoreString}&nbsp;&nbsp;主观总分${student.subjectiveScoreString}&nbsp;&nbsp;全卷总分${student.totalScoreString}">原图</a>
					<!--  
					<c:forEach items="${student.sheetUrls}" var="url" varStatus="status">
					<a class="sheet-link" href="${imageServer}${url}" data-jbox-image="${student.id}-sheet" title="${student.examNumber}&nbsp;&nbsp;${student.name}&nbsp;&nbsp;客观总分${student.objectiveScoreString}&nbsp;&nbsp;主观总分${student.subjectiveScoreString}&nbsp;&nbsp;全卷总分${student.totalScoreString}">原图${status.count}</a>
					</c:forEach>
					-->
					<a class="track-link" href="##" data-image-url="${ctx}/admin/exam/track?studentId=${student.id}" data-title="${student.examNumber}&nbsp;&nbsp;${student.name}">阅卷轨迹</a>
					<a class="package-link" href="##" data-image-url="${student.packageUrlString}" data-title="${student.packageCode}">签到表</a>
					<c:if test="${student.marked == true}">
						<c:if test="${web_user.type.value==0 || web_user.type.value==5}">
						<a href="##" class="back-button" data-student-id="${student.id}">打回</a>
						</c:if>
					</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/sheetView.jsp" %>
	<%@include file="/WEB-INF/views/include/imageView.jsp" %>
<script type="text/javascript">
$(document).ready(function() {
	$("#searchForm").validate();
    /* new jBox('Image', {
    	imageFade: 0,
    	delayOpen: 0,
    	delayClose: 0,
    	maxHeight: $(window).height()*0.88
    }); */
    
    $('.detail-link').click(function(){
    	var url = '${ctx}/admin/exam/score/detail?examNumber=' + $(this).attr('data-exam-number') + '&queryString=' + encodeURIComponent($('#searchForm').serialize());
    	window.location.href = url;
    });
    $('.sheet-link').click(function(){
    	initSheetPopover($(this).attr('data-title'), '${imageServer}', $(this).attr('data-sheet-url'), $(this).attr('data-answer-url'));
    	return false;
    });
    $('.package-link').click(function(){
    	initImagePopover($(this).attr('data-title'), '${packageServer}', $(this).attr('data-image-url'));
    	return false;
    });
    $('.track-link').click(function(){
    	initTrackPopover($(this).attr('data-title'),$(this).attr('data-image-url'));
    	return false;
    });
    $('.back-button').click(function(){
        if(confirm('确定要打回改试卷?')){  
        $.post('${ctx}/admin/exam/tag/back', {studentId: $(this).attr('data-student-id')}, function(result){
            if(result.success==true){
            	$("#searchForm").submit();
            }else{
                alert(result.message || '提交失败，请稍后重试');
            }
        });
        }
    });
});
function page(n,s){
	$("#pageNumber").val(n);
	$("#pageSize").val(s);
	$("#searchForm").attr('action','${ctx}/admin/exam/score');
	$("#searchForm").submit();
	return false;
}
function goSearch(){
	$("#pageNumber").val(1);
	$("#pageSize").val('${query.pageSize}');
	$("#searchForm").attr('action','${ctx}/admin/exam/score');
	$("#searchForm").submit();
	return false;
}
function goExport(){
	$("#searchForm").attr('action','${ctx}/admin/exam/score/export');
	$("#searchForm").submit();
}
function goExportScore(){
	$("#searchForm").attr('action','${ctx}/admin/exam/score/exportScore');
	$("#searchForm").submit();
}
</script>	
</body>
</html>