<%@ 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="inputForm" action="${ctx}/admin/exam/selectiveGroup/add" method="post" class="breadcrumb form-search">
		<input name="subjectCode" value="${subject.code}" type="hidden"/>
		<input name="selectiveCount" value="${selectiveCount}" type="hidden"/>
		<input name="selectivePart" value="${selectivePart}" type="hidden"/>
		<input name="scorePolicy" value="${scorePolicy}" type="hidden"/>
		<input name="parts" value="${parts}" type="hidden" id="parts"/>
		<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>
		</div>
		<br/>
		<div>
			<h4>选做题规则：${selectivePart} &nbsp;选&nbsp;${selectiveCount}</h4>
			<h4>选做题第 ${selectivePartNo } 部分请勾选：</h4>
		</div>
		<br/>
	<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>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${questions}" var="question">
			<tr>
				<td>${question.mainTitle}</td>
				<td>${question.mainNumber}</td>
				<td><fmt:formatNumber pattern="###.###" value="${question.totalScore}"/></td>
				<td>${question.selectiveIndex}</td>
				<td><c:if test="${!question.selective}">
					<input type="checkbox" name="mainNumbers" value = "${question.mainNumber}"/>
					</c:if>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	</form>
	<div class="pull-right">
		<a href="javascript:" onclick="history.back();" class="btn">返回</a>
		&nbsp;&nbsp;		
		<c:if test="${selectivePart>selectivePartNo }">
			<a href="#" class="btn btn-primary" id="btnNext">下一步</a>
		</c:if>
		<c:if test="${selectivePart==selectivePartNo }">
			<a href="#" class="btn btn-primary" id="btnSubmit">完成</a>
		</c:if>
	</div>
<script type="text/javascript">
$('#btnNext').click(function () {
	var check_list = []
	$("input[name='mainNumbers']:checked").each(function(){
    	if($(this).val()!=""){
    		check_list.push($(this).val())
		}
	})
    if(check_list.length==0) {
        alert('请选择题目');
        return false;
    }
	
	var parts =[];
	if($("#parts").val()!=undefined && $("#parts").val()!=""){
		parts =JSON.parse($("#parts").val());
	}
	var partDTO = {
			selectivePart: "${selectivePartNo}",
            mainNumbers :check_list
        };
	parts.push(partDTO);
	$('#parts').val(JSON.stringify(parts));
   $('#inputForm').submit();
});
$('#btnSubmit').click(function () {
	var check_list = []
	$("input[name='mainNumbers']:checked").each(function(){
    	if($(this).val()!=""){
    		check_list.push($(this).val())
		}
	})
    if(check_list.length==0) {
        alert('请选择题目');
        return false;
    }
	var parts =[];
	if($("#parts").val()!=undefined && $("#parts").val()!=""){
		parts =JSON.parse($("#parts").val());
	}
	var partDTO = {
			selectivePart: "${selectivePartNo}",
            mainNumbers :check_list
        };
	parts.push(partDTO);
	$('#parts').val(JSON.stringify(parts));
	$("#inputForm").attr("action", "${ctx}/admin/exam/selectiveGroup/save");
   $('#inputForm').submit();
});
</script>	
</body>
</html>