<%@ 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" %>
	<script type="text/javascript">
		$(document).ready(function() {
			$('#btnSubmit').click(function(){
				return $.isNumeric($('#count-input').val()) ;
			});
			$("#hide").hide();
			$('#subjectCode').change(function(){
				var selected = $(this).children('option:selected');
				$('#markGroupNumber').empty();
				$('#markGroupNumber').append("<option value='all' selected>所有分组</option>");
				$('#markGroupNumber').val('all');
				$('#markGroupNumber').trigger('change');
				if(selected.val()!='all'){
			        var groupCount = selected.attr('data-group-count');
			        for(var i=1; i <= groupCount; i++){
				        $('#markGroupNumber').append("<option value="+i+">分组-"+i+"</option>")
				    }
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="##">批量创建</a></li>
	</ul><br/>
	<form id="inputForm" action="${ctx}/admin/exam/marker/batch-create" method="post" class="form-horizontal">
		<tags:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">科目选择</label>
			<div class="controls">
				<select id="subject-select" name="subjectCode">
					<c:forEach items="${subjectList}" var="subject">
					<option value="${subject.code}" data-group-count="${subject.groupCount}" <c:if test="${subjectCode==subject.code}">selected</c:if>>${subject.code}-${subject.name}</option>
					</c:forEach>
				</select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">大题选择</label>
			<div class="controls">
				<select id="group-select" name="groupNumber">
					<option value="0">所有大题</option>
					<c:forEach items="${groupList}" var="group">
                    <option value="${group.number}" <c:if test="${groupNumber==group.number}">selected</c:if>>${group.number}-${group.title}</option>
                    </c:forEach>
				</select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">创建人数</label>
			<div class="controls">
				<input name="count" htmlEscape="false" maxlength="10" class="required" id="count-input"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">初始密码</label>
			<div class="controls">
				<input name="password" htmlEscape="false" maxlength="10" class="required" id="password-input"/>
			</div>
		</div>
		<div class="form-actions">
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form>
	<script type="text/javascript">
	$('#subject-select').change(function(){
	    var code = $(this).val();
	    $.post('${ctx}/admin/exam/group/query', {subjectCode: code}, function(result){
	        var parent = $('#group-select');
	        parent.empty();
	        $('<option value="0">所有大题</option>').appendTo(parent);
	        for(var i=0;i<result.length;i++){
	            var group = result[i];
	            $('<option value="'+group.number+'">'+group.number+'-'+group.title+'</option>').appendTo(parent);
	        }
	    });
	});
	$('#subject-select').trigger('change');
	</script>
</body>
</html>
