718 lines
32 KiB
JavaScript
718 lines
32 KiB
JavaScript
$(function(){
|
|
$("#major_level").on("change", function(){
|
|
$.ajax({
|
|
url: '/syllabuses/get_discipline_categories',
|
|
type: 'get',
|
|
data: {major_level:$("#major_level").val()},
|
|
success: function(data){
|
|
if (data.result == 1){
|
|
$("#discipline_category_id").html("<option value='0'>选择课程所属学科门类</option>");
|
|
for(var i=0; i<data.options.length; i++){
|
|
$("#discipline_category_id").append("<option value='" + data.options[i][1] + "'>" + data.options[i][0] + "</option>");
|
|
}
|
|
$("#major_level_notice").hide();
|
|
}
|
|
else{
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
$("#discipline_category_id").on("change", function(){
|
|
$.ajax({
|
|
url: '/syllabuses/get_first_level_disciplines',
|
|
type: 'get',
|
|
data: {discipline_category_id:$("#discipline_category_id").val()},
|
|
success: function(data){
|
|
if (data.result == 1){
|
|
$("#first_level_discipline_id").html("<option value='0'>选择课程所属一级学科</option>");
|
|
for(var i=0; i<data.options.length; i++){
|
|
$("#first_level_discipline_id").append("<option value='" + data.options[i][1] + "'>" + data.options[i][0] + "</option>");
|
|
}
|
|
$("#discipline_category_id_notice").hide();
|
|
}
|
|
else{
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
$("#first_level_discipline_id").on("change", function(){
|
|
if($("#first_level_discipline_id").val() != "0"){
|
|
$("#first_level_discipline_id_notice").hide();
|
|
}
|
|
});
|
|
|
|
$("#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();
|
|
}
|
|
});
|
|
|
|
var bt = baidu.template;
|
|
bt.LEFT_DELIMITER = '<!';
|
|
bt.RIGHT_DELIMITER = '!>';
|
|
|
|
$(".program_homework").on('click', 'a.test_icon_add', function () {
|
|
var html = bt('t:test-answer-list', null);
|
|
$(this).parent().parent('li').after(html);
|
|
var inputs = document.getElementsByName("program[input][]");
|
|
var outputs = document.getElementsByName("program[output][]");
|
|
var inputs_labels = document.getElementsByName("inputs_label");
|
|
for (var j = 0; j < inputs_labels.length; j++) {
|
|
$(inputs_labels[j]).html("测试" +(j + 1));
|
|
}
|
|
if (inputs.length == outputs.length) {
|
|
for (var i = 0; i < inputs.length; i++) {
|
|
autoTextarea2(inputs[i], outputs[i], 0, 140);
|
|
autoTextarea2(outputs[i], inputs[i], 0, 140);
|
|
}
|
|
}
|
|
});
|
|
$(".program_homework").on('click', 'a.test_icon_remove', function () {
|
|
$(this).parent().parent('li').remove();
|
|
var inputs_labels = document.getElementsByName("inputs_label");
|
|
for (var j = 0; j < inputs_labels.length; j++) {
|
|
$(inputs_labels[j]).html("测试" +(j + 1));
|
|
}
|
|
});
|
|
|
|
$(".program_homework").on('click', 'a.sample_icon_add', function () {
|
|
var html = bt('t:sample-answer-list', null);
|
|
$(this).parent().parent('li').after(html);
|
|
var inputs = document.getElementsByName("sample[input][]");
|
|
var outputs = document.getElementsByName("sample[output][]");
|
|
var inputs_labels = document.getElementsByName("sample_inputs_label");
|
|
for (var j = 0; j < inputs_labels.length; j++) {
|
|
$(inputs_labels[j]).html("样例" +(j + 1));
|
|
}
|
|
if (inputs.length == outputs.length) {
|
|
for (var i = 0; i < inputs.length; i++) {
|
|
autoTextarea(inputs[i], 0, 140);
|
|
autoTextarea(outputs[i], 0, 140);
|
|
}
|
|
}
|
|
});
|
|
$(".program_homework").on('click', 'a.sample_icon_remove', function () {
|
|
$(this).parent().parent('li').remove();
|
|
var inputs_labels = document.getElementsByName("sample_inputs_label");
|
|
for (var j = 0; j < inputs_labels.length; j++) {
|
|
$(inputs_labels[j]).html("样例" +(j + 1));
|
|
}
|
|
});
|
|
|
|
var sample_inputs = document.getElementsByName("sample[input][]");
|
|
var sample_outputs = document.getElementsByName("sample[output][]");
|
|
if (sample_inputs.length == sample_outputs.length) {
|
|
for (var i = 0; i < sample_inputs.length; i++) {
|
|
autoTextarea(sample_inputs[i], 0, 140);
|
|
autoTextarea(sample_outputs[i], 0, 140);
|
|
}
|
|
}
|
|
var inputs = document.getElementsByName("program[input][]");
|
|
var outputs = document.getElementsByName("program[output][]");
|
|
if (inputs.length == outputs.length) {
|
|
for (var i = 0; i < inputs.length; i++) {
|
|
autoTextarea2(inputs[i], outputs[i], 0, 140);
|
|
autoTextarea2(outputs[i], inputs[i], 0, 140);
|
|
}
|
|
}
|
|
|
|
$(".homework_setting p").on('click', function(){
|
|
$(this).next().show();
|
|
});
|
|
|
|
$("input[name='homework_publish_time']").datetimepicker({
|
|
allowBlank:true,
|
|
lang:'ch',
|
|
format:'Y-m-d H:i',
|
|
validateOnBlur:false,
|
|
onSelectDate:function() {
|
|
$("#reset_publish_time").show();
|
|
if($.trim($("input[name='homework_archive_time']").val()) == ""){
|
|
var date = new Date(Date.parse($("input[name='homework_publish_time']").val().replace(/-/g, "/")));
|
|
$("input[name='homework_archive_time']").val(formate_time(new Date(date.setMonth(date.getMonth()+1))));
|
|
}
|
|
},
|
|
onSelectTime:function() {
|
|
$("#reset_publish_time").show();
|
|
if($.trim($("input[name='homework_archive_time']").val()) == ""){
|
|
var date = new Date(Date.parse($("input[name='homework_publish_time']").val().replace(/-/g, "/")));
|
|
$("input[name='homework_archive_time']").val(formate_time(new Date(date.setMonth(date.getMonth()+1))));
|
|
}
|
|
}
|
|
});
|
|
|
|
$("input[name='homework_end_time']").datetimepicker({
|
|
allowBlank:true,
|
|
lang:'ch',
|
|
format:'Y-m-d H:i',
|
|
validateOnBlur:false,
|
|
onSelectDate:function() {
|
|
$("#reset_end_time").show();
|
|
},
|
|
onSelectTime:function() {
|
|
$("#reset_end_time").show();
|
|
}
|
|
});
|
|
|
|
$("input[name='homework_archive_time']").datetimepicker({
|
|
allowBlank:true,
|
|
lang:'ch',
|
|
format:'Y-m-d H:i',
|
|
validateOnBlur:false
|
|
});
|
|
|
|
$("#reset_publish_time").on('click', function(){
|
|
$("input[name='homework_publish_time']").val("");
|
|
$("#reset_publish_time").hide();
|
|
});
|
|
|
|
$("#reset_end_time").on('click', function(){
|
|
$("input[name='homework_end_time']").val("");
|
|
$("#reset_end_time").hide();
|
|
});
|
|
|
|
$("#publish_setting_form_submit").on('click', function(){
|
|
var myDate = new Date();
|
|
var result = true;
|
|
if($.trim($("input[name='homework_publish_time']").val()) != ""){
|
|
var publish_time = Date.parse($("input[name='homework_publish_time']").val());
|
|
if(publish_time < myDate){
|
|
$("#homework_publish_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>发布时间应晚于当前时间").show();
|
|
result = false;
|
|
} else{
|
|
$("#homework_publish_time_notice").hide();
|
|
}
|
|
if($.trim($("input[name='homework_end_time']").val()) == ""){
|
|
$("#homework_end_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>截止时间不能为空").show();
|
|
result = false;
|
|
}
|
|
}
|
|
if($.trim($("input[name='homework_end_time']").val()) != ""){
|
|
if($.trim($("input[name='homework_publish_time']").val()) == ""){
|
|
$("#homework_publish_time").val(formate_time(myDate));
|
|
}
|
|
var publish_time = Date.parse($("input[name='homework_publish_time']").val());
|
|
var end_time = Date.parse($("input[name='homework_end_time']").val());
|
|
if(end_time <= publish_time){
|
|
$("#homework_end_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>截止时间应晚于发布时间").show();
|
|
result = false;
|
|
} else if(end_time <= myDate) {
|
|
$("#homework_end_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>截止时间应晚于当前时间").show();
|
|
result = false;
|
|
} else{
|
|
$("#homework_end_time_notice").hide();
|
|
}
|
|
}
|
|
if($.trim($("input[name='homework_archive_time']").val()) == ""){
|
|
$("#homework_archive_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>作业结束时间不能为空").show();
|
|
result = false;
|
|
} else{
|
|
if($.trim($("input[name='homework_end_time']").val()) != ""){
|
|
var end_time = Date.parse($("input[name='homework_end_time']").val());
|
|
var archive_time = Date.parse($("input[name='homework_archive_time']").val());
|
|
if(archive_time <= end_time){
|
|
$("#homework_archive_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>作业结束时间应晚于截止时间").show();
|
|
result = false;
|
|
} else{
|
|
$("#homework_archive_time_notice").hide();
|
|
}
|
|
} else if($.trim($("#show_late_time").val()) != ""){
|
|
var end_time = Date.parse($("#show_late_time").val());
|
|
var archive_time = Date.parse($("input[name='homework_archive_time']").val());
|
|
if(archive_time <= end_time){
|
|
$("#homework_archive_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>作业结束时间应晚于匿评结束时间").show();
|
|
result = false;
|
|
} else{
|
|
$("#homework_archive_time_notice").hide();
|
|
}
|
|
} else if($.trim($("#show_evaluation_end").val()) != ""){
|
|
var end_time = Date.parse($("#show_evaluation_end").val());
|
|
var archive_time = Date.parse($("input[name='homework_archive_time']").val());
|
|
if(archive_time <= end_time){
|
|
$("#homework_archive_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>作业结束时间应晚于匿评结束时间").show();
|
|
result = false;
|
|
} else{
|
|
$("#homework_archive_time_notice").hide();
|
|
}
|
|
}else if($.trim($("input[name='homework_appeal_time']").val()) != ""){
|
|
var end_time = Date.parse($("input[name='homework_appeal_time']").val());
|
|
var archive_time = Date.parse($("input[name='homework_archive_time']").val());
|
|
if(archive_time <= end_time){
|
|
$("#homework_archive_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>作业结束时间应晚于申诉结束时间").show();
|
|
result = false;
|
|
} else{
|
|
$("#homework_archive_time_notice").hide();
|
|
}
|
|
} else{
|
|
$("#homework_archive_time_notice").hide();
|
|
}
|
|
}
|
|
|
|
if(result){
|
|
if($.trim($("input[name='homework_publish_time']").val()) == "" && $.trim($("input[name='homework_end_time']").val()) == ""){
|
|
var htmlvalue = '<div class="task-popup" style="width:578px;"><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">发布时间为空,其他设置将不能编辑<br/>确认要保存发布设置吗?</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" onclick="$(\'#publish_setting_form\').submit(); hideModal();">确定</a></div></div>';
|
|
pop_box_new(htmlvalue, 578, 205);
|
|
} else{
|
|
$("#publish_setting_form").submit();
|
|
}
|
|
}
|
|
});
|
|
|
|
$("input[name='homework_late_time']").datetimepicker({
|
|
allowBlank:true,
|
|
lang:'ch',
|
|
format:'Y-m-d H:i',
|
|
validateOnBlur:false
|
|
});
|
|
|
|
$("#edit_allow_late_1").on('click', function(){
|
|
$("#late_relate_setting_ul").show();
|
|
var my_date = new Date();
|
|
var date = new Date(Date.parse($("#show_end_time").val().replace(/-/g, "/")));
|
|
if(my_date > date){
|
|
$("input[name='homework_late_time']").val(formate_time(new Date(my_date.setDate(my_date.getDate()+3))));
|
|
} else{
|
|
$("input[name='homework_late_time']").val(formate_time(new Date(date.setDate(date.getDate()+3))));
|
|
}
|
|
$("input[name='homework_late_penalty']").val("5");
|
|
});
|
|
|
|
$("#edit_allow_late_0").on('click', function(){
|
|
$("#late_relate_setting_ul").hide();
|
|
$("input[name='homework_late_time']").val("");
|
|
$("input[name='homework_late_penalty']").val("0");
|
|
});
|
|
|
|
$("#late_setting_form_submit").live('click', function(){
|
|
var result = true;
|
|
if($("input[name='homework_allow_late']:checked").val() == '1'){
|
|
if($.trim($("input[name='homework_late_time']").val()) == ""){
|
|
$("#homework_late_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>补交截止时间不能为空").show();
|
|
result = false;
|
|
} else{
|
|
var end_time = Date.parse($("#show_end_time").val());
|
|
var archive_time = Date.parse($("#show_archive_time").val());
|
|
var late_time = Date.parse($("input[name='homework_late_time']").val());
|
|
if(late_time <= end_time){
|
|
$("#homework_late_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>补交截止时间应晚于提交截止时间").show();
|
|
result = false;
|
|
} else if(archive_time <= late_time){
|
|
$("#homework_late_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>补交截止时间应早于作业结束时间").show();
|
|
result = false;
|
|
} else if($.trim($("#show_evaluation_start").val()) != ""){
|
|
var end_time = Date.parse($("#show_evaluation_start").val());
|
|
var late_time = Date.parse($("input[name='homework_late_time']").val());
|
|
if(late_time > end_time){
|
|
$("#homework_late_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>补交截止时间应早于匿评开始时间").show();
|
|
result = false;
|
|
} else{
|
|
$("#homework_late_time_notice").hide();
|
|
}
|
|
} else{
|
|
$("#homework_late_time_notice").hide();
|
|
}
|
|
}
|
|
if($.trim($("input[name='homework_late_penalty']").val()) == ""){
|
|
result = false;
|
|
$("#homework_late_penalty_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>迟交扣分不能为空").show();
|
|
} else{
|
|
var str = $.trim($("input[name='homework_late_penalty']").val());
|
|
var regex = /^\d+$/;
|
|
if(!regex.test(str) || parseInt(str) < 0 || parseInt(str) > 50) {
|
|
result = false;
|
|
$("#homework_late_penalty_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>请输入0-50之间的正整数").show();
|
|
} else{
|
|
$("#homework_late_penalty_notice").hide();
|
|
}
|
|
}
|
|
}
|
|
if(result){
|
|
$("#late_setting_form").submit();
|
|
}
|
|
});
|
|
|
|
$("input[name='homework_evaluation_start']").datetimepicker({
|
|
allowBlank:true,
|
|
lang:'ch',
|
|
format:'Y-m-d H:i',
|
|
validateOnBlur:false
|
|
});
|
|
$("input[name='homework_evaluation_end']").datetimepicker({
|
|
allowBlank:true,
|
|
lang:'ch',
|
|
format:'Y-m-d H:i',
|
|
validateOnBlur:false
|
|
});
|
|
$("input[name='homework_appeal_time']").datetimepicker({
|
|
allowBlank:true,
|
|
lang:'ch',
|
|
format:'Y-m-d H:i',
|
|
validateOnBlur:false
|
|
});
|
|
|
|
$("input[name='homework_anonymous_comment']").on('click', function(){
|
|
if($(this).is(':checked')){
|
|
$(this).parent().parent('ul').find('input[type="text"]').removeAttr('disabled');
|
|
$(this).parent().parent('ul').find('input[type="text"]').removeClass('disabled-bg');
|
|
$("#anon_relate_setting_ul").show();
|
|
var my_date = new Date();
|
|
var end_date = new Date(Date.parse($("#show_end_time").val().replace(/-/g, "/")));
|
|
var late_date = $("#show_late_time").val() == "" ? end_date : (new Date(Date.parse($("#show_late_time").val().replace(/-/g, "/"))));
|
|
var max_date = my_date > end_date ? (my_date > late_date ? my_date : late_date) : (end_date > late_date ? end_date : late_date);
|
|
$("input[name='homework_evaluation_start']").val(formate_time(new Date(max_date.setDate(max_date.getDate()+7))));
|
|
$("input[name='homework_evaluation_end']").val(formate_time(new Date(max_date.setDate(max_date.getDate()+14))));
|
|
$("input[name='homework_evaluation_num']").val("3");
|
|
$("input[name='homework_absence_penalty']").val("2");
|
|
} else{
|
|
$(this).parent().parent('ul').find('input[type="text"]').attr('disabled', 'disabled');
|
|
$(this).parent().parent('ul').find('input[type="text"]').addClass('disabled-bg');
|
|
$("input[name='homework_evaluation_start']").val("");
|
|
$("input[name='homework_evaluation_end']").val("");
|
|
$("input[name='homework_evaluation_num']").val("0");
|
|
$("input[name='homework_absence_penalty']").val("0");
|
|
$("#anon_relate_setting_ul").hide();
|
|
}
|
|
});
|
|
|
|
$("input[name='homework_anonymous_appeal']").on('click', function(){
|
|
if($(this).is(':checked')){
|
|
$(this).parent().parent('ul').find('input[type="text"]').removeAttr('disabled');
|
|
$(this).parent().parent('ul').find('input[type="text"]').removeClass('disabled-bg');
|
|
var my_date = new Date();
|
|
var end_date = new Date(Date.parse($("input[name='homework_evaluation_end']").val().replace(/-/g, "/")));
|
|
var max_date = my_date > end_date ? my_date : end_date;
|
|
$("input[name='homework_appeal_time']").val(formate_time(new Date(max_date.setDate(max_date.getDate()+2))));
|
|
$("input[name='homework_appeal_penalty']").val("2");
|
|
} else{
|
|
$(this).parent().parent('ul').find('input[type="text"]').attr('disabled', 'disabled');
|
|
$(this).parent().parent('ul').find('input[type="text"]').addClass('disabled-bg');
|
|
$("input[name='homework_appeal_time']").val("");
|
|
$("input[name='homework_appeal_penalty']").val("0");
|
|
}
|
|
});
|
|
|
|
$("#anon_setting_form_submit").live('click', function(){
|
|
var result = true;
|
|
if($("input[name='homework_anonymous_comment']").is(':checked')){
|
|
if($.trim($("input[name='homework_evaluation_start']").val()) == ""){
|
|
$("#homework_evaluation_start_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>匿评开始时间不能为空").show();
|
|
result = false;
|
|
} else{
|
|
var end_time = Date.parse($("#show_end_time").val());
|
|
var late_time = Date.parse($("#show_late_time").val());
|
|
var archive_time = Date.parse($("#show_archive_time").val());
|
|
var eva_start = Date.parse($("input[name='homework_evaluation_start']").val());
|
|
var eva_end = Date.parse($("input[name='homework_evaluation_end']").val());
|
|
if($("#show_late_time").val() != ""){
|
|
if(eva_start <= late_time){
|
|
$("#homework_evaluation_start_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>匿评开始时间应晚于补交截止时间").show();
|
|
result = false;
|
|
} else{
|
|
$("#homework_evaluation_start_notice").hide();
|
|
}
|
|
} else if(eva_start <= end_time){
|
|
$("#homework_evaluation_start_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>匿评开始时间应晚于提交截止时间").show();
|
|
result = false;
|
|
} else {
|
|
$("#homework_evaluation_start_notice").hide();
|
|
}
|
|
if(eva_end <= eva_start){
|
|
$("#homework_evaluation_end_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>匿评结束时间应晚于匿评开始时间").show();
|
|
result = false;
|
|
} else if(eva_end >= archive_time){
|
|
$("#homework_evaluation_end_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>匿评结束时间应早于作业结束时间").show();
|
|
result = false;
|
|
} else{
|
|
$("#homework_evaluation_end_notice").hide();
|
|
}
|
|
}
|
|
if($.trim($("input[name='homework_evaluation_num']").val()) == ""){
|
|
result = false;
|
|
$("#homework_evaluation_num_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>匿评数不能为空").show();
|
|
} else{
|
|
var str = $.trim($("input[name='homework_evaluation_num']").val());
|
|
var regex = /^\d+$/;
|
|
if(!regex.test(str) || parseInt(str) < 0) {
|
|
result = false;
|
|
$("#homework_evaluation_num_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>请输入正整数").show();
|
|
} else{
|
|
$("#homework_evaluation_num_notice").hide();
|
|
}
|
|
}
|
|
if($.trim($("input[name='homework_absence_penalty']").val()) == ""){
|
|
result = false;
|
|
$("#homework_absence_penalty_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>匿评扣分不能为空").show();
|
|
} else{
|
|
var str = $.trim($("input[name='homework_absence_penalty']").val());
|
|
var regex = /^\d+$/;
|
|
if(!regex.test(str) || parseInt(str) < 0 || parseInt(str) > 50) {
|
|
result = false;
|
|
$("#homework_absence_penalty_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>请输入0-50之间的正整数").show();
|
|
} else{
|
|
$("#homework_absence_penalty_notice").hide();
|
|
}
|
|
}
|
|
}
|
|
if($("input[name='homework_anonymous_appeal']").is(':checked')){
|
|
if($.trim($("input[name='homework_appeal_time']").val()) == ""){
|
|
$("#homework_appeal_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>申诉结束时间不能为空").show();
|
|
result = false;
|
|
} else{
|
|
var archive_time = Date.parse($("#show_archive_time").val());
|
|
var eva_end = Date.parse($("input[name='homework_evaluation_end']").val());
|
|
var appeal_time = Date.parse($("input[name='homework_appeal_time']").val());
|
|
if(eva_end >= appeal_time){
|
|
$("#homework_appeal_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>申诉结束时间应晚于匿评结束时间").show();
|
|
result = false;
|
|
} else if(archive_time <= appeal_time){
|
|
$("#homework_appeal_time_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>申诉结束时间应早于作业结束时间").show();
|
|
result = false;
|
|
} else {
|
|
$("#homework_appeal_time_notice").hide();
|
|
}
|
|
}
|
|
if($.trim($("input[name='homework_appeal_penalty']").val()) == ""){
|
|
result = false;
|
|
$("#homework_appeal_penalty_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>违规匿评扣分不能为空").show();
|
|
} else{
|
|
var str = $.trim($("input[name='homework_appeal_penalty']").val());
|
|
var regex = /^\d+$/;
|
|
if(!regex.test(str) || parseInt(str) < 0 || parseInt(str) > 50) {
|
|
result = false;
|
|
$("#homework_appeal_penalty_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>请输入0-50之间的正整数").show();
|
|
} else{
|
|
$("#homework_appeal_penalty_notice").hide();
|
|
}
|
|
}
|
|
}
|
|
if(result){
|
|
$("#anon_setting_form").submit();
|
|
}
|
|
});
|
|
|
|
$("#homework_final_mode_1").on('click', function(){
|
|
$("select.normal-bg").removeAttr("disabled");
|
|
$("select.normal-bg").removeClass("disabled-bg");
|
|
});
|
|
|
|
$("#homework_final_mode_0").on('click', function(){
|
|
$("select.normal-bg").attr("disabled", "disabled");
|
|
$("select.normal-bg").addClass("disabled-bg");
|
|
});
|
|
|
|
$("#score_setting_form_submit").on('click', function(){
|
|
var result = true;
|
|
if($("input[name='homework_final_mode']:checked").val() == '1'){
|
|
var te_pro = parseFloat($("select[name='te_proportion']").val());
|
|
var ta_pro = parseFloat($("select[name='ta_proportion']").val());
|
|
var st_pro = parseFloat($("select[name='st_proportion']").val());
|
|
if($("select[name='sy_proportion']").length == 1){
|
|
var sy_pro = parseFloat($("select[name='sy_proportion']").val());
|
|
} else{
|
|
var sy_pro = 0;
|
|
}
|
|
if(te_pro + ta_pro + st_pro + sy_pro != 1.0){
|
|
result = false;
|
|
$("#homework_final_mode_notice").html("<i class='fa fa-exclamation-circle mr5 color-orange'></i>各评分比例之和应为100%").show();
|
|
} else{
|
|
$("#homework_final_mode_notice").hide();
|
|
}
|
|
}
|
|
if(result){
|
|
$("#score_setting_form").submit();
|
|
}
|
|
});
|
|
|
|
$("#public_setting_form_submit").on('click', function(){
|
|
$("#public_setting_form").submit();
|
|
});
|
|
});
|
|
|
|
function regex_syllabus_name() {
|
|
var name = $.trim($("#new_syllabus_name").val());
|
|
if(name.length < 2)
|
|
{
|
|
$("#new_syllabus_name_notice").show();
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
$("#new_syllabus_name_notice").hide();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
//新建课程
|
|
function submit_new_syllabus()
|
|
{
|
|
if($("#major_level").val() == "0"){
|
|
$("#major_level_notice").show();
|
|
} else if($("#discipline_category_id").val() == "0"){
|
|
$("#discipline_category_id_notice").show();
|
|
} else if($("#first_level_discipline_id").val() == "0"){
|
|
$("#first_level_discipline_id_notice").show();
|
|
} else {
|
|
if(regex_syllabus_name())
|
|
{
|
|
$.ajax({
|
|
url: '/syllabuses/regex_syllabus_name',
|
|
type: 'post',
|
|
data: {name:$.trim($("#new_syllabus_name").val())},
|
|
success: function(data){
|
|
if (data.result == 0){
|
|
$("#new_syllabus_name_repeat_notice").show();
|
|
$("#new_syllabus_name_notice").hide();
|
|
}
|
|
else{
|
|
$("#new_syllabus").submit();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
//编辑课程
|
|
function submit_edit_syllabus(id)
|
|
{
|
|
if($("#major_level").val() == "0"){
|
|
$("#major_level_notice").show();
|
|
} else if($("#discipline_category_id").val() == "0"){
|
|
$("#discipline_category_id_notice").show();
|
|
} else if($("#first_level_discipline_id").val() == "0"){
|
|
$("#first_level_discipline_id_notice").show();
|
|
} else {
|
|
if(regex_syllabus_name())
|
|
{
|
|
$.ajax({
|
|
url: '/syllabuses/regex_syllabus_name',
|
|
type: 'post',
|
|
data: {name:$.trim($("#new_syllabus_name").val()), syllabus_id:id},
|
|
success: function(data){
|
|
if (data.result == 0){
|
|
$("#new_syllabus_name_repeat_notice").show();
|
|
$("#new_syllabus_name_notice").hide();
|
|
}
|
|
else{
|
|
$("#edit_syllabus").submit();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
function submit_member_all_student_list_search(id){
|
|
$.ajax({
|
|
url: '/courses/'+id+'/member?role=as&search='+$("#all_student_list_search").val().trim(),
|
|
type: 'get',
|
|
success: function(data){
|
|
}
|
|
});
|
|
}
|
|
|
|
function submit_member_no_group_student_search(id){
|
|
$.ajax({
|
|
url: '/courses/'+id+'/member?role=ns&search='+$("#no_group_student_list_search").val().trim(),
|
|
type: 'get',
|
|
success: function(data){
|
|
}
|
|
});
|
|
}
|
|
|
|
function submit_member_has_group_student_search(id, group_id){
|
|
$.ajax({
|
|
url: '/courses/'+id+'/member?role='+group_id+'&&search='+$("#has_group_student_list_search").val().trim(),
|
|
type: 'get',
|
|
success: function(data){
|
|
}
|
|
});
|
|
}
|
|
|
|
function student_choose_group(course_id, member_id){
|
|
$.ajax({
|
|
url: '/courses/'+course_id+'/choose_course_group',
|
|
type: 'post',
|
|
data: {member_ids: [member_id]},
|
|
remote: true,
|
|
success: function(data){
|
|
}
|
|
});
|
|
}
|
|
|
|
function submit_new_common_homework(type){
|
|
var notice_count = 0;
|
|
$("#new_homework_notice_count").parent().hide();
|
|
$("#new_homework_notice>ul").empty();
|
|
if($("#new_homework_name").val().trim() == ""){
|
|
notice_count++;
|
|
$("#new_homework_notice>ul").append("<li>标题不能为空</li>");
|
|
}
|
|
if(homework_description_editor.isEmpty()){
|
|
notice_count++;
|
|
$("#new_homework_notice>ul").append("<li>内容不能为空</li>");
|
|
}
|
|
if(type == 2){
|
|
var result = true;
|
|
$.each($(".program_homework textarea[name='sample[output][]']"), function(i, val){
|
|
if (result && $(val).val().length<=0) {
|
|
result = false;
|
|
}
|
|
});
|
|
$.each($(".program_homework textarea[name='program[output][]']"), function(i, val){
|
|
if (result && $(val).val().length<=0) {
|
|
result = false;
|
|
}
|
|
});
|
|
if(!result){
|
|
notice_count++;
|
|
$("#new_homework_notice>ul").append("<li>样例输出/测试输出不能为空</li>");
|
|
}
|
|
} else if(type == 3){
|
|
var min = $.trim($("#min_num").val());
|
|
var max = $.trim($("#max_num").val());
|
|
var regex = /^\d+$/;
|
|
if(min == "" || max == ""){
|
|
notice_count++;
|
|
$("#new_homework_notice>ul").append("<li>分组人数不能为空</li>");
|
|
} else if(!regex.test(min) || parseInt(min) <= 0 || !regex.test(max) || parseInt(max) <= 0) {
|
|
notice_count++;
|
|
$("#new_homework_notice>ul").append("<li>分组人数应为正整数</li>");
|
|
} else if(parseInt(min) > parseInt(max)) {
|
|
notice_count++;
|
|
$("#new_homework_notice>ul").append("<li>分组最小人数不得大于最大人数</li>");
|
|
}
|
|
}
|
|
if(notice_count == 0){
|
|
homework_description_editor.sync();
|
|
homework_ref_answer_editor.sync();
|
|
$("#new_homework_common").submit();
|
|
console.log("111111111111111111");
|
|
} else{
|
|
$("#new_homework_notice_count").html(notice_count);
|
|
$("#new_homework_notice_count").parent().show();
|
|
$("html,body").scrollTop(0);
|
|
}
|
|
}
|
|
|
|
function SearchByName_1(url)
|
|
{
|
|
//alert($("#student_work_in_group").val());
|
|
$.get(
|
|
url,
|
|
{
|
|
name : $("#course_student_name").val(),
|
|
},
|
|
function (data) {
|
|
}
|
|
);
|
|
} |