diff --git a/app/models/students_for_course.rb b/app/models/students_for_course.rb index 35bb6613a..4027cd7db 100644 --- a/app/models/students_for_course.rb +++ b/app/models/students_for_course.rb @@ -40,7 +40,7 @@ class StudentsForCourse < ActiveRecord::Base #加入班级时创建一条记录 def create_course_homework_statistic - if CourseHomeworkStatistic.where(:user_id => self.student_id, :course_id => self.course_id).count == 0 + if CourseHomeworkStatistics.where(:user_id => self.student_id, :course_id => self.course_id).count == 0 course = self.course user = self.student hw_count = course.homework_commons.includes(:homework_detail_manual).where("homework_detail_manuals.comment_status > 0").count @@ -63,13 +63,13 @@ class StudentsForCourse < ActiveRecord::Base appeal_num = user.student_works_scores.where(:student_work_id => student_works.map(&:id), :appeal_status => 3).count average_score = user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("AVG(student_works.work_score) as score").first.score : 0 total_score = user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first ? user.student_works.where(:id => student_works.map(&:id)).select("SUM(student_works.work_score) as score").first.score : 0 - CourseHomeworkStatistic.create(:course_id => course.id, :user_id => user.id, :committed_work_num => committed_work_num, :un_commit_work_num => un_commit_work_num, + CourseHomeworkStatistics.create(:course_id => course.id, :user_id => user.id, :committed_work_num => committed_work_num, :un_commit_work_num => un_commit_work_num, :late_commit_work_num => late_commit_work_num, :absence_evaluation_work_num => absence_evaluation_work_num, :un_evaluation_work_num => un_evaluation_work_num, :appeal_num => appeal_num, :average_score => average_score, :total_score => total_score) end end def delete_course_homework_statistic - CourseHomeworkStatistic.where(:user_id => self.student_id, :course_id => self.course_id).destroy_all + CourseHomeworkStatistics.where(:user_id => self.student_id, :course_id => self.course_id).destroy_all end end