diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 83c26b713..07278ec45 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -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 diff --git a/db/migrate/20141231020031_add_data_to_student_for_course.rb b/db/migrate/20141231020031_add_data_to_student_for_course.rb new file mode 100644 index 000000000..a507f907c --- /dev/null +++ b/db/migrate/20141231020031_add_data_to_student_for_course.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 528ebdee6..cdd827442 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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