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 = "";
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 = "";
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, "│")
}