删除周海芳老师2882作业的学生匿评

This commit is contained in:
cxt 2016-04-05 11:23:50 +08:00
parent 37e3377fd3
commit 6a8a82e85a
2 changed files with 21 additions and 1 deletions

View File

@ -0,0 +1,19 @@
class DeleteAnonymousWork < ActiveRecord::Migration
def up
student_works = StudentWork.where("homework_common_id = 2882").map{|work| work.id} unless StudentWork.where("homework_common_id = 2882").empty?
student_work_ids = "(" + student_works.join(",") + ")"
student_work_scores = StudentWorksScore.where("student_work_id in #{student_work_ids}")
unless student_work_scores.empty?
student_work_scores.each do |sscore|
student_work = StudentWork.find sscore.student_work_id
student_work.student_score = 0 unless student_work.nil?
student_work.absence_penalty = 0
sscore.destroy
student_work.save
end
end
end
def down
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20160328022623) do
ActiveRecord::Schema.define(:version => 20160405021915) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -1289,6 +1289,7 @@ ActiveRecord::Schema.define(:version => 20160328022623) do
t.datetime "updated_at", :null => false
t.string "field_type"
t.integer "hide", :default => 0
t.integer "status", :default => 1
end
create_table "organizations", :force => true do |t|