<%@ 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="#">分类列表</a></li>
		<c:if test="${web_user.schoolAdmin==true}">
		<li><a href="${ctx}/admin/exam/problem/type/add?examId=${examId}">添加分类</a></li>
		</c:if>
	</ul>
	<tags:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>编号</th>
				<th>分类名称</th>
				<th>类型</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${list}" var="problem">
			<tr>
				<td>${problem.id}</td>
				<td>
					${problem.name}
				</td>
				<td>
				<c:if test="${problem.custom==true}">自定义</c:if>
				<c:if test="${problem.custom!=true}">默认</c:if>		
				</td>
				<td>
    				<c:if test="${problem.custom==true}">  				
    				<a href="${ctx}/admin/exam/problem/type/edit/${problem.id}">编辑</a>
    				<a href="##" class="delete-button" data-problem-id="${problem.id}">删除</a>
    				</c:if>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
<script type="text/javascript">
$(document).ready(function() {
	$('.delete-button').click(function(){
	    if(confirm('确定要删除当前的分类?')){  
	    	$.post('${ctx}/admin/exam/problem/type/delete', {problemId: $(this).attr('data-problem-id')}, function(result){
		        if(result.success==true){
		        	window.location.reload();
		        }else{
		            alert(result.message || '提交失败，请稍后重试');
		        }
		    });
	    }
	});
})
</script>	
</body>
</html>