<%@ 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() {
			$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					var endTime = new Date($("#endTime").val()).getTime();
					var startTime = new Date($("#startTime").val()).getTime();
					if(startTime>=endTime){
						alert("评卷结束时间必须晚于开始时间");
						return;
					}else{
						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);
					}
				}
			});
			$("#inputForm").submit(function(e){
				
				
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/admin/exam/list">考试列表</a></li>
		<li class="active"><a href="##">编辑考试</a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="exam" action="${ctx}/admin/exam/edit" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<tags:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">考试名称:</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="200" class="required"/>
			</div>
		</div>
		<!-- <div class="control-group">
			<label class="control-label">考试日期:</label>
			<div class="controls">
				<input name="examTime" type="text" maxlength="200" class="required" placeholder="格式：yyyy-MM-dd"/>
			</div>
		</div> -->
		<div class="control-group">
			<label class="control-label">考试日期:</label>
			<div class="controls">
				<input name="examTime" type="text" readonly="readonly" maxlength="20" class="Wdate required" 
					value="${exam.examTime }"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"/>
			</div>
		</div>
				<div class="control-group">
			<label class="control-label">评卷开始日期:</label>
			<div class="controls">
				<input name="startTime" type="text" readonly="readonly" maxlength="30" class="Wdate " id="startTime"
					value="<fmt:formatDate value="${exam.startTime}" pattern="yyyy-MM-dd HH:mm:ss" />"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">评卷结束日期:</label>
			<div class="controls">
				<input name="endTime" type="text" readonly="readonly" maxlength="30" class="Wdate " id="endTime"
					value="<fmt:formatDate value="${exam.endTime}" pattern="yyyy-MM-dd HH:mm:ss" />"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">强制标记</label>
			<div class="controls">
				<input name="forceSpecialTag" type="checkbox" <c:if test="${exam.forceSpecialTag}">checked</c:if>/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">显示原卷</label>
			<div class="controls">
				<input name="showSheet" type="checkbox" <c:if test="${exam.showSheet}">checked</c:if>/>
			</div>
		</div>
		<div class="control-group">
            <label class="control-label">评卷模式</label>
            <div class="controls">
            <select name="markMode">
                <option value="">不限</option>
                <c:forEach items="${markModeList}" var="item">
                    <option value="${item}" <c:if test="${exam.markMode!=null && exam.markMode==item}">selected</c:if>>${item.name}</option>
                </c:forEach>
            </select>
            </div>
        </div>
		<div class="control-group">
			<label class="control-label">状态</label>
			<div class="controls">
				<select class="input-small" name="StatusValue">
                <c:forEach items="${statusList}" var="item">
                	 <option value="${item.value}" <c:if test="${item.value==exam.status.value}">selected</c:if>>${item.name}</option>
                </c:forEach>
            </select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">描述:</label>
			<div class="controls">
				<form:textarea path="description" htmlEscape="false" rows="4" maxlength="200" class="input-xxlarge"/>
			</div>
		</div>
		<div class="form-actions">
			<%-- <shiro:hasPermission name="exam:course:edit"> --%>
			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
			<%-- </shiro:hasPermission> --%>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>
