数据迁移student_for_course的数据
Signed-off-by: alan <547533434@qq.com>
This commit is contained in:
parent
23140307aa
commit
486f0b69b1
|
@ -451,8 +451,7 @@ class HomeworkAttachController < ApplicationController
|
|||
homework.score = @m_score
|
||||
homework.is_teacher_score = 1
|
||||
else
|
||||
homework.score = (homework.score.nil? ? 0 : homework.score + @m_score) / homework.rates(:quality).count
|
||||
|
||||
homework.score = homework.rates(:quality).select("avg(stars)")
|
||||
end
|
||||
else
|
||||
if is_teacher == 1
|
||||
|
|
|
@ -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
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# 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|
|
||||
t.integer "act_id", :null => false
|
||||
|
|
Loading…
Reference in New Issue