|
|
|
@ -116,21 +116,23 @@ class Member < ActiveRecord::Base
|
|
|
|
|
|
|
|
|
|
# 查找每个学生每个作业的评分
|
|
|
|
|
def student_homework_score
|
|
|
|
|
score_count = 0
|
|
|
|
|
homework_score = StudentWork.find_by_sql("SELECT homework_commons.name,student_works.final_score as score
|
|
|
|
|
FROM student_works,homework_commons
|
|
|
|
|
WHERE student_works.homework_common_id = homework_commons.id
|
|
|
|
|
AND homework_commons.course_id = #{self.course_id}
|
|
|
|
|
AND student_works.user_id = #{self.user_id}")
|
|
|
|
|
homework_score.each do |homework|
|
|
|
|
|
mem_score = 0
|
|
|
|
|
if homework[:score]
|
|
|
|
|
mem_score = homework[:score]
|
|
|
|
|
end
|
|
|
|
|
score_count = score_count + mem_score
|
|
|
|
|
end
|
|
|
|
|
score_count = StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}").average(:final_score).try(:round, 2).to_f
|
|
|
|
|
[homework_score, format("%0.2f", score_count)]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def student_work_score
|
|
|
|
|
StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def student_work_score_avg
|
|
|
|
|
StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}").average(:final_score).try(:round, 2).to_f
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
|
|
def validate_role
|
|
|
|
|