<%@ 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" %>
    <style type="text/css">.sort {
        color: #0663A2;
        cursor: pointer;
    }</style>
    
    <link rel="stylesheet" type="text/css" href="${ctxStatic}/jBox/Source/jBox.css">
    <script type="text/javascript" src="${ctxStatic}/jBox/Source/jBox.min.js"></script>
</head>
<body>
<form id="searchForm" action="" method="post" class="breadcrumb form-search">
    <div>
        <label>姓名：${student.name}</label>
        <label>准考证号：${student.examNumber}</label>
        <label>学号：${student.studentCode}</label>
        <label>科目：${student.subjectCode}-${student.subjectName}</label>
        <label>客观总分：${student.objectiveScoreString}</label>
        <label>主观总分：${student.subjectiveScoreString}</label>
        <label>试卷总分：${student.totalScoreString}</label>
        <br/>
        &nbsp;
        <a class="btn sheet-link" href="##" data-sheet-url="${student.sheetUrlString}" data-answer-url="<c:if test="${student.answerUrl!=null}">${fileServer}${student.answerUrl}</c:if>"
           data-title="${student.examNumber}&nbsp;&nbsp;${student.name}&nbsp;&nbsp;客观总分${student.objectiveScoreString}&nbsp;&nbsp;主观总分${student.subjectiveScoreString}&nbsp;&nbsp;全卷总分${student.totalScoreString}">原图</a>
        &nbsp;
        <a class="btn package-link" href="##" data-image-url="${student.packageUrlString}" data-title="${student.packageCode}">签到表</a>
        <c:if test="${web_user.schoolAdmin==true}">
            &nbsp;
            <a class="btn btn-warning" href="##" id="edit-button">保存</a>
        </c:if>
        &nbsp;
        <a class="btn" href="${ctx}/admin/exam/score?${queryString}">返回</a>
    </div>
</form>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
    <thead>
    <tr>
        <th>题目</th>
        <th>分数</th>
        <th>答案</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${scoreList}" var="item">
        <tr class="score-tr" data-objective="${item.objective}">
            <td>${item.title}</td>
            <td><input class="score-input" value="${item.scoreString}"/></td>
            <td>
                <c:if test="${item.objective==true}">
                    <input class="answer-input" value="${item.answer}"/>
                </c:if>
                <c:if test="${item.objective==false}">
                    &nbsp;
                </c:if>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<%@include file="/WEB-INF/views/include/sheetView.jsp" %>
<%@include file="/WEB-INF/views/include/imageView.jsp" %>
<script type="text/javascript">
    var examNumber = '${student.examNumber}';
    $(document).ready(function () {
        /* new jBox('Image', {
            imageFade: 0,
            delayOpen: 0,
            delayClose: 0,
            maxHeight: $(window).height()*0.88
        }); */
        $('.sheet-link').click(function () {
            initSheetPopover($(this).attr('data-title'), '', $(this).attr('data-sheet-url'), $(this).attr('data-answer-url'));
            return false;
        });
        $('.package-link').click(function () {
            initImagePopover($(this).attr('data-title'), '${fileServer}', $(this).attr('data-image-url'));
            return false;
        });
        $('#edit-button').click(function () {
            var o = [];
            var s = [];
            $('tr.score-tr').each(function (index, obj) {
                var tr = $(obj);
                if (tr.attr('data-objective') == 'true') {
                    o.push(tr.find('.answer-input').val() + ':' + tr.find('.score-input').val());
                } else {
                    s.push(tr.find('.score-input').val());
                }
            });
            $.post('${ctx}/admin/exam/score/edit', {
                examNumber: examNumber,
                objectiveItems: o.join(';'),
                subjectiveItems: s.join(';')
            }, function (result) {
                if (result.success == true) {
                    alert('修改成功');
                    window.location.reload();
                } else {
                    alert(result.message);
                }
            });
        });
    });
</script>
</body>
</html>