<%@ 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>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名</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-medium"/>
			<br/><br/>
			<label>评卷姓名</label>
			<input type="text" name="markName" value="${query.markName}"  maxlength="20" class="input-mini"/>
			<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>
			<select id="absent" name="absent" class="input-small">
				<option value="">不限</option>
				<option value="1" <c:if test="${query.absent!=null && query.absent==true}">selected</c:if>>缺考</option>
				<option value="0" <c:if test="${query.absent!=null && query.absent==false}">selected</c:if>>正常</option>
			</select>

            <label>是否上传</label>
            <select id="upload" name="upload" class="input-small">
                <option value="">不限</option>
                <option value="1" <c:if test="${query.upload!=null && query.upload==true}">selected</c:if>>已上传</option>
                <option value="0" <c:if test="${query.upload!=null && query.upload==false}">selected</c:if>>未上传</option>
            </select>

            <label>是否违纪</label>
            <select id="breach" name="breach" class="input-small">
                <option value="">不限</option>
                <option value="1" <c:if test="${query.breach!=null && query.breach==true}">selected</c:if>>违纪</option>
                <option value="0" <c:if test="${query.breach!=null && query.breach==false}">selected</c:if>>正常</option>
            </select>
            <br/><br/>
            <!--     总分 > startScore and 总分 <=endScore             -->
			<label>总分：从</label>
			<input  type="text" number="true" id="startScroe"  name="startScroe"value="${query.startScroe}" class="input-mini"/>
			<label> 到&nbsp;&nbsp;&nbsp;</label>
			<input type="text"  number="true" id="endScroe" name="endScroe"  value="${query.endScroe}"  class="input-mini"/>

            <div style="float: right;">
                <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>
                            <c:if test="${showExportScore}">
                                <li><a href="##" onclick="goExportScore()">成绩导出</a></li>
                            </c:if>
                        </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>
		</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>
				<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 style="text-align: center;">
                    <c:choose>
                        <c:when test="${student.absent == true || student.upload == false }">
                            -
                        </c:when>
                        <c:when test="${student.breach == true}">
                            0
                        </c:when>
                        <c:otherwise>
                            ${student.objectiveScoreString}
                        </c:otherwise>
                    </c:choose>
                </td>
				<td style="text-align: center;">
                <c:choose>
                    <c:when test="${student.absent == true || student.upload == false }">
                        -
                    </c:when>
                    <c:when test="${student.breach == true}">
                        0
                    </c:when>
                    <c:otherwise>
                        ${student.subjectiveScoreString}
                    </c:otherwise>
                </c:choose>
                </td>
				<td style="text-align: center;">
                    <c:choose>
                        <c:when test="${student.absent == true || student.upload == false }">
                           -
                        </c:when>
                        <c:when test="${student.breach == true}">
                           0
                        </c:when>
                        <c:otherwise>
                            ${student.totalScoreString}
                        </c:otherwise>
                    </c:choose>
				</td>
				<td>
					<!--在成绩查询页面 未上传或者缺考的情况都判断为缺考情况 -->
					<c:if test="${student.absent == true || student.upload == false }">
						缺考
					</c:if>
				</td>
                <td>
                    <c:choose>
                        <c:when test="${student.upload == false }">
                            未上传
                        </c:when>
                        <c:otherwise>
                            已上传
                        </c:otherwise>
                    </c:choose>
                </td>
                <td>
                    <c:if test="${student.breach == true}">
                        违纪
                    </c:if>
                </td>
				<td>
                    <c:if test="${student.tagValue.indexOf('1')>-1}">
                        试卷雷同<br>
                    </c:if>
                    <c:if test="${student.tagValue.indexOf('2')>-1}">
                        科目错误<br>
                    </c:if>
                    <c:if test="${student.tagValue.indexOf('3')>-1}">
                        贴错条码<br>
                    </c:if>
                    <c:if test="${student.tagValue.indexOf('4')>-1}">
                        违纪<br>
                    </c:if>
				</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(){
    var startScroe = $("#startScroe").val();var endScore = $("#endScroe").val();
    if(startScroe.length>0){
        if(endScore.length == 0){
            alert("请输入结束分数值！");return false;
        }
    }if(endScore.length>0){
        if(startScroe.length == 0){
            alert("请输入开始分数值！");return false;
        }
    }if(endScore.length>0 && startScroe.length > 0){
        if(parseInt(startScroe) > parseInt(endScore)){
            alert("开始分值必须小于结束分值");return false;
        }
    }
	$("#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>