|
|
layui.define([ 'form', 'laydate', 'table','teacherOpenCourseMergeResourcesQuestionApi',"layedit"], function(exports) {
|
|
|
var form = layui.form;
|
|
|
var teacherOpenCourseMergeResourcesQuestionApi = layui.teacherOpenCourseMergeResourcesQuestionApi;
|
|
|
var index = layui.index;
|
|
|
var layedit = layui.layedit;
|
|
|
var childValue = $("#courseInfoId_1").val();
|
|
|
var courseInfoParentId = $("select[name='courseInfoId_0']").val();//课程ID
|
|
|
var sourceType = $("select[name='courseInfoId_0']").find('option:selected').attr("status");
|
|
|
|
|
|
layedit.set({ //富文本上传图片
|
|
|
uploadImage: {
|
|
|
url: Common.ctxPath + "/jlw/file/update.do",
|
|
|
imgUrl:Common.ctxPath
|
|
|
}
|
|
|
});
|
|
|
var questionStem_ = layedit.build('questionStem',{height:100}); //题干
|
|
|
var questionOptionA_ = layedit.build('questionOptionA',{height:100}); //题干
|
|
|
var questionOptionB_ = layedit.build('questionOptionB',{height:100}); //题干
|
|
|
var questionOptionC_ = layedit.build('questionOptionC',{height:100}); //题干
|
|
|
var questionOptionD_ = layedit.build('questionOptionD',{height:100}); //题干
|
|
|
var questionOptionE_ = layedit.build('questionOptionE',{height:100}); //题干
|
|
|
|
|
|
|
|
|
//反显章节下拉框(key,courseInfoParentId,courseInfoType,sourceType,resourcesQuestionIdsIsNotNull)
|
|
|
Lib.getCourseInfo($("select[name='courseInfoId_1']"),courseInfoParentId,2,sourceType,'',childValue);
|
|
|
|
|
|
form.render();
|
|
|
|
|
|
var view = {
|
|
|
init:function(){
|
|
|
Lib.initGenrealForm($("#addForm"),form);
|
|
|
this.initSubmit();
|
|
|
},
|
|
|
initSubmit:function(){
|
|
|
$("#addButton").click(function(){
|
|
|
form.on('submit(form)', function(){
|
|
|
var teacherOpenCourseMergeResourcesQuestionId = $("#addForm input[name='teacherOpenCourseMergeResourcesQuestionId']").val();
|
|
|
var courseInfoId = "";
|
|
|
var courseInfoId_0 = $("select[name='courseInfoId_0']").val();//课程ID
|
|
|
var courseInfoId_1 = $("select[name='courseInfoId_1']").val();//章节ID
|
|
|
if(!$.isEmpty(courseInfoId_0) && !$.isEmpty(courseInfoId_1)){
|
|
|
courseInfoId = courseInfoId_1;//数据库存的ID
|
|
|
}else if(!$.isEmpty(courseInfoId_0) && $.isEmpty(courseInfoId_1)){
|
|
|
courseInfoId = courseInfoId_0;//数据库存的ID
|
|
|
}else if($.isEmpty(courseInfoId_0) && $.isEmpty(courseInfoId_1)){
|
|
|
layer.msg("请选择所属课程!", {
|
|
|
offset: ['50%'],
|
|
|
icon: 2,
|
|
|
time: 1500 //2秒关闭(如果不配置,默认是3秒)
|
|
|
});
|
|
|
return ;
|
|
|
}
|
|
|
var questionScore = $("input[name=questionScore]").val();
|
|
|
var questionStem = layedit.getContent(questionStem_);
|
|
|
var questionOptionA = layedit.getContent(questionOptionA_);
|
|
|
var questionOptionB = layedit.getContent(questionOptionB_);
|
|
|
var questionOptionC = layedit.getContent(questionOptionC_);
|
|
|
var questionOptionD = layedit.getContent(questionOptionD_);
|
|
|
var questionOptionE = layedit.getContent(questionOptionE_);
|
|
|
var questionAnswer = $("input[name=questionAnswer]").val();
|
|
|
var questionAnalysis = $("textarea[name=questionAnalysis]").val();
|
|
|
var resourcesQuestionId = $("input[name=resourcesQuestionId]").val();
|
|
|
var v = $("select[name='questionType']").val();// 1:单选 2:多选 3:判断
|
|
|
var param = {
|
|
|
teacherOpenCourseMergeResourcesQuestionId:teacherOpenCourseMergeResourcesQuestionId,
|
|
|
teacherOpenCourseId:courseInfoId_0,
|
|
|
teacherOpenCourseMergeCourseInfoId:courseInfoId_1,
|
|
|
questionScore:questionScore,
|
|
|
questionStem:questionStem,
|
|
|
questionType:v,
|
|
|
questionAnswer:questionAnswer,
|
|
|
questionAnalysis:questionAnalysis
|
|
|
};
|
|
|
if(v == 1 || v == 2){
|
|
|
param.questionOptionA = questionOptionA;
|
|
|
param.questionOptionB = questionOptionB;
|
|
|
param.questionOptionC = questionOptionC;
|
|
|
param.questionOptionD = questionOptionD;
|
|
|
param.questionOptionE = questionOptionE;
|
|
|
}
|
|
|
|
|
|
var url = "/jlw/teacherOpenCourseMergeResourcesQuestion/add.json";
|
|
|
if(!$.isEmpty(teacherOpenCourseMergeResourcesQuestionId)){
|
|
|
url = "/jlw/teacherOpenCourseMergeResourcesQuestion/edit.json";
|
|
|
}
|
|
|
var ret = Common.postAjax(url,param);
|
|
|
layer.msg(ret.code == 0?"提交成功!":ret.msg, {
|
|
|
offset: ['50%'],
|
|
|
icon: ret.code == 0?1:2,
|
|
|
time: 1500 //2秒关闭(如果不配置,默认是3秒)
|
|
|
},function (){
|
|
|
if(ret.code == 0){
|
|
|
parent.Lib.tableRefresh();
|
|
|
Lib.closeFrame();
|
|
|
}
|
|
|
});
|
|
|
/*if(!$.isEmpty(teacherOpenCourseMergeResourcesQuestionId)){
|
|
|
teacherOpenCourseMergeResourcesQuestionApi.updateTeacherOpenCourseMergeResourcesQuestion($('#addForm'),function(){
|
|
|
parent.window.dataReload();
|
|
|
Common.info("更新成功");
|
|
|
Lib.closeFrame();
|
|
|
});
|
|
|
}else{
|
|
|
teacherOpenCourseMergeResourcesQuestionApi.addTeacherOpenCourseMergeResourcesQuestion($('#addForm'),function(){
|
|
|
parent.window.dataReload();
|
|
|
Common.info("添加成功");
|
|
|
Lib.closeFrame();
|
|
|
});
|
|
|
}*/
|
|
|
|
|
|
});
|
|
|
});
|
|
|
|
|
|
$("#addButton-cancel").click(function(){
|
|
|
Lib.closeFrame();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//选择题目类型
|
|
|
form.on('select(select_question_type)', function (obj) {
|
|
|
if(obj.value == 1 || obj.value == 2){
|
|
|
$(".dx").show(1000);
|
|
|
$(".pd").hide(1000);
|
|
|
}else if(obj.value == 3){
|
|
|
$(".dx").hide(1000);
|
|
|
$(".pd").show(1000);
|
|
|
}
|
|
|
$("input[name='da']").prop("checked",false);
|
|
|
$("input[name='dc']").prop("checked",false);
|
|
|
form.render();
|
|
|
che();
|
|
|
});
|
|
|
|
|
|
//选择题目类型
|
|
|
form.on('checkbox(checkbox_question_type)', function (obj) {
|
|
|
var a = $(obj.elem).prop("checked");
|
|
|
var v = $("select[name='questionType']").val();
|
|
|
if(v == 1){
|
|
|
$("input[name='da']").prop("checked",false);
|
|
|
}
|
|
|
$(obj.elem).prop("checked",a);
|
|
|
form.render();
|
|
|
che();
|
|
|
});
|
|
|
|
|
|
//对错选择
|
|
|
form.on('radio(radio_question_type)', function (obj) {
|
|
|
$("input[name='questionAnswer']").val($("input[name='dc']:checked").val());
|
|
|
});
|
|
|
|
|
|
//双击
|
|
|
$(".questionOption").dblclick(function (){
|
|
|
var i = $(this).attr("index");
|
|
|
var v = $("select[name='questionType']").val();
|
|
|
if(v == 1){
|
|
|
$("input[name='da']").prop("checked",false);
|
|
|
}
|
|
|
if($("input[name='da']:eq("+i+")").prop("checked") == false){
|
|
|
$("input[name='da']:eq("+i+")").prop("checked",true);
|
|
|
}else {
|
|
|
$("input[name='da']:eq("+i+")").prop("checked",false);
|
|
|
}
|
|
|
che();
|
|
|
form.render();
|
|
|
});
|
|
|
|
|
|
//答案
|
|
|
function che(){
|
|
|
var v = "";
|
|
|
$("input[name='da']:checked").each(function (i){
|
|
|
v += $(this).val();
|
|
|
if(i < $("input[name='da']:checked").length - 1){
|
|
|
v += ",";
|
|
|
}
|
|
|
});
|
|
|
$("input[name='questionAnswer']").val(v);
|
|
|
}
|
|
|
|
|
|
//选择归属课程 并且根据选择的课程查询章节
|
|
|
form.on('select(select_courseInfoIds)', function (obj) {
|
|
|
let sourceType = $("select[name='courseInfoId_0']").find('option:selected').attr("status");
|
|
|
let courseInfoType = 2;//courseInfoType(2 章节,3 节)
|
|
|
Lib.getCourseInfo($("select[name='courseInfoId_1']"),obj.value,courseInfoType,sourceType);
|
|
|
});
|
|
|
|
|
|
exports('add',view);
|
|
|
});
|