From 7a62b7f13d28f175ba05f9aeb5a9bc4b1e3d764d Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 21 Sep 2015 17:11:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8C=BF=E8=AF=84=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E6=97=B6=E9=97=B4=E5=92=8C=E5=8C=BF=E8=AF=84=E5=85=B3?= =?UTF-8?q?=E9=97=AD=E6=97=B6=E9=97=B4=EF=BC=8C=E5=B9=B6=E5=AF=B9=E5=85=B6?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E9=80=BB=E8=BE=91=E8=BF=9B=E8=A1=8Cjs?= =?UTF-8?q?=E7=9A=84=E6=8E=A7=E5=88=B6=E3=80=82=E4=BB=A5=E5=8F=8A=E8=BF=99?= =?UTF-8?q?=E4=B8=A4=E4=B8=AA=E5=80=BC=E5=BE=97=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 4 ++ app/controllers/users_controller.rb | 4 +- app/views/student_work/new.html.erb | 2 +- app/views/users/_user_homework_form.html.erb | 8 +++ app/views/users/user_homeworks.html.erb | 1 + db/schema.rb | 33 ++++++------ public/javascripts/new_user.js | 54 ++++++++++++++++--- 7 files changed, 80 insertions(+), 26 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 9d5768948..41d302829 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -150,6 +150,10 @@ class HomeworkCommonController < ApplicationController @homework.end_time = params[:homework_common][:end_time] || Time.now @homework.course_id = params[:course_id] + homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new + homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? @homework.end_time + 7 : params[:evaluation_start] + homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end] + @homework.save_attachments(params[:attachments]) render_attachment_warning_if_needed(@homework) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0783d1805..76643a099 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -468,8 +468,8 @@ class UsersController < ApplicationController homework_detail_manual = HomeworkDetailManual.new homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3 homework_detail_manual.comment_status = 1 - homework_detail_manual.evaluation_start = Time.now - homework_detail_manual.evaluation_end = Time.now + homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? homework.end_time + 7 : params[:evaluation_start] + homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end] homework_detail_manual.evaluation_num = params[:evaluation_num] || 3 homework_detail_manual.absence_penalty = 5 homework.homework_detail_manual = homework_detail_manual diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index f9b242443..c7f1d45c4 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -7,7 +7,7 @@ $('#ajax-modal').siblings().remove(); $('#ajax-modal').before("" + ""); - $('#ajax-modal').parent().css("top","30%").css("left","40%"); + $('#ajax-modal').parent().css("top","65%").css("left","60%"); $('#ajax-modal').parent().addClass("anonymos_work"); }); <% end%> diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 6e07e7122..b19125ec6 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -21,6 +21,14 @@ <%= calendar_for('homework_end_time')%> +
+ + <%= calendar_for('evaluation_start_time')%> +
+
+ + <%= calendar_for('evaluation_end_time')%> +

diff --git a/app/views/users/user_homeworks.html.erb b/app/views/users/user_homeworks.html.erb index f375496d1..a169be166 100644 --- a/app/views/users/user_homeworks.html.erb +++ b/app/views/users/user_homeworks.html.erb @@ -21,6 +21,7 @@
<% homework = HomeworkCommon.new %> + <% homework.homework_detail_manual = HomeworkDetailManual.new%> <%= labelled_form_for homework,:url => user_new_homework_users_path,:method => "post" do |f| %>
<%= render :partial => 'users/user_homework_form', :locals => { :homework => homework,:f => f,:edit_mode => false } %> diff --git a/db/schema.rb b/db/schema.rb index 1c6760345..1f40c93b4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -497,23 +497,26 @@ ActiveRecord::Schema.define(:version => 20150918134804) do add_index "documents", ["created_on"], :name => "index_documents_on_created_on" add_index "documents", ["project_id"], :name => "documents_project_id" - create_table "dts", :force => true do |t| - t.string "IPLineCode" - t.string "Description" - t.string "Num" - t.string "Variable" - t.string "TraceInfo" - t.string "Method" + create_table "dts", :primary_key => "Num", :force => true do |t| + t.string "Defect", :limit => 50 + t.string "Category", :limit => 50 t.string "File" - t.string "IPLine" - t.string "Review" - t.string "Category" - t.string "Defect" - t.string "PreConditions" - t.string "StartLine" + t.string "Method" + t.string "Module", :limit => 20 + t.string "Variable", :limit => 50 + t.integer "StartLine" + t.integer "IPLine" + t.string "IPLineCode", :limit => 200 + t.string "Judge", :limit => 15 + t.integer "Review", :limit => 1 + t.string "Description" + t.text "PreConditions", :limit => 2147483647 + t.text "TraceInfo", :limit => 2147483647 + t.text "Code", :limit => 2147483647 t.integer "project_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" + t.integer "id", :null => false end create_table "enabled_modules", :force => true do |t| diff --git a/public/javascripts/new_user.js b/public/javascripts/new_user.js index e5f5e8b4c..95d85e48c 100644 --- a/public/javascripts/new_user.js +++ b/public/javascripts/new_user.js @@ -56,18 +56,20 @@ function show_more_project(url){ } //老师提交 新建/修改 作业 -function submit_homework(id) -{ - if(!regex_homework_name()) - { +function submit_homework(id){ + if(!regex_homework_name()){ $("#homework_name").focus(); } - else if(!regex_homework_end_time()) - { + else if(!regex_homework_end_time()){ $("#homework_end_time").focus(); } - else if(!regex_course_id()) - { + else if(!regex_evaluation_start()){ + $("#evaluation_start_time").focus() + } + else if(!regex_evaluation_end()){ + $("#evaluation_end_time").focus() + } + else if(!regex_course_id()){ $("#course_id").focus(); } else{ @@ -134,6 +136,42 @@ function search_homework_by_name(url){ ); } +//验证匿评开启时间:大于截止时间,或者为空 +function regex_evaluation_start(){ + var evaluation_start = $.trim($("#evaluation_start_time").val()); + if(evaluation_start == ""){ + return true; + } + var end_time = new Date($.trim($("#homework_end_time").val())); + var evaluation_start_time = new Date(evaluation_start); + if(evaluation_start_time > end_time){ + return true; + }else{ + $("#homework_end_time_span").text("开启匿评日期必须大于截止日期"); + return false; + } +} + +//验证匿评结束时间:大于匿评开启时间,或者为空。当匿评开启时间为空时,匿评结束时间必须为空 +function regex_evaluation_end(){ + var evaluation_start = $.trim($("#evaluation_start_time").val()); + var evaluation_end = $.trim($("#evaluation_end_time").val()); + if(evaluation_end == ""){ + return true; + }else if(evaluation_start == ""){ + $("#homework_end_time_span").text("开启匿评日期为空时,关闭匿评日期必须为空"); + return false; + } + var evaluation_start_time = new Date(evaluation_start); + var evaluation_end_time = new Date(evaluation_end); + if(evaluation_end_time > evaluation_start_time){ + return true; + }else{ + $("#homework_end_time_span").text("关闭匿评日期必须大于开启匿评日期"); + return false; + } +} + //提交新建作品 function new_student_work() {