1、主页面,用来弹出弹出页面
//查看错误小练习$.exerciseClick = function(rowId ){$.event.get().preventDefault();var tdScore = $("#" + rowId).find("[aria-describedby='homeworkStudentListGrid_score']");if( parseInt(tdScore.html()) == 100 ){art.tips("小练习没有错误!", 1.5);return;}art.dialog.open("<c:url value='/teacherhomeworkmgr/showErrorExercise.action?homeworkRecordId='/>" +rowId,{id: 'errorExerciseDialog',title: '',top:"10%",lock: false,init: function () {var iframe = this.iframe.contentWindow; //获取子页面对象var top = art.dialog.top;// 获取父页面对象}},false);};
2、弹出页面
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%><style>
.mydiv{
width:700px;
margin:10px;
min-height:250px;
}.td{
width:50%;
text-align: center;
}
</style>
<script type="text/javascript">
function dyniframesize(ifm) {var pTar = null; if (document.getElementById){pTar = window.document.getElementById(ifm); } else { eval('pTar = ' + ifm + ';'); }if (pTar && pTar.src && !window.opera) {//begin resizing iframe pTar.style.display="block" ;if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){ //ns6 syntax pTar.height = pTar.contentDocument.body.offsetHeight +20; //pTar.width = pTar.contentDocument.body.scrollWidth+20; } else if (pTar.Document && pTar.Document.body.scrollHeight){ //ie5+ syntax pTar.height = pTar.Document.body.scrollHeight; //pTar.width = pTar.Document.body.scrollWidth; } }var width = $(".mydiv").width() + 30;var height = $(".mydiv").height() + 30;var myDialog = window.top.art.dialog.get("errorExerciseDialog");myDialog.size(width+"px", height+"px");
}//题号var topicNo = 0;//题目总数var topicLimit = '${fn:length(exerciseItemIdList)}'-1;var exerciseItemArray = JSON.parse('${exerciseItemIdListJsonString }');var answerArray = new Array(topicLimit);$().ready(function(){//设置题号$(".exercise_refresh_btn").bind("click",function(){topicNo = 0;if(exerciseItemArray.length>0){//默认显示错题号$("#wordErrorExercise").attr("src","<s:url value='/exercise/showExercise.action?itemId='/>"+exerciseItemArray[topicNo].exerciseItemId+"&exerciseStudyRecordItemId=" +exerciseItemArray[topicNo].id);//清空答案answerArray = new Array(topicLimit);$("#no").html("No."+(topicNo+1));if(exerciseItemArray.length==1){$("#next").hide();$("#prev").hide();}else{$("#next").show();$("#prev").show();$("#finishBtn").hide();$("#prev").attr("class", "button-disabled");$("#next").attr("class", "button");$("#finishBtn").attr("class", "button");$("#finishBtn").removeAttr("disabled");}}else{$(".mydiv").empty();$(".mydiv").append("<div style='height:100%;text-align:center;padding-top:100px;' class='font-18'>还没有错题!</div>");}});//上一题$("#prev").click(function(){if('${roleType}' == "child"){$("#next").show();$("#finishBtn").hide();}else{$("#next").attr("class", "button");}if(topicNo!=0){topicNo--;if(topicNo==0){$(this).attr("class", "button-disabled");}var userAnswer = wordErrorExercise.window.$.getUserAnswer(0);if(wordErrorExercise.window.$(".exercise_item_number_selected").hasClass("exercise_item_number_do")){answerArray[topicNo+1] = userAnswer.isCorrect;saveRecord(exerciseItemArray[topicNo+1].id,userAnswer.isCorrect);}$("#wordErrorExercise").attr("src","<s:url value='/exercise/showExercise.action?itemId='/>"+exerciseItemArray[topicNo].exerciseItemId+"&exerciseStudyRecordItemId=" +exerciseItemArray[topicNo].id);}$("#no").html("No."+(topicNo+1));});//下一题$("#next").click(function(){$("#prev").attr("class", "button");if(topicNo!=topicLimit){topicNo++;if(topicNo==topicLimit){if('${roleType}' == "child"){$(this).hide();$("#finishBtn").show();}else{$(this).attr("class", "button-disabled");}}var userAnswer = wordErrorExercise.window.$.getUserAnswer(0);if(wordErrorExercise.window.$(".exercise_item_number_selected").hasClass("exercise_item_number_do")){answerArray[topicNo-1] = userAnswer.isCorrect;saveRecord(exerciseItemArray[topicNo-1].id,userAnswer.isCorrect);}$("#wordErrorExercise").attr("src","<s:url value='/exercise/showExercise.action?itemId='/>"+exerciseItemArray[topicNo].exerciseItemId+"&exerciseStudyRecordItemId=" +exerciseItemArray[topicNo].id);}$("#no").html("No."+(topicNo+1));});$("#finishBtn").click(function(){var userAnswer = wordErrorExercise.window.$.getUserAnswer(0);if(wordErrorExercise.window.$(".exercise_item_number_selected").hasClass("exercise_item_number_do")){answerArray[topicNo] = userAnswer.isCorrect;saveRecord(exerciseItemArray[topicNo].id,userAnswer.isCorrect);}showExerciseResult(answerArray);});$(".exercise_refresh_btn").trigger("click");});function saveRecord(id,isCorrect){var requestUrl = "<s:url value='/studyreport/saveOrUpdateWordExerciseRecordItem.action?exerciseStudRecordItemId='/>"+ id+"&isFixed="+isCorrect;$.ajax({async: false,cache: false,url: requestUrl,type: "GET",dataType: "json",success: function(response) {}});}</script>
<div class="mydiv"><div style="left: 10px;position: relative;" class="font-18 errorCount">共做错了${fn:length(exerciseItemIdList)}道题。<div class="exercise_refresh_btn" title="重做一遍" style="margin-top:5px;position: absolute;right: 20px;display:none;"></div></div><div><span id = "no" class="font-18" style="margin-left: 10px;"></span></div><div><iframe id="wordErrorExercise" name ="wordErrorExercise"src="javascript:void(0)"scrolling=no width="100%" frameborder="no" border="0" οnlοad="javascript:dyniframesize('wordErrorExercise');"></iframe></div><table><tr><td class="td"><input id="prev" type="button" class="button" value="上一题"></td><td class="td"><input id="next" type="button" class="button" value="下一题"><input id="finishBtn" type="button" class="button" value="完成" style="display: none;"></td></tr></table></div>