学生删除作品时将作品还原为初始状态
This commit is contained in:
parent
cdffaed1ea
commit
0ce61bfee8
|
@ -734,26 +734,35 @@ class StudentWorkController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
if @homework.homework_type == 3
|
||||||
if @work.destroy
|
if @work.destroy
|
||||||
if @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1
|
if @homework.homework_detail_group.base_on_project == 1
|
||||||
pros = @work.student_work_projects.where("is_leader = 0")
|
pros = @work.student_work_projects.where("is_leader = 0")
|
||||||
pros.each do |pro|
|
pros.each do |pro|
|
||||||
pro.destroy
|
pro.destroy
|
||||||
end
|
end
|
||||||
project = @work.student_work_projects.where("is_leader = 1").first
|
project = @work.student_work_projects.where("is_leader = 1").first
|
||||||
project.update_attributes(:student_work_id => nil)
|
project.update_attributes(:student_work_id => nil)
|
||||||
elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 0
|
elsif @homework.homework_detail_group.base_on_project == 0
|
||||||
@work.student_work_projects.each do |pro2|
|
@work.student_work_projects.each do |pro2|
|
||||||
pro2.destroy
|
pro2.destroy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@work.attachments.destroy_all
|
||||||
|
@work.student_works_scores.destroy_all
|
||||||
|
@work.course_messages.destroy_all
|
||||||
|
@work.student_work_tests.destroy_all
|
||||||
|
@work.update_attributes(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0, :commit_time => nil,:final_score => nil,:teacher_score => nil,:student_score => nil,:teaching_asistant_score => nil,:system_score => 0,:work_score => nil)
|
||||||
|
@work.update_column("work_score",nil)
|
||||||
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
redirect_to student_work_index_url(:homework => @homework.id)
|
redirect_to student_work_index_url(:homework => @homework.id)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def delete_work
|
def delete_work
|
||||||
@work = StudentWork.where("user_id =? and homework_common_id =?", User.current.id, @homework.id).first
|
@work = StudentWork.where("user_id =? and homework_common_id =?", User.current.id, @homework.id).first
|
||||||
|
@ -794,6 +803,7 @@ class StudentWorkController < ApplicationController
|
||||||
elsif @homework.homework_type == 1
|
elsif @homework.homework_type == 1
|
||||||
@work.update_attributes(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0, :commit_time => nil)
|
@work.update_attributes(:work_status => 0, :name => "#{@homework.name}的作品提交", :description => nil, :late_penalty => 0, :commit_time => nil)
|
||||||
@work.attachments.destroy_all
|
@work.attachments.destroy_all
|
||||||
|
@work.course_messages.destroy_all
|
||||||
end
|
end
|
||||||
@student_work = StudentWork.new
|
@student_work = StudentWork.new
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#学生提交作品表
|
#学生提交作品表
|
||||||
class StudentWork < ActiveRecord::Base
|
class StudentWork < ActiveRecord::Base
|
||||||
attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :project_id, :is_test, :simi_id, :simi_value, :work_status, :commit_time
|
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
|
||||||
|
|
||||||
belongs_to :homework_common
|
belongs_to :homework_common
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
Loading…
Reference in New Issue