<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="../common/init.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>试题中心-审核试题</title>
<%@ include file="../common/top.jsp"%>
<link rel='stylesheet' type='text/css' href='${ctx}/resources/css/themes/default/easyui.css'/>
<link rel="stylesheet" type="text/css" href="${ctx}/resources/css/themes/icon.css"/>
<link rel="stylesheet" href="${ctx}/resources/css/main.css" type="text/css" />
<link href='${ctx}/resources/css/user-center-style.css' rel='stylesheet' type='text/css' />

<script type="text/javascript" src="${ctx}/resources/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/validator.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/question/audit.jsp"></script>
<style>
@charset "utf-8";
.pages {text-align:center;width:100%;margin:20px auto;padding-top:20px;height:26px;overflow:hidden;}
.pages a {padding:5px;border:1px solid #CCC;margin:0px 5px;text-decoration:none;color:#333;}
.pages a:hover {border:1px solid #FC0;color:#F60;}
.pages .this {border:1px solid #FC0;color:#F60;}

.title {text-align: center;background-color: #FFF9E7;}
.short {width: 30px;}
.container {width: 98%;margin: auto;padding-top: 15px;}
.caption {width: 100%;border-collapse:collapse;}
.info{width: 100%;border-collapse:collapse;}
.caption tr td{border: solid 1px #E0BF8D;color: #E84100;font-size: 16px;font-weight: bold;}
th{border: solid 1px #E0BF8D;}
.caption tr td select{width: 90%;}
.row{height: 30px;padding-top: 15px;}
.question-body {
    line-height: 1.5em;
    cursor: pointer;
    color: #333;
}

.bigBtn{width: 60px;height: 25px;}

.logDiv{
	margin-bottom: 10px;
	border-style: solid;
	border-width: 1px;
	border-color: #000000;
}

.myMargin1{
	margin-right: 10px;
}
.myMargin3{
	margin-right: 30px;
}
.myMargin4{
	margin-left: 3px;
}
.myTd1{
	width: 35px;
	text-align: left;
}
.myTd2{
	text-align: left;
}
</style>
<script type="text/javascript">
	function load(){
		$("#course").get(0).selectedIndex=0;
		search('${ctx}','1');
	}

	var codeMap = {};
    <c:forEach items="${codes }" var="code">
    codeMap['${code.itemType}-${code.itemCode}'] = '${code.itemValue}';
    </c:forEach>

	function getAuditLogs(quesId){
		$(document).mask('正在查询试题日志，请稍等...');
		var param = {"quesId":quesId};
		$.post('${ctx}/question/getAuditLogs',param,function(res){
			$(document).unmask();
			if(res.flag=='failed'){
	           $.messager.alert('提示', res.msg, 'error', function () {
	        	   //do nothing
	           });
	           return false;
			}else{
				$('#showLogsDiv').html('');
				var htmlStr = '';
				for(var i=0;i<res.auditLogs.length;i++){
					htmlStr = htmlStr + '<div class="logDiv">';
					htmlStr = htmlStr + '<div><span class="myMargin1 myMargin4">操作时间:</span><span class="myMargin3">' + res.auditLogs[i].createdTimeStr + '</span><span class="myMargin1">操作类型:</span><span class="myMargin3">' + res.auditLogs[i].operCode + '</span><span class="myMargin1">操作人:</span><span>' + res.auditLogs[i].createdByName + '</span></div>';
					htmlStr = htmlStr + '<div><table width="100%"><tr><td class="myTd1" valign ="top" nowrap="nowrap">备注:</td><td class="myTd2"><div id="logRemark' + res.auditLogs[i].id + '"></div></td></tr></table></div>';
					htmlStr = htmlStr + '</div>';
				}
				$('#showLogsDiv').html(htmlStr);
				for(var i=0;i<res.auditLogs.length;i++){
					$('#logRemark' + res.auditLogs[i].id).text(res.auditLogs[i].remark);
				}
		    	$('#logListDiv').window('open');
			}
		});
	}
	
	//审核
	function audit(quesId){
		$("#quesIdForAudit").val(quesId);
		$("#auditRemark").val("");
		calculate_byte(200,'auditRemark','count');
		$('#auditDiv').window('open');
	}

	$(document).ready(function(){
		{//初始化审核意见输入框字符数控制
			$("#auditRemark").keydown(function(){
		    	calculate_byte(200,'auditRemark','count');
		    });
		    $("#auditRemark").keyup(function(){
		    	calculate_byte(200,'auditRemark','count');
		    });
		    $("#auditRemark").keypress(function(){
		    	calculate_byte(200,'auditRemark','count');
		    });
		}
	
		$("#saveAuditBtn").click(function(){
			$.messager.confirm("操作提示", "您确定要保存审核结果吗？", function (data) {
		        if (data) {
		        	$(document).mask('正在保存审核结果，请稍等...');
		        	var param = $('#formForAudit').serialize();
		        	$.post('${ctx}/question/saveAudit',param,function(res){
		    			$(document).unmask();
		    			if(res.flag=='failed'){
		    	           $.messager.alert('提示', res.msg, 'error', function () {
		    	        	   //do nothing
		    	           });
		    	           return false;
		    			}else{
		    				$('#auditDiv').window('close');
		    				refreshTbl();
		    			}
		    		});
		        }
		    });
			return false;
		});
		
		$("#cancelAuditBtn").click(function(){
	    	$('#auditDiv').window('close');
			return false;
	    });
		
		$("#statBtn").click(function(){
			showStatWin($("#course").val());
			return false;
	    });
		
		$("#closeStatDiv").click(function(){
			$('#statDiv').window('close');
			return false;
	    });
		
		$("#keyword").keyup(function(){
			$('#queryBtn').click();
	    });
	});
	
	function showStatWin(courseId){
		$(document).mask('正在查询统计数据，请稍等...');
		var param = {"courseId":courseId};
		$.post('${ctx}/question/statAuditorJob',param,function(res){
			$(document).unmask();
			if(res.flag=='failed'){
	           $.messager.alert('提示', res.msg, 'error', function () {
	        	   //do nothing
	           });
	           return false;
			}else{
				$('#draftNum').html(res.draftNum);
				$('#statDg').datagrid({data:res.auditorJob});
		    	$('#statDiv').window('open');
			}
		});
	}

	function toEditQues(courseId,quesId){
		var ques = {courseId:courseId,quesId:quesId};
		showQuesEditWin(ques);
	}

	function showQuesEditWin(ques){
		var paramStr = JSON.stringify(ques);
		var src = "${ctx}/question/questionForEdit?courseId=" + ques.courseId + "&fun=initEditQuesParam&paramStr=" + encodeURIComponent(paramStr);
		$("#quesEditDiv").window({top:$(document).scrollTop() + 20,
			left:$(document).scrollLeft() + 20,
			height:$(document).height()-40,
			width:$(document).width()-40,
			onResize:function(){
				var winBody = $("#quesEditDiv").window("body");
				$("#quesEditFrame").css({width:winBody.width(),
					height:winBody.height()
				});
			}
		});
		var winBody = $("#quesEditDiv").window("body");
		$("#quesEditFrame").css({width:winBody.width(),
			height:winBody.height()
		});
		$("#quesEditFrame").attr("src", src);
		$(document).mask('正在加载试题，请稍等...');
		window.setTimeout(function(){
			$(document).unmask();
			$("#quesEditDiv").window('open');
		},300);
	}

	function closeEditQuestionDiv(){
		$("#quesEditDiv").window('close');
	}
</script>
</head>

<body onload="load()">
<%@ include file="../common/header.jsp"%>
<div>	
	<%@ include file="../common/sub_menu.jsp"%>
	<div id="page" style="margin-left: 0px;">
		<div class="page-header">试题中心-审核试题</div>
		<div class="page-body" >
			    <table class="caption">
			        <tbody>
			        <tr>
			            <td class="title">状态：</td>
			            <td>
			                <select id="status" name="statusCode">
			                    <option value="">全部</option>
			                    <c:forEach items="${status }" var="status">
			                    	<option value="${status.itemType}">${status.itemCode }</option>
			                    </c:forEach>
			                </select>
			            </td>
			            <td class="title">课程：</td>
			            <td style="width: 250px;">
			                <select id="course" name="courseId" onchange="courseChange('${ctx}','${role.id }')" style="width: 200px;">
			                    <option value="">全部课程</option>
			                    <c:forEach items="${courses }" var="c">
			                    <option value="${c.id }">${c.code}-${c.name }</option>
			                    </c:forEach>
			                </select>
			                <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-sum',plain:true" style="visibility:hidden;" id="statBtn">&nbsp;</a>
			            </td>
			            <td class="title" >题型：</td>
			            <td>
			                <select id="typeId" name="typeId" onchange="questionChange('${ctx }')">
			                    <option value="">全部题型</option>
			                </select>
			            </td>
			            <td class="title">教材：</td>
			            <td>
			                <select id="bookId" name="bookId">
			                    <option value="0">全部教材</option>
			                </select>
			            </td>
			        </tr>
			        <tr>
			            <td class="title">知识点：</td>
			            <td>
			                <input placeholder="章" class="short" id="chapter" name="chapter" />
			                <input placeholder="节" class="short"  id="section" name="section"/>
			                <input placeholder="目" class="short" id="item" name="item"/>
			                <input placeholder="页" class="short" id="ye" name="page"/>
			            </td>
			            <td class="title">能力要求：</td>
			            <td>
			                <select id="abilityCode" name="abilityCode" style="width: 200px;">
			                	<option value="">请选择</option>
			                    <c:forEach items="${codes }" var="code">
			                    	<c:if test="${ code.itemType=='ABILITY'}">
			                    		<option value="${code.itemCode}">${code.itemValue }</option>
			                    	</c:if>
			                    </c:forEach>
			                </select>
			            </td>
			            <td class="title">预计难度：</td>
			            <td>
			                <select id="estimateDifficultyCode" name="estimateDifficultyCode">
			                    <option value="">请选择</option>
			                    <c:forEach items="${codes }" var="code">
			                    	<c:if test="${ code.itemType=='QUESTION_DIFFICULTY'}">
			                    		<option value="${code.itemCode}" id="${code.itemCode}">${code.itemValue }</option>
			                    	</c:if>
			                    </c:forEach>
			                </select>
			            </td>
			            <td class="title">考核要求：</td>
			            <td>
			                <select id="assessmentDemand" name="assessmentDemand">
			                	<option value="">请选择</option>
			                    <c:forEach items="${codes }" var="code">
			                    	<c:if test="${ code.itemType=='ASSESSMENT_DEMAND'}">
			                    		<option value="${code.itemCode}" id="${code.itemCode}">${code.itemValue }</option>
			                    	</c:if>
			                    </c:forEach>
			                </select>
			            </td>
			        </tr>
			        <tr>
			            <td class="title">关键字：</td>
			            <td colspan="2" style="border-right-style: hidden;" >
			            <input type="hidden"/>
			                <input placeholder="题号或关键字查询" style="width: 90%;" id="keyword"/>
			            </td>
			            <td colspan="5"><input type="submit" class="bigBtn" id="queryBtn" value="查询" onclick="search('${ctx}','1')"/></td>
			        </tr>
			        </tbody>
			    </table>
		    <div class="row" id="row">
		    	
		    </div>
		    <table class="info questionList" style="font-size:13px;">
		        <tbody>
		        </tbody>
		    </table>
			<div class="pages"></div>
		</div>
	</div>	
</div>
<div style="display: none;">
	<div id="logListDiv" title="试题操作日志列表" class="easyui-window" data-options="modal:true,closed:true,maximizable:false,minimizable:false,resizable:false,iconCls:'icon-import'" style="width:600px;height:340px;padding:5px;overflow-x: hidden;">
		<div id="barcode-scan" style="font-size: 12px;margin-top: 10px;">
			<div id="showLogsDiv">
					
			</div>
		</div>
	</div>
	
	<div id="auditDiv" title="审核试题" class="easyui-window" data-options="modal:true,closed:true,maximizable:false,minimizable:false,resizable:false,iconCls:'icon-import'" style="width:420px;height:250px;padding:5px;overflow-x: hidden;">
        <div id="barcode-scan" style="font-size: 12px;margin-top: 10px;">
        	<form action="#" id="formForAudit">
				<input type="hidden" name="quesId" id="quesIdForAudit" value=""/>
				<table cellpadding="5">
					<tr>
						<td nowrap="nowrap">审核结果</td>
						<td>
							<input type="radio" name="auditResult" id="approved" value="QUESTION_APPROVED" checked="checked"/><label for="approved" class="myMargin3">通过</label>
							<input type="radio" name="auditResult" id="rejected" value="QUESTION_REJECTED"/><label for="rejected">拒绝</label>
						</td>
					</tr>
					<tr>
						<td nowrap="nowrap" valign="top">审核意见</td>
						<td><textarea rows="5" cols="50" style="width: 320px;" name="remark" id="auditRemark"></textarea><span id="count"></span></td>
					</tr>
					<tr>
						<td colspan="2" align="center">
							<button class="btn" id="saveAuditBtn">确定</button>
							<button class="btn" id="cancelAuditBtn">取消</button>
						</td>
					</tr>
				</table>
            </form>
        </div>
    </div>
	
	<div id="statDiv" title="审核数据统计" class="easyui-window" data-options="modal:true,closed:true,maximizable:false,minimizable:false,resizable:false,iconCls:'icon-import'" style="width:420px;height:250px;padding:5px;overflow-x: hidden;">
        <div id="barcode-scan" style="font-size: 12px;margin-top: 10px;">
        	<div>该课程草稿状态的题量：<span id="draftNum">0</span></div>
        	<div style="margin-top: 10px;margin-bottom: 10px;">
        		<table id="statDg" class="easyui-datagrid"
	                     data-options="fitColumns:true,singleSelect:true,striped:true,pagination:false">
	                     <thead>
	                         <tr class="title">
	                             <th data-options="field:'auditorName',width:60">审题教师</th>
	                             <th data-options="field:'approvedNum',width:100">审核通过的题量</th>
	                             <th data-options="field:'rejectedNum',width:100">审核拒绝的数量</th>
	                             <th data-options="field:'statTotalNum',width:100">总计</th>
	                         </tr>
	                     </thead>
        		</table>
        	</div>
        	<div style="text-align: center;"><button class="btn" id="closeStatDiv">确定</button></div>
        </div>
    </div>
    
	<div id="quesAddDiv" class="easyui-window" title="新建试题" data-options="modal:true,closed:true,iconCls:'icon-import',minimizable:false" style="width:400px;height:190px;padding:0px;overflow: hidden;margin: 0px;">
		<iframe frameborder="0" name="quesAddFrame" id="quesAddFrame" style="width:1010px;height:570px;" scrolling="auto" src="">
		</iframe>
	</div>
		
	<div id="quesEditDiv" class="easyui-window" title="编辑试题" data-options="modal:true,closed:true,iconCls:'icon-import',minimizable:false" style="width:400px;height:190px;padding:0px;overflow: hidden;margin: 0px;">
		<iframe frameborder="0" name="quesEditFrame" id="quesEditFrame" style="width:1010px;height:570px;" scrolling="auto" src="">
		</iframe>
	</div>
</div>
</body>
</html>