<%@ 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" %>
    <%@include file="/WEB-INF/views/include/dialog.jsp" %>
    <style type="text/css">.sort {
        color: #0663A2;
        cursor: pointer;
    }</style>
</head>
<body>
<ul class="nav nav-tabs">
    <li class="active"><a href="${ctx}/admin/exam/list">考试列表</a></li>
    <c:if test="${web_user.schoolAdmin==true}">
        <li><a href="${ctx}/admin/exam/create">创建考试</a></li>
    </c:if>
</ul>
<form id="searchForm" action="${ctx}/admin/exam/list" method="post" class="breadcrumb form-search">
    <input type="hidden" id="pageNumber" name="pageNumber" value="${query.pageNumber }"/>
    <input type="hidden" id="pageSize" name="pageSize" value="${query.pageSize }"/>
    <div>
        <label>名称</label>
        <input type="text" id="name" name="name" value="${query.name}" htmlEscape="false" maxlength="20" class="input-medium"/>
        <label>状态</label>
        <select class="input-small" name="status">
            <option value="">不限</option>
            <c:forEach items="${statusList}" var="item">
                <option value="${item.value}" <c:if test="${item.value==query.status.value}">selected</c:if>>${item.name}</option>
            </c:forEach>
        </select>
        <label>类型</label>
        <select class="input-small" name="type">
            <option value="">不限</option>
            <c:forEach items="${typeList}" var="item">
                <option value="${item.value}" <c:if test="${item.value==query.type.value}">selected</c:if>>${item.name}</option>
            </c:forEach>
        </select>
        &nbsp;
        <input id="btnSubmit" class="btn btn-primary" type="button" value="查询" onclick="goSearch()"/>
    </div>
</form>
<tags:message content="${message}"/>
<table id="contentTable" class="table table-striped table-bordered table-condensed">
    <thead>
    <tr>
        <th>ID</th>
        <th>名称</th>
        <th>类型</th>
        <th>考试时间</th>
        <th>强制标记</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${examList}" var="exam">
        <tr>
            <td>${exam.id}</td>
            <td><a href="${ctx}/admin/exam/view/${exam.id}">${exam.name}</a></td>
            <td>${exam.type.name}</td>
            <td><fmt:formatDate value="${exam.examTime}" pattern="yyyy-MM-dd"/></td>
            <td>
                <c:if test="${exam.forceSpecialTag}">是</c:if>
                <c:if test="${!exam.forceSpecialTag}">否</c:if>
            </td>
            <td>${exam.status.name}</td>
            <td>
                <a href="${ctx}/admin/exam/view/${exam.id}">详情</a>
                <c:if test="${web_user.schoolAdmin==true}">
                    <a href="${ctx}/admin/exam/edit/${exam.id}?pageNumber=${query.pageNumber}&status=${query.status.value}&type=${query.type.value}">编辑</a>
                    <a href="${ctx}/admin/exam/problem/type?examId=${exam.id}">问题卷分类</a>
                    <c:if test="${exam.type=='MULTI_MEDIA'}">
                        <a href="${ctx}/admin/exam/data/sync?examId=${exam.id}">数据同步</a>
                    </c:if>
                </c:if>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div class="pagination">${query}</div>
<script type="text/javascript">
    function page(n, s) {
        $("#pageNumber").val(n);
        $("#pageSize").val(s);
        $("#searchForm").submit();
        return false;
    }

    function goSearch() {
        $("#pageNumber").val(1);
        $("#pageSize").val('${query.pageSize}');
        $("#searchForm").submit();
        return false;
    }

</script>
</body>
</html>