<%@ 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 () {
            var pictureConfig = '${pictureConfig}';
            window.localStorage.setItem("pictureConfig", pictureConfig);
            $("#title").focus();
            $("#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);
                    }
                }
            });
            var openDouble = "${group.doubleRate}";
            if (openDouble != null && openDouble > 0) {
                $("#openDouble").prop("checked", true);
                $("#openDouble").attr("disabled", "disabled");
                $(".doubleDiv").show();
            } else {
                $("#doubleRate").attr("value", "");
                $("#thirdPolicy").attr("value", "");
                $("#arbitrateThreshold").attr("value", "");
                $(".doubleDiv").hide();
            }

            $("#openDouble").change(function () {
                if ($("#openDouble").is(':checked')) {
                    $(".doubleDiv").show();
                } else {
                    $("#doubleRate").attr("value", "");
                    $("#thirdPolicy").attr("value", "");
                    $("#arbitrateThreshold").attr("value", "");
                    $(".doubleDiv").hide();
                }

            });
        });
    </script>
</head>
<body>
<ul class="nav nav-tabs">
    <li><a href="${ctx}/admin/exam/group?subjectCode=${group.subjectCode}">分组列表</a></li>
    <li class="active"><a href="##">简要修改</a></li>
</ul>
<br/>
<form:form id="inputForm" modelAttribute="group" action="${ctx}/admin/exam/group/update" method="post"
           class="form-horizontal">
    <tags:message content="${message}"/>
    <form:hidden path="subjectCode"/>
    <form:hidden path="number"/>
    <form:hidden path="doubleRate"/>
    <input type="hidden" id="rest" name="reset" value="false"/>
    <input type="hidden" id="intervalScoreList" name="intervalScoreList" value=""/>
    
	<div class="control-group">
        <label class="control-label">分组序号</label>
        <div class="controls">
            <form:input path="number" htmlEscape="false" class="required" readonly="true"/>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">名称</label>
        <div class="controls">
            <form:input path="title" htmlEscape="false" class="required" readonly="true"/>
        </div>
    </div>
   <%--  <c:if test="${group.status.value==1}">
        <div class="control-group">
            <label class="control-label">试评数量</label>
            <div class="controls">
                <form:input path="trialCount" htmlEscape="false" min="1" class="required digits" type="number"/>
            </div>
        </div>
    </c:if> --%>
    <c:if test="${exam.type!='MULTI_MEDIA' && exam.markMode!='TRACK'}">
    <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="${group.markMode!=null && group.markMode==item}">selected</c:if>>${item.name}</option>
                </c:forEach>
            </select>
        </div>
    </div>
    </c:if>
    <c:if test="${exam.type!='MULTI_MEDIA'}">
        <div class="control-group">
            <label class="control-label">图片显示</label>
            <div class="controls">
                <a href="${ctx}/admin/exam/group/getPictureConfig?subjectCode=${group.subjectCode}&number=${group.number}"
                   target="_blank" class="required" id="configuration" rel="opener">设置</a>
            </div>
        </div>
    </c:if>
    <form:input path="picList" class="required" id="picList" type="hidden"/>
    <c:forEach items="${questions}" var="question">
        <div class="control-group">
            <label class="control-label">${question.mainNumber}-${question.subNumber}间隔分</label>
            <div class="controls">
                <input type="number" class="required interval-score-input" htmlEscape="false" maxlength="10"
                       value="${question.intervalScore}"/>
            </div>
        </div>
    </c:forEach>
<%-- 	<div class="control-group">
		<label class="control-label">双评</label>
		<div class="controls"> 
		<input type="checkbox" id="openDouble">开启
		</div> 
	</div> 
	<div class="doubleDiv">
	<div class="control-group" >
		<label class="control-label">双评比例</label>
		<div class="controls"> 
			<form:input path="doubleRate" htmlEscape="false" maxlength="100" class="required" type="number" id="doubleRate"/>*比例范围为0-1
		</div> 
	</div> --%>
	<c:if test="${group.doubleRate>0}">
    <div class="control-group">
    	<label class="control-label">仲裁阀值</label>
    	<div class="controls"> 
			<form:input path="arbitrateThreshold" htmlEscape="false" maxlength="100" class="required" type="number" id="arbitrateThreshold"/>*阈值为分数 
		</div>
	</div> 
	</c:if>
<!-- 	</div>  -->
    <c:if test="${exam.type!='MULTI_MEDIA'}">
   		<c:if test="${exam.sheetView}">
        <div class="control-group">
	        <label class="control-label">原卷显示</label>
	        <div class="controls">
	        <input name="sheetView" type="checkbox" value="1" <c:if test="${group.sheetView}">checked</c:if>/>
	        </div>
        </div>
        </c:if>
    </c:if>
        <div class="control-group">
            <label class="control-label">启用全零分</label>
            <div class="controls">
                <input name="enableAllZero" type="checkbox" value="1" <c:if test="${group.enableAllZero}">checked</c:if>/>
            </div>
        </div>
    <div class="form-actions">
    	<c:if test="${fnx:hasPrivilegeCode(role_privilege_codes, 'exam_mark-group-reset_edit')}">
    	<a class="btn" href="${ctx}/admin/exam/group/edit-full?subjectCode=${group.subjectCode}&number=${group.number}">重置修改</a>&nbsp;
        </c:if>
        <a id="btnSubmit" href="##" class="btn btn-primary">保 存</a>
    </div>
</form:form>
<script type="text/javascript">
    $('#btnSubmit').click(function () {
        var array = [];
        var fill = true;
        $('.interval-score-input').each(function () {
            var score = $(this).val();
            var reg= /^-?\d+\.?\d{0,2}$/; 
            if (score == '' || !reg.test(score) ||score<=0) {
                fill = false;
            } else {
                array.push(score);
            }
        });
        if (fill) {
            $('#intervalScoreList').val(array.join(','));
            $('#inputForm').submit();
        } else {
        	alert('间隔分不能为空,必须大于等于0分且只支持两位小数');
        }
    });
</script>
</body>
</html>
