<%@ 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 src="${ctxStatic}/jquery/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="${ctxStatic}/jquery/jquery-migrate-1.1.1.min.js" type="text/javascript"></script>
    <link href="${ctxStatic}/jquery-validation/1.11.1/jquery.validate.min.css" type="text/css" rel="stylesheet"/>
    <script src="${ctxStatic}/jquery-validation/1.11.1/jquery.validate.min.js" type="text/javascript"></script>
    <script src="${ctxStatic}/jquery-validation/1.11.1/jquery.validate.method.min.js" type="text/javascript"></script>
    <link rel="stylesheet" href="${ctxStatic}/common/login.css">
    <script type="text/javascript">
        $(document).ready(function () {
            <!--针对nw.js评卷客户端，自动窗口最大化-->
            try {
                require('nw.gui').Window.get().maximize();
            } catch (e) {
            }

            $('#submit-button').click(function () {
                var markerId = $('#marker-select').val();
                return markerId != undefined && markerId != '' && markerId != null;
            });

            $('.point').hide();

            $('#exam-select').change(function () {
                var examId = $(this).val();
                $('#subject-select').empty();
                if (examId == '') {
                    $('#subject-select').val('').trigger('change');
                    return;
                }
                $.post('${ctx}/mark/subject/query', {examId: examId}, function (result) {
                    var parent = $('#subject-select');
                    var first = '';
                    for (var i = 0; i < result.length; i++) {
                        var marker = result[i];
                        $('<option value="' + marker.subjectCode + '">' + marker.subjectCode + '_' + marker.subjectName + '</option>').appendTo(parent);
                        if (i == 0) {
                            first = marker.id;
                        }
                    }
                    parent.val(first).trigger('change');
                });
                $('.point').hide();
            });
            $('#subject-select').change(function () {
            	var examId = $("#exam-select").val();
                var subjectCode = $(this).val();
                $('#marker-select').empty();
                if (examId == '') {
                    $('#marker-select').val('').trigger('change');
                    return;
                }
                $.post('${ctx}/mark/subject/group/query', {examId: examId,subjectCode:subjectCode}, function (result) {
                    var parent = $('#marker-select');
                    var first = '';
                    for (var i = 0; i < result.length; i++) {
                        var marker = result[i];
                        if(marker.title.length>15){
                        	marker.title = marker.title.substring(0,15)+"...";
                        }
                        $('<option value="' + marker.id + '">分组:' + marker.groupNumber + '-' + marker.title +' '+ marker.percent+'%</option>').appendTo(parent);
                        if (i == 0) {
                            first = marker.id;
                        }
                    }
                    parent.val(first).trigger('change');
                });
              //  $('.point').hide();
            });
            
            $(document).ajaxError(function (evt, req, settings) {
                if (req.status == 401) {
                    alert("账号已在其他地方登录！");
                    window.location.href = "/mark-login";
                }
            });

            $('#exam-select').trigger("change");

            var message = "${message}";
            if (message != null && message != "") {
                $('.point').show();
            }
        });

        // 如果在框架中，则跳转刷新上级页面
        if (self.frameElement && self.frameElement.tagName == "IFRAME") {
            parent.location.reload();
        }
    
    
    </script>
</head>
<body>
<div class="container">
    <div class="middle cl">
        <div class="left">
            <%-- <div class="logo"><img src="${ctxStatic}/images/<c:if test="${indexLogo ==null||indexLogo =='' }">logo@2x.png</c:if><c:if test="${indexLogo !=null }">${indexLogo }</c:if>"/></div> --%>
             <p>
				<a target="_blank" style="color: rgba(255,255,255,.65)">v${versionName} beta${versionDate}</a><br/>
				<a href="https://beian.miit.gov.cn/" target="_blank" style="color: rgba(255,255,255,.65)">鄂ICP备12000033号-3</a>
			</p>
        </div>
        <div class="right">
            <div class="title">
                <h1>请选择评卷科目</h1>
                <br/>
            </div>
            <div class="loginbox">
                <form class="form login-form" action="${ctx}/mark/subject-select" method="post">
                    <div class="option">
                        <select name="examId" id="exam-select">
                            <option value="">请选择考试</option>
                            <c:forEach items="${examList}" var="item">
                                <option value="${item.id}" <c:if test="${item.id==exam.id}">selected</c:if>>${item.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                    <div class="option">
                        <select name="subjectCode" id="subject-select">
                            <c:if test="${subject!=null}">
                                <option value="${subject.code}">${subject.code}_${subject.name}</option>
                            </c:if>
                        </select>
                    </div>
                    <div class="option">
                        <select name="markerId" id="marker-select">
                            <c:if test="${group!=null}">
                                <option value="">分组:${group.groupNumber}-${group.title}&nbsp;${group.percent }%</option>
                            </c:if>
                        </select>
                    </div>
                    <c:if test="${message != null }">
                        <div class="point <c:if test="${message != null }"></c:if><c:if test="${message == null }">hide</c:if>">
                            <em class="error">${message }</em>
                        </div>
                    </c:if>
                    <div class="login-btn">
                        <input class="opacity" type="submit" id="submit-button" value="确 定"/>
                        <a href="${ctx}/logout" class="opacity">退 出</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
</body>
</html>