数据迁移student_for_course的数据

Signed-off-by: alan <547533434@qq.com>
This commit is contained in:
alan 2014-12-31 10:23:21 +08:00
parent 23140307aa
commit 486f0b69b1
3 changed files with 15 additions and 3 deletions

View File

@ -451,8 +451,7 @@ class HomeworkAttachController < ApplicationController
homework.score = @m_score homework.score = @m_score
homework.is_teacher_score = 1 homework.is_teacher_score = 1
else else
homework.score = (homework.score.nil? ? 0 : homework.score + @m_score) / homework.rates(:quality).count homework.score = homework.rates(:quality).select("avg(stars)")
end end
else else
if is_teacher == 1 if is_teacher == 1

View File

@ -0,0 +1,13 @@
class AddDataToStudentForCourse < ActiveRecord::Migration
def change
Course.all.each do |course|
course.members.each do |m|
if m && m.user && m.user.allowed_to?(:student,course) && StudentsForCourse.find_by_student_id(m.user_id).nil?
StudentsForCourse.create(:student_id => m.user_id, :course_id => course.id)
end
end
end
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20141230081744) do ActiveRecord::Schema.define(:version => 20141231020031) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false