You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1176 lines
43 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

var answer_cache = new Array();
var ismark_cache = false;
var time = 0;
$(function () {
UserTimeHelper.Init();
//退出系统
$(".link").unbind("click").bind("click", function () {
dialogHelper.Confirm({
content: "您确定退出系统吗?",
success: function () {
location.href = "/SignIn/SignOut";
}
});
})
$("#btnChangePwd").unbind("click").click(function () {
var area = $("#hdArea").val();
var oldPwd = $.trim($("#txtOldPwd").val());
var newPwd = $.trim($("#txtNewPwd").val());
var confirmPwd = $.trim($("#txtConfirmPwd").val());
//输入验证
var checkData = function () {
if (newPwd != confirmPwd) {
showValidateMsg("txtConfirmPwd", "确认密码与新密码不一致!");
}
};
if (!VerificationHelper.checkFrom("popChangePassword", checkData)) {
return;
}
$.ajax({
url: "/Student/Common/ChangePass",
type: "POST",
dataType: "json",
data:
{
oldPwd: oldPwd,
newPwd: newPwd,
rId: Math.random()
},
//成功,绑定数据
success: function (data) {
dialogHelper.Success({
content: "密码修改成功!",
success: function () {
location.href = location.href;
}
});
}
});
});
//获取列表
var Id = $.getUrlParam("Id");
//是否为认证考试
var LibraryId = $.getUrlParam("LibraryId");
//已评分查看
var Type = $.getUrlParam("type");
if (Type == 1) {
LookOver(Id);
//readonly = "readonly"
$("#TextContent2").attr('readonly', true); //TextContent2
$("#zaida").html("当前");
} else {
$("#tijiao").show();
$("#tiankongAnswer2").hide();
$("#tab_1").hide();
$("#tab_2").hide();
}
var charpterID = $.getUrlParam("charpterID");
if (LibraryId == 23) {
if (charpterID == 13 || charpterID == 14) {
//$(".pracTitle").append("助理理财规划师(国家职业资格三级)");
$(".pracTitle").append("金融智能投顾认证教育部1+X证书");
} else {
$(".pracTitle").append("中国银行业从业人员资格认证");
}
}
if (LibraryId==1) {
$("#fujian2").show();
} else {
$("#fujian2").hide();
}
GetPaperDetailList(Id, LibraryId)
//获取第一题
GetQuestion(Id, LibraryId);
//上一题
$("#btnPrev").unbind("click").click(function () {
var prevType = parseInt($("#hdPrevType").val());
var prevId = parseInt($("#hdPrevId").val());
if (prevId == 0) {
var question = $("#question_list_content .mistake2").attr("tag");
var type = $("#question_list_content .mistake2").attr("ty");
if (Type!=1) {
UpdateExamAnswer(Id, question, type);
}
$("#btnPrev").attr('disabled', true);
$("#btnPrev").css("background-color", "#808080");//00a2e2
//UpdateExamAnswer(Id, question, type);
return;
} else {
$("#btnPrev").attr('disabled', false); //TextContent2
$("#btnPrev").css("background-color", "#00a2e2");//00a2e2
$("#btnNext").attr('disabled', false);
$("#btnNext").css("background-color", "#00a2e2");//00a2e2
var question = $("#question_list_content .mistake2").attr("tag");// $("#hdQuestionId").val();
var type = $("#question_list_content .mistake2").attr("ty");
if (Type != 1) {
UpdateExamAnswer(Id, question, type);
}
GetQuestion(Id, LibraryId, prevType, prevId);
}
});
//下一题
$("#btnNext").unbind("click").click(function () {
var nextType = parseInt($("#hdNextType").val());
var nextId = parseInt($("#hdNextId").val());
if (nextType==0) {
var question = $("#question_list_content .mistake2").attr("tag");
var type = $("#question_list_content .mistake2").attr("ty");
if (Type != 1) {
UpdateExamAnswer(Id, question, type);
}
$("#btnNext").attr('disabled', true);
$("#btnNext").css("background-color", "#808080");//00a2e2
return;
} else {
$("#btnNext").attr('disabled', false);
$("#btnNext").css("background-color", "#00a2e2");//00a2e2
$("#btnPrev").attr('disabled', false);
$("#btnPrev").css("background-color", "#00a2e2");//00a2e2
var question = $("#question_list_content .mistake2").attr("tag");
var type = $("#question_list_content .mistake2").attr("ty");
if (Type != 1) {
UpdateExamAnswer(Id, question, type);
}
GetQuestion(Id, LibraryId, nextType, nextId);
}
});
if (Type == 1) {
} else {
//倒计时
daojishi(Id);
}
//提交
$("#tijiao").unbind("click").bind("click", function () {
if (Type == 1) {
if (LibraryId==23) {
var charpterID = $.getUrlParam("charpterID");
location.href = "/Student/Cert/CertEntrance?charpterID=" + charpterID;
} else {
location.href = "/Student/EheoryExamine/AlreadyEheoryExamine";
}
} else {
CheckExam(LibraryId);
}
})
});
//加载左侧列表
function GetPaperDetailList(Id, LibraryId, questionType, pageIndex, questionTypeId, optAsync) {
//点击题型按钮时保存题目
var question = $("#question_list_content .mistake2").attr("tag");
var type = $("#question_list_content .mistake2").attr("tyid");
var type3 = $("#question_list_content .mistake2").attr("ty");
var type2 = $("#hdQuestionType").val();
if (type2 == type) {
var Type = $.getUrlParam("type");
if (Type != 1) {
UpdateExamAnswer(Id, question, type3);
}
}
var async = true;
//题型选中样式
if(questionType != undefined){
$(".caption-switch-con > span").removeClass("on");
$(".caption-switch-con > span[name='type_" + questionTypeId + "']").addClass("on");
}
if (optAsync != undefined) {
async = optAsync;
}
$.ajax({
url: "/Student/EheoryExamine/GetPaperDetailList",
async: false,
type: "POST",
data: {
questionType: questionType,
pageIndex: pageIndex,
questionTypeId:questionTypeId,
Id: Id,
LibraryId: LibraryId
},
success: function (data) {
//if (!$.checkSignIn(data)) return;
//是否为认证考试
var LibraryId = $.getUrlParam("LibraryId");
var charpterID = $.getUrlParam("charpterID");
var Number = 0;
if (data != null && data != "") {
//姓名、科目、时间等信息
$(".user-name").html(data.UserName);
var lens = 0;
var name = "";
if (data.UserName.length>10) {
name = data.UserName.substring(0, 10) + "...";
} else {
name = data.UserName;
}
$("#li_name").html("姓 名:" + name).attr("title", data.UserName);
$("#Sexs").val(data.Sex);
$("#StudentNo").val(data.StudentNo);
$("#li_subject").html("试卷名称:" + data.PaperName).attr("title", data.PaperName);
$("#li_examtime").html("考试时间:" + data.strTime);
var title = $(".pracTitle").html();
if (title.indexOf(data.PaperName) < 0) {
if (LibraryId==23) {
if (charpterID == 13 || charpterID == 14) {
$("#li_subject").html("考试科目:" + data.PaperName);
} else {
$("#li_subject").html("考试科目:" + data.PaperName);
}
}
}
$("#question_list_content").html("");
var QID = 0;
//加载题目
$(data.Question).each(function (index, dom) {
if(index==0){
$("#FirstQuestionId").val(dom.Id);
}
var html = "";
if (dom.StructType == 4) {
html += "<li id=\"li_question_" + dom.Id + "\" tyid=" + dom.strIdList + " ty=" + dom.StructType + " tag=" + dom.Id + " class=\"";
} else {
html += "<li id=\"li_question_" + dom.Id + "\" tyid=" + dom.strIdList + " ty=" + dom.StructType + " tag=" + dom.Id + " class=\"";
}
//是否已完成
if (dom.Result != null && dom.IsDaTi == true) {
html += " mistake ";
} else if (dom.Result == null && dom.IsDaTi == true) {
html += " mistake ";
}
//是否当前题目
if (String(dom.strIdList) == $("#hdQuestionType").val() || index == 0) {
//在查看的时候不需要在答的底色
var type = $.getUrlParam("type");
if (type!=1) {
if (dom.StructType == 4) {
if (String(dom.Id) == $("#hdQuestionId").val()) {
html += " mistake2 ";
}
} else {
if (String(dom.Id) == $("#hdQuestionId").val() || index == 0) {
html += " mistake2 ";
}
}
}
}
//是否对题目进行了标记
if (dom.IsMark) {
html += " ico-sign ";
}
html += "\" >";
if (dom.IsMark) {
html += "<i></i>";
}
if (dom.StructType == 4) {
html += "<strong onclick=\"javascript:UpdateExamAnswer(" + Id + "," + dom.Id + "," + dom.StructType + ");GetQuestion(" + Id + "," + LibraryId + "," + dom.StructType + "," + dom.Id + ")\">";
} else {
html += "<strong onclick=\"javascript:UpdateExamAnswer(" + Id + "," + dom.Id + "," + dom.StructType + ");GetQuestion(" + Id + "," + LibraryId + "," + dom.StructType + "," + dom.Id + ")\">";
}
html += ((data.PageIndex - 1) * data.PageSize + index + 1);
html += "</strong></li>";
$("#question_list_content").append(html);
});
//加载题目类型
if (data.QuestionTypes != null && data.QuestionTypes.length > 0) {
var htmls = "";
$(".caption-switch-con").html("");
$(data.QuestionTypes).each(function (index, dom) {
htmls += "<span data-value=\"" + dom.strIdList + "\" name=\"type_" + dom.strIdList + "\"" + (index == 0 ? "class=\"on\"" : "") + " onclick=\"javascript:GetPaperDetailList(" + Id + "," + LibraryId + "," + GetTypeId(dom.TypeName) + ",1,'" + dom.strIdList + "',true);GetQuestion(" + Id + "," + LibraryId + "," + GetTypeId(dom.TypeName) + ",-1)\" >" + dom.TypeName + "</span>";
});
$(".caption-switch-con").html(htmls);
}
//该题型下有多少题
$("#hdQuestionCount").val(data.Count);
//该题型当前页数
$("#hdQuestionPageIndex").val(data.PageIndex);
//该题型总页数
$("#hdQuestionPageCount").val(data.PageCount);
//具体的题目列表
//$("#question_list_content").html("");
}
}
});
}
//题目上下翻页
function GoPage(type) {
var pageIndex = parseInt($("#hdQuestionPageIndex").val());
var pageCount = parseInt($("#hdQuestionPageCount").val());
var questionType = $(".caption-switch-con > span[class='on']").attr("data-value");
var Id = $.getUrlParam("Id");
if (type == 1) {
//上翻页
if (pageIndex - 1 < 1) {
return;
} else {
GetPaperDetailList(Id,questionType, (pageIndex - 1), true);
}
} else {
//下翻页
if (pageIndex + 1 > pageCount) {
return;
} else {
GetPaperDetailList(Id,questionType, (pageIndex + 1), true);
}
}
}
//获取题目
function GetQuestion(PaperId, LibraryId,questionType, questionId) {
if (questionId != undefined && questionId==-1) {
questionId = $("#FirstQuestionId").val();
}
$("#fujian2").hide();
//清空标记框
$("#isMark").removeAttr("checked");
$.ajax({
url: "/Student/EheoryExamine/GetQuestion",
type: "POST",
async: false,
dataType: "json",
crossDomain: false,
data:
{
questionType: questionType,
questionId: questionId,
PaperId: PaperId,
LibraryId: LibraryId
},
success: function (data) {
// if (!$.checkSignIn(data)) return;
var num;
if(data != null && data != ""){
var Type = $.getUrlParam("type");
if (data.Flag) {
//显示试题
var question = data.Data;
$("#questionContext").html(question.Context);
$(".item-info ul").html("");
if (data.StructType == 1) {
$("#tiankongAnswer").hide();
$("#selectAnswer").show();
//单选
var html1 = "";
$.each(question.OptionList, function (i, item) {
html1 += " <li><label><input value=" + (i) + " type='radio' name='answer' >" + GetAnswerStr(i) + "</label><input type='text' disabled='disabled' class='inputtext' style='overflow:hidden' title='" + item.OptionName + "' value='" + item.OptionName + "' /></li>";
});
$(".item-info ul").html(html1);
} else if (data.StructType == 2) {
$("#tiankongAnswer").hide();
$("#selectAnswer").show();
//多选
var html2 = "";
$.each(question.OptionList, function (i, item) {
html2 += " <li><label><input value=" + (i) + " type='checkbox' name='answer'>" + GetAnswerStr(i) + "</label><input type='text' disabled='disabled' style='overflow:hidden' class='inputtext' title='" + item.OptionName + "' value='" + item.OptionName + "' /></li>";
});
$(".item-info ul").html(html2);
} else if (data.StructType == 3) {
$("#tiankongAnswer").hide();
$("#selectAnswer").show();
//判断
var html3 = "";
$.each(question.OptionList, function (i, item) {
html3 += " <li><label><input value=" + (i) + " type='radio' name='answer'>" + GetAnswerStr(i) + "</label><input type='text' disabled='disabled' style='overflow:hidden' class='inputtext' title='" + item.OptionName + "' value='" + item.OptionName + "' /></li>";
});
$(".item-info ul").html(html3);
$("#selectAnswer").show();
} else if (data.StructType == 4) {
//填空题
$("#tiankongAnswer").show();
$("#selectAnswer").hide();
} else {
$("#tiankongAnswer").show();
$("#selectAnswer").hide();
}
var LibraryId = $.getUrlParam("LibraryId");
var ty = "";
if (LibraryId == 1) {
if (question.AttachmentList != null) {
if (question.AttachmentList.length > 0) {
//附件
$("#fujian2").show();
var html = "";
$.each(question.AttachmentList, function (i, item) {
if (i == 0) {
ty = "一";
} else if (i == 1) {
ty = "二";
} else if (i == 2) {
ty = "三";
}
var lastIndex = item.Name.lastIndexOf("\\");
var fullName = item.Name.substring(lastIndex + 1);
var _index = fullName.lastIndexOf(".");
var name = fullName.substring(0, _index);
html += " <a href=\"javascript:DownLoad('" + item.FileUrl + "','" + escape(name) + "','" + item.Id + "');\"><img src=\"/Content/images/text-icon.png\"><span>附件" + ty + "</span></a>";
});
$(".accessory").html(html);
}
}
} else {
$("#fujian2").hide();
}
//当前题目类型和ID
$("#hdQuestionType").val(data.Current.Key);
$("#hdQuestionId").val(data.Current.Value);
var Id = $.getUrlParam("Id");
//是否为认证考试
var LibraryId = $.getUrlParam("LibraryId");
//题型跟左侧是否一致,不一致则切换加载,一致则看是否在当前页
var type = $(".caption-switch-con > span[class='on']").attr("data-value");
if (type != String(data.Current.Key)) {
GetPaperDetailList(Id,LibraryId, data.StructType, 1, data.Current.Key, false);
} else {
var pageIndex = parseInt($("#hdQuestionPageIndex").val());
//找不到当前题目时
if ($("#li_question_" + data.Current.Value).length < 1) {
//上一题存在,则说明本题在下一页
if ($("#li_question_" + data.Prev.Value).length > 0) {
GetPaperDetailList(Id,LibraryId, data.StructType, (pageIndex + 1), data.Current.Key, false);
} else {
//下一题存在,则说明本题在上一页
if ($("#li_question_" + data.Next.Value).length > 0) {
GetPaperDetailList(Id,LibraryId, data.StructType, (pageIndex - 1), data.Current.Key, false);
return;
}
}
}
}
//当前题目颜色
$("#question_list_content > li").removeClass("mistake2");
$("#li_question_" + data.Current.Value).addClass("mistake2");
if (data.StructType == 4 || data.StructType == 5) {
if (data.Answers2 != null && data.Answers2.length!=0) {
$(data.Answers2).each(function (index, dom) {
$("#TextContent").val(htmlDecode(dom));
answer_cache.push(dom);
});
} else {
$("#TextContent").val("");
}
$("#daan1").hide();
$("#daan2").hide();
} else {
var checked = "";
$("#daan1").show();
$("#daan2").show();
$("#daan3").show();
$("#daan4").show();
//答案
answer_cache = new Array();
if (data.StructType == 1 || data.StructType == 2 || data.StructType == 3) {
if (data.Answers != null && data.Answers.length > 0) {
$(data.Answers).each(function (index, dom) {
$("input[name='answer'][value='" + dom + "']").attr("checked", true);
answer_cache.push(dom);
checked += GetAnswerStr(dom);
});
}
}
$("#span_3").html(checked);//您的答案
}
//是否标记
$("#isMark").attr("checked", data.IsMark);
ismark_cache = data.IsMark;
//上一题,下一题
$("#hdPrevType").val(data.Prev.Key)
$("#hdPrevId").val(data.Prev.Value);
$("#hdNextType").val(data.Next.Key);
$("#hdNextId").val(data.Next.Value);
$("#btnPrev,#btnNext").removeClass("btnNo");
if (data.Prev.Value == 0) {
$("#btnPrev").addClass("btnNo");
}
if (data.Next.Value == 0) {
$("#btnNext").addClass("btnNo");
}
//头部信息
$(".crumb").html(data.Info);
//主题干
if (data.Topic == null || data.Topic == "") {
$("#itm").hide();
} else {
$("#itm").show();
$("#itm").html(data.Topic);
}
} else {
if (data.ErrorCode != undefined) {
if (data.ErrorCode == 404 || data.ErrorCode == "404") {
dialogHelper.Error({
content: data.ErrorMsg,
success: function () {
location.href = "/Student/Index";
},
cancle: function () {
location.href = "/Student/Index";
}
});
} else {
dialogHelper.Error({ content: data.ErrorMsg });
}
} else {
dialogHelper.Error({ content: data.ErrorMsg });
}
}
$(".li_question_" + questionId).addClass("mistake2");
}
if (Type == 1) {
//是否为认证考试
var LibraryId = $.getUrlParam("LibraryId");
if (LibraryId == 1) {
if (data.analyse != null && data.analyse!="") {
$("#tiankongAnswer2").show();
$("#TextContent2").val(data.analyse);
var type = $("#question_list_content .mistake2").attr("ty");
if (type == 1 || type == 2 || type == 3 ) {
$("#pingxi").html("解析:");
} else {
$("#pingxi").html("评析:");
}
} else {
$("#tiankongAnswer2").hide();
}
} else {
if (data.analyse != null && data.analyse != "") {
$("#pingxi").html("解析:");
$("#tiankongAnswer2").show();
$("#TextContent2").val(data.analyse);
} else {
$("#tiankongAnswer2").hide();
}
}
$("#span_1").html(data.StandardScore);//标准分
$("#span_2").html(data.RightScore);//得分
if (data.StructType == 1 || data.StructType == 2 || data.StructType == 3) {
$("#daan1").show();
$("#daan2").show();
$("#daan3").show();
$("#daan4").show();
var check = "";
$.each(data.answer, function (i, n) {
check += GetAnswerStr(n);
});
$("#span_4").html(check);//标准答案
} else {
$("#daan3").hide();
$("#daan4").hide();
}
$(".item-info ul").find("input").attr("disabled", "disabled");
$("#TextContent").attr("readonly", "readonly");
$("#isMark").attr("disabled", "disabled");
$("#time").hide();
$("#tijiao").html("返回");
}
var prevType = parseInt($("#hdPrevType").val());
var prevId = parseInt($("#hdPrevId").val());
var prev = $("#hdPrevId").val();
var nextType = parseInt($("#hdNextType").val());
var nextId = parseInt($("#hdNextId").val());
var next = $("#hdNextId").val();
if (prevId == 0 || prev=="") {
$("#btnPrev").attr('disabled', true);
$("#btnPrev").css("background-color", "#808080");//00a2e2
} else {
$("#btnPrev").attr('disabled', false);
$("#btnPrev").css("background-color", "#00a2e2");//00a2e2
}
if (nextId == 0 || next == "") {
$("#btnNext").attr('disabled', true);
$("#btnNext").css("background-color", "#808080");//00a2e2
} else {
$("#btnNext").attr('disabled', false);
$("#btnNext").css("background-color", "#00a2e2");//00a2e2
}
}
});
}
//更新答案
function UpdateExamAnswer(Id, question, nextType,bo) {
var Type = $.getUrlParam("type");
if (Type != 1) {
if (!VerificationHelper.checkFrom("tiankongAnswer")) {
return false;
}
//是否为认证考试
var LibraryId = $.getUrlParam("LibraryId");
var check_answer_flag = true;
var check_ismark_flag = true;
//拼接
var strAnswer = "";
$("input[name='answer']").each(function (index, dom) {
if ($(dom).attr("checked")) {
strAnswer += $(dom).val();
strAnswer += ",";
}
});
if ($("#TextContent").val() != "") {
strAnswer = $("#TextContent").val();
strAnswer = htmlEncode(strAnswer);
//strAnswer = strAnswer.replace(/[<>&"]/g, function (c) { return { '<': '&lt;', '>': '&gt;', '&': '&amp;', '"': '&quot;', '"': '&quot;', "'": '&prime;', "'": '&prime;' }[c]; });
}
//答案是否更改
var arr = [];
if (nextType == 1 || nextType == 2 || nextType==3) {
if (strAnswer.lastIndexOf(",") > -1) {
strAnswer = strAnswer.substring(0, strAnswer.lastIndexOf(","));
}
if (strAnswer.length > 0) {
arr = strAnswer.split(',');
}
} else {
if (strAnswer.length > 0) {
arr = strAnswer;
}
}
if (answer_cache.length == arr.length) {
$(arr).each(function (index, dom) {
if (answer_cache[index] != undefined) {
if (answer_cache[index] != parseInt(dom)) {
check_answer_flag = false;
}
}
});
} else {
check_answer_flag = false;
}
//标记是否被更改
var isMark = $("#isMark").attr("checked") == "checked";
if (ismark_cache != isMark) {
check_ismark_flag = false;
}
if (check_answer_flag && check_ismark_flag) {
return;
}
question = $("#question_list_content .mistake2").attr("tag");
//更新答案
$.ajax({
url: "/Student/EheoryExamine/UpdateExamAnswer",
type: "POST",
async: false,
dataType: "json",
crossDomain: false,
data:
{
strAnswer: strAnswer,
isMark: isMark,
Id: Id,
QuestionId: question,
Type: nextType,
LibraryId: LibraryId
},
success: function (data) {
//if (!$.checkSignIn(data)) return;
//填写答案则标识为已完成
if (strAnswer.length > 0) {
$("#li_question_" + $("#hdQuestionId").val()).addClass("mistake")
} else {
$("#li_question_" + $("#hdQuestionId").val()).removeClass("mistake")
}
//更新标识
SetMark($("#hdQuestionType").val(),$("#hdQuestionId").val(), $("#isMark").attr("checked") == "checked");
if(bo!=true){
$("#TextContent").val("");
}
if (!data.Flag) {
dialogHelper.Error({ content: data.ErrorMsg });
}
}
});
// $("#TextContent").val("");
}
}
//获取答案序号
function GetAnswerStr(index) {
var result = "";
switch (index) {
case 0:
result = "A";
break;
case 1:
result = "B";
break;
case 2:
result = "C";
break;
case 3:
result = "D";
break;
case 4:
result = "E";
break;
case 5:
result = "F";
break;
case 6:
result = "G";
break;
case 7:
result = "H";
break;
case 8:
result = "I";
break;
case 9:
result = "J";
break;
}
return result;
}
//检测试卷完成情况
function CheckExam(LibraryId) {
var Id = $.getUrlParam("Id");
//更新当前页答案
var question = $("#question_list_content .mistake2").attr("tag");
var type = $("#question_list_content .mistake2").attr("ty");
UpdateExamAnswer(Id, question, type,true);
//检测是否有未完成题目
$.ajax({
url: "/Student/EheoryExamine/CheckExamQuestion",
type: "POST",
async: false,
dataType: "json",
crossDomain: false,
data:
{
ExamPaperId: Id,
LibraryId: LibraryId
},
success: function (data) {
// if (!$.checkSignIn(data)) return;
var error = "";
if (data.radioNum > 0) {
error += "您还有" + data.radioNum + "道题未完成,";
error += "确认提交试卷?<br>";
dialogHelper.Confirm({
content: error,
success: function () {
FinishExam(Id);
}
});
return;
}
if (data.Flag) {
dialogHelper.Confirm({
content: "考试尚未结束,确认提交试卷?",
success: function () {
FinishExam(Id);
}
});
} else {
if (data.ErrorCode != undefined) {
if (data.ErrorCode == 404 || data.ErrorCode == "404") {
dialogHelper.Error({
content: data.ErrorMsg,
success: function () {
location.href = "/Student/EheoryExamine/Index";
},
cancle: function () {
location.href = "/Student/EheoryExamine/Index";
}
});
} else {
dialogHelper.Error({ content: data.ErrorMsg });
}
} else {
}
}
}
});
}
//结束考试
function FinishExam(PaperId) {
//是否为认证考试
var LibraryId = $.getUrlParam("LibraryId");
$.ajax({
url: "/Student/EheoryExamine/FinishExam",
type: "POST",
async: false,
dataType: "json",
crossDomain: false,
data:
{
PaperId: PaperId,
LibraryId: LibraryId
},
success: function (data) {
//if (!$.checkSignIn(data)) return;
if (data.Flag) {
dialogHelper.Success({
content: "试卷提交成功!",
success: function () {
if (LibraryId==1) {
location.href = "/Student/EheoryExamine/AlreadyEheoryExamine";
} else {
var charpterID = $.getUrlParam("charpterID");
location.href = "/Student/Cert/CertEntrance?charpterID=" + charpterID;
}
},
cancle: function () {
if (LibraryId == 1) {
location.href = "/Student/EheoryExamine/AlreadyEheoryExamine";
} else {
var charpterID = $.getUrlParam("charpterID");
location.href = "/Student/Cert/CertEntrance?charpterID=" + charpterID;
}
}
})
} else {
dialogHelper.Error({ content: "系统出错,请联系管理员!" });
}
}
});
}
//设置标识
function SetMark(questionType, questionId, flag) {
if (flag) {
//增加标识
$("#li_question_" + questionId).addClass("ico-sign");
$("#li_question_" + questionId).prepend("<i></i>");
} else {
//去除标识
$("#li_question_" + questionId).removeClass("ico-sign");
$("#li_question_" + questionId + " > i").remove();
}
}
//获取题目类型
function GetQuestionType(type) {
var typename = ""
if(String(type) == 1){
typename = "单选题";
} else if(String(type) == 2){
typename = "多选题";
} else if(String(type) == 3){
typename = "判断题";
} else if (String(type) == 4) {
typename = "综合题";
}
return typename;
}
//获取题目类型
function GetTypeId(type) {
var typename = ""
if (String(type) == "单选题") {
typename =1 ;
} else if (String(type) == "多选题") {
typename = 2;
} else if (String(type) == "判断题") {
typename = 3;
} else if (String(type) == "填空题") {
typename = 4;
} else {
typename = 5;
}
return typename;
}
//标记事件
function IsMark(value) {
var questionType = $("#question_list_content .mistake2").attr("tyid");
var questionId = $("#question_list_content .mistake2").attr("tag");
var Id = $.getUrlParam("Id");
if ($(value).attr("checked") == "checked") {
//增加标识
$("#li_question_" + questionId).addClass("ico-sign");
$("#li_question_" + questionId).prepend("<i></i>");
// UpdateExamAnswer(Id, questionId, questionType);
// GetQuestion(Id, nextType, nextId);
} else {
//去除标识
$("#li_question_" + questionId).removeClass("ico-sign");
$("#li_question_" + questionId + " > i").remove();
}
}
function daojishi(Id) {
//倒计时
time = 2 * 60 * 60;
var flag = true;
time = GetTimes(false, Id);
//倒计时,每秒刷新一次
window.setInterval(function () {
if (time >= 0) {
var hh = parseInt(time / 60 / 60 % 24, 10); //计算剩余的小时数
var mm = parseInt(time / 60 % 60, 10); //计算剩余的分钟数
var ss = parseInt(time % 60, 10); //计算剩余的秒数
$("#strTimes").html(hh + ":" + checkTime(mm) + ":" + checkTime(ss));
time = time - 1;
} else {
//提交试卷
if (flag) {
flag = false;
// UpdateExamAnswer();
var Id = $.getUrlParam("Id");
FinishExam(Id);
}
}
}, 1000);
//每五分钟访问一次后台,校准时间
window.setInterval("GetTimes(true," + Id + ")", 1 * 60 * 1000);
}
//倒计时选相关方法
function GetTimes(async, Id) {
//是否为认证考试
var LibraryId = $.getUrlParam("LibraryId");
$.ajax({
url: "/Student/EheoryExamine/GetExamTimes",
type: "POST",
async: async,
dataType: "json",
crossDomain: false,
data:
{
Id: Id,
LibraryId: LibraryId
},
success: function (data) {
//if (!$.checkSignIn(data)) return;
if (data != null && data != "") {
time = data;
}
}
});
return time;
}
function checkTime(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}
/**
* 登出系统
*/
function SignOut() {
dialogHelper.Confirm({
content: msgList["20002"],
success: function () {
location.href = "/SignIn/SignOut";
},
});
}
/**
* 修改密码
*/
function ChangePwd() {
$("#popChangePassword .btn-close").unbind("click").click(function () {
dialogHelper.Close("popChangePassword");
});
//清空数据
$("#popChangePassword .warn-box").remove()
$("#txtOldPwd").val("");
$("#txtNewPwd").val("");
$("#txtConfirmPwd").val("");
dialogHelper.Show("popChangePassword");
}
//文件下载
function DownLoad(path, name, Id) {
location.href = "/Student/EheoryExamine/DownloadFile?path=" + encodeURIComponent(path)+ "&name=" + encodeURIComponent(name) + "&randomId=" + Math.random();
}
//已评分查看正确率
function LookOver(Id) {
//是否为认证考试
var LibraryId = $.getUrlParam("LibraryId");
$.ajax({
url: "/Student/EheoryExamine/GetPaperDetail",
async: false,
type: "POST",
data: {
Id: Id,
LibraryId: LibraryId
},
success: function (data) {
if (data != null && data != "") {
//加载题目类型
if (data.QuestionTypes != null && data.QuestionTypes.length > 0) {
var htmll = "";
var AllNumber = 0;
var YesNumber = 0;
var fengshu=0;
$(data.QuestionTypes).each(function (index, dom) {
var str = dom.strIdList.split(',');
for (var s = 0; s < str.length;s++){
$(data.Details).each(function (i, n) {
if (n.StructTypeId == str[s]) {
AllNumber = Number(AllNumber) + 1;
}
});
$(data.PUserAnswerResult).each(function (a, b) {
if (b.QuestionTypeId == str[s]) {
if (b.Result == 2) {
YesNumber = Number(YesNumber) + 1;
fengshu = Number(fengshu) + Number(b.UserScore);
}
}
});
}
htmll += "<tr >";
htmll += "<td style='border:1px solid gray'>" + dom.TypeName + "</td>";
if (dom.TypeName == "单选题" || dom.TypeName == "多选题" || dom.TypeName == "判断题") {
htmll += "<td style='border:1px solid gray'><span style='Color:red'>" + YesNumber + "</span>/" + AllNumber + "</td>";
}else{
htmll += "<td style='border:1px solid gray'><span style='Color:red'>——</td>";
}
htmll += "<td style='border:1px solid gray'>" + fengshu + "</td>";
if(index==0){
htmll += "<td style='border:1px solid gray' rowspan='" + data.QuestionTypes.length + "' ><span style='Color:red'>" + data.ExamPagerScore + "</span></td>";
}
htmll += "</tr>";
AllNumber = 0;
YesNumber = 0;
fengshu = 0;
});
$("#tab").html(htmll);
}
} else {
dialogHelper.Error({
content: "没有找到该试卷!", success: function () {
location.href = "/Student/EheoryExamine/AlreadyEheoryExamine";
}
});
}
}
});
}