educoder/public/javascripts/edu/course.js

739 lines
30 KiB
JavaScript
Raw Normal View History

$(function() {
2017-09-22 21:09:35 +08:00
// $("#search_not_teacher").live('input', function (e) {
// throttle(search_not_teacher_f,window,e);
// });
2017-09-22 20:37:44 +08:00
// $("#search_not_student").live('input', function (e) {
// throttle(search_not_student_f,window,e);
// });
//模块切换
$(".stud-class-set .news .nav").click(function(e) {
var $a = $(e.target);
var $b = $a.attr("data-option");
console.log($b);
if($b){
$(".stud-class-set .news .nav p").removeClass("sheet");
$(".stud-class-set .news .nav p i").hide();
$a.addClass("sheet");
$a.find("i").show();
$(".stud-class-set .news .container").children().hide();
$(".stud-class-set .news .container").find("." + $b + "").show();
}
});
//操作弹框中单选复选框的选中与否
$(".tip li").click(function(e) {
if($(this).find(".blue").css("display") == "none") {
$(this).find(".grey").hide();
$(this).find(".blue").show();
} else {
$(this).find(".blue").hide();
$(this).find(".grey").show();
}
});
$(".student .fa").click(function() {
console.log(1);
});
//教师学生模块切换
$(".stud-class-set .news .container .member .people .left ul li").live('click', function(e) {
//$(".stud-class-set .news .container .member .people .left ul li").removeClass("sheet");
//$(this).addClass("sheet");
var $course_id = $(this).attr("data-course-id");
if($(this).attr("data-option") == "teacher") {
$.get(
'/courses/'+$course_id+'/members'
)
}
if($(this).attr("data-option") == "allstudent") {
$.get(
'/courses/'+$course_id+'/all_student_list'
)
}
if($(this).attr("data-option") == "noclass") {
$.get(
'/courses/'+$course_id+'/no_group_student_list'
)
}
if($(this).attr("data-option") == "hasclass") {
var $group_id = $(this).attr("data-group-id");
$.get(
'/courses/'+$course_id+'/has_group_student_list?group_id='+$group_id
)
}
});
// $(".stud-class-set .news .container .member .people .left ul li .p1 i").hover(function () {
// $(this).parent().next().show().hover(function () { clearTimeout(window.timer); }, function () { $(this).hide(); });
// }, function (e) {
// var dom = $(this).parent().next();
// window.timer = setTimeout(function () { dom.hide(); }, 200); //延时隐藏以便鼠标移动到div上时clear掉计时器
// });
$(".stud-class-set .news .container .member .people .left ul li .p1 i").live({
mouseenter:
function()
{
$(this).parent().next().show().hover(function () { clearTimeout(window.timer); }, function () { $(this).hide(); });
},
mouseleave:
function(e)
{
var dom = $(this).parent().next();
window.timer = setTimeout(function () { dom.hide(); }, 200); //延时隐藏以便鼠标移动到div上时clear掉计时器
}
});
$("#choose_course_group_submit").live('click', function(){
if($("#course_group_id").val() == '0'){
$("#choose_course_group_notice").show();
} else{
$("#teacher_assign_group_form").submit();
$("#choose_course_group_notice").hide();
}
});
$(".join .handle").live('click', function(){
if($("input[name='member_ids[]']:checked").length > 0){
$("#choose_course_group_form").submit();
}
});
$("input[name='member_ids[]']").live('click', function(){
if($("input[name='member_ids[]']:checked").length == $("input[name='member_ids[]']").length){
$("#all_member_select").attr("checked", "checked");
} else{
$("#all_member_select").removeAttr("checked");
}
});
$("#all_member_select").live('click', function(){
if($("#all_member_select").is(':checked')){
$("input[name='member_ids[]']").attr("checked", "checked");
} else {
$("input[name='member_ids[]']").removeAttr("checked");
}
});
2017-05-18 15:38:29 +08:00
// 课堂设置
$("#edit_course_list").on('input', function(e){
throttle(search_course_list, window, e);
});
$("#edit_course_list").on('click', function (e) {
if ($("#edit_course_list").val().trim() != '') { //如果已经有id了。肯定存在不用去找了。
event.stopPropagation();
return;
} else{
event.stopPropagation();
search_course_ajax('');
}
});
$("#edit_course_list").on('blur', function(e){
if($("#edit_course_name").val() == ""){
$("#edit_course_name").val($("#edit_course_list").val());
} else{
if($("#edit_course_name").val().indexOf(course_list_name) == 0){
$("#edit_course_name").val($("#edit_course_name").val().replace(course_list_name, $("#edit_course_list").val()));
} else{
$("#edit_course_name").val($("#edit_course_list").val() + $("#edit_course_name").val());
}
}
course_list_name = $("#edit_course_list").val();
regex_course_name('edit');
});
});
function add_new_group(id){
var htmlvalue = '<div class="task-popup newclass" style="width:450px;">' +
'<div class="task-popup-title clearfix task-popup-bggrey">' +
'<h3 class="fl">新建分班</h3>' +
'<a href="javascript:void(0);" onclick="hideModal();"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a>' +
'</div>' +
'<div class="task_popup_con clearfix">' +
'<div class="pt20 clearfix mb20" style="width:400px;">' +
'<label class="panel-form-label label fl">分班名称&nbsp;&nbsp;&nbsp;&nbsp;</label>' +
'<input type="text" name="group_name" id="new_group_name" style="width:300px;" placeholder="示例:分班" maxlength="20" class="pl10 task task-height-40 panel-box-sizing fl color-grey3">' +
'<div class="cl"></div>' +
'<span class="color-orange fl none" id="add_new_group_notice" style="margin-left:22.5%;"><i class="fa fa-exclamation-circle mr5" ></i>该分班已存在</span></div>' +
'<a href="javascript:void(0);" class="task-btn task-btn-blue fr mr20" onclick="submit_new_group_form('+id+');">确定</a>' +
'<a href="javascript:void(0);" onclick="hideModal();" class="task-btn fr mr10">取消</a>' +
'</div>' +
'</div>';
pop_box_new(htmlvalue, 450, 205);
}
function submit_new_group_form(id){
var val = $.trim($("#new_group_name").val());
if(val == ""){
$("#add_new_group_notice").html('<i class="fa fa-exclamation-circle mr5" ></i>名称不能为空').show();
return false;
} else{
$.ajax({
url: "/courses/"+ id +"/addgroups",
type: 'post',
data: {group_name: val},
success: function(data){
if(data.result == 0){
2017-09-15 20:59:35 +08:00
$("#add_new_group_notice").html('<i class="fa fa-exclamation-circle mr5" ></i>该分班已存在').show();
} else{
$("#add_new_group_notice").hide();
hideModal();
2017-09-15 20:59:35 +08:00
if($("#sy_08").length > 0){
window.location.href = "/courses/"+id+"/all_student_list";
} else{
$(".stud-class-set .news .container .member .people .left ul li[data-option='allstudent']").click();
2017-09-15 20:59:35 +08:00
}
}
}
});
}
}
function update_choose_group_allow(id){
$.ajax({
url: "/courses/"+ id +"/choose_group_allow",
type: 'get',
success: function(data){
}
});
}
function rename_group_name(course_id, group_id){
var htmlvalue = '<div class="task-popup rename" style="width:450px">' +
'<div class=" task-popup-title clearfix task-popup-bggrey">' +
'<h3 class="fl color-grey">重命名</h3>' +
'<a href="javascript:void(0);" onclick="hideModal();"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a>' +
'</div>' +
'<div class="task-popup-content clearfix">' +
'<div class="pt20 clearfix mb20">' +
'<label class="fl font-16 color-grey" style="line-height:40px;"> 名 称:&nbsp;&nbsp;&nbsp;&nbsp;</label>' +
'<input type="text" id="edit_group_name" maxlength="20" class="task-form-80 task-height-40 panel-box-sizing fl">' +
'<div class="cl"></div>' +
'<span class="color-orange fl none" id="edit_new_group_notice" style="margin-left:14%;"><i class="fa fa-exclamation-circle mr5" ></i>该分班已存在</span></div>' +
'<a href="javascript:void(0);" class="task-btn task-btn-blue fr mr25" onclick="submit_rename_group_form('+course_id+', '+ group_id +');">确定</a>' +
'<a href="javascript:void(0);" onclick="hideModal();" class="task-btn fr mr10">取消</a>' +
'</div>' +
'</div>';
pop_box_new(htmlvalue, 450, 195);
}
function submit_rename_group_form(course_id, group_id){
var val = $.trim($("#edit_group_name").val());
if(val == ""){
$("#edit_new_group_notice").html('<i class="fa fa-exclamation-circle mr5" ></i>名称不能为空').show();
return false;
} else{
$.ajax({
url: "/courses/"+ course_id +"/updategroupname",
type: 'post',
data: {group_name: val,
group_id: group_id},
success: function(data){
if(data.result == 0){
2017-09-15 15:10:35 +08:00
$("#edit_new_group_notice").html('<i class="fa fa-exclamation-circle mr5" ></i>该分班已存在').show();
} else{
$("#edit_new_group_notice").hide();
hideModal();
2017-09-15 20:59:35 +08:00
if($("#sy_08").length > 0){
window.location.href = "/courses/"+course_id+"/has_group_student_list?group_id="+group_id;
} else{
$(".stud-class-set .news .container .member .people .left ul li[data-group-id='"+group_id+"']").click();
}
}
}
});
}
}
function delete_group(course_id, group_id){
var htmlvalue = '<div class="task-popup twohint" style="width:450px">' +
'<div class=" task-popup-title clearfix">' +
'<h3 class="fl color-grey">提示</h3>' +
'<a href="javascript:void(0);" onclick="hideModal();"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a>' +
'</div>' +
'<div class="task-popup-content">' +
'<p class="task-popup-text-center font-16">确定要删除吗?<br/> 删除分班后,该分班的学生需要重新选择分班。' +
'</div>' +
'<div class="task-popup-submit02 clearfix" style="width:120px;">' +
2017-09-15 20:59:35 +08:00
'<a onclick="submit_delete_group_form('+course_id+', '+ group_id +');" href="javascript:void(0);" class="task-btn task-btn-blue fr">确定</a>' +
'<a href="javascript:void(0);" onclick="hideModal();" class="task-btn fr mr10">取消</a>' +
'</div>' +
'</div>';
pop_box_new(htmlvalue, 450, 300);
}
2017-09-15 20:59:35 +08:00
function submit_delete_group_form(course_id, group_id){
hideModal();
$.ajax({
url: "/courses/"+ course_id +"/deletegroup?group_id=" + group_id,
type: 'get',
data: {},
success: function(data){
if($("#sy_08").length > 0){
window.location.href = "/courses/"+course_id+"/all_student_list";
} else{
$(".stud-class-set .news .container .member .people .left ul li[data-option='allstudent']").click();
2017-09-15 20:59:35 +08:00
}
}
});
}
function submit_change_manager_form(){
if($("input[name='chooseteacher']:checked").length == 0) {
$("#change_manager_notice").show();
} else{
$("#change_manager_form").submit();
hideModal();
}
}
2017-09-22 21:09:35 +08:00
//var lastteSearchCondition = '';
function search_not_teacher_f(e){
2017-09-22 21:09:35 +08:00
// if($(e.target).val().trim() == "" || ($(e.target).val().trim() == lastteSearchCondition && lastteSearchCondition != ''))
// {
// return;
// }
// lastteSearchCondition = $(e.target).val().trim();
$.ajax({
url: '/courses/' + $("#course_search_not_teacher_id").val() + '/search_not_teachers',
type:'post',
2017-09-22 21:09:35 +08:00
data: {is_observe:true, search:$("#search_not_teacher").val().trim(), school:$("#search_not_teacher_school").val().trim()},
success: function(data){ }
});
}
function submit_add_teacher_form(){
2017-09-22 21:09:35 +08:00
if($("#choose_student_ids").val().trim() != ""){
if($("input[name='membership[role_ids][]']:checked").length >= 1){
$("#add_teacher_notice").html("").hide();
$("#add_teacher_form").submit();
hideModal();
} else{
$("#add_teacher_notice").html("请先选择一个角色").show();
}
}else{
$("#add_teacher_notice").html("请至少选择一个用户").show();
}
}
function submit_all_student_list_search(id){
2017-09-07 16:20:54 +08:00
$.get(
'/courses/'+id+'/all_student_list?search='+$("#all_student_list_search").val().trim()
)
}
function submit_no_group_student_search(id){
2017-09-07 16:20:54 +08:00
$.get(
'/courses/'+id+'/no_group_student_list?search='+$("#no_group_student_list_search").val().trim()
)
}
function submit_has_group_student_search(id, group_id){
2017-09-07 16:20:54 +08:00
$.get(
'/courses/'+id+'/has_group_student_list?group_id='+group_id+'&search='+$("#has_group_student_list_search").val().trim()
)
}
2017-09-22 20:37:44 +08:00
//var laststSearchCondition = '';
function search_not_student_f(e){
2017-09-22 20:37:44 +08:00
// if($(e.target).val().trim() == "" || ($(e.target).val().trim() == laststSearchCondition && laststSearchCondition != ''))
// {
// return;
// }
// laststSearchCondition = $(e.target).val().trim();
$.ajax({
url: '/courses/' + $("#course_search_not_student_id").val() + '/search_not_students',
type:'post',
2017-09-22 20:37:44 +08:00
data: {is_observe:true, search:$("#search_not_student").val().trim(), school:$("#search_not_student_school").val().trim()},
success: function(data){ }
});
}
function submit_add_student_form(){
2017-09-22 21:09:35 +08:00
if($("#choose_student_ids").val().trim() != ""){
$("#add_student_notice").html("").hide();
$("#add_student_form").submit();
hideModal();
}else{
$("#add_student_notice").html("请至少选择一个用户").show();
}
}
function res_send_to_course(id, user_id, send_type){
$.ajax({
type: 'get',
url: '/users/' + user_id + '/search_user_course',
data:{send_id:id, send_type:send_type}
});
2017-06-08 17:39:29 +08:00
}
//滑动打分
$.fn.peSlider = function(settings){
//configurable options (none so far)
var o = $.extend({},settings);
if( !$('body').is('[role]') ){ $('body').attr('role','application'); }
return $(this).each(function(){
var thisLabel = $('label[for=' + $(this).attr('id') + ']').attr('id', $(this).attr('id') + '-label').attr('id');
var thisUnits = $(this).attr('data-units') || '';
var slider = $('<div></div>');
if( $(this).is('input') ){
var input = $(this);
var thisUnits = input.attr('data-units');
var friendlyVal = input.val() + ' ' + thisUnits;
var sliderOptions = $.extend(o,{
min: parseFloat(input.attr('min')),
max: parseFloat(input.attr('max')),
value: parseFloat(input.val())
});
if(parseFloat(input.val()) == -1){
input.css("color", "#fff");
input.next().next().html("未评分");
input.next().next().show();
} else{
input.css("color", "#29bd8b");
2017-06-08 17:39:29 +08:00
input.next().next().hide();
}
slider
.insertBefore(input)
.slider(sliderOptions)
.bind('slide', function(e, ui){
if(ui.value == -1){
input.css("color", "#fff");
input.next().next().html("未评分");
input.next().next().show();
} else {
input.css("color", "#29bd8b");
2017-06-08 17:39:29 +08:00
input.next().next().hide();
}
input.val(ui.value);
friendlyVal = input.val() + ' ' + thisUnits;
slider.find('a').attr({
'aria-valuenow': ui.value,
'aria-valuetext': friendlyVal
});
})
.find('a')
.attr({
'role': 'slider',
'aria-valuemin': input.attr('min'),
'aria-valuemax': input.attr('max'),
'aria-valuenow': input.val(),
'aria-valuetext': friendlyVal,
'aria-labelledby': thisLabel
});
input
.keyup(function(){
var inVal = parseFloat(input.val());
if( !isNaN(inVal) ){
if(inVal == -1){
input.css("color", "#fff");
input.next().next().html("未评分");
input.next().next().show();
} else {
input.css("color", "#29bd8b");
2017-06-08 17:39:29 +08:00
input.next().next().hide();
}
slider.slider('value', inVal);
input.val(slider.slider('value'));
}
})
.change(function(){
var inVal = parseFloat(input.val());
if( !isNaN(inVal) ){
if(inVal == -1){
input.css("color", "#fff");
input.next().next().html("未评分");
input.next().next().show();
} else {
input.css("color", "#29bd8b");
2017-06-08 17:39:29 +08:00
input.next().next().hide();
}
slider.slider('value', inVal);
input.val(slider.slider('value'));
}
})
.blur(function(){
var inVal = parseFloat(input.val());
if( isNaN(inVal) ){
input.val(-1);
}
if(input.val() == -1){
input.css("color", "#fff");
input.next().next().html("未评分");
input.next().next().show();
} else {
input.css("color", "#29bd8b");
2017-06-08 17:39:29 +08:00
input.next().next().hide();
}
});
if( !settings.step ){
var step = Math.round( parseFloat(input.attr('max')) / slider.width());
if(step > 1){ slider.slider('option','step',step); }
}
}
});
2017-06-28 15:23:09 +08:00
};
$(function() {
//匿评评分提示
$(".student_score_info").live("mouseover", function () {
$(this).find("div").show();
});
$(".student_score_info").live("mouseout", function () {
$(this).find("div").hide();
});
2017-07-28 16:59:17 +08:00
});
function regexSubject() {
var content = $.trim($("#course_message_subject").val());
if (content.length == 0) {
$("#new_course_message_notice").show();
return false;
}
else {
$("#new_course_message_notice").hide();
return true;
}
return false;
}
function regexContent() {
if(message_content_editor.isEmpty()){
$("#new_course_message_content_notice").show();
return false;
}
else {
$("#new_course_message_content_notice").hide();
return true;
}
return false;
}
function submitCoursesBoard(){
if(regexSubject() && regexContent()){
message_content_editor.sync();
$("#message-form").submit();
}
}
2017-09-15 20:59:35 +08:00
function join_group(type, id){
if($("input[name='member_ids[]']:checked").length == 0){
$("#no_student_notice").show();
} else{
$("#no_student_notice").hide();
$.ajax({
url: '/courses/'+id+'/choose_course_group',
type: 'post',
data: {member_ids: $("#choose_member_ids").val(), type:type},
remote: true,
success: function(data){
}
});
hideModal();
}
}
function delete_students(type, id, group_id){
if($("input[name='member_ids[]']:checked").length == 0){
$("#no_student_notice").show();
} else{
$("#no_student_notice").hide();
var htmlvalue = '<div class="task-popup" style="width:480px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey">提示</h3><a href="javascript:void(0);" class="pop_close"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a></div>'+
'<div class="task-popup-content"><p class="task-popup-text-center font-16">确定要删除这些学生吗?</p></div><div class="task-popup-submit clearfix"><a href="javascript:void(0);" onclick="hideModal();" class="task-btn fl">取消</a>'+
'<a href="javascript:void(0)" class="task-btn task-btn-blue fr pop_close" id="confirm-button">确定</a></div></div>';
pop_box_new(htmlvalue, 480, 140);
$("#confirm-button").on('click',function(){
hideModal();
$.ajax({
url: '/courses/'+id+'/delete_course_students',
type: 'post',
data: {member_ids: $("#choose_member_ids").val(), type:type, group_id:group_id},
remote: true,
success: function(data){
}
});
});
return;
}
}
2017-09-28 16:51:15 +08:00
function show_ex_edit_setting(){
$("#show_exercise_setting").hide();
$("#edit_exercise_setting").show();
$("#exam_setting_submit_block").show();
$("input[name='exercise_publish_time']").datetimepicker({
allowBlank:true,
lang:'ch',
format:'Y-m-d H:i',
validateOnBlur:false,
onSelectDate:function() {
if($.trim($("input[name='exercise_end_time']").val()) == ""){
var date = new Date(Date.parse($("input[name='exercise_publish_time']").val().replace(/-/g, "/")));
$("input[name='exercise_end_time']").val(formate_time(new Date(date.setDate(date.getDate()+14))));
}
// if($.trim($("input[name='homework_archive_time']").val()) == ""){
// var date = new Date(Date.parse($("input[name='homework_end_time']").val().replace(/-/g, "/")));
// $("input[name='homework_archive_time']").val(formate_time(new Date(date.setMonth(date.getMonth()+1))));
// }
},
onSelectTime:function() {
if($.trim($("input[name='exercise_end_time']").val()) == ""){
var date = new Date(Date.parse($("input[name='exercise_publish_time']").val().replace(/-/g, "/")));
$("input[name='exercise_end_time']").val(formate_time(new Date(date.setDate(date.getDate()+14))));
}
// if($.trim($("input[name='homework_archive_time']").val()) == ""){
// var date = new Date(Date.parse($("input[name='homework_end_time']").val().replace(/-/g, "/")));
// $("input[name='homework_archive_time']").val(formate_time(new Date(date.setMonth(date.getMonth()+1))));
// }
}
});
$("input[name='exercise_end_time']").datetimepicker({
allowBlank:true,
lang:'ch',
format:'Y-m-d H:i',
validateOnBlur:false,
// onSelectDate:function() {
// if($.trim($("input[name='homework_archive_time']").val()) == ""){
// var date = new Date(Date.parse($("input[name='homework_end_time']").val().replace(/-/g, "/")));
// $("input[name='homework_archive_time']").val(formate_time(new Date(date.setMonth(date.getMonth()+1))));
// }
// },
// onSelectTime:function() {
// if($.trim($("input[name='homework_archive_time']").val()) == ""){
// var date = new Date(Date.parse($("input[name='homework_end_time']").val().replace(/-/g, "/")));
// $("input[name='homework_archive_time']").val(formate_time(new Date(date.setMonth(date.getMonth()+1))));
// }
// }
});
}
function ex_setting_form_submit(){
var myDate = new Date();
var result = true;
if($("input[name='exercise_publish_time']").prop("disabled")==false && $.trim($("input[name='exercise_publish_time']").val()) != ""){
var publish_time = Date.parse($("input[name='exercise_publish_time']").val());
if(publish_time < myDate){
$("#exercise_publish_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>发布时间应晚于当前时间").show();
result = false;
} else{
$("#exercise_publish_time_notice").hide();
}
if($.trim($("input[name='exercise_end_time']").val()) == ""){
$("#exercise_end_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>截止时间不能为空").show();
result = false;
}
}
if($("input[name='exercise_end_time']").prop("disabled")==false && $.trim($("input[name='exercise_end_time']").val()) != ""){
if($.trim($("input[name='exercise_publish_time']").val()) == ""){
$("#exercise_publish_time").val(formate_time(myDate));
}
var publish_time = Date.parse($("input[name='exercise_publish_time']").val());
var end_time = Date.parse($("input[name='exercise_end_time']").val());
if(end_time <= publish_time){
$("#exercise_end_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>截止时间应晚于发布时间").show();
result = false;
} else if(end_time <= myDate) {
$("#exercise_end_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>截止时间应晚于当前时间").show();
result = false;
} else{
$("#exercise_end_time_notice").hide();
}
}
if(result){
$("#exercise_setting_form").submit();
}
}
//添加标题时确定按钮
function add_ex_question(doc,quest_type)
2017-09-28 16:51:15 +08:00
{
var title = $.trim($("#poll_questions_title").val());
var score = $.trim($("#question_score").val());
var standard_ans = $.trim($("#exercise_choice_" + quest_type).val());
if(title.length == 0 || score.length == 0){
notice_box("题目标题/分数不能为空");
doc.one('click', function(){
add_ex_question($(this),quest_type);
2017-09-28 16:51:15 +08:00
});
}else if(!/^[1-9][0-9]*$/.test(score)) {
notice_box("分数必须是非零开头的数字");
doc.one('click', function(){
add_ex_question($(this),quest_type);
2017-09-28 16:51:15 +08:00
});
}else if(quest_type !=3 && quest_type !=4 && standard_ans.length == 0) {
notice_box("标准答案不能为空");
doc.one('click', function(){
add_ex_question($(this),quest_type);
2017-09-28 16:51:15 +08:00
});
}else{
doc.parent().parent().parent().parent().submit();
}
}
function ex_head_submit(doc){
2017-09-28 16:51:15 +08:00
var title = $.trim($("#exercise_name").val());
if(title.length == 0){
notice_box("试卷标题不能为空");
} else {
doc.parent().parent().submit();
}
}
function ex_head_cancel(){
2017-09-28 16:51:15 +08:00
$("#exercise_head_edit").hide();
$("#exercise_head_show").show();
}
function exQuestionEdit(question_id){
var forms = $("form.new_exercise_question");
if($.trim($("#insert_new_poll_question_"+question_id).html()) == "") {
if(forms.length > 0){
2017-09-30 16:10:07 +08:00
notice_box("请先保存正在编辑的题目再编辑。");
} else{
$("#show_poll_questions_"+question_id).hide();
$("#edit_poll_questions_"+question_id).show();
$("#poll_questions_title_"+question_id).focus();
}
}
2017-09-30 16:10:07 +08:00
}
//修改标题时确定按钮
function edit_poll_question(doc,id,quest_type)
{
var title = $.trim($("#poll_questions_title_" + id).val());
var score = $.trim($("#poll_question_score_"+ id).val());
var standard_ans = $.trim($("#exercise_choice_" + id).val());
if(title.length == 0 || score.length == 0){
notice_box("题目标题/分数不能为空");
}else if(!/^[1-9][0-9]*$/.test(score)) {
notice_box("分数必须是非零开头的数字");
}else if(quest_type !=3 && quest_type !=4 && standard_ans.length == 0) {
notice_box("标准答案不能为空");
}else if(quest_type ==3) {
var div = $("#poll_answers_" + id);
var candiate_answer = $(".candiate_answer",div);
if(candiate_answer.length > 0) {
for(i=0;i<candiate_answer.length;i++) {
if(i<candiate_answer.length-1 && $.trim($(candiate_answer[i]).val()) == "") {
continue;
} else if(i == (candiate_answer.length-1) && $.trim($(candiate_answer[i]).val()) == "") {
notice_box("参考答案不能为空");
} else if($.trim($(candiate_answer[i]).val()) != ""){
doc.parent().parent().parent().submit();
break;
}
}
} else{
notice_box("参考答案不能为空");
}
}else{
doc.parent().parent().parent().submit();}
2017-09-28 16:51:15 +08:00
}