<%@ 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>
<%@ include file="../common/top.jsp"%>
<link rel="stylesheet" href="${ctx}/resources/css/main.css" type="text/css" />
<link rel='stylesheet' href='${ctx}/resources/css/easyui.css' type='text/css' media='screen' />
<link rel='stylesheet' href='${ctx}/resources/css/easyui/icon.css' type='text/css' media='screen' />
<link rel='stylesheet' href='${ctx}/resources/css/user-center-style.css' type='text/css' media='screen' />

<script type="text/javascript" src="${ctx}/resources/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${ctx}/resources/js/validator.js"></script>
<style>
.my-dialog .ui-dialog-titlebar-close{display: none;
 }
.select-knowledge{width:auto;}

.row div,label {
	float: left;
}
	.progressWrapper {
	width: 357px;
	overflow: hidden;
}

.progressContainer {
	margin: 5px;
	padding: 4px;
	border: solid 1px #E8E8E8;
	background-color: #F7F7F7;
	overflow: hidden;
}

.progressBarInProgress,
.progressBarComplete,
.progressBarError {
	font-size: 0;
	width: 0%;
	height: 2px;
	background-color: blue;
	margin-top: 2px;
}

.progressBarComplete {
	width: 100%;
	background-color: green;
	visibility: hidden;
}

.progressBarError {
	width: 100%;
	background-color: red;
	visibility: hidden;
}

.progressBarStatus {
	margin-top: 2px;
	width: 337px;
	font-size: 7pt;
	font-family: Arial;
	text-align: left;
	white-space: nowrap;
}

.myButton1{
	width: 52px;height: 26px;margin: 0px;
}
.myButton2{
	width: 59px;height: 26px;margin: 0px;
}
.myButton3{
	width: 79px;height: 26px;margin: 0px;
}
.myMargin1{
	margin-right: 8px;
}
.myMargin2{
	margin-right: 15px;
}
.myMargin3{
	margin-right: 25px;
}
.myMargin4{
	margin-left: 3px;
}

.optTable{
	padding: 0px;
}

.optTable td{
	padding-left: 0px;
	padding-right: 0px;
	text-align:left;
	vertical-align: middle;
}

.myWidth1{
	width: 18px;
}

.myWidth2{
	width: 200px;
}

.normalBorder{
	border-style: solid;
	border-width: 2px;
	border-color: #FFFFFF;
}

.curBorder{
	border-style: ridge;
	border-width: 2px;
	border-color: #FF0000;
}

.btnDiv{
	height:30px;
	text-align: right;
	position:relative;
	right:0;
	visibility: hidden;
}

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

.myTd1{
	width: 35px;
	text-align: left;
}

.myTd2{
	text-align: left;
}

.myTd3{border:solid windowtext 1px;padding:0px 2px 0px 2px;text-align:center;font-weight:bold;}

.myTd4{border:solid windowtext 1px;padding:0px 2px 0px 2px;}

.myTd5{border-style:none;padding:0px 2px 0px 2px;text-align:right;font-weight:bold;}

.myTd6{border-style:none;padding:0px 2px 0px 2px;text-align:left;}

