123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- var parctiteBuilder = function() {
- this.buildPaper = function() {
- if (typeof (question) != 'undefined') {
- $("#questionContent").setTemplateURL(CMS_SystemConfig.VirtualDirectoryPath + '/Scripts/Business/QuestionTemplate.htm?v=1111.111ss', null, { filter_data: false });
- $("#questionContent").processTemplate(question);
- }
- }
- }
- function showRefAnswer() {
- var reg1 = /^.{1}/;
- var answer = "";
- if (question.base_question_type_id == 1) {
- answer = reg1.exec($(question.Answers).filter(function() { return this.provid_answer_id == question.rightAnswer; })[0].answer_name) + "";
- }
- else if (question.base_question_type_id == 3) {
- var a = question.rightAnswer.split(',');
- $(question.Answers).filter(function() { return $.inArray(this.provid_answer_id + '', a) > -1; }).each(function(i, j) {
- if (answer.length > 0)
- answer += ',';
- answer += reg1.exec(j.answer_name);
- });
- }
- else if (question.base_question_type_id == 4) {
- answer = $(question.Answers).filter(function() { return this.provid_answer_id == question.rightAnswer; })[0].answer_name + "";
- }
- else if (question.base_question_type_id == 2) {
- if (typeof (question.Answers[0]) == 'undefined')
- answer = '找不到对应答案';
- else {
- var a = question.rightAnswer.split(',');
- $(question.Answers).filter(function() { return $.inArray(this.provid_answer_id + '', a) > -1; }).each(function(i, j) {
- if (answer.length > 0)
- answer += ' | ';
- answer += j.answer_name;
- });
- }
- }
- else {
- if (typeof (question.Answers[0]) == 'undefined')
- answer = '找不到对应答案';
- else
- answer = question.Answers[0].answer_name;
- }
- $("#refAnswer").text(answer);
- $("#rightAnswerContainer").show();
- }
- // 转换填空题单体占位符
- function transformSingle(type, question, answer) {
- var body = question.content;
- var target = "<input type='text' class='txt_underline' />";
- body = transform(body, target);
- return body;
- }
- // 替换占位符
- function transform(content, target) {
- var reg = /【.*?】/;
- return content.replace(reg, target);
- }
- function transformMuilte(typeid, typeName,question, answer) {
- var body = question.content;
- var answers = ""; //GetTextAnswer(question.id).split('|');
- for (var a in question.Answers) {
- var an = "";
- // if (answers.length > a)
- // an = answers[a];
- var ctrlName = "ST-" + typeid + "-" + question.test_question_Id;
- var target = "<input type='text' questionid='" + question.test_question_Id + "' answertype='" + typeName +
- "' class='txt_underline' name='" + ctrlName + "' value=\"" + an + "\"" +
- "onblur=\"Check_text2(this,'" + ctrlName + "','" + question.Answers[a].provid_answer_id + "','" + question.test_question_Id + "');\" />";
- body = transform(body, target);
- }
- return body;
- }
- // 保存答案
- var Save = function (question_id, answer) {
- $("[id$=hd_right_questionid]").val(question_id);
- right_answers=answer;
- }
- // 单选题
- function Check_rad(obj, answerid, questionid) {
- Save(questionid, answerid);
- }
- // 多选题
- function Check_chk(obj, ctrlName, answerid, questionid) {
- var answers = $("input[name=" + ctrlName + "]:checked");
- var answer = "";
- if (answers.length > 0) {
- answers.each(function (i, j) {
- if (answer.length > 0)
- answer += "|";
- answer += $(j).val();
- });
- }
- Save(questionid, answer);
- }
- // 填空题和计算题
- function Check_text (obj, answerid, questionid) {
- if ($(obj).val().length > 0) {
- Save(questionid, $(obj).val());
- }
- }
- // 简答题和论述题
- function Check_area (obj, answerid, questionid) {
- if ($(obj).text().length > 0) {
- Save(questionid, $(obj).text());
- }
- }
- // 多项填空题
- function Check_text2 (obj, ctrlName, answerid, questionid) {
- var inputs = $("input[name=" + ctrlName + "]");
-
- var answer = "";
- inputs.each(function (i, j) {
- if (answer.length > 0)
- answer += "|";
- answer += clearKeyChar($(j).val());
- });
- Save(questionid, answer);
- }
- // 将答案半角字符修改成全角
- var clearKeyChar = function(val) {
- return val.replace(/\|/gi, "│")
- }
|