diff --git a/app/views/courses/_copy_course.html.erb b/app/views/courses/_copy_course.html.erb index 402e00cf6..3b6d55d96 100644 --- a/app/views/courses/_copy_course.html.erb +++ b/app/views/courses/_copy_course.html.erb @@ -1,17 +1,17 @@ \ No newline at end of file diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index b0c4a067f..82123a767 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -33,35 +33,35 @@ - - + +
  • - - + +
  • - <%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {:id=>"time"} %> - <%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{:id=>"term"} %> + <%= select_tag :time,options_for_select(course_time_option(@course.time),@course.time), {:id=>"edit_time"} %> + <%= select_tag :term,options_for_select(course_term_option,@course.term || cur_course_term),{:id=>"edit_term"} %>
  • - <%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {:id=>"end_time"} %> - <%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{:id=>"end_term"} %> - + <%= select_tag :end_time,options_for_select(course_time_option(@course.end_time),@course.end_time), {:id=>"edit_end_time"} %> + <%= select_tag :end_term,options_for_select(course_term_option,@course.end_term || cur_course_term),{:id=>"edit_end_term"} %> +
  • - + 显示明码 - +
    学生或其他成员申请加入课程时候需要使用该口令,该口令可以由老师在课堂上公布。
  • diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 0bba3264b..7cfad6005 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -73,79 +73,79 @@ function hidden_homework_score_form() /////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////新建课程相关 //验证课程名称 -function regex_course_name() +function regex_course_name(str) { - var name = $.trim($("#course_name").val()); + var name = $.trim($("#"+str+"_course_name").val()); if(name.length < 2) { - $("#course_name_notice").show(); + $("#"+str+"_course_name_notice").show(); return false; } else { - $("#course_name_notice").hide(); + $("#"+str+"_course_name_notice").hide(); return true; } } //验证课程学时 -function regex_course_class_period() +function regex_course_class_period(str) { - var class_period = $.trim($("#class_period").val()); + var class_period = $.trim($("#"+str+"_class_period").val()); var regex = /^\d*$/; if(class_period.length == 0) { - $("#course_class_period_notice").html("学时总数不能为空"); - $("#course_class_period_notice").show(); + $("#"+str+"_course_class_period_notice").html("学时总数不能为空"); + $("#"+str+"_course_class_period_notice").show(); return false; } else if (regex.test(class_period)) { if(parseInt(class_period) > 0) { - $("#course_class_period_notice").html(""); - $("#course_class_period_notice").hide(); + $("#"+str+"_course_class_period_notice").html(""); + $("#"+str+"_course_class_period_notice").hide(); return true; } else { - $("#course_class_period_notice").html("学时总数必须大于0"); - $("#course_class_period_notice").show(); + $("#"+str+"_course_class_period_notice").html("学时总数必须大于0"); + $("#"+str+"_course_class_period_notice").show(); return false; } } else { - $("#course_class_period_notice").html("学时总数必须为正整数"); - $("#course_class_period_notice").show(); + $("#"+str+"_course_class_period_notice").html("学时总数必须为正整数"); + $("#"+str+"_course_class_period_notice").show(); return false; } } //验证开始学期和结束学期 -function regex_time_term(){ - var obj_time = document.getElementById("time"); - var obj_end_time = document.getElementById("end_time"); - var obj_term = document.getElementById("term"); - var obj_end_term = document.getElementById("end_term"); +function regex_time_term(str){ + var obj_time = document.getElementById(str+"_time"); + var obj_end_time = document.getElementById(str+"_end_time"); + var obj_term = document.getElementById(str+"_term"); + var obj_end_term = document.getElementById(str+"_end_term"); var time = obj_time.options[obj_time.selectedIndex]; var end_time = obj_end_time.options[obj_end_time.selectedIndex]; var term = obj_term.options[obj_term.selectedIndex]; var end_term = obj_end_term.options[obj_end_term.selectedIndex]; if(time.value == end_time.value) { if(set_term_val(term.value) > set_term_val(end_term.value)) { - $("#course_time_term_notice").html("开始学期不能晚于结束学期"); - $("#course_time_term_notice").show(); + $("#"+str+"_course_time_term_notice").html("开始学期不能晚于结束学期"); + $("#"+str+"_course_time_term_notice").show(); return false; } else { - $("#course_time_term_notice").html(""); - $("#course_time_term_notice").hide(); + $("#"+str+"_course_time_term_notice").html(""); + $("#"+str+"_course_time_term_notice").hide(); return true; } } else if(time.value < end_time.value) { - $("#course_time_term_notice").html(""); - $("#course_time_term_notice").hide(); + $("#"+str+"_course_time_term_notice").html(""); + $("#"+str+"_course_time_term_notice").hide(); return true; } else { - $("#course_time_term_notice").html("开始学期不能晚于结束学期"); - $("#course_time_term_notice").show(); + $("#"+str+"_course_time_term_notice").html("开始学期不能晚于结束学期"); + $("#"+str+"_course_time_term_notice").show(); return false; } } @@ -160,32 +160,32 @@ function set_term_val(val) { } } //验证密码 -function regex_course_password() +function regex_course_password(str) { - var class_period = $.trim($("#course_course_password").val()); + var class_period = $.trim($("#"+str+"_course_course_password").val()); var regex = /^\w+$/; if(class_period.length == 0) { - $("#course_course_password_notice").html("课程密码不能为空"); - $("#course_course_password_notice").show(); + $("#"+str+"_course_course_password_notice").html("课程密码不能为空"); + $("#"+str+"_course_course_password_notice").show(); return false; } else if (regex.test(class_period)) { - $("#course_course_password_notice").html(""); - $("#course_course_password_notice").hide(); + $("#"+str+"_course_course_password_notice").html(""); + $("#"+str+"_course_course_password_notice").hide(); return true; } else { - $("#course_course_password_notice").html("课程密码有非法字符"); - $("#course_course_password_notice").show(); + $("#"+str+"_course_course_password_notice").html("课程密码有非法字符"); + $("#"+str+"_course_course_password_notice").show(); return false; } } //提交新建课程 function submit_new_course() { - if(regex_course_name()&®ex_course_class_period()&®ex_time_term()&®ex_course_password()) + if(regex_course_name('new')&®ex_course_class_period('new')&®ex_time_term('new')&®ex_course_password('new')) { $("#new_course").submit(); } @@ -193,7 +193,7 @@ function submit_new_course() function submit_edit_course(id) { - if(regex_course_name()&®ex_course_class_period()&®ex_time_term()&®ex_course_password()) + if(regex_course_name('edit')&®ex_course_class_period('edit')&®ex_time_term('edit')&®ex_course_password('edit')) { $("#edit_course_"+id).submit(); }