.myTd7{vertical-align:top;border-top:1px solid #000;padding-top: 5px;}

p{white-space:sWrap;word-wrap:break-word;}

span{white-space:sWrap;word-wrap:break-word;}

.statTbl{
	border-collapse:collapse;border:none;width: 600px;margin-bottom: 10px;
}
.statTbl th{border:solid black 1px;padding:2px 2px 2px 2px;text-align: center;}
.statTbl td{border:solid black 1px;padding:2px 2px 2px 8px;}

.red{color: red}
</style>
<%@ include file="../common/validation.jsp"%>
<title>手工组卷</title>

<script language="javascript">
var hostAddress = encodeURIComponent(location.protocol + "//" + location.host + "${ctx}/");
var confirmMsg = "您确定提交吗？";
var quesMap = {};//试题Map，用于缓存试题统计信息
var quesEditableMap = {};//是否可以编辑的Map，如果该试题有启用时间，则不允许修改
<c:forEach var='qt' items="${sj.qtypeList}"  varStatus="status">
<c:forEach var='detail' items="${qt.constructDetails}"  varStatus="statusxx">
<c:if test="${detail.question.enableTime != null}">
quesEditableMap['${detail.question.id}']=true;
</c:if>
<c:if test="${detail.question.enableTime == null}">
quesEditableMap['${detail.question.id}']=true;
</c:if>
</c:forEach>
</c:forEach>
$(document).ready(function(){
	countBlankQuesNum();
	
    $('#goBackBtn').click(function(){
    	window.close();
    	return false;
    });
    
    $('#searchQuesBtn').click(function(){
        var param = {'keyword':$('#keywordForSearchQues').val(),'pcqtId':$('#pcqtIdForSearchQues').val()};
        param = $.extend(param, {page:1,rows:10});
        $('#availableQuesDg').datagrid('load',param);
        return false;
    });
    
    $("#availableQuesDg").datagrid({
    	onClickRow: function (rowIndex, rowData) {
    		$('#confirmQuesBtn').attr("disabled",false);
        },
        onDblClickRow: function (rowIndex, rowData) {
        	$('#confirmQuesBtn').click();
        }
    });
    
    $("#blankNumForShow").click(function(){
    	$(document).mask('正在加载中，请稍等...');
    	$.ajax({
    		type : "POST",
    		url : "${ctx}/question/calcAllRestQuesDetails",
    		data : {"paperId":${task.pagerConstruct.id}},
    		success : function(res) {
    			$(document).unmask();
    			$('#blankQuesListDg').datagrid({data:res.allRestQuesDetails});
    			$("#blankQuesListDiv").window({top:$(document).scrollTop() + 100});
				$('#blankQuesListDiv').window('open');
    		}
    	});
    });
    
    $('#confirmQuesBtn').click(function(){
    	var selectedRow = $("#availableQuesDg").datagrid('getSelected');
    	if(selectedRow == null){
    		$.messager.alert('提示', "请选中一行后确定！", 'error');
    	}else{
    		curQues = selectedRow;
    		$.messager.confirm("操作提示", "您确定要换题吗？", function (data) {
                if (data) {
                	var hasRepeated = false;
            		$('[suoshuQt="' + curPcqtId + '"]').each(function(){
            			var detailId = $(this).attr('detailId');
            			var quesId = $(this).attr('quesId') - 0;
            			if(detailId != curDetailId && quesId == (curQues.id - 0)){
            				hasRepeated = true;
            				$.messager.alert('提示', "该题已存在，请重新选择！", 'error');
            				return;
            			}
            		});
            		if(!hasRepeated){
            			changeQues(curDetailId,curQues);
            			$('#quesListDiv').window('close');
            		}
                }
            });
    	}
        return false;
    });
    
    $("[divType='quesDiv']").each(function(index,element){
    	$(this).mouseover(function(){
    		if(this.className != "curBorder"){
            	this.className = "curBorder";
            	var quesId = $(this).attr("quesId");
            	if(!quesId){
            		$(this).find("[btnType='add']").show();
            		$(this).find("[btnType='edit']").hide();
            		$(this).find("[btnType='remove']").hide();
            	}else{
            		$(this).find("[btnType='add']").hide();
            		if(quesEditableMap[quesId + '']){
            			$(this).find("[btnType='edit']").show();
            		}else{
            			$(this).find("[btnType='edit']").hide();
            		}
            		$(this).find("[btnType='remove']").show();
            	}
            	//$(this).children(".btnDiv").show();
            	$(this).children(".btnDiv").css("visibility","visible");
    		}
        });
        $(this).mouseout(function(){
        	if(this.className != "normalBorder"){
            	this.className = "normalBorder";
            	//$(this).children(".btnDiv").hide();
            	$(this).children(".btnDiv").css("visibility","hidden");
        	}
        });
        $(this).dblclick(function(){
        	var detailId = $(this).attr("detailId");
        	var qatb = $("#ques_answer_tbody_" + detailId);
        	var qatd = $("#ques_answer_" + detailId);
        	if($.trim(qatd.text()) != ''){
	        	if(qatb.is(":hidden")){
	        		qatb.show();
	        	}else{
	        		qatb.hide();
	        	}
        	}
        });
        var isLasts = index >= $("[divType='quesDiv']").length - 1;
        $(this).tooltip({
        	position: (isLasts ? 'top' : 'right'),
        	//content: '<span style="color:#fff">This is the tooltip message.</span>',
        	//hideEvent:null,
        	deltaX:(isLasts ? 0 : -8),
        	deltaY:(isLasts ? 8 : 0),
        	onShow: function(){
        		//quesId
        		var questionDiv = $(this);
        		var questionId = $(this).attr('quesId');
        		if(!questionId){
        			questionDiv.tooltip('tip').css({
		        		visibility: 'hidden'
            		});
        			return;
        		}
        		var paperId = $(this).parent().attr('suoshuSjForStat');
        		var quesKey = questionId + '';
        		var content = quesMap[quesKey];
        		if(content != null && content != ''){
        			//questionDiv.tooltip('update',content);
            		questionDiv.tooltip('tip').css({
            			backgroundColor: '#EEE',
		        		borderColor: '#333',
		        		visibility: 'visible'
            		});
            		return;
        		}
        		var param = {'questionId':questionId,'paperId':paperId};
        		questionDiv.tooltip('update','正在统计中...');
        		questionDiv.tooltip('tip').css({
        			visibility: 'hidden',
        			backgroundColor: '#EEE',
        			borderColor: '#333'
        		});
        		$.ajax({
        			type : "POST",
        			global: false,
        			url : "${ctx}/zujuan/questionStat",
        			data : param,
        			success : function(res) {
        				if(res.flag=='failed'){
     		        		var content = '<span style="color:red">' + res.msg + '</span>';
     		        		questionDiv.tooltip('update',content);
     		        		questionDiv.tooltip('tip').css({
     		        			backgroundColor: '#FFF',
     		        			borderColor: '#000',
     		        			visibility: 'visible'
     		        		});
             				questionDiv.tooltip('reposition');
             			}else{
             				var qustion = res.statResult.qustion;
             				var randomStr = qustion.id + "_" + (new Date()).getTime();
             				var contentDivId = "_contentDivId_" + randomStr;
             				var content = '<div><div id="' + contentDivId + '">';
             				//content = content + '<div style="color:#000;margin-top:8px;">此题其他信息:</div>';
             				content = content + '<table cellpadding="0" cellspacing="0" border="0" style="border:none;">';
             				//content = content + '<tr><td class="myTd5" nowrap="nowrap">ID：</td><td class="myTd6">' + qustion.id + '</td></tr>';
             				content = content + '<tr><td class="myTd5" nowrap="nowrap">编号：</td><td class="myTd6">' + trimStr(qustion.questionNo,'-') + '</td></tr>';
             				content = content + '<tr><td class="myTd5" nowrap="nowrap">知识点：</td><td class="myTd6">' + trimStr(qustion.chapter,'-') + "章" + trimStr(qustion.section,'-') + "节" + trimStr(qustion.item,'-') + "目" + trimStr(qustion.page,'-')+"页" + '</td></tr>';
             				content = content + '<tr><td class="myTd5" nowrap="nowrap">认知层次：</td><td class="myTd6">' + qustion.abilityText + '</td></tr>';
             				content = content + '<tr><td class="myTd5" nowrap="nowrap">考核要求：</td><td class="myTd6">' + trimStr(qustion.assessmentDemandText,'--') + '</td></tr>';
             				content = content + '<tr><td class="myTd5" nowrap="nowrap">预计难度：</td><td class="myTd6">' + qustion.estimateDifficultyText + '</td></tr>';
             				//content = content + '<tr><td class="myTd5" nowrap="nowrap">层次：</td><td class="myTd6">' + qustion.gradeText + '</td></tr>';
             				content = content + '<tr><td class="myTd5" nowrap="nowrap">命题教师：</td><td class="myTd6">' + trimStr(qustion.setTeacherName,'') + '</td></tr>';
             				content = content + '<tr><td class="myTd5" nowrap="nowrap">启用时间：</td><td class="myTd6">' + trimStr(qustion.enableTimeStr,'') + '</td></tr>';
             				content = content + '</table>';
//             				content = content + '<hr/>';
//             				content = content + '<table cellpadding="0" cellspacing="0" border="0" style="border:none;">';
//             				var answerTdId = "_answerTdId_" + randomStr;
//             				content = content + '<tr><td class="myTd5" nowrap="nowrap">答案：</td><td class="myTd6" id="' + answerTdId + '"> </td></tr>'
//             				content = content + '</table>';
             				var papersSize = res.statResult.papersSize - 0;
             				if(papersSize == 0){
             					content = content + '<div style="color:#000">此题没有被其它试卷使用。</div>';
             				}else{
             					content = content + '<div style="color:#000">此题已被其它<span style="font-weight:bold;">' + papersSize + '</span>个试卷使用：</div>';
             					content = content + '<table cellpadding="0" width="100%" cellspacing="0" border="0" style="border-collapse:collapse;border:none;">';
             					content = content + '<tr><td class="myTd3" nowrap="nowrap">试卷名称</td><td class="myTd3" nowrap="nowrap">状态</td></tr>'
             					var papers = res.statResult.papers;
             					for(var i=0;i<papersSize;i++){
             						var paper = papers[i];
             						content = content + '<tr><td class="myTd4">' + paper.name + '</td><td class="myTd4">' + paper.statusName + '</td></tr>';
             					}
             					content = content + '</table>';
             				}
             				content = content + '</div></div>';
             				var contentDiv=$(content);
             				contentDiv.appendTo($('#hiddenDiv'));
//             				$('#' + answerTdId).html(qustion.answerHtml);
             				content = contentDiv.html();
             				contentDiv.remove();
             				
             				quesMap[quesKey] = content;
             				questionDiv.tooltip('update',content);
             				questionDiv.tooltip('tip').css({
     		        			backgroundColor: '#EEE',
     		        			borderColor: '#333',
     		        			visibility: 'visible'
     		        		});
             				if(!isLasts){
	             				var divTmp = $('#' + contentDivId);
	             				var divWidth = divTmp.width();
	             				var blankWidth = $(document.body).width() - 50 - (questionDiv.outerWidth() + questionDiv.offset().left);
	             				if(blankWidth >= divWidth){
	             					
	             				}
	             				var deltaX = (blankWidth >= divWidth)?-8:(blankWidth - divWidth);
	             				
	             				questionDiv.tooltip({
	             		        	'deltaX':deltaX
	             				});
             				}
             				questionDiv.tooltip('reposition');
             			}
        			}
        		});
        	}});
    });
    
    $(".panel-header.accordion-header").each(function(){
    	$(this).live('contextmenu',function(e){
    		var qtId = $(this).next().attr('qtId');
    		if(qtId != null && qtId != ''){
	    		curQtPanel = $(this).parent();
	    		//显示快捷菜单
	    		$('#menu').height(45);
    	    	$('#menu').width(150);
	            $('#menu').menu('show', {
	                left: e.pageX,
	                top: e.pageY
	            });
    		}
            return false;
        });
    });
    
    $("#m-up").click(function(){
    	var selfDiv = curQtPanel;
    	var prevDiv = selfDiv.prev()
    	if(prevDiv.size() == 1){
    		selfDiv.insertBefore(prevDiv);
    		resetQuesSortNo(selfDiv);
    		saveSj(true);
    	}
    });
    
    $("#m-down").click(function(){
    	var selfDiv = curQtPanel;
    	var nextDiv = selfDiv.next()
    	if(nextDiv.size() == 1){
    		selfDiv.insertAfter(nextDiv);
    		resetQuesSortNo(selfDiv);
    		saveSj(true);
    	}
    });
    
    $("#cancelAuditBtn").click(function(){
    	$('#auditDiv').window('close');
    });
    
    $("#saveAuditBtn").click(function(){
    	$.messager.confirm("操作提示", "您确定要保存审核结果吗？", function (data) {
            if (data) {
            	$(document).mask('正在保存审核结果，请稍等...');
            	var param = $('#formForAudit').serialize();
            	$.post('${ctx}/zujuan/saveAudit',param,function(res){
        			$(document).unmask();
        			if(res.flag=='failed'){
        	           $.messager.alert('提示', res.msg, 'error', function () {
        	        	   //do nothing
        	           });
        	           return false;
        			}else{
        				reloadWin();
        			}
        		});
            }
        });
    });

	{//初始化审核意见输入框字符数控制
		$("#remarkForNormalSubmit").keydown(function(){
	    	calculate_byte(200,'remarkForNormalSubmit','countForNormalSubmit');
	    });
	    $("#remarkForNormalSubmit").keyup(function(){
	    	calculate_byte(200,'remarkForNormalSubmit','countForNormalSubmit');
	    });
	    $("#remarkForNormalSubmit").keypress(function(){
	    	calculate_byte(200,'remarkForNormalSubmit','countForNormalSubmit');
	    });
		$("#remarkForAudit").keydown(function(){
	    	calculate_byte(200,'remarkForAudit','countForAudit');
	    });
	    $("#remarkForAudit").keyup(function(){
	    	calculate_byte(200,'remarkForAudit','countForAudit');
	    });
	    $("#remarkForAudit").keypress(function(){
	    	calculate_byte(200,'remarkForAudit','countForAudit');
	    });
	}
    
	$("#submitPaperToTypeset").click(function(){
		$.ajax({
    		type : "POST",
    		url : "${ctx}/business/getTikaType/${task.pagerConstruct.id}",
    		data : {},
    		success : function(res) {
    			if(res.tikaType == null || res.tikaType == ''){
    				$.messager.alert('提示', "您还未设置答题卡类型，请在主页面里面设置后再提交排版！", 'error');
    			}else{
    				$.ajax({
    		    		type : "POST",
    		    		url : "${ctx}/zujuan/countBlankQuesNum/${task.pagerConstruct.id}",
    		    		data : {},
    		    		success : function(res) {
    		    			var blankQuesNum = res.blankQuesNum - 0;
    		    			if(blankQuesNum > 0){
    		    				$.messager.alert('提示', "当前试卷里面还有" + blankQuesNum + "道空题，请组完卷后再提交!", 'error');
    		    			}else{
    		    				calculate_byte(200,'remarkForNormalSubmit','countForNormalSubmit');
    		    				$("#normalSubmitDiv").window({top:$(document).scrollTop() + 100});
    		    				$('#normalSubmitDiv').window('open');
    		    			}
    		    		}
    		    	});
    			}
    		}
    	});
	});
	
	$("#submitPaperToAudit").click(function(){
		$.ajax({
    		type : "POST",
    		url : "${ctx}/zujuan/countBlankQuesNum/${task.pagerConstruct.id}",
    		data : {},
    		success : function(res) {
    			var blankQuesNum = res.blankQuesNum - 0;
    			if(blankQuesNum > 0){
    				$.messager.alert('提示', "当前试卷里面还有" + blankQuesNum + "道空题，请组完卷后再提交!", 'error');
    			}else{
    		    	confirmMsg = "您确定要提交吗？（提交前请确认是否已经上传了排版后的Word试卷及答案）";
    				calculate_byte(200,'remarkForNormalSubmit','countForNormalSubmit');
    				$("#normalSubmitDiv").window({top:$(document).scrollTop() + 100});
    				$('#normalSubmitDiv').window('open');
    			}
    		}
    	});
	});
	
	$("#saveNormalSubmitBtn").click(function(){
		$.messager.confirm("操作提示", confirmMsg, function (data) {
	        if (data) {
	        	$(document).mask('正在处理，请稍等...');
	        	var param = $('#formForNormalSubmit').serialize();
	        	$.post('${ctx}/taskCenter/normalSubmit',param,function(res){
	    			$(document).unmask();
	    			if(res.flag=='failed'){
	    	           $.messager.alert('提示', res.msg, 'error', function () {
	    	        	   //do nothing
	    	           });
	    	           return false;
	    			}else{
	    				try{
	    					window.opener.location.reload();
	    				}catch(e){
	    					//do nothing
	    				}
	    				reloadWin();
	    			}
	    		});
	        }
	    });
		return false;
	});
	
	$("#cancelNormalSubmitBtn").click(function(){
    	$('#normalSubmitDiv').window('close');
		return false;
    });
	
	$("#openAuditWin").click(function(){
		$.ajax({
    		type : "POST",
    		url : "${ctx}/zujuan/countBlankQuesNum/${task.pagerConstruct.id}",
    		data : {},
    		success : function(res) {
    			var blankQuesNum = res.blankQuesNum - 0;
    			if(blankQuesNum > 0){
    				$.messager.alert('提示', "当前试卷里面还有" + blankQuesNum + "道空题，请组完卷后再提交!", 'error');
    			}else{
    				calculate_byte(200,'remarkForAudit','countForAudit');
    				$("#auditDiv").window({top:$(document).scrollTop() + 100});
    				$('#auditDiv').window('open');
    			}
    		}
    	});
	});
    
    $("input[name='auditResult']").click(function(){
    	if($("#approved").attr("checked")){
			$("#nextDealersSpan").show();
			$("#nextDealersSpan").find("select").attr("disabled",false);
			$("#preDealersSpan").hide();
			$("#preDealersSpan").find("select").attr("disabled",true);
			$("#normalAuditText").hide();
		}else{
			$("#nextDealersSpan").hide();
			$("#nextDealersSpan").find("select").attr("disabled",true);
			$("#preDealersSpan").show();
			$("#preDealersSpan").find("select").attr("disabled",false);
			$("#normalAuditText").show();
		}
    });
	
	$("#saveAuditBtn").click(function(){
		$.messager.confirm("操作提示", "您确定要提交审核结果吗？", function (data) {
	        if (data) {
	        	$(document).mask('正在提交，请稍等...');
	        	var param = $('#formForAudit').serialize();
	        	$.post('${ctx}/taskCenter/saveAuditResult',param,function(res){
	    			$(document).unmask();
	    			if(res.flag=='failed'){
	    	           $.messager.alert('提示', res.msg, 'error', function () {
	    	        	   //do nothing
	    	           });
	    	           return false;
	    			}else{
	    				try{
	    					window.opener.location.reload();
	    				}catch(e){
	    					//do nothing
	    				}
	    				reloadWin();
	    			}
	    		});
	        }
	    });
		return false;
	});
	
	$("#cancelAuditBtn").click(function(){
    	$('#auditDiv').window('close');
		return false;
    });
    
    statQues();
});

function statQues(){
    	var sjId = ${sj.id};
    	var diffQuantityMap = {"10":0,"20":0,"30":0,"40":0};
    	var diffScoreMap = {"10":0,"20":0,"30":0,"40":0};
    	var abilityQuantityMap = {"A":0,"B":0,"C":0,"D":0};
    	var abilityScoreMap = {"A":0,"B":0,"C":0,"D":0};
    	var size = $("[estimateDifficultyCode]").size();
    	var quesScoreArr = $("[quesScore]");
    	$("[estimateDifficultyCode]").each(function(index,element){
        	var score = quesScoreArr.eq(index).attr("quesScore") - 0;
        	var diff = $(this).attr("estimateDifficultyCode");
        	var ability = $(this).attr("abilityCode");
        	diffQuantityMap[diff] = diffQuantityMap[diff] + 1;
        	diffScoreMap[diff] = (diffScoreMap[diff] - 0) + score;
        	abilityQuantityMap[ability] = abilityQuantityMap[ability] + 1;
        	abilityScoreMap[ability] = (abilityScoreMap[ability] - 0) + score;
        });
    	for(var tmp in diffQuantityMap){
    		var rate = ((new Number(diffQuantityMap[tmp] / size * 100)).toFixed(2) - 0) + "%";
    		$("#diff_quantity_" + tmp + "_" + sjId).html("<span style='float:left;width:30px;'>" + diffQuantityMap[tmp] + "</span>（" + rate + "）");
    	}

    	for(var tmp in diffScoreMap){
    		$("#diff_score_" + tmp + "_" + sjId).text(diffScoreMap[tmp]);
    	}

    	for(var tmp in abilityQuantityMap){
    		var rate = ((new Number(abilityQuantityMap[tmp] / size * 100)).toFixed(2) - 0) + "%";
    		$("#ability_quantity_" + tmp + "_" + sjId).html("<span style='float:left;width:30px'>" + abilityQuantityMap[tmp] + "</span>（" + rate + "）");
    	}

    	for(var tmp in abilityScoreMap){
    		$("#ability_score_" + tmp + "_" + sjId).text(abilityScoreMap[tmp]);
    	}
}

function trimStr(str,defaultStr){
	if(str == null || str == '' || typeof(str) == "undefined"){
		return defaultStr;
	}else{
		return str;
	}
}

	var curPcqtId;
	var curDetailId;
	var curQues;
	var curQtPanel;
	
	function changeQues(detailId,quesInfo){
		var oldQuesId = $('[detailId="' + detailId + '"]').attr('quesId');
		quesMap[oldQuesId + ''] = null;
		quesEditableMap[quesInfo.id + ''] = !quesInfo.enableTime;
		var isOwn = (oldQuesId == quesInfo.id);
		$('[detailId="' + detailId + '"]').attr('quesId',quesInfo.id);
		
		var tbTmp = "<tr><td tdType='quesSortNo'></td><td><div estimateDifficultyCode='" + quesInfo.estimateDifficultyCode + "' abilityCode='" + quesInfo.abilityCode + "' chapter='" + quesInfo.chapter + "' id='quesbody_" + detailId + "'/>";
		if(quesInfo.options && quesInfo.options.length > 0){
			tbTmp = tbTmp + "<table class='optTable'>";
			for(var i=0;i<quesInfo.options.length;i++){
				var opt = quesInfo.options[i];
				tbTmp = tbTmp + "<tr><td class='myWidth1'>" + opt.optionNoString + ".</td><td><span id='opt_" + detailId + "_" + opt.id + "'/></td></tr>";
			}
			tbTmp = tbTmp + "</table>"
		}
		tbTmp = tbTmp + "</td></tr>";
		var curQuTb = $('#ques_' + detailId);
		if(curQuTb.attr("backupData") == null || curQuTb.attr("backupData") == ""){
			curQuTb.attr("backupData",curQuTb.html());
		}
		curQuTb.html(tbTmp);
		var answerHtml = '';
		if(quesInfo.bodyHtml == null){
			quesInfo.bodyHtml = '<span class="red">空题</span>';
		}else{
			answerHtml = '<span style="color: #330099">答案：</span>' + quesInfo.answer;
		}
		$('#quesbody_' + detailId).html(quesInfo.bodyHtml);
		$('#ques_answer_' + detailId).html(answerHtml);
		if(quesInfo.options && quesInfo.options.length > 0){
			for(var i=0;i<quesInfo.options.length;i++){
				var opt = quesInfo.options[i];
				$('#opt_' + detailId + '_' + opt.id).html(opt.contentHtml);
			}
		}
		if(!isOwn){
			$('#revBtn_' + detailId).show();
		}
		resetQuesSortNo(curQuTb);
		statQues();
	}
	
	function revertQues(tbId,pcId,pcqtId,detailId){
		$.messager.confirm("操作提示", "您确定要还原试题吗？", function (data) {
            if (data) {
            	var tb = $('#' + tbId);
            	var backupQuesId = tb.attr("backupQuesId");
            	if(backupQuesId){
            		var hasRepeated = false;
            		$('[suoshuQt="' + pcqtId + '"]').each(function(){
            			var quesIdTmp = $(this).attr('quesId') - 0;
            			if(quesIdTmp == (backupQuesId - 0)){
            				hasRepeated = true;
            				return false;
            			}
            		});
            		if(hasRepeated){
            			$.messager.alert('提示', "要还原的试题已在试卷里，无法还原！", 'error');
            			return;
            		}
            	}
				$('[detailId="' + detailId + '"]').attr('quesId',tb.attr("backupQuesId"));
				tb.html(tb.attr("backupData"));

				$('#revBtn_' + detailId).hide();
				resetQuesSortNo(tb);
				statQues();
				saveSj(true);
            }
        });
	}

    function selectTab(){
        var tabs = $('#paperTabs').tabs().tabs('tabs');
        for(var i=0; i<tabs.length; i++){
            tabs[i].panel('options').tab.unbind().bind('mouseenter',{index:i},function(e){
                $('#paperTabs').tabs('select', e.data.index);
            });
        }
    }
    
    function openChangeQuesWin(tbId,pcId,pqtId,detailId,quesTypeId,score,courseId,bookId){
		$("#quesChooseFrame").attr("src","");
    	var quesId = $('[detailId="' + detailId + '"]').attr('quesId');
    	var paramStr = JSON.stringify({"blankQuesNum":1,
			"paperId":${sj.id},
			"pqtId":pqtId,
			"quesTypeId":quesTypeId,
			"score":score,
			"courseId":courseId,
			"bookId":bookId,
			"detailId":detailId,
			"quesId":quesId});
		var src = "${ctx}/zujuan/questionListForZj?fun=initChooseParam&paramStr=" + encodeURIComponent(paramStr);
		$("#quesChooseFrame").attr("src",src);
    	$("#goChooseQuesDiv").window({top:$(document).scrollTop() + 30});
    	$("#goChooseQuesDiv").window("open");
    }
    
    function closeChangeQuesWin(){
    	$("#goChooseQuesDiv").window('close');
    }
    
    function editQues(tbId,pcId,pcqtId,detailId){
    	var quesId = $('[detailId="' + detailId + '"]').attr('quesId');
    	goEditQues(detailId,quesId);
    }
    
    function removeQues(tbId,pcId,pcqtId,detailId){
    	$.messager.confirm("操作提示", "您确定要移除此题吗？", function (data) {
            if (data) {
            	var ques = {'id':''};
            	changeQues(detailId, ques);
    	    	saveSj(true);
    	    	return true;
            }
        });
    }
    
    var randomArr = {};
    function randomQues(tbId,pcId,pcqtId,detailId){
    	$(document).mask('正在随机换题，请稍等...');
    	var quesIdList = [];
    	$('[suoshuQt="' + pcqtId + '"]').each(function(){
    		quesIdList[quesIdList.length] = $(this).attr('quesId') - 0;
    	});
    	var rndList = randomArr["" + pcqtId];
    	var rndListStr = '';
    	if(rndList != null && rndList.length > 0){
    		rndListStr = rndList.join(',');
    	}
    	var param = {
    			'pcqtId':pcqtId,
    			'detailId':detailId,
    			'curQuesIdListStr':quesIdList.join(','),
    			'rndListStr':rndListStr
    	};
    	$.post('${ctx}/zujuan/randomQues',param,function(res){
			$(document).unmask();
			if(res.flag=='failed'){
	           $.messager.alert('提示', res.msg, 'error', function () {
	        	   //do nothing
	           });
	           return false;
			}else{
				if(res.ques == null){
					$.messager.alert('提示', '对不起，没有可以换的题了!', 'warning' , function () {
			        	   //do nothing
			        });
			        return false;
				}
				var rndList = randomArr["" + pcqtId];
		    	if(rndList == null || rndList.length == 0){
		    		rndList = [];
		    		randomArr["" + pcqtId] = rndList;
		    	}
		    	rndList[rndList.length] = res.ques.id;
				changeQues(detailId,res.ques);
				saveSj(true);
			}
		});
    }
    
    function goUp(btn){
    	var selfDiv = $(btn).parents("[divType='quesDiv']");
    	var prevDiv = selfDiv.prev();
    	if(prevDiv.size() == 1 && prevDiv.attr("divType") == "quesDiv"){
    		selfDiv.insertBefore(prevDiv);
    		resetQuesSortNo(selfDiv);
    		saveSj(true);
    	}
    }
    
    function goDown(btn){
    	var selfDiv = $(btn).parents("[divType='quesDiv']");
    	var nextDiv = selfDiv.next();
    	if(nextDiv.size() == 1 && nextDiv.attr("divType") == "quesDiv"){
    		selfDiv.insertAfter(nextDiv);
    		resetQuesSortNo(selfDiv);
    		saveSj(true);
    	}
    }
    
    /**
    function resetQuesSortNo(obj){
    	var quesIndex = 1;
    	var qtIndex = 1;
    	$("[tdType='quesSortNo']").each(function(){
			$(this).text((quesIndex++) + ".");
		});
    }
    **/
    
    function resetQuesSortNo(){
    	var quesIndex = 1;
    	var qtIndex = 1;
    	var sjDiv = $("#autoGeneratedPapers");
    	sjDiv.find(".panel-header.accordion-header").find(".panel-title").each(function(){
    		var title = $(this).text();
    		var qtName = title.substring(title.indexOf("、"));
			$(this).text((qtIndex++) + qtName);
		});
    	sjDiv.find("[tdType='quesSortNo']").each(function(){
			$(this).text((quesIndex++) + ".");
		});
    }
    
    function saveSj(silence){
    	silence = true && ((silence==null)?false:silence);
    	var sjId = ${sj.id};
    	if(!silence){$(document).mask('正在保存试卷，请稍等...');}
    	var sjName = $('#sjName_' + sjId).val();
    	var sjHead = $('#sjHead_' + sjId).val();
    	var qtArrStr = '';
    	$("[suoshuSj='" + sjId + "']").each(function(){
    		var qtId = $(this).attr("qtId");
    		var detailArrStr = qtId + "@";
    		$("[suoshuQt='" + qtId + "']").each(function(){
    			var detailId = $(this).attr('detailId');
    			var quesId = $(this).attr('quesId') - 0;
    			detailArrStr = detailArrStr + detailId + ":" + quesId + "|";
    		});
    		qtArrStr = qtArrStr + detailArrStr + ";";
    	});
    	qtArrStr = qtArrStr.substring(0,qtArrStr.length - 1);
    	var param = {
    				'pcId':sjId,
	    			'pcName':sjName,
	    			'pcHead':sjHead,
	    			'qtArrStr':qtArrStr
    			};
    	$.post('${ctx}/zujuan/savePaper',param,function(res){
    		if(!silence){$(document).unmask();}
			if(res.flag=='failed'){
	           $.messager.alert('提示', res.msg, 'error', function () {
	        	   //do nothing
	           });
	           return false;
			}else{
				if(!silence){
					reloadWin();
				}else{
					countBlankQuesNum();
				}
			}
		});
    	return false;
    }
    
    function submitAudit(sjId){
    	$.messager.confirm("操作提示", "您确定要提交审核吗？", function (data) {
            if (data) {
            	$(document).mask('正在提交审核，请稍等...');
            	var param = {"paperId":sjId};
            	$.post('${ctx}/zujuan/submitAudit',param,function(res){
        			$(document).unmask();
        			if(res.flag=='failed'){
        	           $.messager.alert('提示', res.msg, 'error', function () {
        	        	   //do nothing
        	           });
        	           return false;
        			}else{
        				reloadWin();
        			}
        		});
            }
        });	
    }
    
    function createPaperWord(paperId,paperName){
    	$(document).mask('正在生成试卷，请稍等...');
    	$.ajax({
    		type : "POST",
    		url : "${ctx}/zujuan/previewPaper/" + paperId,
    		data : {}, 
    		success : function(res) {
    			$(document).unmask();
    			if(res.flag=='success'){
    				$("#downloadForm").attr("action","${ctx}/attachment/download/" + res.att.id);
    				$("#downloadForm").submit();
    			}else{
    				$.messager.alert('提示', "生成试卷失败，请刷新后操作!", 'error');
    			}
    		}
    	});
    	return false;
    }
    
    function createWangpingPaper(paperId,paperName){
    	$(document).mask('正在生成网评卷，请稍等...');
    	$.ajax({
    		type : "POST",
    		url : "${ctx}/zujuan/previewWangpingPaper/" + paperId,
    		data : {}, 
    		success : function(res) {
    			$(document).unmask();
    			if(res.flag=='success'){
    				$("#downloadForm").attr("action","${ctx}/attachment/download/" + res.att.id);
    				$("#downloadForm").submit();
    			}else{
    				$.messager.alert('提示', "生成网评卷失败，请刷新后操作!", 'error');
    			}
    		}
    	});
    	return false;
    }
    
    function createTika(paperId,paperName){
    	$(document).mask('正在生成题卡，请稍等...');
    	$.ajax({
    		type : "POST",
    		url : "${ctx}/zujuan/previewTika/" + paperId,
    		data : {}, 
    		success : function(res) {
    			$(document).unmask();
    			if(res.flag=='success'){
    				$("#downloadForm").attr("action","${ctx}/attachment/download/" + res.att.id);
    				$("#downloadForm").submit();
    			}else{
    				$.messager.alert('提示', "生成题卡失败，请刷新后操作!", 'error');
    			}
    		}
    	});
    	return false;
    }
    
    function createAnswerWord(paperId,paperName){
    	$(document).mask('正在生成答案，请稍等...');
    	$.ajax({
    		type : "POST",
    		url : "${ctx}/zujuan/previewAnswer/" + paperId,
    		data : {}, 
    		success : function(res) {
    			$(document).unmask();
    			if(res.flag=='success'){
    				$("#downloadForm").attr("action","${ctx}/attachment/download/" + res.att.id);
    				$("#downloadForm").submit();
    			}else{
    				$.messager.alert('提示', "生成试卷失败，请刷新后操作!", 'error');
    			}
    		}
    	});
    	return false;
    }
    
    function manualAddQues(pqtId,questionInfo){
    	var blankQues = $('[qtId="' + pqtId + '"]').find('[quesTypeId="' + questionInfo.typeId + '"][quesId=""]');
    	var blankQuesNum = blankQues.length;
    	if(blankQuesNum == 0){
    		return false;
    	}
    	if(questionInfo){
	    	var detail = blankQues.first();
	    	changeQues(detail.attr('detailId'), questionInfo);
	    	saveSj(true);
	    	return true;
    	}else{
    		return false;
    	}
    }
    function goSelectQues(pqtId,quesTypeId,score,courseId,bookId){
    	var blankQues = $('[qtId="' + pqtId + '"]').find('[quesTypeId="' + quesTypeId + '"][quesId=""]');
    	var blankQuesNum = blankQues.length;
    	if(blankQuesNum == 0){
    		$.messager.alert('提示', "该题型的题已经组好了，不用再选题了!", 'warning');
    		return false;
    	}
    	var detail = blankQues.first();
    	var paramStr = JSON.stringify({"blankQuesNum":blankQuesNum,
    								"paperId":${sj.id},
    								"pqtId":pqtId,
    								"quesTypeId":quesTypeId,
    								"score":score,
    								"courseId":courseId,
    								"bookId":bookId});
    	var src = "${ctx}/zujuan/questionListForZj?fun=initSelectParam&paramStr=" + encodeURIComponent(paramStr);
    	$("#quesSelectFrame").attr("src", src);
    	$("#goSelectQuesDiv").window({top:$(document).scrollTop() + 30});
    	$("#goSelectQuesDiv").window("open");
    }
    
    function goAddQues(pqtId,quesTypeId,quesTypeName,score,courseId,bookId){
    	var chapterSize = '${task.book.chapterSize}' - 0;
    	if(!chapterSize || chapterSize <= 0){
    		$.messager.alert('提示', "教材《${task.book.name}》的总章数设置不正确，请联系管理员完善该教材信息后再录题!", 'error');
    		return false;
    	}
    	var blankQues = $('[qtId="' + pqtId + '"]').find('[quesTypeId="' + quesTypeId + '"][quesId=""]');
    	var blankQuesNum = blankQues.length;
    	if(blankQuesNum == 0){
    		$.messager.alert('提示', "该题型的题已经组好了，不用再新建试题了!", 'warning');
    		return false;
    	}
    	var detail = blankQues.first();
    	var paramStr = JSON.stringify({"blankQuesNum":blankQuesNum,
			"paperId":${sj.id},
			"pqtId":pqtId,
			"quesTypeId":quesTypeId,
			"quesTypeName":quesTypeName,
			"score":score,
			"courseId":courseId,
			"bookId":bookId,
			"chapterSize":chapterSize});
		var src = "${ctx}/zujuan/questionForZj?fun=initAddQuesParam&paramStr=" + encodeURIComponent(paramStr);
		$("#quesAddFrame").attr("src", src);
    	$("#addQuestionDiv").window({top:$(document).scrollTop() + 30});
    	$("#addQuestionDiv").window('open');
    }
    
    function closeAddQuestionDiv(){
    	$("#addQuestionDiv").window('close');
    }
    
    function goEditQues(detailId,questionId){
    	var chapterSize = '${task.book.chapterSize}' - 0;
    	if(!chapterSize || chapterSize <= 0){
    		$.messager.alert('提示', "教材《${task.book.name}》的总章数设置不正确，请联系管理员完善该教材信息后再录题!", 'error');
    		return false;
    	}
    	var paramStr = JSON.stringify({"paperId":${sj.id},
			"detailId":detailId,
			"questionId":questionId,
			"chapterSize":chapterSize});
		var src = "${ctx}/zujuan/questionForZj?fun=initEditQuesParam&paramStr=" + encodeURIComponent(paramStr);
		$("#quesEditFrame").attr("src", src);
    	$("#editQuestionDiv").window({top:$(document).scrollTop() + 30});
    	$("#editQuestionDiv").window('open');
    }
    
    function updateQues(detailId,quesInfo){
    	changeQues(detailId,quesInfo);
    	saveSj(true);
    	return true;
    }
    
    function closeEditQuestionDiv(){
    	if(!$("#editQuestionDiv").panel("options").closed){
    		$("#editQuestionDiv").window('close');
    	}
    	if(!$("#addQuestionDiv").panel("options").closed){
    		$("#addQuestionDiv").window('close');
    	}
    }
    
    $(function(){
        $('#keyword').bind('keypress',function(event){
            if(event.keyCode == "13"){
            	$('#searchQuesBtn').click();
            }
        });
        
        $(window).scroll(function(){
        	if(!$("#editQuestionDiv").panel("options").closed){
        		$("#editQuestionDiv").panel("move",{top:$(document).scrollTop() + 30});
        	}
        	if(!$("#addQuestionDiv").panel("options").closed){
        		$("#addQuestionDiv").panel("move",{top:$(document).scrollTop() + 30});
        	}
        });
    });
    
    function sortSj(){
    	$(document).mask('正在排序中，请稍等...');
    	$.ajax({
    		type : "POST",
    		url : "${ctx}/zujuan/sortSj/${sj.id}",
    		data : {},
    		success : function(paper) {
    			$(document).unmask();
    			reloadWin();
    		}
    	});
    	return false;
    }
    
    function countBlankQuesNum(){
    	$.ajax({
    		type : "POST",
    		url : "${ctx}/zujuan/countBlankQuesNum/${sj.id}",
    		data : {},
    		success : function(res) {
    			var blankQuesNum = res.blankQuesNum - 0;
    			$("#blankNum").text(blankQuesNum);
    			if(blankQuesNum > 0){
    				$("#blankNumForShow").show();
    			}else{
    				$("#blankNumForShow").hide();
    			}
    		}
    	});
    }

    function reloadWin(){
    	$(document).mask('正在加载，请稍等...');
    	window.location.reload();
    }
    
    function openClientForAdd(courseId){
    	var url = 'proposition://Proposition/parm=' + hostAddress + 'parm=' + encodeURIComponent('client/getCourseInfo/' + courseId)
    	+ 'parm=mingtiparm=0parm=${sessionScope.web_session_user.id}';
    	//+ 'parm=tikaparm=0parm=${sessionScope.web_session_user.id}';
    	$('#iframeForClient').attr('src',url);
    }
    
    function openClientForEdit(detailId){
    	$(document).mask('正在加载中，请稍等...');
    	var quesId = $('[detailId="' + detailId + '"]').attr('quesId');
    	$.ajax({
    		type : "POST",
    		url : "${ctx}/zujuan/isUsedByOtherPaper",
    		data : {"quesId":quesId,"paperId":${sj.id}},
    		success : function(res) {
    			$(document).unmask();
    	    	var url = 'proposition://Proposition/parm=' + hostAddress + 'parm=' + encodeURIComponent('client/getQuestionInfo/' + quesId)
    	    	+ 'parm=mingtiparm=' + (res.used?'1':'0') + 'parm=${sessionScope.web_session_user.id}';
    	    	$('#iframeForClient').attr('src',url);
    		}
    	});
    }
    
    function checkSimilarity(paperId){
    	$(document).mask('正在计算中，请稍等...');
    	$.ajax({
    		type : "POST",
    		url : "${ctx}/zujuan/checkSimilarity",
    		data : {"paperId":paperId},
    		success : function(res) {
    			$(document).unmask();
    			$('#similarQuesListDg').datagrid({data:res.allSimilarQuestion});
    			$("#similarQuesListDiv").window({top:$(document).scrollTop() + 100});
				$('#similarQuesListDiv').window('open');
    		}
    	});
    }
</script>
</head>
<body style="margin-left: 2px;margin-top: 2px;clear:both;float: none;">
	           <div style="position: fixed;top: 0px;z-index: 1000;width:1000px;background-color: #FFF;">
                    	<input type="hidden" name="sjHead" id="sjHead_${sj.id}" value="${sj.head}"/>
                    	<input type="hidden" id="detailId" value="${detail.id}"/>
                        <table class="searchTable" style="margin-bottom: 5px;margin-top: 3px;">
                           <tr>
                               	<th style="width: 80px;">课程：</th>
                               	<td style="padding:0px 5px;width:250px;">${task.course.code}-${task.course.name}</td>
								<th>试卷编号：</th>
                            	<td>${sj.name}</td>
                            </tr>
                            <tr>
                            	<td colspan="4" style="text-align: center;">
                            		<c:if test="${canPaperEdit}">
                            		<button class="btn" style="display: none;" onclick="saveSj(false)">保存</button>
                            		<button class="btn" onclick="sortSj()" title="排序规则：每个题型里面的题按照难度和章节排序">排序</button>
                            		</c:if>
        					<c:if test="${sessionScope.web_session_user.id == task.curDealer && task.status=='GENERATE_PAPER'}">
	        					<button class="btn" id="submitPaperToTypeset">提交排版</button>
	        				</c:if>
	        				
	        				<c:if test="${sessionScope.web_session_user.id == task.curDealer && (task.status=='TYPESET' || task.status=='FINAL_TYPESET')}">
	        					<button class="btn" id="submitPaperToAudit">提交排版审核</button>
	        				</c:if>
	        				<c:if test="${sessionScope.web_session_user.id == task.curDealer && task.status=='TO_AUDIT_PAPER'}">
	        					<button class="btn" id="openAuditWin">审核试卷</button>
	        				</c:if>
	        				<c:if test="${sessionScope.web_session_user.id == task.curDealer && task.status=='TO_CHECK_PAPER'}">
	        					<button class="btn" id="openAuditWin">审核试卷</button>
	        				</c:if>
                            		<button class="btn" onclick="createPaperWord('${sj.id}')" title="按照最新的试题信息生成Word试卷">生成Word试卷</button>
                            		<button class="btn" onclick="createWangpingPaper('${sj.id}')" title="按照最新的试题信息生成网评卷">生成网评卷</button>
                            		<button class="btn" onclick="createTika('${sj.id}')" title="按照最新的试题信息生成题卡">生成题卡</button>
                            		<button class="btn" onclick="createAnswerWord('${sj.id}')" title="按照最新的试题信息生成Word答案">生成Word答案</button>
                            		<button class="btn" onclick="checkSimilarity('${sj.id}')" title="检查题目相似度">检查题目相似度</button>
                            		<button class="btn" id="goBackBtn">关闭</button>
				           		</td>
                            </tr>
                         </table>
                         <div style="margin-left: 20px;margin-top:20px; color: red;display:none;cursor:pointer;" id="blankNumForShow" title="点击查看详情">&nbsp;&nbsp;空题数量：<span style="font-weight: bold;text-decoration: underline;" id="blankNum">0</span></div>
                </div>
	            <div id="autoGeneratedPapers" style="clear:both;float: none;width:1000px;padding-top: 60px;">
                   		<c:set var="index" value="0" />
				           <div style="margin-bottom: 10px;"></div>
				           <div class="easyui-accordion" data-options="multiple:true">
				               <c:forEach var='qt' items="${sj.qtypeList}"  varStatus="status">
				                  <div divType="qtypeDiv" suoshuSjForStat='${sj.id}' <c:if test="${canPaperEdit}">suoshuSj='${sj.id}' qtId='${qt.id}'</c:if> title="${status.count}、${qt.name}（本大题共${qt.questionSum}小题，每题${fn:formatScore(qt.score)}分，共${fn:formatScore(qt.questionScores)}分）<c:if test="${qt.remark != null && qt.remark!= ''}">（${qt.remark}）</c:if>" data-options="collapsed:false" style="overflow:auto;padding:10px;">
				                  	<c:if test="${canPaperEdit}"><div>
<a href="#" class="easyui-linkbutton myMargin2" data-options="iconCls:'icon-select'" onclick="goSelectQues('${qt.id}','${qt.questionTypeId}', '${fn:formatScore(qt.score)}', '${task.course.id }', '${task.book.id }')">选题</a>
<a href="javascript:void(0)" class="easyui-splitbutton" data-options="menu:'#mmQtId${qt.id}',plain:false,iconCls:'icon-addQues'" onclick="goAddQues('${qt.id}','${qt.questionTypeId}', '${qt.name}', '${fn:formatScore(qt.score)}', '${task.course.id }', '${task.book.id }')">新建试题</a>   
<div id="mmQtId${qt.id}" style="width:100px;">   
    <div data-options="iconCls:'icon-addByApp'" onclick="openClientForAdd('${task.course.id }')">录题客户端</div>
</div>

				                  	</div></c:if>
						              <c:forEach var='detail' items="${qt.constructDetails}"  varStatus="statusxx">
							              <div divType="quesDiv" unselectable="on" onselectstart="return false" style="min-height: 60px;" suoshuQt='${qt.id}' quesScore='${qt.score}' quesTypeId='${qt.questionTypeId}' detailId='${detail.id}' quesId='${detail.question.id}' class="normalBorder">
								              <div class="btnDiv">
	<c:if test="${canPaperEdit}">
								              	<button class="myButton3 myMargin1" onclick="goUp(this);">↑上移</button>
								              	<button class="myButton3 myMargin1" onclick="goDown(this);">↓下移</button>
								              	<button class="myButton3 myMargin1" onclick="openChangeQuesWin('ques_${detail.id}','${sj.id}','${qt.id}','${detail.id}','${qt.questionTypeId}','${fn:formatScore(qt.score)}','${task.course.id }','${task.book.id }');">换题</button>
								              	<button class="myButton3 myMargin1" onclick="randomQues('ques_${detail.id}','${sj.id}','${qt.id}','${detail.id}');">随机换题</button>
<a btnType="edit" href="javascript:void(0)" class="easyui-splitbutton myMargin1" data-options="menu:'#mmQtId${qt.id}detail${detail.id}ForEdit',plain:false,iconCls:'icon-editQues'" onclick="editQues('ques_${detail.id}','${sj.id}','${qt.id}','${detail.id}');">编辑</a>   
<div id="mmQtId${qt.id}detail${detail.id}ForEdit" style="width:100px;">   
    <div data-options="iconCls:'icon-addByApp'" onclick="openClientForEdit('${detail.id}')">录题客户端</div>
</div>
<a btnType="add" href="javascript:void(0)" class="easyui-splitbutton myMargin1" data-options="menu:'#mmQtId${qt.id}detail${detail.id}ForAdd',plain:false,iconCls:'icon-addQues'" onclick="goAddQues('${qt.id}','${qt.questionTypeId}', '${qt.name}', '${fn:formatScore(qt.score)}', '${task.course.id }', '${task.book.id }')">新建</a>   
<div id="mmQtId${qt.id}detail${detail.id}ForAdd" style="width:100px;">   
    <div data-options="iconCls:'icon-addByApp'" onclick="openClientForAdd('${task.course.id }')">录题客户端</div>
</div>
								              	
								              	<button btnType="remove" class="myButton3 myMargin1" onclick="removeQues('ques_${detail.id}','${sj.id}','${qt.id}','${detail.id}');">移除</button>
								              	<!-- 
								              	<button id="revBtn_${detail.id}" class="myButton1" style="display: none;" onclick="revertQues('ques_${detail.id}','${sj.id}','${qt.id}','${detail.id}');">还原</button>
								              	 -->
	</c:if>
								              </div>
									          <table class="paperQuestionTable" style="margin-top: -30px;">
									          	<tbody id="ques_${detail.id}" backupData="" backupQuesId="${detail.question.id}">
										             <tr>
										             <c:set var="index" value="${index+1}" />
										             	<td tdType="quesSortNo">${index}.</td>
										             	<td>
										             		<div estimateDifficultyCode="${detail.question.estimateDifficultyCode}" abilityCode="${detail.question.abilityCode}" chapter="${detail.question.chapter}"><c:if test="${detail.question == null}"><span class="red">空题</span></c:if>${detail.question.bodyHtml}</div>
											             <c:if test="${detail.question.options != null }">
											             <table class="optTable">
											                 <c:forEach var='option' items="${detail.question.options }">
											                 <tr><td class="myWidth1">${option.optionNoString }.</td><td>${option.contentHtml }</td></tr>
											                 </c:forEach>
											             </table>
											             </c:if>
										             	</td>
										             </tr>
										          </tbody>
										          <tbody id="ques_answer_tbody_${detail.id}" style="display: none;">
										          	<tr>
										          		<td></td>
										          		<td id="ques_answer_${detail.id}">
										          		<c:if test="${detail.question != null}">
										          		<span style="color: #330099">答案：</span>${detail.question.answer}
										          		</c:if>
										          		</td>
										          	</tr>
										          </tbody>
									          </table>
							              </div>
						              </c:forEach>
						        </div>
				               </c:forEach>
						    </div>
						    <div style="margin-top: 10px;">
						    	<div style="font-size: 16px;">统计信息：</div>
						    	<table class="statTbl">
						    		<tr>
						    			<th>预计难度</th>
						    			<th>题量</th>
						    			<th>分值</th>
						    			<th>认知层次</th>
						    			<th>题量</th>
						    			<th>分值</th>
						    		</tr>
						    		<tr>
						    			<td>A.易</td>
						    			<td id="diff_quantity_10_${sj.id}"></td>
						    			<td id="diff_score_10_${sj.id}"></td>
						    			<td>I.识记</td>
						    			<td id="ability_quantity_A_${sj.id}"></td>
						    			<td id="ability_score_A_${sj.id}"></td>
						    		</tr>
						    		<tr>
						    			<td>B.中等偏易</td>
						    			<td id="diff_quantity_20_${sj.id}"></td>
						    			<td id="diff_score_20_${sj.id}"></td>
						    			<td>II.理解</td>
						    			<td id="ability_quantity_B_${sj.id}"></td>
						    			<td id="ability_score_B_${sj.id}"></td>
						    		</tr>
						    		<tr>
						    			<td>C.中等偏难</td>
						    			<td id="diff_quantity_30_${sj.id}"></td>
						    			<td id="diff_score_30_${sj.id}"></td>
						    			<td>III.简单应用</td>
						    			<td id="ability_quantity_C_${sj.id}"></td>
						    			<td id="ability_score_C_${sj.id}"></td>
						    		</tr>
						    		<tr>
						    			<td>D.难</td>
						    			<td id="diff_quantity_40_${sj.id}"></td>
						    			<td id="diff_score_40_${sj.id}"></td>
						    			<td>IV.综合应用</td>
						    			<td id="ability_quantity_D_${sj.id}"></td>
						    			<td id="ability_score_D_${sj.id}"></td>
						    		</tr>
						    	</table>
						    </div>
	            </div>
	            
<div id="hiddenDiv" style="display: none;">
    <div id="menu" class="easyui-menu" style="width:150px;">
	    <div id="m-up">↑上移</div>
	    <div id="m-down">↓下移</div>
	</div>

	<div id="goChooseQuesDiv" class="easyui-window" title="换题" data-options="modal:true,closed:true,iconCls:'icon-import',draggable:true,maximizable:false,minimizable:false" style="width:1000px;height:600px;overflow-x: hidden;"">
		<iframe frameborder="0" name="quesChooseFrame" id="quesChooseFrame" style="width:983px;height:558px;" scrolling="auto" src="">
		</iframe>
	</div>
    
    <div>
	    <form id="downloadForm" action="#">
	    </form>
    </div>

	<div id="goSelectQuesDiv" class="easyui-window" title="选题" data-options="modal:true,closed:true,iconCls:'icon-import',draggable:true,maximizable:false,minimizable:false" style="width:1000px;height:600px;overflow-x: hidden;"">
		<iframe frameborder="0" name="quesSelectFrame" id="quesSelectFrame" style="width:983px;height:558px;" scrolling="auto" src="">
		</iframe>
	</div>
	
	<div id="addQuestionDiv" class="easyui-window" title="新建试题" data-options="modal:true,closed:true,iconCls:'icon-import',draggable:true,maximizable:false,minimizable:false" style="width:1030px;height:610px;overflow-x: hidden;"">
		<iframe frameborder="0" name="quesAddFrame" id="quesAddFrame" style="width:1010px;height:570px;" scrolling="auto" src="">
		</iframe>
	</div>
	
	<div id="editQuestionDiv" class="easyui-window" title="编辑试题" data-options="modal:true,closed:true,iconCls:'icon-import',draggable:true,maximizable:false,minimizable:false" style="width:1030px;height:610px;overflow-x: hidden;"">
		<iframe frameborder="0" name="quesEditFrame" id="quesEditFrame" style="width:1010px;height:570px;" scrolling="auto" src="">
		</iframe>
	</div>
	
	<div id="blankQuesListDiv" title="空题详情" class="easyui-window" data-options="modal:true,closed:true,minimizable:false,maximizable:false,resizable:false,iconCls:'icon-import'" style="width:560px;height:400px;padding:5px;overflow-x: hidden;">
		<table id="blankQuesListDg" class="easyui-datagrid"
	                     data-options="fitColumns:true,singleSelect:true,striped:true,pagination:false,remoteSort:false">
	                     <thead>
	                         <tr class="title">
	                             <th data-options="sortable:true,field:'quesTypeName',width:30">题型</th>
	                             <th data-options="sortable:true,field:'score',width:15">分值</th>
	                             <th data-options="sortable:true,field:'chapterNo',width:15">章</th>
	                             <th data-options="sortable:true,field:'abilityText',width:30">认知层次</th>
	                             <th data-options="sortable:true,field:'estimateDifficultyText',width:30">预计难度</th>
	                             <th data-options="sortable:true,field:'quesNum',width:20">空题数量</th>
	                         </tr>
	                     </thead>
		</table>
	</div>
	
	<div id="similarQuesListDiv" title="相似题详情" class="easyui-window" data-options="modal:true,closed:true,minimizable:false,maximizable:false,resizable:false,iconCls:'icon-import'" style="width:560px;height:400px;padding:5px;overflow-x: hidden;">
		<table id="similarQuesListDg" class="easyui-datagrid"
	                     data-options="fitColumns:true,singleSelect:true,striped:true,pagination:false,remoteSort:false">
	                     <thead>
	                         <tr class="title">
	                             <th data-options="sortable:true,field:'similarQuestionName',width:50">题目</th>
	                             <th data-options="sortable:true,field:'similarity',width:40">相似度</th>
	                         </tr>
	                     </thead>
		</table>
	</div>
	
	<div id="normalSubmitDiv" title="选择下一个处理人" class="easyui-window" data-options="modal:true,closed:true,minimizable:false,maximizable:false,resizable:false,iconCls:'icon-import'" style="width:490px;height:260px;padding:5px;overflow-x: hidden;">
        <div id="barcode-scan" style="font-size: 12px;margin-top: 10px;">
        	<form action="#" id="formForNormalSubmit">
        		<input type="hidden" name="taskId" value="${task.id}"/>
				<table cellpadding="5">
					<tr>
						<td nowrap="nowrap" valign="top">下一个处理人</td>
						<td>
							<select name="nextDealer"><c:forEach items="${task.nextDealers}" var="dealer"><option value="${dealer.id}" <c:if test="${dealer.id==task.defaultNextDealer}">selected="selected"</c:if>>${dealer.name}</option></c:forEach></select>
						</td>
					</tr>
					<tr>
						<td nowrap="nowrap" valign="top">备注</td>
						<td>
							<textarea rows="5" cols="50" name="remark" id="remarkForNormalSubmit"></textarea>
							<div id="countForNormalSubmit"></div>
						</td>
					</tr>
					<tr>
						<td colspan="2" align="center">
							<button class="btn myMargin3" id="saveNormalSubmitBtn">确定</button>
							<button class="btn" id="cancelNormalSubmitBtn">取消</button>
						</td>
					</tr>
				</table>
            </form>
        </div>
    </div>
	
    <div id="auditDiv" title="提交审核结果" class="easyui-window" data-options="modal:true,closed:true,minimizable:false,maximizable:false,resizable:false,iconCls:'icon-import'" style="width:490px;height:280px;padding:5px;overflow-x: hidden;">
        <div id="barcode-scan" style="font-size: 12px;margin-top: 10px;">
        	<form action="#" id="formForAudit">
        		<input type="hidden" name="taskId" value="${task.id}"/>
				<table cellpadding="5">
					<tr>
						<td nowrap="nowrap">审核结果</td>
						<td>
							<span><input style="float:left;" type="radio" name="auditResult" id="approved" value="2" checked="checked"/><label for="approved" class="myMargin3"> 通过</label></span>
							<span><input style="float:left;" type="radio" name="auditResult" id="rejected" value="4"/><label for="rejected"> 驳回</label></span>
						</td>
					</tr>
					<tr>
						<td nowrap="nowrap" valign="top">下一个处理人</td>
						<td>
							<span id="nextDealersSpan"><select name="nextDealer"><c:forEach items="${task.nextDealers}" var="dealer"><option value="${dealer.id}" <c:if test="${dealer.id==task.defaultNextDealer}">selected="selected"</c:if>>${dealer.name}</option></c:forEach></select></span>
							<span id="preDealersSpan" style="display: none;"><select name="nextDealer"><c:forEach items="${task.preDealers}" var="dealer"><option value="${dealer.id}">${dealer.name}</option></c:forEach></select></span>
						</td>
					</tr>
					<tr>
						<td nowrap="nowrap" valign="top">审核意见</td>
						<td>
							<textarea rows="5" cols="50" name="remark" id="remarkForAudit"></textarea>
							<div id="countForAudit"></div>
							<div style="display: none;">
								<select id="normalAuditText" style="display: none;" onchange="changeAuditRemark()">
									<option value="">--请选择常用审核意见--</option>
									<option value="难度分布不符合大纲要求">难度分布不符合大纲要求</option>
									<option value="认知层次分布不符合大纲要求">认知层次分布不符合大纲要求</option>
									<option value="总题数不合理">总题数不合理</option>
								</select>
							</div>
						</td>
					</tr>
					<tr>
						<td colspan="2" align="center">
							<button class="btn myMargin3" id="saveAuditBtn">确定</button>
							<button class="btn" id="cancelAuditBtn">取消</button>
						</td>
					</tr>
				</table>
            </form>
        </div>
    </div>
    
    <iframe id="iframeForClient" src=""></iframe>
</div>
</body>
</html>