// ==UserScript== // @name 安全培训考试系统辅助 // @namespace http://tampermonkey.net/ // @version 0.2 // @description 在http://61.128.255.173:8045/SpeJobCard/CheckInfo.aspx考试系统中直接显示答案 // @author chuckie // @match http://61.128.255.173:8045/* // @grant none // @downloadURL none // ==/UserScript== /* jshint -W097 */ 'use strict'; // Your code here... showQuestion = function showQuestion(questionNo) { if (questionNo <= arrStu.length) { if (questionNo == 1) { $("#btnBefore").attr("disabled", true); $("#btnNext").val("下一题"); } else { if (document.getElementById("btnStopExam").disabled == false) { $("#btnBefore").attr("disabled", false); } else { $("#btnBefore").attr("disabled", true); } if (questionNo == arrStu.length) { $("#btnNext").val("完成"); } else { $("#btnNext").val("下一题"); } } } else { return; } //arrStu下标 var no = parseInt(questionNo) - 1; var perScore = parseInt(100 / parseInt($("#ctl00_ContentPlaceHolder1_lblQuestionCount").html())); var limitScore = 100 % parseInt($("#ctl00_ContentPlaceHolder1_lblQuestionCount").html()); var innerHtm = ""; switch (arrStu[no].Que_Type) { case "0": innerHtm = innerHtm + "单选题(该题型共有" + quesCount0 + "题,当前第" + questionNo + "题)

"; break; case "1": innerHtm = innerHtm + "多选题(该题型共有" + quesCount1 + "题,当前第" + questionNo + "题)

"; break; case "2": innerHtm = innerHtm + "判断题(该题型共有" + quesCount2 + "题,当前第" + questionNo + "题)

"; break; } innerHtm = innerHtm + "."; if (no == 0) { innerHtm = innerHtm + arrStu[no].Que_Question + "(" + (perScore + limitScore) + "分)" + "
--"+arrStu[no].Que_Answer+"--
"; } else { innerHtm = innerHtm + arrStu[no].Que_Question + "(" + perScore + "分)"+ "
--"+arrStu[no].Que_Answer+"--
"; } //显示题目 switch (arrStu[no].Que_Type) { case "0": if (arrStu[no].Que_OptionA != "") { innerHtm = innerHtm + "A:" + arrStu[no].Que_OptionA + "

"; } if (arrStu[no].Que_OptionB != "") { innerHtm = innerHtm + "B:" + arrStu[no].Que_OptionB + "

"; } if (arrStu[no].Que_OptionC != "") { innerHtm = innerHtm + "C:" + arrStu[no].Que_OptionC + "

"; } if (arrStu[no].Que_OptionD != "") { innerHtm = innerHtm + "D:" + arrStu[no].Que_OptionD + "

"; } if (arrStu[no].Que_OptionE != "") { innerHtm = innerHtm + "E:" + arrStu[no].Que_OptionE + "

"; } break; case "1": if (arrStu[no].Que_OptionA != "") { innerHtm = innerHtm + "A:" + arrStu[no].Que_OptionA + "

"; } if (arrStu[no].Que_OptionB != "") { innerHtm = innerHtm + "B:" + arrStu[no].Que_OptionB + "

"; } if (arrStu[no].Que_OptionC != "") { innerHtm = innerHtm + "C:" + arrStu[no].Que_OptionC + "

"; } if (arrStu[no].Que_OptionD != "") { innerHtm = innerHtm + "D:" + arrStu[no].Que_OptionD + "

"; } if (arrStu[no].Que_OptionE != "") { innerHtm = innerHtm + "E:" + arrStu[no].Que_OptionE + "

"; } break; case "2": innerHtm = innerHtm + "正确

"; innerHtm = innerHtm + "错误

"; break; } $("#divTrueAnswer").hide(); $("#divShow").html(innerHtm); //如果是有答案的,显示之前的答案 if (answer[no] != null && answer[no] != undefined) { switch (arrStu[no].Que_Type) { case "0": $("input[name='rdoAnswer']").each(function() { if (answer[no] == $(this).val()) { $(this).attr("checked", true); } }); break; case "1": $("input[name='chkAnswer']").each(function() { var answerDuoxuan = answer[no].split(','); for (var i = 0; i <= answerDuoxuan.length - 1; i++) { if (answerDuoxuan[i] == $(this).val()) { $(this).attr("checked", true); } } }); break; case "2": $("input[name='rdoPanduan']").each(function() { if (answer[no] == $(this).val()) { $(this).attr("checked", true); } }); break; } } }