From 7de40ac88b89449b19a059a5910239396ed31c8d Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 8 Mar 2017 09:54:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8F=8D=E9=A6=88=EF=BC=88?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E7=BE=A4=EF=BC=89-=E8=AF=84=E5=88=86?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E8=A2=AB=E4=BF=AE=E6=94=B9=E7=9A=84=E6=8F=90?= =?UTF-8?q?=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 4 + app/helpers/application_helper.rb | 3 +- app/helpers/student_work_helper.rb | 20 +- app/models/student_work.rb | 2 +- .../_contest_evaluation_group_work.html.erb | 2 +- ..._contest_evaluation_un_group_work.html.erb | 2 +- .../_evaluation_un_group_work.html.erb | 2 +- .../student_work/_evaluation_un_work.html.erb | 2 +- .../student_work/_evaluation_work.html.erb | 2 +- ...07082304_add_re_commit_to_student_works.rb | 5 + db/schema.rb | 176 ++++++++++++++---- 11 files changed, 168 insertions(+), 52 deletions(-) create mode 100644 db/migrate/20170307082304_add_re_commit_to_student_works.rb diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index cd433a450..d54774333 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -954,6 +954,9 @@ class StudentWorkController < ApplicationController render_attachment_warning_if_needed(@new_score) if @new_score.save + if @work.re_commit && @new_score.reviewer_role != 3 + @work.re_commit = 0 + end if @homework.homework_type == 3 @is_group_leader = !@work.student_work_projects.empty? end @@ -1351,6 +1354,7 @@ class StudentWorkController < ApplicationController student_work = StudentWork.find attachment.container_id CourseMessage.create(:user_id => student_work.homework_common.user_id, :course_id => student_work.homework_common.course_id, :viewed => false,:course_message_id=>attachment.container_id,:course_message_type=>'StudentWork',:status=>2) end + @work.update_attributes(:re_commit => 1) respond_to do |format| format.js end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0ddca7032..05565a9f2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2566,7 +2566,8 @@ module ApplicationHelper #如果学生作品被打分后修改,应该给老师提示 def send_message_to_teacher student_work if StudentWork === student_work - if student_work.student_works_scores.any? + if student_work.student_works_scores.where("reviewer_role != 3").any? + student_work.update_column('re_commit', 1) course = student_work.homework_common.course course.members.map(&:user_id).uniq.each do|user_id| if User.find(user_id).allowed_to?(:as_teacher, course) diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index afe16497b..89a9455f5 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -56,15 +56,19 @@ module StudentWorkHelper result end - def get_status status + def get_status status, re_commit str = "" - case status - when 0 - str = "未提交" - when 1 - str = "已提交" - when 2 - str = "迟交" + if re_commit + str = "重新提交" + else + case status + when 0 + str = "未提交" + when 1 + str = "已提交" + when 2 + str = "迟交" + end end str end diff --git a/app/models/student_work.rb b/app/models/student_work.rb index ffc369af0..9ea0e75eb 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -1,6 +1,6 @@ #学生提交作品表 #work_status :0 未提交 1 已提交 2 迟交 3 分组作品复制的组员作品 class StudentWork < ActiveRecord::Base - attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :system_score, :work_score, :project_id, :is_test, :simi_id, :simi_value, :work_status, :commit_time, :late_penalty, :absence_penalty + attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :system_score, :work_score, :project_id, :is_test, :simi_id, :simi_value, :work_status, :commit_time, :late_penalty, :absence_penalty, :re_commit belongs_to :homework_common belongs_to :user diff --git a/app/views/contestant_works/_contest_evaluation_group_work.html.erb b/app/views/contestant_works/_contest_evaluation_group_work.html.erb index dcbfa06ac..366b4ff92 100644 --- a/app/views/contestant_works/_contest_evaluation_group_work.html.erb +++ b/app/views/contestant_works/_contest_evaluation_group_work.html.erb @@ -4,7 +4,7 @@ <% if student_work.work_status %> - <%= get_status student_work.work_status %> + <%= get_status student_work.work_status, student_work.re_commit %> <% end %> diff --git a/app/views/contestant_works/_contest_evaluation_un_group_work.html.erb b/app/views/contestant_works/_contest_evaluation_un_group_work.html.erb index 9a89110b3..caacd0e3f 100644 --- a/app/views/contestant_works/_contest_evaluation_un_group_work.html.erb +++ b/app/views/contestant_works/_contest_evaluation_un_group_work.html.erb @@ -4,7 +4,7 @@ <% if student_work.work_status %> - <%= get_status student_work.work_status %> + <%= get_status student_work.work_status, student_work.re_commit %> <% end %> diff --git a/app/views/student_work/_evaluation_un_group_work.html.erb b/app/views/student_work/_evaluation_un_group_work.html.erb index 78c026bad..57c201620 100644 --- a/app/views/student_work/_evaluation_un_group_work.html.erb +++ b/app/views/student_work/_evaluation_un_group_work.html.erb @@ -5,7 +5,7 @@ <% if student_work.work_status %> - <%= get_status student_work.work_status %> + <%= get_status student_work.work_status, student_work.re_commit %> <% end %> diff --git a/app/views/student_work/_evaluation_un_work.html.erb b/app/views/student_work/_evaluation_un_work.html.erb index 04e48bf7d..18c42ba68 100644 --- a/app/views/student_work/_evaluation_un_work.html.erb +++ b/app/views/student_work/_evaluation_un_work.html.erb @@ -48,7 +48,7 @@ <% end %> <% if student_work.work_status%> - <%=get_status student_work.work_status %> + <%= get_status student_work.work_status, student_work.re_commit %> <% end %> diff --git a/app/views/student_work/_evaluation_work.html.erb b/app/views/student_work/_evaluation_work.html.erb index 9d7d4dbb7..0432b83d1 100644 --- a/app/views/student_work/_evaluation_work.html.erb +++ b/app/views/student_work/_evaluation_work.html.erb @@ -72,7 +72,7 @@ <% end%> <% if student_work.work_status%> - <%=get_status student_work.work_status %> + <%= get_status student_work.work_status, student_work.re_commit %> <% end %> diff --git a/db/migrate/20170307082304_add_re_commit_to_student_works.rb b/db/migrate/20170307082304_add_re_commit_to_student_works.rb new file mode 100644 index 000000000..2e189fff5 --- /dev/null +++ b/db/migrate/20170307082304_add_re_commit_to_student_works.rb @@ -0,0 +1,5 @@ +class AddReCommitToStudentWorks < ActiveRecord::Migration + def change + add_column :student_works, :re_commit, :boolean, :default => false + end +end diff --git a/db/schema.rb b/db/schema.rb index 9e58e8485..bdbcd0a5e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20170210082105) do +ActiveRecord::Schema.define(:version => 20170307082304) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -350,14 +350,16 @@ ActiveRecord::Schema.define(:version => 20170210082105) do add_index "changeset_parents", ["parent_id"], :name => "changeset_parents_parent_ids" create_table "changesets", :force => true do |t| - t.integer "repository_id", :null => false - t.string "revision", :null => false + t.integer "repository_id", :null => false + t.string "revision", :null => false t.string "committer" - t.datetime "committed_on", :null => false + t.datetime "committed_on", :null => false t.text "comments" t.date "commit_date" t.string "scmid" t.integer "user_id" + t.integer "project_id" + t.integer "type", :default => 0 end add_index "changesets", ["committed_on"], :name => "index_changesets_on_committed_on" @@ -519,6 +521,13 @@ ActiveRecord::Schema.define(:version => 20170210082105) do add_index "contest_messages", ["contest_id"], :name => "index_contest_messages_on_contest_id" add_index "contest_messages", ["user_id"], :name => "index_contest_messages_on_user_id" + create_table "contest_notifications", :force => true do |t| + t.text "title" + t.text "content" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "contestant_for_contests", :force => true do |t| t.integer "student_id" t.integer "contest_id" @@ -586,6 +595,37 @@ ActiveRecord::Schema.define(:version => 20170210082105) do add_index "contestant_works", ["user_id"], :name => "index_contestant_works_on_user_id" add_index "contestant_works", ["work_id"], :name => "index_contestant_works_on_work_id" + create_table "contesting_projects", :force => true do |t| + t.integer "project_id" + t.string "contest_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "contesting_softapplications", :force => true do |t| + t.integer "softapplication_id" + t.integer "contest_id" + t.integer "user_id" + t.string "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.string "reward" + end + + create_table "contestnotifications", :force => true do |t| + t.integer "contest_id" + t.string "title" + t.string "summary" + t.text "description" + t.integer "author_id" + t.integer "notificationcomments_count" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "contests", :force => true do |t| t.integer "user_id" t.string "name" @@ -628,20 +668,6 @@ ActiveRecord::Schema.define(:version => 20170210082105) do t.integer "container_id", :default => 0 end - create_table "course_class_post", :id => false, :force => true do |t| - t.integer "班级id", :default => 0, :null => false - t.string "班级名" - t.integer "帖子id", :default => 0, :null => false - t.integer "主贴id" - t.string "帖子标题", :default => "", :null => false - t.text "帖子内容" - t.integer "帖子用户id" - t.integer "帖子回复数", :default => 0, :null => false - t.integer "最后回帖id" - t.datetime "发帖时间", :null => false - t.datetime "帖子更新时间", :null => false - end - create_table "course_contributor_scores", :force => true do |t| t.integer "course_id" t.integer "user_id" @@ -832,6 +858,21 @@ ActiveRecord::Schema.define(:version => 20170210082105) do add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" + create_table "delayed_jobs_20161218", :id => false, :force => true do |t| + t.integer "id", :default => 0, :null => false + t.integer "priority", :default => 0, :null => false + t.integer "attempts", :default => 0, :null => false + t.text "handler", :null => false + t.text "last_error" + t.datetime "run_at" + t.datetime "locked_at" + t.datetime "failed_at" + t.string "locked_by" + t.string "queue" + t.datetime "created_at" + t.datetime "updated_at" + end + create_table "discuss_demos", :force => true do |t| t.string "title" t.text "body" @@ -944,11 +985,13 @@ ActiveRecord::Schema.define(:version => 20170210082105) do t.integer "exercise_id" t.integer "score" t.datetime "start_at" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.datetime "end_at" t.integer "status" - t.integer "commit_status", :default => 0 + t.integer "commit_status", :default => 0 + t.integer "objective_score", :default => -1 + t.integer "subjective_score", :default => -1 end create_table "exercises", :force => true do |t| @@ -1064,17 +1107,44 @@ ActiveRecord::Schema.define(:version => 20170210082105) do add_index "homework_attaches", ["bid_id"], :name => "index_homework_attaches_on_bid_id" + create_table "homework_bank_tests", :force => true do |t| + t.text "input" + t.text "output" + t.boolean "test_type" + t.integer "homework_bank_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + create_table "homework_banks", :force => true do |t| + t.integer "user_id" + t.string "name" + t.text "description" + t.integer "homework_type" + t.integer "quotes", :default => 0 + t.boolean "is_public" + t.string "language" + t.text "standard_code", :limit => 2147483647 + t.integer "min_num" + t.integer "max_num" + t.boolean "base_on_project" + t.string "applicable_syllabus" + t.integer "homework_common_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "homework_commons", :force => true do |t| t.string "name" t.integer "user_id" t.text "description" - t.date "publish_time" - t.date "end_time" + t.datetime "publish_time" + t.datetime "end_time" t.integer "homework_type", :default => 1 t.string "late_penalty" t.integer "course_id" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "teacher_priority", :default => 1 t.integer "anonymous_comment", :default => 0 t.integer "quotes", :default => 0 @@ -1082,6 +1152,8 @@ ActiveRecord::Schema.define(:version => 20170210082105) do t.datetime "simi_time" t.integer "score_open", :default => 1 t.integer "anonymous_appeal", :default => 0 + t.integer "homework_bank_id" + t.boolean "is_update", :default => false end add_index "homework_commons", ["course_id", "id"], :name => "index_homework_commons_on_course_id_and_id" @@ -1137,6 +1209,16 @@ ActiveRecord::Schema.define(:version => 20170210082105) do add_index "homework_for_courses", ["bid_id"], :name => "index_homework_for_courses_on_bid_id" add_index "homework_for_courses", ["course_id"], :name => "index_homework_for_courses_on_course_id" + create_table "homework_samples", :force => true do |t| + t.text "input" + t.text "output" + t.integer "homework_common_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + + add_index "homework_samples", ["homework_common_id"], :name => "index_homework_samples_on_homework_common_id" + create_table "homework_tests", :force => true do |t| t.text "input" t.text "output" @@ -1154,6 +1236,10 @@ ActiveRecord::Schema.define(:version => 20170210082105) do t.datetime "updated_at", :null => false end + create_table "innodb_monitor", :id => false, :force => true do |t| + t.integer "a" + end + create_table "invite_lists", :force => true do |t| t.integer "project_id" t.integer "user_id" @@ -1735,35 +1821,37 @@ ActiveRecord::Schema.define(:version => 20170210082105) do end create_table "projects", :force => true do |t| - t.string "name", :default => "", :null => false + t.string "name", :default => "", :null => false t.text "description" - t.string "homepage", :default => "" - t.boolean "is_public", :default => true, :null => false + t.string "homepage", :default => "" + t.boolean "is_public", :default => true, :null => false t.integer "parent_id" t.datetime "created_on" t.datetime "updated_on" t.string "identifier" - t.integer "status", :default => 1, :null => false + t.integer "status", :default => 1, :null => false t.integer "lft" t.integer "rgt" - t.boolean "inherit_members", :default => false, :null => false + t.boolean "inherit_members", :default => false, :null => false t.integer "project_type" - t.boolean "hidden_repo", :default => false, :null => false - t.integer "attachmenttype", :default => 1 + t.boolean "hidden_repo", :default => false, :null => false + t.integer "attachmenttype", :default => 1 t.integer "user_id" - t.integer "dts_test", :default => 0 + t.integer "dts_test", :default => 0 t.string "enterprise_name" t.integer "organization_id" t.integer "project_new_type" t.integer "gpid" t.integer "forked_from_project_id" t.integer "forked_count" - t.integer "publish_resource", :default => 0 - t.integer "visits", :default => 0 - t.integer "hot", :default => 0 + t.integer "publish_resource", :default => 0 + t.integer "visits", :default => 0 + t.integer "hot", :default => 0 t.string "invite_code" t.string "qrcode" - t.integer "qrcode_expiretime", :default => 0 + t.integer "qrcode_expiretime", :default => 0 + t.text "script" + t.integer "training_status", :limit => 1, :default => 0 end add_index "projects", ["lft"], :name => "index_projects_on_lft" @@ -2064,6 +2152,7 @@ ActiveRecord::Schema.define(:version => 20170210082105) do t.datetime "commit_time" t.integer "is_delete", :default => 0 t.integer "appeal_penalty", :default => 0 + t.boolean "re_commit", :default => false end add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" @@ -2249,6 +2338,19 @@ ActiveRecord::Schema.define(:version => 20170210082105) do t.integer "fields_bits", :default => 0 end + create_table "training_tasks", :force => true do |t| + t.integer "project_id" + t.integer "tracker_id" + t.string "subject" + t.text "description" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "author_id" + t.integer "status", :limit => 1, :default => 0 + t.integer "position", :limit => 1, :default => 0 + t.integer "result", :default => 0 + end + create_table "user_actions", :force => true do |t| t.integer "user_id" t.string "action_type"