diff --git a/app/controllers/student_works_controller.rb b/app/controllers/student_works_controller.rb index b4677f4e3..f6872e533 100644 --- a/app/controllers/student_works_controller.rb +++ b/app/controllers/student_works_controller.rb @@ -92,6 +92,7 @@ class StudentWorksController < ApplicationController student_work.commit_time = Time.now student_work.update_time = Time.now student_work.commit_user_id = current_user.id + student_work.update_user_id = current_user.id student_work.group_id = @homework.homework_type == "group" ? @homework.max_group_id : 0 #提交作品时,计算是否迟交 @@ -112,7 +113,7 @@ class StudentWorksController < ApplicationController homework_common_id: @homework.id, project_id: student_work.project_id, late_penalty: student_work.late_penalty, work_status: student_work.work_status, commit_time: Time.now, update_time: Time.now, group_id: student_work.group_id, - commit_user_id: current_user.id) + commit_user_id: current_user.id, update_user_id: current_user.id) stu_work.save! student_work.attachments.each do |attachment| att = attachment.copy @@ -156,6 +157,7 @@ class StudentWorksController < ApplicationController begin @work.description = params[:description] @work.update_time = Time.now + @work.update_user_id = current_user.id # @work.commit_user_id = current_user.id if @work.save! Attachment.associate_container(params[:attachment_ids], @work.id, @work.class) @@ -172,7 +174,7 @@ class StudentWorksController < ApplicationController # 原成员更新描述、更新时间以及附件 @homework.student_works.where(group_id: @work.group_id, user_id: (work_user_ids & params_user_ids)).each do |work| # work.update_attributes(update_time: Time.now, description: @work.description, commit_user_id: current_user.id) - work.update_attributes(update_time: Time.now, description: @work.description) + work.update_attributes(update_time: Time.now, description: @work.description, update_user_id: current_user.id) work.attachments.destroy_all @work.attachments.each do |attachment| att = attachment.copy @@ -192,7 +194,7 @@ class StudentWorksController < ApplicationController @homework.student_works.where(group_id: @work.group_id, user_id: delete_user_ids). update_all(work_status: 0, description: nil, late_penalty: 0, commit_time: nil, update_time: nil, final_score: nil, teacher_score: nil, student_score: nil, teaching_asistant_score: nil, - work_score: nil, project_id: 0, group_id: 0, commit_user_id: nil) + work_score: nil, project_id: 0, group_id: 0, commit_user_id: nil, update_user_id: nil) # 新增加的成员 (params_user_ids - work_user_ids).each do |user_id| @@ -200,7 +202,7 @@ class StudentWorksController < ApplicationController stu_work.update_attributes(user_id: user_id, description: @work.description, homework_common_id: @homework.id, project_id: @work.project_id, late_penalty: @work.late_penalty, work_status: @work.work_status, commit_time: Time.now, update_time: Time.now, - group_id: @work.group_id, commit_user_id: @work.commit_user_id) + group_id: @work.group_id, commit_user_id: @work.commit_user_id, update_user_id: current_user.id) @work.attachments.each do |attachment| att = attachment.copy att.author_id = attachment.author_id diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 074068273..168cfeb68 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -2,6 +2,7 @@ class StudentWork < ApplicationRecord #学生提交作品表 #work_status :0 未提交 1 已提交 2 迟交 belongs_to :user belongs_to :commit_user, class_name: 'User', foreign_key: :commit_user_id, optional: true + belongs_to :update_user, class_name: 'User', foreign_key: :update_user_id, optional: true belongs_to :homework_common belongs_to :myshixun, optional: true has_many :student_works_evaluation_distributions, dependent: :destroy diff --git a/app/views/student_works/show.json.jbuilder b/app/views/student_works/show.json.jbuilder index 5756ac9cb..192e4d8ec 100644 --- a/app/views/student_works/show.json.jbuilder +++ b/app/views/student_works/show.json.jbuilder @@ -5,7 +5,8 @@ json.is_evaluation @is_evaluation json.author_name @is_evaluation ? "匿名" : @work.user.real_name json.is_leader_work @work.user_id == @work.commit_user_id if @homework.homework_type == "group" json.is_author @is_author -json.update_user_name @is_evaluation ? "匿名" : @work.commit_user.try(:real_name) +json.commit_user_name @is_evaluation ? "匿名" : @work.commit_user.try(:real_name) +json.update_user_name @is_evaluation ? "匿名" : @work.update_user.try(:real_name) json.update_atta @homework.late_duration && @is_author diff --git a/db/migrate/20190828011222_add_update_user_id_to_student_works.rb b/db/migrate/20190828011222_add_update_user_id_to_student_works.rb new file mode 100644 index 000000000..c8e007998 --- /dev/null +++ b/db/migrate/20190828011222_add_update_user_id_to_student_works.rb @@ -0,0 +1,6 @@ +class AddUpdateUserIdToStudentWorks < ActiveRecord::Migration[5.2] + def change + add_column :student_works, :update_user_id, :integer + StudentWork.update_all("update_user_id = commit_user_id") + end +end