var QuestionOption = new arrayHelper("Sort");//选项
var QuestionAnswer = new arrayHelper("QuestionId");//答案
var QuestionAttachments = new arrayHelper("Name");//附件
var QuestionOption2 = new arrayHelper("Sort");//选项
var QuestionAnswer2 = new arrayHelper("QuestionId");//答案
var QuestionAttachments2 = new arrayHelper("Name");//附件
var CurQuestionCount = 0;
var ty = "";
$(function () {
//章节Id
var TheoryChapterId = $.getUrlParam("TheoryChapterId");
var typeid = $.getUrlParam("typeid");
var ChapterName = unescape($.getUrlParam("ChapterName"));
//当是认证考试时隐藏附件
var Library = $.getUrlParam("CertificationId");
if (Library == 2 || Library == 3) {
$("#fujian").hide();
}
SelectTitle(TheoryChapterId, ChapterName, typeid);
//获得题号
var count = GetTitleCount(type, typeid);
CurQuestionCount = count;
var edit = $.getUrlParam("edit");
ty = edit;
if (edit==1) {
$("#CurQuestionCount").html(CurQuestionCount);
} else {
$("#CurQuestionCount").html(CurQuestionCount + 1);
}
var QuestionId = Number($.getUrlParam("QuestionId"));
if (QuestionId != null && QuestionId!=0) {
LoadTitle(QuestionId);
}
//文件选择
$("#FileChoose").click(function () {
$("#HFilePath").click();
});
//将file的值赋值给input
$("#HFilePath").live("change", function () {
var filepath = $(this).val();
$("#filePath").val(filepath);
});
//上传附件按钮
$("#btnAdd").click(function () {
dialogHelper.Show("addpop", 756);
$("#txtResourceName").val("");
$("#filePath").val("");
});
//附件确定按钮
$("#FileUpload").click(function () {
FileUpload();
});
//附件上传取消按钮
$("#addclose").click(function () {
dialogHelper.Close("addpop");
$("#txtResourceName").val("");
$("#filePath").val("");
$("#HFilePath").val("");
var CurQuestionCounts = $("#CurQuestionCount").html();
QuestionAttachments.Remove(CurQuestionCounts);
});
//保存按钮
$("#preserve").click(function () {
//章节Id
var TheoryChapterId = $.getUrlParam("TheoryChapterId");
var typeid = $.getUrlParam("typeid");
AddTitle(TheoryChapterId, typeid);
});
//屏蔽按钮
var edit = $.getUrlParam("edit");
if (edit != 1) {
$("#AddTitle").attr('disabled', true);
$("#AddTitle").css("background-color", "#808080");
$("#upward").attr('disabled', true);
$("#upward").css("background-color", "#808080");
$("#down").attr('disabled', true);
$("#down").css("background-color", "#808080");
}
});
var Index = 0;
var Contxt = "";
var Analysi = "";
//加载试题
function LoadTitle(QuestionId) {
$.ajax({
url: "/Teacher/TheoryQuestion/GetQuestionObj",
async: false,
type: "POST",
data: {
QuestionId: QuestionId,
},
success: function (data) {
QuestionOption.RemoveAll();//选项
QuestionAnswer.RemoveAll();//答案
QuestionAttachments.RemoveAll();//附件
QuestionOption2.RemoveAll();//选项
QuestionAnswer2.RemoveAll();//答案
QuestionAttachments2.RemoveAll();//附件
var mode = data.TE;
if (mode.Context != "") {
$("#Context").val(mode.Context);
$("#Analysis").val(mode.Analysis);
$("#option").find("li").remove();
$("#Id").val(mode.Id);
if (mode.Source == 1) {
$("#CurFrom").html("内置");
$("#preserve").attr('disabled', true);
$("#preserve").css("background-color", "#808080");
}else{
$("#CurFrom").html("自定义");
$("#preserve").attr('disabled', false);
$("#preserve").css("background-color", "#00a2e2");
}
}
//选项
if (mode.OptionList != null) {
var html = "";
$.each(mode.OptionList, function (i, n) {
QuestionOption.Add(n);
QuestionOption2.Add(n);
});
}
//附件
if (mode.AttachmentList != null) {
$.each(mode.AttachmentList, function (i1, n1) {
var obj = new Object();
obj["Name"] = n1.Name;
obj["Url"] = n1.FileUrl;
obj["FileUrl"] = n1.FileUrl;
QuestionAttachments.Add(obj);
QuestionAttachments2.Add(obj);
});
}
createOptions();
CreateSelect();
//答案
if (mode.AnswerList != null) {
$.each(mode.AnswerList, function (i2, n2) {
QuestionAnswer.Add(n2);
QuestionAnswer2.Add(n2);
switch (n2.Answer1) {
case 0:
$("#A").attr("checked", true);
break;
case 1:
$("#B").attr("checked", true);
break;
case 2:
$("#C").attr("checked", true);
break;
case 3:
$("#D").attr("checked", true);
break;
default:
$("#option").find("li:eq(4)").find("input").attr("checked", true);
break;
}
});
}
$("#CurQuestionCount").html($.getUrlParam("count"));
var edit = $.getUrlParam("edit");
if (edit == 1) {
jinyong();
$("#preserve").val("编辑");
}
if ($.getUrlParam("count")==1) {
$("#upward").attr('disabled', true);
$("#upward").css("background-color", "#808080");
}
var StructTypeName = $("#TypeName").find("option:selected").text();
var typeid = $.getUrlParam("typeid");
var QuesCount = GetTitleCount(StructTypeName, typeid);
if (QuesCount == $.getUrlParam("count")) {
$("#down").attr('disabled', true);
$("#down").css("background-color", "#808080");
}
Index = data.index;
SaveDefaultValueCommon("Questions");
}
});
}
var type = "";
//查询对应题型
function SelectTitle(TheoryChapterId, ChapterName, typeid) {
var a = decodeURI(ChapterName);
$("#charpterName").html(a);
$.ajax({
url: "/Teacher/TheoryQuestion/GetQuestionTypeList",
async: false,
type: "POST",
data: {
charpterId: TheoryChapterId,
},
success: function (data) {
var html = "";
var type2=0;
$.each(data, function (e, f) {
if (typeid == f.Id) {
type = f.TypeName
type2 = f.Id
}
html += "";
});
$("#TypeName").html(html);
$("#TypeName").attr("defaultVal", type);
$("#TypeName option[text='" + type + "']").attr("selected", true);
}
});
}
//保存题目
function AddTitle(TheoryChapterId, typeid) {
var CertificationId = $.getUrlParam("CertificationId");
if ($("#preserve").val() == "编辑") {
var bo = neizhi($("#Id").val());
if (bo) {
dialogHelper.Error({ content: "内置题目不能进行编辑!", success: function () { } });
return false;
}
$("#preserve").val("保存");
//启用文本框
$("#Context").removeClass('disabled').attr("readonly", false);
//选项
var Fobj = $("#option").find("li");
$.each(Fobj, function (i, n) {
$(n).find("input:eq(0)").attr('disabled',false);
$(n).find("input:eq(1)").attr('disabled', false);
$(n).find("span").show();
});
$("#btnAdd").attr('disabled', false);
//添加选项按
if (Fobj.length <= 4) {
$("#Add").show();
} else {
$("#Add").hide();
}
//附件
var Fobj = $("#Dappendix").find("a");
$.each(Fobj, function (i, n) {
$(n).find("b").show();
});
//解析
$("#Analysis").removeClass('disabled').attr("readonly", false);;
$("#upward").attr('disabled', true);
$("#upward").css("background-color", "#808080");
$("#down").attr('disabled', true);
$("#down").css("background-color", "#808080");
$("#AddTitle").attr('disabled', true);
$("#AddTitle").css("background-color", "#808080");
ty = 2;
} else {
if (!VerificationHelper.checkFrom("Questions")) {
return false;
}
QuestionOption.RemoveAll();//选项
QuestionAnswer.RemoveAll();//答案
QuestionOption2.RemoveAll();//选项
QuestionAnswer2.RemoveAll();//答案
//添加试题
var obg = new Object();
obg["Id"] = $("#Id").val();//Id
obg["Context"] = $("#Context").val();//题干
obg["LibraryID"] = CertificationId;//所属题库(理论考核/认证考试)
obg["StructType"] = 1;//题目类型(枚举)
obg["CharpterID"] = typeid;//认证类型Id/章节Id(对应下面的题型)
obg["Analysis"] = $("#Analysis").val();//解析
obg["Status"] = 1;//状态 开启
//obg["Source"] = 2;//来源 管理员
//添加选项和答案
var num = 0;
var num2 = 0;
var Fobj = $("#option").find("li");
$.each(Fobj, function (i, n) {
var obj = new Object();
obj["OptionName"] = $(n).find("input:eq(1)").val();
obj["Sort"] = i;
QuestionOption.Add(obj);
QuestionOption2.Add(obj);
num2 = num2 + 1;
//选中的为答案
if ($(n).find("label").find("input").attr("checked") == "checked") {
var objs = new Object();
objs["Answer1"] = i;
objs["Sort"] = i;
QuestionAnswer.Add(objs);
QuestionAnswer2.Add(objs);
num = num + 1;
}
});
var number = 0;
var lis = QuestionOption.GetList();
$.each(lis, function (i,n) {
$.each(lis, function (a, b) {
if (i != a) {
if (n.OptionName == b.OptionName) {
number = number + 1;
}
}
});
$("#option").find("li:eq("+i+")").find("input:eq(1)").attr("title", n.OptionName);
});
if (num2 < 3) {
num2 = 0;
dialogHelper.Error({ content: "请至少输入3个选项!", success: function () { } });
return false;
}
if (num == 0) {
dialogHelper.Error({ content: "请选择正确答案!", success: function () { } });
return false;
}
if (number >0) {
number = 0;
dialogHelper.Error({ content: "不能添加相同的选项!", success: function () { } });
return false;
}
obg["OptionList"] = QuestionOption.GetList();//选项
obg["AnswerList"] = QuestionAnswer.GetList();//答案
obg["AttachmentList"] = QuestionAttachments.GetList();//附件
$(QuestionAttachments.GetList()).each(function (i, n) {
QuestionAttachments2.Add(n);
});
$.ajax({
url: "/Teacher/TheoryQuestion/AddUpdateQuestion",
type: "POST",
async: false,
dataType: "json",
data: JSON.stringify(obg),
contentType: "application/json",
success: function (data) {
dialogHelper.Success({
content: "保存成功!", success: function () {
Index = data.index;
$("#Id").val(data.result);
$("#preserve").val("编辑");
ty = 0;
//激活按钮
var count = $("#CurQuestionCount").html();
var StructTypeName = $("#TypeName").find("option:selected").text();
var typeid = $.getUrlParam("typeid");
var CurQuestionCount = GetTitleCount(StructTypeName, typeid);
$("#CurQuestionCount").html(CurQuestionCount)
var count = $("#CurQuestionCount").html();
if (count==1) {
$("#upward").attr('disabled', true);
$("#upward").css("background-color", "#808080");
$("#down").attr('disabled', false);
$("#down").css("background-color", "#00a2e2");
} else if (count == CurQuestionCount) {
$("#down").attr('disabled', true);
$("#down").css("background-color", "#808080");
$("#upward").attr('disabled', false);
$("#upward").css("background-color", "#00a2e2");
}
else {
$("#upward").attr('disabled', false);
$("#upward").css("background-color", "#00a2e2");
$("#down").attr('disabled', false);
$("#down").css("background-color", "#00a2e2");
}
if (count == 1 && count == CurQuestionCount) {
$("#upward").attr('disabled', true);
$("#upward").css("background-color", "#808080");
$("#down").attr('disabled', true);
$("#down").css("background-color", "#808080");
}
$("#AddTitle").attr('disabled', false);
$("#AddTitle").css("background-color", "#00a2e2");
//禁用文本框
$("#Context").addClass('disabled').attr("readonly", true);
//选项
var Fobj = $("#option").find("li");
$.each(Fobj, function (i, n) {
$(n).find("input:eq(0)").attr('disabled',true);
$(n).find("input:eq(1)").attr('disabled', true);
$(n).find("span").hide();
});
$("#btnAdd").attr('disabled', true);
//添加选项按
$("#Add").hide();
//附件
var Fobj = $("#Dappendix").find("a");
$.each(Fobj, function (i, n) {
$(n).find("b").hide();
});
//解析
$("#Analysis").addClass('disabled').attr("readonly", true);
QuestionOption.RemoveAll();//选项
QuestionAnswer.RemoveAll();//答案
//QuestionAttachments.RemoveAll();//附件
SaveDefaultValueCommon("Questions");
}
});
}, error: function (msg) {
$(".background,.progressBar").hide();
}
});
}
}
//删除选项
function DeleteSelect(obj) {
var optionName = $(obj).parent().find("input:eq(1)").val();
QuestionOption.Remove(optionName);
$(obj).parent().remove();
var Fobj = $("#option").find("li");
var num = 0;
$.each(Fobj, function (i, n) {
var valu = Option(i);
var li = $(n).find("label").html('');
var iuput = $(n).find("input:eq(1)").attr("id", "text" + valu);
num = num + 1;
});
if (num < 5) {
$("#Add").show();
}
}
//添加选项
function AddOption() {
var Fobj = $("#option").find("li");
var html = '';
if (Fobj.length == 0) {
html = '
';
} else if (Fobj.length == 1) {
html = '';
} else if (Fobj.length == 2) {
html = '';
} else if (Fobj.length == 3) {
html = '';
} else if (Fobj.length == 4) {
html = '';
}
if (Fobj.length==0) {
$("#Add").before(html);
} else {
$("#Add").prevAll("li:eq(0)").after(html);
}
var Fobj = $("#option").find("li");
var lis = QuestionOption2.GetList();
var num = 0;
$.each(Fobj, function (i, n) {
var valu = Option(i);
var li = $(n).find("label").html('');
var iuput = $(n).find("input:eq(1)").attr("id", "text" + valu);
$(lis).each(function (i2, n2) {
if(i==i2){
$(n).find("input:eq(1)").attr("defaultVal", n2.OptionName);
}
});
num = num + 1;
});
if(num>=5){
$("#Add").hide();
}
}
//文件上传
function FileUpload() {
var chapterId = $.getUrlParam("TheoryChapterId");
var resourceName = "";
var i = $("#Dappendix").find("a").length;
resourceName = "附件" + Num((i + 1));
var num= UploaDappendix(resourceName);
if (num==3) {
dialogHelper.Error({
content: "本试题资源数量超过最大限制3个!"
})
$("#filePath").val("");
$("#HFilePath").val("");
return;
}
if (chapterId != "" && chapterId != 0) {
var filePath = $("#filePath").val();
if (filePath == "") {
dialogHelper.Error({ content: "请选择要上传的文件!" });
$("#filePath").val("");
$("#HFilePath").val("");
return false;
}
//文件上传
$.ajaxFileUpload({
url: "/Teacher/TheoryQuestion/UploadFile",
secureuri: false,
fileElementId: 'HFilePath',
dataType: 'json',
data: {
resourceName: resourceName
},
success: function (data, status) {
$(".window-mask,.progressBar").hide();
if (data.result) {
var obj = new Object();
obj["Name"] = $("#filePath").val();
obj["Url"] = $("#filePath").val();
obj["FileUrl"] = data.error;
var index = QuestionAttachments.Add(obj);
if (index >= 0) {
dialogHelper.Error({
content: "不能添加相同的附件!"
})
$("#filePath").val("");
$("#HFilePath").val("");
return;
}
dialogHelper.Success({
content: "资源上传成功",
success: function () {
var a = QuestionAttachments.GetList();
$("#fujian").find("a").remove();
//生成附件
createOptions();
$("#txtResourceName").val("");
$("#filePath").val("");
$("#HFilePath").val("");
$("#txtResourceName").val("");
$("#filePath").val("");
dialogHelper.Close("addpop");
$("#resourceList").empty();
}
});
}
else {
if (data.error != "" && data.error != undefined) {
dialogHelper.Error({
content: data.error,
success: function () {
$("#filePath").val("");
$("#HFilePath").val("");
}
});
}
else {
dialogHelper.Error({
content: "您上传的资源超过500KB,请重新上传!",
success: function () {
$("#filePath").val("");
$("#HFilePath").val("");
}
});
}
}
},
error: function (data, status, e) {
dialogHelper.Error({ context: "上传异常" });
$("#filePath").val("");
$("#HFilePath").val("");
}
});
}
else { dialogHelper.Error({ context: "系统出错,没有选中章节" }); }
}
function UploaDappendix(valu) {
var list = $("#Dappendix").find("a");
var num = 0;
$.each(list, function (i,n) {
num = num + 1;
});
return num;
}
//生成附件
function createOptions() {
var list = QuestionAttachments.GetList();
var html = "";
$.each(list, function (i, n) {
html += '';
html += '
';
html += '附件' + Num((i + 1)) + '';
html += '';
html += '';
});
$("#Dappendix").html(html);
}
function Num(valu) {
switch (valu) {
case 1:
return "一";
break;
case 2:
return "二";
break;
case 3:
return "三";
break;
};
}
//生成选项
function CreateSelect() {
var list = QuestionOption.GetList();
var html = "";
var ID = "";
var nums = 0;
$.each(list, function (i, n) {
switch (i) {
case 0:
ID = "A";
break;
case 1:
ID = "B";
break;
case 2:
ID = "C";
break;
case 3:
ID = "D";
break;
default:
ID = "E";
break;
}
var OptionName = n.OptionName;
OptionName=OptionName.replace(/[<>&"]/g, function (c) { return { '<': '<', '>': '>', '&': '&', '"': '"', '"': '"', "'": '′', "'": '′' }[c]; });
// alert(OptionName);
html += '';
nums = nums + 1;
});
html += '';
$("#option").html(html);
if (nums>=5) {
$("#Add").hide();
} else {
$("#Add").show();
}
}
//删除上传文件
function DeleteAttachments(valu) {
var url = $(valu).attr("tag");
QuestionAttachments.Remove(url);
$(valu).parent().remove();
createOptions();
}
//返回按钮
function ComeBack() {
//是否来自认证考试
var strFromCert = "";
var fromcert = $.getUrlParam("fromcert");
if (fromcert != null && fromcert != "") {
strFromCert = "fromcert=" + fromcert + "&";
}
var TheoryChapterId = $.getUrlParam("TheoryChapterId");
var typeid = $.getUrlParam("typeid");
var ChapterName = unescape($.getUrlParam("ChapterName"));
var CertificationId = $.getUrlParam("CertificationId");
var CurQuestionCount = $.getUrlParam("CurQuestionCount");
//if(ty == 2){
var bo= ChangeText("/Teacher/TheoryQuestion/QuestionList?" + strFromCert + "TheoryChapterId=" + TheoryChapterId + "&CertificationId=" + CertificationId + "&typeid=" + typeid + "&CurQuestionCount=" + CurQuestionCount + "&ChapterName=" + escape(ChapterName) + "");
if (!bo) {
SaveJudgeTagTwo("/Teacher/TheoryQuestion/QuestionList?" + strFromCert + "TheoryChapterId=" + TheoryChapterId + "&CertificationId=" + CertificationId + "&typeid=" + typeid + "&CurQuestionCount=" + CurQuestionCount + "&ChapterName=" + escape(ChapterName) + "");
} else {
return;
// window.location.href = "/Teacher/TheoryQuestion/QuestionList?" + strFromCert + "TheoryChapterId=" + TheoryChapterId + "&CertificationId=" + CertificationId + "&typeid=" + typeid + "&CurQuestionCount=" + CurQuestionCount + "&ChapterName=" + escape(ChapterName) + "";//
}
//} else {
// window.location.href = "/Teacher/TheoryQuestion/QuestionList?" + strFromCert + "TheoryChapterId=" + TheoryChapterId + "&CertificationId=" + CertificationId + "&typeid=" + typeid + "&CurQuestionCount=" + CurQuestionCount + "&ChapterName=" + escape(ChapterName) + "";//
//}
}
//选项
function Option(valu) {
var option = "";
switch (valu) {
case 0:
option = "A";
break;
case 1:
option = "B";
break;
case 2:
option = "C";
break;
case 3:
option = "D";
break;
case 4:
option = "E";
break;
}
return option;
}
//下拉框的改变事件
function SelectChange(valu) {
//是否来自认证考试
var strFromCert = "";
var fromcert = $.getUrlParam("fromcert");
if (fromcert != null && fromcert != "") {
strFromCert = "fromcert=" + fromcert + "&";
}
//类型Id
var typeid = 0;
//获得界面题型名称
var typeName = $(valu).find("option:selected").text();
//章节Id
var TheoryChapterId = $.getUrlParam("TheoryChapterId");
//章节名称
var ChapterName = unescape($.getUrlParam("ChapterName"));
//题目数量
var CurQuestionCount = 0;
var CertificationId = $.getUrlParam("CertificationId");
$.ajax({
url: "/Teacher/TheoryQuestion/GetQuestionTypeList",
type: "POST",
async: false,
data: { charpterId: TheoryChapterId, },
success: function (data) {
var html = "";
$(data).each(function (index, dom) {
if (typeName == dom.TypeName) {
typeid = dom.Id;
CurQuestionCount=dom.CurQuestionCount;
}
});
}
});
switch (typeName) {
case "单选题":
if (CertificationId == 2 || CertificationId == 3) {
if (TheoryChapterId==13) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd1?fromcert=1&CertificationId=3&TheoryChapterId=13&typeid=73&CurQuestionCount=0&ChapterName=%u7406%u8bba%u77e5%u8bc6";//
} else if (TheoryChapterId == 14) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd1?fromcert=1&CertificationId=3&TheoryChapterId=14&typeid=73&CurQuestionCount=0&ChapterName=%u7406%u8bba%u77e5%u8bc6";//
} else if (TheoryChapterId == 15) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd1?fromcert=1&CertificationId=3&TheoryChapterId=15&typeid=73&CurQuestionCount=0&ChapterName=%u7406%u8bba%u77e5%u8bc6";//
} else if (TheoryChapterId == 16) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd1?fromcert=1&CertificationId=2&TheoryChapterId=16&typeid=82&CurQuestionCount=0&ChapterName=%u4e2a%u4eba%u7406%u8d22";
}
else if (TheoryChapterId == 17) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd1?fromcert=1&CertificationId=2&TheoryChapterId=17&typeid=85&CurQuestionCount=0&ChapterName=%u98ce%u9669%u7ba1%u7406";
}
else if (TheoryChapterId == 18) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd1?fromcert=1&CertificationId=2&TheoryChapterId=18&typeid=88&CurQuestionCount=0&ChapterName=%u516c%u53f8%u4fe1%u8d37";
}
else if (TheoryChapterId == 19) {
"/Teacher/TheoryQuestion/QuestionBankAdd1?fromcert=1&CertificationId=2&TheoryChapterId=19&typeid=91&CurQuestionCount=0&ChapterName=%u4e2a%u4eba%u8d37%u6b3e";
}
} else {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd1?" + strFromCert + "TheoryChapterId=" + TheoryChapterId + "&CertificationId=" + CertificationId + "&typeid=" + typeid + "&ChapterName=" + escape(ChapterName) + "&CurQuestionCount=" + CurQuestionCount + "";//
}
break;
case "多选题":
if (CertificationId == 2 || CertificationId == 3) {
if (TheoryChapterId == 13) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd2?fromcert=1&CertificationId=3&TheoryChapterId=13&typeid=74&CurQuestionCount=0&ChapterName=%u7406%u8bba%u77e5%u8bc6";
} else if (TheoryChapterId == 14) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd2?fromcert=1&CertificationId=3&TheoryChapterId=14&typeid=73&CurQuestionCount=0&ChapterName=%u7406%u8bba%u77e5%u8bc6";//
} else if (TheoryChapterId == 15) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd2?fromcert=1&CertificationId=2&TheoryChapterId=15&typeid=80&CurQuestionCount=0&ChapterName=%u516c%u5171%u57fa%u7840";
} else if (TheoryChapterId == 16) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd2?fromcert=1&CertificationId=2&TheoryChapterId=16&typeid=83&CurQuestionCount=0&ChapterName=%u4e2a%u4eba%u7406%u8d22";
}
else if (TheoryChapterId == 17) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd2?fromcert=1&CertificationId=2&TheoryChapterId=17&typeid=86&CurQuestionCount=0&ChapterName=%u98ce%u9669%u7ba1%u7406";
}
else if (TheoryChapterId == 18) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd2?fromcert=1&CertificationId=2&TheoryChapterId=18&typeid=89&CurQuestionCount=0&ChapterName=%u516c%u53f8%u4fe1%u8d37";
}
else if (TheoryChapterId == 19) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd2?fromcert=1&CertificationId=2&TheoryChapterId=19&typeid=92&CurQuestionCount=0&ChapterName=%u4e2a%u4eba%u8d37%u6b3e";
}
} else {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd2?" + strFromCert + "TheoryChapterId=" + TheoryChapterId + "&CertificationId=" + CertificationId + "&typeid=" + typeid + "&ChapterName=" + escape(ChapterName) + "&CurQuestionCount=" + CurQuestionCount + "";//
}
break;
case "判断题":
if (CertificationId == 2 || CertificationId == 3) {
if (TheoryChapterId == 13) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd3?fromcert=1&CertificationId=3&TheoryChapterId=13&typeid=75&CurQuestionCount=0&ChapterName=%u7406%u8bba%u77e5%u8bc6";
} else if (TheoryChapterId == 14) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd3?fromcert=1&CertificationId=3&TheoryChapterId=14&typeid=73&CurQuestionCount=0&ChapterName=%u7406%u8bba%u77e5%u8bc6";//
} else if (TheoryChapterId == 15) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd3?fromcert=1&CertificationId=2&TheoryChapterId=15&typeid=81&CurQuestionCount=0&ChapterName=%u516c%u5171%u57fa%u7840";
} else if (TheoryChapterId == 16) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd3?fromcert=1&CertificationId=2&TheoryChapterId=16&typeid=84&CurQuestionCount=0&ChapterName=%u4e2a%u4eba%u7406%u8d22";
}
else if (TheoryChapterId == 17) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd3?fromcert=1&CertificationId=2&TheoryChapterId=17&typeid=87&CurQuestionCount=0&ChapterName=%u98ce%u9669%u7ba1%u7406";
}
else if (TheoryChapterId == 18) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd3?fromcert=1&CertificationId=2&TheoryChapterId=18&typeid=90&CurQuestionCount=0&ChapterName=%u516c%u53f8%u4fe1%u8d37";
}
else if (TheoryChapterId == 19) {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd3?fromcert=1&CertificationId=2&TheoryChapterId=19&typeid=93&CurQuestionCount=0&ChapterName=%u4e2a%u4eba%u8d37%u6b3e";
}
} else {
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd3?" + strFromCert + "TheoryChapterId=" + TheoryChapterId + "&CertificationId=" + CertificationId + "&typeid=" + typeid + "&ChapterName=" + escape(ChapterName) + "&CurQuestionCount=" + CurQuestionCount + "";//
}
break;
case "填空题":
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd4?" + strFromCert + "TheoryChapterId=" + TheoryChapterId + "&CertificationId=" + CertificationId + "&typeid=" + typeid + "&ChapterName=" + escape(ChapterName) + "&CurQuestionCount=" + CurQuestionCount + "";//
break;
default:
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd4?" + strFromCert + "TheoryChapterId=" + TheoryChapterId + "&CertificationId=" + CertificationId + "&typeid=" + typeid + "&ChapterName=" + escape(ChapterName) + "&CurQuestionCount=" + CurQuestionCount + "";//
break;
}
}
//获取题号
function GetTitleCount(StructTypeName, CharpterID) {
var count = 0;
$.ajax({
url: "/Teacher/TheoryQuestion/GetTitleCount",
type: "POST",
async: false,
dataType: "json",
data: { StructTypeName: StructTypeName, CharpterID: CharpterID },
success: function (data) {
count = data.Count;
}
});
return count;
}
//新增按钮
function AddTitleClick() {
////清除集合
//QuestionOption.RemoveAll();
//QuestionAnswer.RemoveAll();
//QuestionAttachments.RemoveAll();
//$("#Id").val("0");
////题号加1
//var StructTypeName = $("#TypeName").find("option:selected").text();
//var typeid = $.getUrlParam("typeid");
//var count = GetTitleCount(StructTypeName, typeid);
//$("#CurQuestionCount").html(count + 1);
////清空文本
//$("#Context").val("");
//$("#Analysis").val("");
//$("#Context").attr('disabled', false);
//$("#Analysis").attr('disabled', false);
//$("#preserve").val("保存");
////选项
//var Fobj = $("#option").find("li");
//$.each(Fobj, function (i, n) {
// if (i<=3) {
// $(n).find("input:eq(0)").attr('disabled', false);
// $(n).find("input:eq(1)").attr('disabled', false);
// $(n).find("span").show();
// $(n).find("input:eq(0)").attr("checked", false);
// $(n).find("input:eq(1)").val("");
// } else if(i==4) {
// $(n).remove();
// } else {
// $(n).hide();
// }
//});
////附件
//var Fobj = $("#Dappendix").find("a");
//$.each(Fobj, function (i, n) {
// $(n).remove();
//});
//$("#btnAdd").attr('disabled', false);
//$("#Add").show();
////屏蔽按钮
//$("#AddTitle").attr('disabled', true);
//$("#AddTitle").css("background-color", "#808080");
//$("#upward").attr('disabled', true);
//$("#upward").css("background-color", "#808080");
//$("#down").attr('disabled', true);
//$("#down").css("background-color", "#808080");
//清除集合
QuestionOption.RemoveAll();
QuestionAnswer.RemoveAll();
QuestionAttachments.RemoveAll();
$("#Id").val("0");
//题号加1
var StructTypeName = $("#TypeName").find("option:selected").text();
var typeid = $.getUrlParam("typeid");
var count = GetTitleCount(StructTypeName, typeid);
$("#CurQuestionCount").html(count + 1);
//是否来自认证考试
var strFromCert = "";
var fromcert = $.getUrlParam("fromcert");
if (fromcert != null && fromcert != "") {
strFromCert = "fromcert=" + fromcert + "&";
}
//获得界面题型名称
var typeName = StructTypeName;
//章节Id
var TheoryChapterId = $.getUrlParam("TheoryChapterId");
//章节名称
var ChapterName = unescape($.getUrlParam("ChapterName"));
//题目数量
var CurQuestionCount = count + 1;
var CertificationId = $.getUrlParam("CertificationId");
window.location.href = "/Teacher/TheoryQuestion/QuestionBankAdd1?" + strFromCert + "TheoryChapterId=" + TheoryChapterId + "&CertificationId=" + CertificationId + "&typeid=" + typeid + "&ChapterName=" + escape(ChapterName) + "&CurQuestionCount=" + CurQuestionCount + "";//
}
//上一题
function Thelast() {
//章节Id
var typeid = $.getUrlParam("typeid");
var PaperId = $.getUrlParam("PaperId");
if (PaperId==null) {
PaperId = "0";
}
Index = Index-1;
if (Index < 0) {
Index = 0;
}
//清除集合
QuestionOption.RemoveAll();
QuestionAnswer.RemoveAll();
QuestionAttachments.RemoveAll();
//清除集合
QuestionOption2.RemoveAll();
QuestionAnswer2.RemoveAll();
QuestionAttachments2.RemoveAll();
$.ajax({
url: "/Teacher/TheoryQuestion/GetQuestionId",
async: false,
type: "POST",
data: {
Index: Index,
CharpterID: typeid,
PaperId: PaperId
},
success: function (data) {
var mode = data.model;
if (mode != undefined) {
if (mode.Context != "") {
var count = Number($("#CurQuestionCount").html());
if (count>1) {
$("#CurQuestionCount").html(count - 1);
}
var count = Number($("#CurQuestionCount").html());
if (count == 1) {
Index = 0;
$("#upward").attr("disabled", true);
$("#upward").css("background-color", "#808080");
} else {
$("#upward").attr("disabled", false);
$("#upward").css("background-color", "#00a2e2");
}
if ($("#down").attr("disabled") == "disabled") {
$("#down").attr("disabled", false);
$("#down").css("background-color", "#00a2e2");
}
$("#Context").val(mode.Context);
$("#Analysis").val(mode.Analysis);
$("#option").find("li").remove();
$("#Id").val(mode.Id);
if (mode.Source == 1) {
$("#CurFrom").html("内置");
$("#preserve").attr('disabled', true);
$("#preserve").css("background-color", "#808080");
} else {
$("#CurFrom").html("自定义");
$("#preserve").attr('disabled', false);
$("#preserve").css("background-color", "#00a2e2");
}
}
//选项
if (mode.OptionList != null) {
var html = "";
$.each(mode.OptionList, function (i, n) {
QuestionOption.Add(n);
QuestionOption2.Add(n);
});
}
//附件
if (mode.AttachmentList != null) {
$.each(mode.AttachmentList, function (i1, n1) {
QuestionAttachments.Add(n1);
QuestionAttachments2.Add(n1);
});
}
createOptions();
CreateSelect();
//答案
if (mode.AnswerList != null) {
$.each(mode.AnswerList, function (i2, n2) {
QuestionAnswer.Add(n2);
QuestionAnswer2.Add(n2);
switch (n2.Answer1) {
case 0:
$("#A").attr("checked", true);
break;
case 1:
$("#B").attr("checked", true);
break;
case 2:
$("#C").attr("checked", true);
break;
case 3:
$("#D").attr("checked", true);
break;
default:
$("#option").find("li:eq(4)").find("input").attr("checked", true);
break;
}
});
}
SaveDefaultValueCommon("Questions");
}
}
});
jinyong()
}
var styles = 0;
//下一题
function Thedown() {
//章节Id
var typeid = $.getUrlParam("typeid");
var PaperId = $.getUrlParam("PaperId");
if (PaperId == null) {
PaperId = "0";
}
//清除集合
QuestionOption.RemoveAll();
QuestionAnswer.RemoveAll();
QuestionAttachments.RemoveAll();
//清除集合
QuestionOption2.RemoveAll();
QuestionAnswer2.RemoveAll();
QuestionAttachments2.RemoveAll();
var sty = Index;
if (Index<0) {
Index = 0;
}
Index = Index + 1;
if (Index > 0) {
$.ajax({
url: "/Teacher/TheoryQuestion/GetQuestionId",
async: false,
type: "POST",
data: {
Index: Index,
CharpterID: typeid,
PaperId: PaperId
},
success: function (data) {
var mode = data.model;
styles = data.style;
if (mode != undefined) {
if (mode.Context != "") {
var count = Number($("#CurQuestionCount").html());
$("#CurQuestionCount").html(count + 1);
var StructTypeName = $("#TypeName").find("option:selected").text();
var typeid = $.getUrlParam("typeid");
var CurQuestionCount = GetTitleCount(StructTypeName, typeid);
if (CurQuestionCount == count+1) {
$("#down").attr("disabled", true);
$("#down").css("background-color", "#808080");
Index = CurQuestionCount-1;
} else {
$("#down").attr("disabled", false);
$("#down").css("background-color", "#00a2e2");
}
$("#Context").val(mode.Context);
$("#Analysis").val(mode.Analysis);
$("#option").find("li").remove();
$("#Id").val(mode.Id);
if (mode.Source == 1) {
$("#CurFrom").html("内置");
$("#preserve").attr('disabled', true);
$("#preserve").css("background-color", "#808080");
} else {
$("#CurFrom").html("自定义");
$("#preserve").attr('disabled', false);
$("#preserve").css("background-color", "#00a2e2");
}
}
//选项
if (mode.OptionList != null) {
var html = "";
$.each(mode.OptionList, function (i, n) {
QuestionOption.Add(n);
QuestionOption2.Add(n);
});
}
//附件
if (mode.AttachmentList != null) {
$.each(mode.AttachmentList, function (i1, n1) {
QuestionAttachments.Add(n1);
QuestionAttachments2.Add(n1);
});
}
createOptions();
CreateSelect();
//答案
if (mode.AnswerList != null) {
$.each(mode.AnswerList, function (i2, n2) {
QuestionAnswer.Add(n2);
QuestionAnswer2.Add(n2);
switch (n2.Answer1) {
case 0:
$("#A").attr("checked", true);
break;
case 1:
$("#B").attr("checked", true);
break;
case 2:
$("#C").attr("checked", true);
break;
case 3:
$("#D").attr("checked", true);
break;
default:
$("#option").find("li:eq(4)").find("input").attr("checked", true);
break;
}
});
}
if ($("#upward").attr("disabled") == "disabled") {
$("#upward").attr("disabled", false);
$("#upward").css("background-color", "#00a2e2");
}
SaveDefaultValueCommon("Questions");
}
}
});
jinyong();
}
}
//禁用文本
function jinyong() {
//禁用文本框
//$("#Context").attr('disabled', true);
$("#Context").addClass('disabled').attr("readonly", true);
//选项
var Fobj = $("#option").find("li");
$.each(Fobj, function (i, n) {
$(n).find("input:eq(0)").attr('disabled',true);
$(n).find("input:eq(1)").attr('disabled', true);
$(n).find("span").hide();
});
$("#btnAdd").addClass('disabled');
//添加选项按
$("#Add").hide();
//附件
var Fobj = $("#Dappendix").find("a");
$.each(Fobj, function (i, n) {
$(n).find("b").hide();
});
//解析
$("#Analysis").addClass('disabled').attr("readonly", true);
}
//查看是否是内置题
function neizhi(Id) {
var bo = false;
$.ajax({
url: "/Teacher/TheoryQuestion/NeiZhi",
async: false,
type: "POST",
data: {
Id: Id,
},
success: function (data) {
if (data) {
bo = true;
}
}
});
return bo;
}
//判断编辑时内容是否变化,给出提示
function ChangeText(url) {
var bool = false;
var Attachments = $("#Dappendix").find("a");//附件
var Option2 = QuestionOption2.GetList();//选项
var Answer2 = QuestionAnswer2.GetList();//答案
var Attachments2 = QuestionAttachments2.GetList();//附件
var Fobj = $("#option").find("li");
if (Fobj.length != Option2.length && Option2.length!=0) {
bool = true;
}
var ans1 = "";
var ans2 = "";
$.each(Fobj, function (i, n) {
//选中的为答案
if ($(n).find("label").find("input").attr("checked") == "checked") {
ans1 = ans1 + i;
}
});
$(Answer2).each(function (i, n) {
ans2 = ans2 + n.Answer1;
});
if (ans1 != ans2) {
bool = true;
}
if (Attachments.length != Attachments2.length && Attachments2.length!=0) {
bool = true;
}
var nu = 0;
$(Attachments).each(function (i, n) {
$(Attachments2).each(function (i2, n2) {
if($(n).find("span").attr("tag")==n2.Name){
nu++;
}
});
});
if (nu != Attachments.length) {
bool = true;
}
if (bool) {
navFinancePageTwo(url);
return true;
}
}