1086 lines
46 KiB
JavaScript
1086 lines
46 KiB
JavaScript
$(function(){
|
|
$("#major_level_option p").live("click", function(){
|
|
$("#major_level").val($(this).attr("data-major"));
|
|
$.ajax({
|
|
url: '/syllabuses/get_discipline_categories',
|
|
type: 'get',
|
|
data: {major_level:$(this).attr("data-major")},
|
|
success: function(data){
|
|
if (data.result == 1){
|
|
$("#discipline_category_id").val(0);
|
|
$("#first_level_discipline_id").val(0);
|
|
$("#major_id").val(0);
|
|
$("#discipline_category_option").html("");
|
|
$("#discipline_category_option").prev().val("");
|
|
$("#first_level_discipline_option").html("");
|
|
$("#first_level_discipline_option").prev().val("");
|
|
$("#syllabus_major_option").html("");
|
|
$("#syllabus_major_option").prev().val("");
|
|
for(var i=0; i<data.options.length; i++){
|
|
$("#discipline_category_option").append("<p data-discipline-category-id='" + data.options[i][1] + "'>" + data.options[i][0] + "</p>");
|
|
}
|
|
$("#major_level_notice").hide();
|
|
}
|
|
else{
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
$("#discipline_category_option p").live("click", function(){
|
|
$(this).parents().prev("input").val($(this).html().trim());
|
|
$(this).parents(".down-select").hide();
|
|
$("#discipline_category_id").val($(this).attr("data-discipline-category-id"));
|
|
$.ajax({
|
|
url: '/syllabuses/get_first_level_disciplines',
|
|
type: 'get',
|
|
data: {discipline_category_id:$(this).attr("data-discipline-category-id")},
|
|
success: function(data){
|
|
if (data.result == 1){
|
|
$("#first_level_discipline_id").val(0);
|
|
$("#major_id").val(0);
|
|
$("#first_level_discipline_option").html("");
|
|
$("#first_level_discipline_option").prev().val("");
|
|
$("#syllabus_major_option").html("");
|
|
$("#syllabus_major_option").prev().val("");
|
|
for(var i=0; i<data.options.length; i++){
|
|
$("#first_level_discipline_option").append("<p data-first-level-discipline-id='" + data.options[i][1] + "'>" + data.options[i][0] + "</p>");
|
|
}
|
|
$("#discipline_category_id_notice").hide();
|
|
}
|
|
else{
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
$("#first_level_discipline_option p").live("click", function(){
|
|
$(this).parents().prev("input").val($(this).html().trim());
|
|
$(this).parents(".down-select").hide();
|
|
$("#first_level_discipline_id").val($(this).attr("data-first-level-discipline-id"));
|
|
$.ajax({
|
|
url: '/syllabuses/get_major',
|
|
type: 'get',
|
|
data: {first_level_discipline_id:$(this).attr("data-first-level-discipline-id")},
|
|
success: function(data){
|
|
if (data.result == 1){
|
|
$("#major_id").val(0);
|
|
$("#syllabus_major_option").html("");
|
|
$("#syllabus_major_option").prev().val("");
|
|
for(var i=0; i<data.options.length; i++){
|
|
$("#syllabus_major_option").append("<p data-major_id='" + data.options[i][1] + "'>" + data.options[i][0] + "</p>");
|
|
}
|
|
$("#first_level_discipline_id_notice").hide();
|
|
}
|
|
else{
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
$("#syllabus_major_option p").live("click", function(){
|
|
$(this).parents().prev("input").val($(this).html().trim());
|
|
$(this).parents(".down-select").hide();
|
|
$("#major_id").val($(this).attr("data-major_id"));
|
|
if ($("#major_id").val() != "0") {
|
|
$("#major_id_notice").hide();
|
|
}
|
|
});
|
|
|
|
$("#syllabus_type_option p").live("click", function(){
|
|
$("#syllabus_type").val($(this).attr("data-syllabus-type"));
|
|
})
|
|
|
|
$("#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() {
|
|
if($.trim($("input[name='homework_end_time']").val()) == ""){
|
|
var date = new Date(Date.parse($("input[name='homework_publish_time']").val().replace(/-/g, "/")));
|
|
$("input[name='homework_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='homework_end_time']").val()) == ""){
|
|
var date = new Date(Date.parse($("input[name='homework_publish_time']").val().replace(/-/g, "/")));
|
|
$("input[name='homework_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='homework_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))));
|
|
}
|
|
}
|
|
});
|
|
|
|
$("input[name='homework_archive_time']").datetimepicker({
|
|
allowBlank:true,
|
|
lang:'ch',
|
|
format:'Y-m-d H:i',
|
|
validateOnBlur:false
|
|
});
|
|
|
|
$("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
|
|
});
|
|
|
|
// $("#reset_publish_time").live('click', function(){
|
|
// $("input[name='homework_publish_time']").val("");
|
|
// $("#reset_publish_time").hide();
|
|
// });
|
|
|
|
// $("#reset_end_time").live('click', function(){
|
|
// $("input[name='homework_end_time']").val("");
|
|
// $("#reset_end_time").hide();
|
|
// });
|
|
|
|
$("input[name='homework_anonymous_comment']").live('click', function(){
|
|
$("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
|
|
});
|
|
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($("input[name='homework_end_time']").val().replace(/-/g, "/")));
|
|
var max_date = my_date > end_date ? my_date : end_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");
|
|
$("select[name='st_proportion']").removeAttr('disabled').removeClass('disabled-bg');
|
|
} 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();
|
|
$("select[name='st_proportion']").attr('disabled', 'disabled').addClass('disabled-bg').val(0.0);
|
|
}
|
|
});
|
|
|
|
$("input[name='homework_anonymous_appeal']").live('click', function(){
|
|
$("input[name='homework_appeal_time']").datetimepicker({
|
|
allowBlank:true,
|
|
lang:'ch',
|
|
format:'Y-m-d H:i',
|
|
validateOnBlur:false
|
|
});
|
|
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");
|
|
}
|
|
});
|
|
|
|
$("#homework_setting_form_submit").live('click', function(){
|
|
var myDate = new Date();
|
|
var result = true;
|
|
if($("input[name='homework_publish_time']").prop("disabled")==false && $.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($("input[name='homework_end_time']").prop("disabled")==false && $.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{
|
|
$("#homework_archive_time_notice").hide();
|
|
}
|
|
}
|
|
|
|
if($("input[name='homework_allow_late']:checked").val() == '1'){
|
|
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($("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($("input[name='homework_end_time']").val());
|
|
var archive_time = Date.parse($("input[name='homework_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(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($("input[name='homework_evaluation_num']").prop("disabled")==false && $.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 if($("input[name='homework_evaluation_num']").prop("disabled")==false){
|
|
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($("input[name='homework_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($("input[name='homework_final_mode']:checked").val() == '0'){
|
|
var te_pro = (parseFloat($("select[name='te_proportion']").val()))*100;
|
|
var ta_pro = (parseFloat($("select[name='ta_proportion']").val()))*100;
|
|
var st_pro = (parseFloat($("select[name='st_proportion']").val()))*100;
|
|
if($("select[name='sy_proportion']").length == 1){
|
|
var sy_pro = (parseFloat($("select[name='sy_proportion']").val()))*100;
|
|
} else{
|
|
var sy_pro = 0;
|
|
}
|
|
if(parseInt(te_pro + ta_pro + st_pro + sy_pro) != 100){
|
|
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){
|
|
$("#homework_setting_form").submit();
|
|
}
|
|
});
|
|
|
|
$("#edit_allow_late_1").live('click', function(){
|
|
$("#edit_late_notice").html("允许补交,则在结束日期之前,学生可以补交作品 <br/>是在提交截止时间之后才提交作品的学生,将被扣迟交分");
|
|
$("input[name='homework_late_penalty']").val("5");
|
|
});
|
|
|
|
$("#edit_allow_late_0").live('click', function(){
|
|
$("#edit_late_notice").html("禁止补交,则在提交截止时间之后,学生不能再提交作品");
|
|
$("input[name='homework_late_penalty']").val("0");
|
|
});
|
|
|
|
$("#homework_final_mode_1").live('click', function(){
|
|
$("select.normal-bg").removeAttr("disabled");
|
|
$("select.normal-bg").removeClass("disabled-bg");
|
|
});
|
|
|
|
$("#homework_final_mode_0").live('click', function(){
|
|
$("select.normal-bg").attr("disabled", "disabled");
|
|
$("select.normal-bg").addClass("disabled-bg");
|
|
});
|
|
|
|
$(".group_member_li").live("dblclick",function(e){
|
|
var doc = $(e.target).parents('.group_member_li');
|
|
var id = doc.attr("data-id");
|
|
if($("#group_member_choose_li_"+id).length > 0){
|
|
$("#group_member_num_notice").html("该成员已添加").show();
|
|
} else{
|
|
$("#group_member_num_notice").hide();
|
|
$("#group_member_notice_span").html("双击添加成员");
|
|
$("#group_member_choose_list").append("<tr class='choose_group_member_li' id='group_member_choose_li_"+id+"'></tr>");
|
|
$("#group_member_choose_li_"+id).html(doc.html());
|
|
$("#group_member_choose_li_"+id).append('<input type="hidden" name="user_id[]" value="'+id+'">');
|
|
}
|
|
});
|
|
|
|
$(".choose_group_member_li").live("dblclick",function(e){
|
|
$(e.target).parents('.choose_group_member_li').remove();
|
|
});
|
|
|
|
$(".edu-ces-top").live("click", function(){
|
|
$(this).next().toggle();
|
|
$(this).find("i:first-child").toggleClass("fa-caret-right");
|
|
$(this).find("i:first-child").toggleClass("fa-caret-down");
|
|
});
|
|
|
|
$("#search_group_member_input").keydown(function(event){
|
|
var target, code, tag;
|
|
if (!event) {
|
|
event = window.event; //针对ie浏览器
|
|
code = event.keyCode;
|
|
}
|
|
else {
|
|
code = event.keyCode;
|
|
}
|
|
if(code == 13) {
|
|
search_group_member_submit();
|
|
return false;
|
|
}
|
|
});
|
|
});
|
|
|
|
function search_group_member_submit(){
|
|
$.get('/student_work/search_course_students?homework='+$("#homework_id").val()+'&name=' + $("#search_group_member_input").val().trim());
|
|
}
|
|
|
|
function submit_new_student_work(type){
|
|
//.console.log($("#_file").attr("name"));
|
|
var result = true;
|
|
if(student_work_description_editor.isEmpty()){
|
|
result = false;
|
|
$("#student_work_description_notice").show();
|
|
} else{
|
|
$("#student_work_description_notice").hide();
|
|
}
|
|
if($("textarea[name='late_reason']").length > 0 && $("textarea[name='late_reason']").val().trim() == ""){
|
|
result = false;
|
|
$("#student_work_reason_notice").show();
|
|
} else{
|
|
$("#student_work_reason_notice").hide();
|
|
}
|
|
if(type == 3){
|
|
var min_num = parseInt($("#min_num_member").html());
|
|
var max_num = parseInt($("#max_num_member").html());
|
|
if( max_num < $("input[name='user_id[]']").length || $("input[name='user_id[]']").length < min_num){
|
|
result = false;
|
|
notice_box("成员人数不符合要求");
|
|
}
|
|
}
|
|
// if(lebel_file_uploding!==0){
|
|
// result = false;
|
|
// notice_box("有文件正在上传请洒红后提交");
|
|
// }
|
|
if(result){
|
|
student_work_description_editor.sync();
|
|
$("#student_work_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($("#major_id").val() == "0"){
|
|
$("#major_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_name").val($.trim($("#new_syllabus_name").val()));
|
|
$("#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($("#major_id").val() == "0"){
|
|
$("#major_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{
|
|
$("#new_syllabus_name").val($.trim($("#new_syllabus_name").val()));
|
|
$("#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, edit_mode){
|
|
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(edit_mode){
|
|
var data_min = parseInt($("#min_max_num_notice").attr("data-min-num"));
|
|
var data_max = parseInt($("#min_max_num_notice").attr("data-max-num"));
|
|
if(parseInt(min) > data_min || parseInt(max) < data_max){
|
|
$("#min_max_num_notice").show();
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
if(notice_count == 0){
|
|
homework_description_editor.sync();
|
|
homework_ref_answer_editor.sync();
|
|
$("#homework_common_submit_form").submit();
|
|
} else{
|
|
$("#new_homework_notice_count").html(notice_count);
|
|
$("#new_homework_notice_count").parent().show();
|
|
$("html,body").scrollTop(0);
|
|
}
|
|
}
|
|
|
|
function show_edit_setting(){
|
|
$('#edit_publish_setting').show();
|
|
$('#show_publish_setting').hide();
|
|
$('#edit_late_setting').show();
|
|
$('#show_late_setting').hide();
|
|
$('#edit_anon_setting').show();
|
|
$('#show_anon_setting').hide();
|
|
$('#edit_score_setting').show();
|
|
$('#show_score_setting').hide();
|
|
$('#edit_public_setting').show();
|
|
$('#show_public_setting').hide();
|
|
$('#homework_setting_submit_block').show();
|
|
}
|
|
|
|
function setting_cancel_edit(fn){
|
|
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">修改的内容将全部丢失<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="'+ fn +'();">确定</a></div></div>';
|
|
pop_box_new(htmlvalue, 480, 140);
|
|
}
|
|
|
|
$(function(){
|
|
$("#comment_no_limit").live('click', function(){
|
|
if(!$(this).hasClass("link-color-blue")){
|
|
$(this).addClass("link-color-blue");
|
|
$("input[name='comment[]']").attr("checked", false);
|
|
$.ajax({
|
|
url: '/student_work?homework='+$("#homework_id").val(),
|
|
type: 'get',
|
|
data: $("#student_work_search_form").serialize(),
|
|
remote: true,
|
|
success: function(data){
|
|
}
|
|
});
|
|
}
|
|
});
|
|
$("input[name='comment[]']").live('click', function(){
|
|
if($("input[name='comment[]']:checked").length == 2 || $("input[name='comment[]']:checked").length == 0){
|
|
$("input[name='comment[]']:checked").attr("checked", false);
|
|
$("#comment_no_limit").addClass("link-color-blue");
|
|
} else{
|
|
$("#comment_no_limit").removeClass("link-color-blue");
|
|
}
|
|
$.ajax({
|
|
url: '/student_work?homework='+$("#homework_id").val(),
|
|
type: 'get',
|
|
data: $("#student_work_search_form").serialize(),
|
|
remote: true,
|
|
success: function(data){
|
|
}
|
|
});
|
|
});
|
|
$("#status_no_limit").live('click', function(){
|
|
if(!$(this).hasClass("link-color-blue")){
|
|
$(this).addClass("link-color-blue");
|
|
$("input[name='status[]']").attr("checked", false);
|
|
$.ajax({
|
|
url: '/student_work?homework='+$("#homework_id").val(),
|
|
type: 'get',
|
|
data: $("#student_work_search_form").serialize(),
|
|
remote: true,
|
|
success: function(data){
|
|
}
|
|
});
|
|
}
|
|
});
|
|
$("input[name='status[]']").live('click', function(){
|
|
if($("input[name='status[]']:checked").length == 3 || $("input[name='status[]']:checked").length == 0){
|
|
$("input[name='status[]']:checked").attr("checked", false);
|
|
$("#status_no_limit").addClass("link-color-blue");
|
|
} else{
|
|
$("#status_no_limit").removeClass("link-color-blue");
|
|
}
|
|
$.ajax({
|
|
url: '/student_work?homework='+$("#homework_id").val(),
|
|
type: 'get',
|
|
data: $("#student_work_search_form").serialize(),
|
|
remote: true,
|
|
success: function(data){
|
|
}
|
|
});
|
|
});
|
|
$("#group_no_limit").live('click', function(){
|
|
if(!$(this).hasClass("link-color-blue")){
|
|
$(this).addClass("link-color-blue");
|
|
$("input[name='group[]']").attr("checked", false);
|
|
$.ajax({
|
|
url: '/student_work?homework='+$("#homework_id").val(),
|
|
type: 'get',
|
|
data: $("#student_work_search_form").serialize(),
|
|
remote: true,
|
|
success: function(data){
|
|
}
|
|
});
|
|
}
|
|
});
|
|
$("input[name='group[]']").live('click', function(){
|
|
if($("input[name='group[]']:checked").length == $("input[name='group[]']").length || $("input[name='group[]']:checked").length == 0){
|
|
$("input[name='group[]']:checked").attr("checked", false);
|
|
$("#group_no_limit").addClass("link-color-blue");
|
|
} else{
|
|
$("#group_no_limit").removeClass("link-color-blue");
|
|
}
|
|
$.ajax({
|
|
url: '/student_work?homework='+$("#homework_id").val(),
|
|
type: 'get',
|
|
data: $("#student_work_search_form").serialize(),
|
|
remote: true,
|
|
success: function(data){
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
function SearchByName_1()
|
|
{
|
|
$.ajax({
|
|
url: '/student_work?homework='+$("#homework_id").val()+'&name='+$("#course_student_name").val(),
|
|
type: 'get',
|
|
data: $("#student_work_search_form").serialize(),
|
|
remote: true,
|
|
success: function(data){
|
|
}
|
|
});
|
|
}
|
|
|
|
function choose_course(user_id, hw_id) {
|
|
$.ajax({
|
|
type: 'get',
|
|
url: '/users/' + user_id + '/choose_user_course?homework='+hw_id
|
|
});
|
|
}
|
|
function submit_homework_bank_search(url){
|
|
$.get(url, {search: $("#homework_bank_search").val()}, function(data){})
|
|
}
|
|
function alert_choose_homework_bank_type(){
|
|
var htmlvalue = '<div class="task-popup" style="width:300px;">' +
|
|
'<div class="task-popup-title clearfix task-popup-bggrey">' +
|
|
'<h3 class="fl">选择类别</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_con">' +
|
|
'<div class="newupload_conbox">' +
|
|
'<div class="clearfix mb15 ml35">' +
|
|
'<span class="fl mt5">类别:</span>' +
|
|
'<ul class="fl ml20">' +
|
|
'<li class="clearfix">' +
|
|
'<input type="radio" name="homework_type" value="1" id="homework_type_1" class="fl magic-radio">' +
|
|
'<label for="homework_type_1" class="fl ml5 edu-class-pop-label edu-color-grey">' +
|
|
'普通' +
|
|
'</label>' +
|
|
'</li>' +
|
|
'<li class="clearfix">' +
|
|
'<input type="radio" name="homework_type" value="4" id="homework_type_4" class="fl magic-radio edu-color-grey">' +
|
|
'<label for="homework_type_4" class="fl ml5 edu-class-pop-label">' +
|
|
'实训' +
|
|
'</label>' +
|
|
'</li>' +
|
|
'</ul>' +
|
|
'</div>' +
|
|
'<div class="cl"></div>' +
|
|
'<div id="homework_type_notice" class="clearfix color-red none mt-10 ml75">请先选择作业类型</div>' +
|
|
'<div class="task-popup-submit clearfix">' +
|
|
'<a href="javascript:void(0);" class="task-btn fl pop_close">取消</a>' +
|
|
'<a href="javascript:void(0);" onclick="new_homework_bank_type();" class="task-btn task-btn-blue fr">确定</a>' +
|
|
'</div>' +
|
|
'</div>' +
|
|
'</div>' +
|
|
'</div>';
|
|
pop_box_new(htmlvalue, 300, 308);
|
|
}
|
|
function new_homework_bank_type(){
|
|
if($("input[name='homework_type']:checked").length == 0){
|
|
$("#homework_type_notice").show();
|
|
} else{
|
|
var type=$("input[name='homework_type']:checked").val();
|
|
console.log(type == 4);
|
|
if(type == 4){
|
|
$.ajax({
|
|
url: '/homework_bank/shixuns',
|
|
remote: true
|
|
});
|
|
}else{
|
|
window.location.href = '/homework_bank/new?homework_type=' + $("input[name='homework_type']:checked").val();
|
|
}
|
|
}
|
|
}
|
|
|
|
function new_shixun_homework_bank(){
|
|
if($("input[name='shixun_homework']:checked").length == 0){
|
|
$("#homework_type_notice").show();
|
|
} else{
|
|
var type=$("input[name='shixun_homework']:checked").val();
|
|
console.log(type);
|
|
$("#shixun_homework_bank_new").submit();
|
|
}
|
|
}
|
|
|
|
$(function(){
|
|
$("input[name='check_homework_bank[]']").live('click', function(){
|
|
if($("input[name='check_homework_bank[]']:checked").length == $("input[name='check_homework_bank[]']").length){
|
|
$("#homework_bank_all_select").attr("checked", "checked");
|
|
} else{
|
|
$("#homework_bank_all_select").attr("checked", false);
|
|
}
|
|
});
|
|
$("#homework_bank_all_select").live('click', function(){
|
|
if($("#homework_bank_all_select").is(':checked')){
|
|
$("input[name='check_homework_bank[]']").attr("checked", "checked");
|
|
} else{
|
|
$("input[name='check_homework_bank[]']").attr("checked", false);
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
function choose_course_to_send_hb(){
|
|
if($("input[name='check_homework_bank[]']:checked").length >= 1){
|
|
$("#choose_homework_bank_to_send_notice_h").html("").hide();
|
|
$("#hb_search_course_h_form").submit();
|
|
}else{
|
|
$("#choose_homework_bank_to_send_notice_h").html("请先选择题目").show();
|
|
}
|
|
}
|
|
|
|
function search_hw_course(url){
|
|
$.ajax({
|
|
url: url,
|
|
type: 'post',
|
|
data: {search: $("#hb_search_course_input").val(), is_observe: true},
|
|
success: function(data){
|
|
}
|
|
});
|
|
}
|
|
|
|
function submit_send_hb_to_course(){
|
|
if($("input[name='course_id']:checked").length >= 1){
|
|
$("#search_course_notice_h").html("").hide();
|
|
$("#send_hb_to_course_form").submit();
|
|
hideModal();
|
|
}else{
|
|
$("#search_course_notice_h").html("请先选择一个班级").show();
|
|
}
|
|
}
|
|
|
|
function destroy_all_hb(url){
|
|
if($("input[name='check_homework_bank[]']:checked").length >= 1){
|
|
$("#choose_homework_bank_to_send_notice_h").html("").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" id="destroy_all_hb_btn">确定</a></div></div>';
|
|
pop_box_new(htmlvalue,480,140);
|
|
$("#destroy_all_hb_btn").on('click',function(){
|
|
$.ajax({
|
|
url: url,
|
|
type: 'post',
|
|
data: $("#hb_search_course_h_form").serialize(),
|
|
success: function(data){
|
|
}
|
|
});
|
|
hideModal();
|
|
});
|
|
}else{
|
|
$("#choose_homework_bank_to_send_notice_h").html("请先选择题目").show();
|
|
}
|
|
}
|
|
|
|
function submit_new_subject(){
|
|
var check = true;
|
|
if($("#new_subject_name").val().trim() == ""){
|
|
check = false;
|
|
$("#new_subject_name_notice").show();
|
|
} else{
|
|
$("#new_subject_name_notice").hide();
|
|
}
|
|
if($("#new_subject_description").val().trim() == ""){
|
|
check = false;
|
|
$("#new_subject_description_notice").show();
|
|
} else{
|
|
$("#new_subject_description_notice").hide();
|
|
}
|
|
if($("#new_learning_notes").val().trim() == ""){
|
|
check = false;
|
|
$("#new_learning_notes_notice").show();
|
|
} else {
|
|
$("#new_learning_notes_notice").hide();
|
|
}
|
|
if(check){
|
|
$("#new_subject").submit();
|
|
}
|
|
}
|
|
|
|
function submit_edit_subject(id){
|
|
var check = true;
|
|
if($("#new_subject_name").val().trim() == ""){
|
|
check = false;
|
|
$("#new_subject_name_notice").show();
|
|
} else{
|
|
$("#new_subject_name_notice").hide();
|
|
}
|
|
if($("#new_subject_description").val().trim() == ""){
|
|
check = false;
|
|
$("#new_subject_description_notice").show();
|
|
} else{
|
|
$("#new_subject_description_notice").hide();
|
|
}
|
|
if($("#new_learning_notes").val().trim() == ""){
|
|
check = false;
|
|
$("#new_learning_notes_notice").show();
|
|
} else {
|
|
$("#new_learning_notes_notice").hide();
|
|
}
|
|
if(check){
|
|
$("#edit_subject_"+id).submit();
|
|
}
|
|
} |