parent
fa36e6d2b0
commit
259799eb89
|
@ -0,0 +1,3 @@
|
|||
class SeemsRateableRates < ActiveRecord::Base
|
||||
attr_accessible :rater_id, :rateable_id, :rateable_type, :stars, :dimension, :is_teacher_score
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
class ChangeSeemsRateableRates < ActiveRecord::Migration
|
||||
def up
|
||||
SeemsRateableRates.where("rateable_type = 'HomeworkAttach'").each do |rate|
|
||||
homework = HomeworkAttach.find_by_id rate.rateable_id
|
||||
if homework
|
||||
course = homework.bid.courses.first
|
||||
if course
|
||||
teachers = []
|
||||
course.members.each do |m|
|
||||
teachers << m.user_id if m && m.user && m.user.allowed_to?(:as_teacher,course)
|
||||
end
|
||||
if teachers.include?(rate.rater_id)
|
||||
rate.is_teacher_score = 1
|
||||
rate.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20141229025519) do
|
||||
ActiveRecord::Schema.define(:version => 20141229025925) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
|
Loading…
Reference in New Issue