1.增加评分的model

2.修改评分表中为教师评分的历史数据的is_teacher_score的值
This commit is contained in:
sw 2014-12-29 11:38:35 +08:00
parent fa36e6d2b0
commit 259799eb89
3 changed files with 27 additions and 1 deletions

View File

@ -0,0 +1,3 @@
class SeemsRateableRates < ActiveRecord::Base
attr_accessible :rater_id, :rateable_id, :rateable_type, :stars, :dimension, :is_teacher_score
end

View File

@ -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

View File

@ -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