|
|
|
@ -61,16 +61,21 @@ class StudentWorksController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def delete_work
|
|
|
|
|
begin
|
|
|
|
|
work = @homework.student_works.find_by!(user_id: params[:user_id])
|
|
|
|
|
work.update_attributes(description: nil, project_id: 0,
|
|
|
|
|
late_penalty: 0, work_status: 0,
|
|
|
|
|
commit_time: nil, update_time: nil, group_id: 0,
|
|
|
|
|
commit_user_id: nil, final_score: nil, work_score: nil, teacher_score: nil, teaching_asistant_score: nil)
|
|
|
|
|
normal_status("删除成功")
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger(e.message)
|
|
|
|
|
tip_exception(e.message)
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
begin
|
|
|
|
|
work = @homework.student_works.find_by!(user_id: params[:user_id])
|
|
|
|
|
tip_exception("只有组长才能删除组员") if work.commit_user_id != current_user.id
|
|
|
|
|
work.update_attributes(description: nil, project_id: 0,
|
|
|
|
|
late_penalty: 0, work_status: 0,
|
|
|
|
|
commit_time: nil, update_time: nil, group_id: 0,
|
|
|
|
|
commit_user_id: nil, final_score: nil, work_score: nil, teacher_score: nil, teaching_asistant_score: nil)
|
|
|
|
|
work.attachments.destroy_all
|
|
|
|
|
work.tidings.destroy_all
|
|
|
|
|
normal_status("删除成功")
|
|
|
|
|
rescue Exception => e
|
|
|
|
|
uid_logger(e.message)
|
|
|
|
|
tip_exception(e.message)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -137,8 +142,9 @@ class StudentWorksController < ApplicationController
|
|
|
|
|
@current_user = current_user
|
|
|
|
|
if @homework.homework_type == "group"
|
|
|
|
|
# todo user_extension
|
|
|
|
|
@commit_user_id = @work.commit_user_id
|
|
|
|
|
@work_members = @course.students.where(user_id: @homework.student_works.where(group_id: @work.group_id).pluck(:user_id)).
|
|
|
|
|
order("course_members.id=#{@work.user_id} desc").includes(:course_group, user: :user_extension)
|
|
|
|
|
order("course_members.user_id=#{@work.commit_user_id} desc").includes(:course_group, user: :user_extension)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -150,7 +156,7 @@ class StudentWorksController < ApplicationController
|
|
|
|
|
begin
|
|
|
|
|
@work.description = params[:description]
|
|
|
|
|
@work.update_time = Time.now
|
|
|
|
|
@work.commit_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)
|
|
|
|
|
|
|
|
|
@ -165,7 +171,8 @@ 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, commit_user_id: current_user.id)
|
|
|
|
|
work.update_attributes(update_time: Time.now, description: @work.description)
|
|
|
|
|
work.attachments.destroy_all
|
|
|
|
|
@work.attachments.each do |attachment|
|
|
|
|
|
att = attachment.copy
|
|
|
|
@ -193,7 +200,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: current_user.id)
|
|
|
|
|
group_id: @work.group_id, commit_user_id: @work.commit_user_id)
|
|
|
|
|
@work.attachments.each do |attachment|
|
|
|
|
|
att = attachment.copy
|
|
|
|
|
att.author_id = attachment.author_id
|
|
|
|
|