123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- var examineeBehaviour = function () {
- var sender = this;
- // 题目导航ID前缀
- var prefix = '#navigation_';
- // 已完成题目的样式
- var complateClass = "navigation_question_complate";
- // 考试答案
- var examinee_answers = new Hashtable();
- // 已标识题目
- var signcount = 0;
- // 命令列表
- var commander = new Hashtable();
- // 单独警告次数
- var warningCount = 0;
- // 全体警告次数
- var allWarningCount = 0;
- // 考生状态
- var examState = 1;
- // 操作类型
- var ExamOperaType = {
- 交卷: 0,
- 取消交卷: 1,
- 提醒: 2,
- 警告: 3,
- 取消绑定: 4,
- 延时: 5,
- 强制交卷: 6,
- 取消强制交卷: 7,
- 举手: 8,
- 取消举手: 9,
- 更新状态: 10,
- 取消控制: 11
- }
- // 保存答案
- var Save = function (question_id, answer) {
- examinee_answers.add(question_id, answer);
- $("#exam_over").text(examInfo.questionCount - examinee_answers.count());
- }
- // 单选题
- this.Check_rad = function (obj, answerid, questionid) {
- cl(questionid);
- Save(questionid, answerid);
- }
- // 多选题
- this.Check_chk = function (obj, ctrlName, answerid, questionid) {
- var answers = $("input[name=" + ctrlName + "]:checked");
- var answer = "";
- if (answers.length > 0) {
- cl(questionid);
- answers.each(function (i, j) {
- if (answer.length > 0)
- answer += "|";
- answer += $(j).val();
- });
- }
- Save(questionid, answer);
- }
- // 填空题和计算题
- this.Check_text = function (obj, answerid, questionid) {
- if ($(obj).val().length > 0) {
- cl(questionid);
- Save(questionid, $(obj).val());
- }
- }
- // 简答题和论述题
- this.Check_area = function (obj, answerid, questionid) {
- if ($(obj).text().length > 0) {
- cl(questionid);
- Save(questionid, $(obj).text());
- }
- }
- // 多项填空题
- this.Check_text2 = function (obj, ctrlName, answerid, questionid) {
- var inputs = $("input[name=" + ctrlName + "]");
- if (inputs.filter(function (index) { return $(this).val().length > 0 }).length == inputs.length) {
- cl(questionid);
- }
- var answer = "";
- inputs.each(function (i, j) {
- if (answer.length > 0)
- answer += "|";
- answer += clearKeyChar($(j).val());
- });
- Save(questionid, answer);
- }
- // 交卷按钮点击事件
- $("#btn_takePaper").click(function () {
- takePaper();
- //sender.setSaftLeaveFlat(true);
- });
- this.bindSignEvent = function () {
- $(".btn_sign").click(function () {
- setSign(this);
- });
- }
- // 将答案半角字符修改成全角
- var clearKeyChar = function (val) {
- return val.replace(/\|/gi, "│")
- }
- // 屏蔽考试页面
- this.togglePapert = function (enabled) {
- if (enabled) {
- examState = 1;
- sender.setSaftLeaveFlat(false);
- $("#paper_body").show();
- $("#ExamMessage").hide();
- //$("#btn_takePaper").val("交 卷");
- $("#btn_takePaper").removeAttr("disabled");
- } else {
- examState = 2;
- sender.setSaftLeaveFlat(true);
- $("#paper_body").hide();
- $("#ExamMessage").show();
- //$("#btn_takePaper").val("已交卷");
- $("#btn_takePaper").attr("disabled", "disabled");
- }
- }
- this.registTimer = function (len) {
- len = len || examinee.lastLength;
- sender.setSaftLeaveFlat(false);
- $(".timer").calcTimer({
- limit: len,
- inputType: "s",
- format: "<span style='color:white;padding-right:40pt;'><font size='20pt' style='color:blue'>#H</font>时<font size='20pt' style='color:blue'>#M</font>分<font size='20pt' style='color:blue'>#S</font>秒</span>",
- ontimeout: function () {
- takePaper();
- },
- onCountdownError: function (container) {
- var examLength = Invoke(CMS_SystemConfig.VirtualDirectoryPath + "/OnlineTest/GetLastLengthOfExam", { test_id: examInfo.test_id, userid: examinee.userid });
- sender.registTimer(examLength);
- }
- });
- }
- this.setSaftLeaveFlat = function (saftleave) {
- if (saftleave) {
- window.onbeforeunload = null;
- }
- else {
- window.onbeforeunload = function () {
- return ('离开考试页面将清除您的答案,且增加考试登录次数!\n请确认是否离开当前考试页面?');
- }
- }
- }
- // 处理服务端返回命令
- this.handleCommand = function (cmdType, args) {
- commander.items(cmdType)(args);
- }
- // 标识已做题目
- var cl = function (id) {
- $(prefix + id).addClass(complateClass);
- }
- // 交卷
- var takePaper = function () {
- var result = JSON.stringify(examinee_answers.allitems());
- debugger
- var re = Invoke(CMS_SystemConfig.VirtualDirectoryPath + "/OnlineTest/TakePaper",
- { test_id: examInfo.test_id, userid: examinee.userid, answer: result });
- if (re.length > 6)
- alert(re);
- else {
- $('[id$=lbScore]').text("本次考试分数:" + re + "分");
-
- $(".timer").clear();
- sender.togglePapert(false);
- }
- }
- // 设置标识
- var setSign = function (btn) {
- var me = $(btn);
- var questionid = $(btn).attr("author");
- if (me.hasClass("btn_sign")) {
- $(prefix + questionid).addClass("navigation_question_sign");
- me.val(' 取消 ');
- me.removeClass("btn_sign");
- me.addClass("btn_signed");
- signcount += 1;
- }
- else {
- $(prefix + questionid).removeClass("navigation_question_sign");
- me.val(' 标识 ');
- me.removeClass("btn_signed");
- me.addClass("btn_sign");
- signcount -= 1;
- }
- $("#exam_sign").text(signcount);
- }
- // 警告处理
- commander.add(ExamOperaType.警告, function (args) {
- if (examState == 1) {
- if (args.type == 'person') {
- warningAlert(personWarring, args.intData);
- }
- else {
- warningAlert(allWarring, args.intData);
- }
- }
- });
- commander.add(ExamOperaType.交卷, function (args) {
- if (examState == 1) {
- takePaper();
- }
- });
- commander.add(ExamOperaType.取消交卷, function (args) {
- if (examState == 2) {
- examState = 1;
- sender.togglePapert(true);
- var examLength = Invoke("WaitExam.aspx/CancelTakePaper", { test_id: examInfo.test_id, userid: examinee.userid });
- sender.registTimer(examLength);
- }
- });
- commander.add(ExamOperaType.延时, function (args) {
- examState = 1;
- sender.togglePapert(true);
- var examLength = Invoke("WaitExam.aspx/CancelTakePaper", { test_id: examInfo.test_id, userid: examinee.userid });
- sender.registTimer(examLength);
- });
- commander.add(ExamOperaType.取消控制, function (args) {
- args.sender.removeExamineeExchangeEvent();
- });
- var warningAlert = function (warningInfo, count) {
- var message = '提示:监考员向您发出警告!请您遵守考场规则。';
- var msg = $(warningInfo).filter(function () { return this.key == count; });
- if (msg.length > 0) {
- message = msg.val();
- }
- examAlert(message);
- }
- var examAlert = function (msg) {
- radalert("<font size='6px'>" + msg + "</font>", 400, 210);
- }
- }
|