<%@ 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>
	<%-- <%@include file="/WEB-INF/views/include/examInfoNavTabs.jsp" %> --%>
	<form id="searchForm" action="${ctx}/admin/exam/paper/detail" method="post" class="breadcrumb form-search">
		<input name="subjectCode" value="${subject.code}" type="hidden"/>
		<div>
			<label>科目：${subject.code}-${subject.name}</label>
			<label>客观总分：<fmt:formatNumber pattern="###.###" value="${subject.objectiveScore}"/></label>
			<label>主观总分：<fmt:formatNumber pattern="###.###" value="${subject.subjectiveScore}"/></label>
			<label>试卷总分：<fmt:formatNumber pattern="###.###" value="${subject.totalScore}"/></label>
			&nbsp;<br/><br/>
			<label>题型</label>
			<select id="type-select" name="objective" class="input-small">
				<option value="">不限</option>
				<option value="true" <c:if test="${objective!=null && objective==true}">selected</c:if>>客观题</option>
				<option value="false" <c:if test="${objective!=null && objective==false}">selected</c:if>>主观题</option>
			</select>
			&nbsp;
			<label>大题</label>
			<select id="main-select" name="mainNumber" class="input-large">
				<option value="">不限</option>
				<c:forEach items="${mainList}" var="question">
					<option value="${question.mainNumber}" <c:if test="${question.mainNumber ==mainNumber }">selected</c:if>>${question.mainNumber}-${question.mainTitle}</option>
				</c:forEach>
			</select>
			&nbsp;		
			<a class="btn" type="button" href="${ctx}/admin/exam/paper/question/add?subjectCode=${subject.code }&pageNumber=${query.pageNumber}&code=${query.code }&category=${ query.category}&level=${query.level }&upload=${ upload}&totalScoreNotEqual=${  query.totalScoreNotEqual}">新增</a>
			&nbsp;		
			<input id="btnDelete" class="btn" type="button" value="删除" onclick="goDelete()"/>
			&nbsp;		
			<a class="btn" href="${ctx}/admin/exam/paper?pageNumber=${query.pageNumber}&code=${query.code }&category=${ query.category}&level=${query.level }&upload=${ upload}&totalScoreNotEqual=${  query.totalScoreNotEqual}">返回</a>
		</div>
	</form>
	<form id="checkForm" action="${ctx}/admin/exam/paper/question/delete" method="post" class="breadcrumb form-search">
	 <input type="hidden" id="pageNumber" name="pageNumber" value="${query.pageNumber }"/>
	 <input type="hidden" id="code" name="code" value="${query.code }"/>
	 <input type="hidden" id="category" name="category" value="${query.category }"/>
	 <input type="hidden" id="level" name="level" value="${query.level }"/>
	 <input type="hidden" id="upload" name="upload" value="${upload}"/>
	 <input type="hidden" id="totalScoreNotEqual" name="totalScoreNotEqual" value="${query.totalScoreNotEqual }"/>
	<tags:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
			    <th><input type="checkbox" id="ids">试卷类型</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="${questionList}" var="question">
			<tr>
			    <td><c:if test="${question.groupNumber==null ||question.groupNumber==0}">
			    		<input type="checkbox" class="ids" name="ids" value="${question.id}">
			    	</c:if>${question.paperType}
			    </td>
				<td>${question.mainTitle}</td>
				<td>${question.name}</td>
				<td>${question.mainNumber}</td>
				<td>${question.subNumber}</td>
				<td><fmt:formatNumber pattern="###.###" value="${question.totalScore}"/></td>
				<td><fmt:formatNumber pattern="###.###" value="${question.intervalScore}"/></td>
				<td>${question.answer}</td>
				<td>
					<c:if test="${question.objective && question.objectivePolicy==null}">无</c:if>
					<c:if test="${question.objective && question.objectivePolicy!=null}">${question.objectivePolicy.name}</c:if>
					<c:if test="${!question.objective && question.selective}">
						${question.selectiveIndex}-
						<c:if test="${question.scorePolicy==1}">平均分</c:if>
						<c:if test="${question.scorePolicy==2}">取高分</c:if>
						<c:if test="${question.scorePolicy==3}">取低分</c:if>
					</c:if>
				</td>
				<td><c:if test="${!question.objective}">${question.groupNumber}</c:if>
				</td>
				<td>
				<c:if test="${question.deleting==true}">
                    正在删除
                </c:if>
                <c:if test="${question.deleting!=true}">
					<c:if test="${question.objective}"><a href="${ctx}/admin/exam/paper/question-edit/${question.id}?pageNumber=${query.pageNumber}&code=${query.code }&category=${ query.category}&level=${query.level }&upload=${ upload}&totalScoreNotEqual=${  query.totalScoreNotEqual}">编辑</a></c:if>
					<c:if test="${!question.objective && question.enableUpdate}"><a href="${ctx}/admin/exam/paper/question-edit/${question.id}?pageNumber=${query.pageNumber}&code=${query.code }&category=${ query.category}&level=${query.level }&upload=${ upload}&totalScoreNotEqual=${  query.totalScoreNotEqual}">编辑</a></c:if>
					<c:if test="${question.groupNumber==null ||question.groupNumber==0}"><a href="${ctx}/admin/exam/paper/question-delete/${question.id}?pageNumber=${query.pageNumber}&code=${query.code }&category=${ query.category}&level=${query.level }&upload=${ upload}&totalScoreNotEqual=${  query.totalScoreNotEqual}" class="delete-button">删除</a></c:if>
                </c:if>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	</form>
<script type="text/javascript">
$('#type-select').change(function(){
	$('#searchForm').submit();
});
$('#main-select').change(function(){
	$('#searchForm').submit();
});
$('.delete-button').click(function () {
    return confirm('确定要删除吗？');
});
$("#ids").change(function () {
    if ($("#ids").is(':checked')) {
        $(".ids").attr("checked", true);
    } else {
    	$(".ids").attr("checked", false);
    }
});

$(".ids").change(function () {
	var all = true;
	$("input[name='ids']").each(function(){
		if(!$(this).is(':checked')){
			all = false;
		}
	})
	 $("#ids").attr("checked", all);
});
function goDelete() {
	var check_list = []
	$("input[name='ids']:checked").each(function(){
		check_list.push($(this).val())
	})
    if(check_list.length==0) {
        alert('请选择');
        return false;
    }
    $("#checkForm").submit();
    return false;
}
</script>	
</body>
</html>