<%@ 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 () {
            $("#inputForm").validate({
                submitHandler: function (form) {
                    loading('正在提交，请稍等...');
                    form.submit();
                },
                errorContainer: "#messageBox",
                errorPlacement: function (error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });
            if ($("#objective").is(':checked')) {
                $(".objectiveDiv").show();
            }else{
	            $(".objectiveDiv").hide();
            }
            $('#btnSubmit').click(function () {
                var score = $('#interval-score-input').val();
                var reg= /^-?\d+\.?\d{0,2}$/; 
                if (score == '' || !reg.test(score) ||score<=0) {
                	alert('间隔分不能为空,必须大于0分且只支持两位小数');
                	return false;
                }
                var total = $('#total-score-input').val();
                if (total == '' || total<=0) {
                	alert('满分不能为空且大于0分');
                	return false;
                }
                $('#inputForm').submit();
        });
        });
    </script>
</head>
<body>
<ul class="nav nav-tabs">
		<li class="active"><a href="javascript:" onclick="history.go(-1);">试题列表</a></li>
	</ul><br/>
	<form id="inputForm" action="${ctx}/admin/exam/paper/question-edit" method="post" class="form-horizontal">
		<tags:message content="${message}"/>
		<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="enableUpdate" name="enableUpdate" value="${enableUpdate}"/>
	 	<input type="hidden" id="totalScoreNotEqual" name="totalScoreNotEqual" value="${query.totalScoreNotEqual }"/>
	 	
	 	<input type="hidden" name="subjectCode" value="${examQuestion.subjectCode}"/>
	 	<input type="hidden" name="id" value="${examQuestion.id}"/>
		<div class="control-group">
			<label class="control-label">大题名称</label>
			<div class="controls">
			 <input <c:if test="${!examQuestion.objective && !enableUpdate}">disabled</c:if> name="mainTitle" value="${examQuestion.mainTitle }" type="text" maxlength="32" class="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">大题昵称</label>
			<div class="controls">
			 <input name="name" value="${examQuestion.name }" type="text" maxlength="32"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">大题号</label>
			<div class="controls">
			 <input <c:if test="${!examQuestion.objective && !enableUpdate}">disabled</c:if> name="mainNumber" value="${examQuestion.mainNumber }" type="number" htmlEscape="false" max="10000" min="1" class="required digits"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">小题号</label>
			<div class="controls">
			 <input <c:if test="${!examQuestion.objective && !enableUpdate}">disabled</c:if> name="subNumber" value="${examQuestion.subNumber }" type="number" htmlEscape="false" max="10000" min="1" class="required digits"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">满分</label>
			<div class="controls">
			 <input <c:if test="${!examQuestion.objective && !enableUpdate}">disabled</c:if> name="totalScore" value="${examQuestion.totalScore }" type="number" id="total-score-input" htmlEscape="false"  maxlength="10" class="required"/>
			</div>
		</div>
		<div class="control-group">
	        <label class="control-label">是否客观题</label>
	        <div class="controls">
	            <input type="checkbox" id="objective" <c:if test="${examQuestion.objective }">checked</c:if> disabled="disabled">
	            <input  type="hidden" name="objective" value="${examQuestion.objective }">
	        </div>
    	</div>
			<div class="control-group">
	            <label class="control-label">间隔分</label>
	            <div class="controls">
	                <input <c:if test="${!examQuestion.objective && !enableUpdate}">disabled</c:if> type="number" name="intervalScore" class="required" id="interval-score-input" htmlEscape="false" maxlength="10" class="required"
	                       value="${examQuestion.intervalScore}"/>
	            </div>
	        </div>
        <div class="objectiveDiv">
        	<div class="control-group">
				<label class="control-label">试卷类型</label>
				<div class="controls">
				 <input <c:if test="${!examQuestion.objective && !enableUpdate}">disabled</c:if> name="paperType" value="${examQuestion.paperType }" type="text" class="required"/>
				</div>
			</div>
	        <div class="control-group">
				<label class="control-label">题型</label>
				<div class="controls">
					<select <c:if test="${!examQuestion.objective && !enableUpdate}">disabled</c:if> class="input-small" name="type">
	                <c:forEach items="${questionTypeList}" var="item">
	                	 <option value="${item.value}" <c:if test="${item.value==examQuestion.type.value}">selected</c:if>>${item.name}</option>
	                </c:forEach>
	            </select>
				</div>
			</div>
	        <div class="control-group">
	            <label class="control-label">答案</label>
	            <div class="controls">
	                <input <c:if test="${!examQuestion.objective && !enableUpdate}">disabled</c:if> type="text" name="answer" htmlEscape="false" maxlength="10" class="required"
	                       value="${examQuestion.answer}"/>
	            </div>
	        </div>
			<div class="control-group">
				<label class="control-label">判分策略</label>
				<div class="controls">
					<select <c:if test="${!examQuestion.objective && !enableUpdate}">disabled</c:if> class="input-small" name="objectivePolicy">
	                <c:forEach items="${objectivePolicyList}" var="item">
	                	 <option value="${item.value}" <c:if test="${item.value==examQuestion.objectivePolicy.value}">selected</c:if>>${item.name}</option>
	                </c:forEach>
	            </select>
				</div>
			</div>
		</div>
		<div class="form-actions">
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>
			&nbsp;
			<a href="javascript:" onclick="history.go(-1);"  class="btn"/>返回</a>
		</div>
	</form>
</body>
</html>
