|
|
@ -129,6 +129,16 @@ class Member < ActiveRecord::Base
|
|
|
|
StudentWork.select("homework_commons.name, student_works.final_score").joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}")
|
|
|
|
StudentWork.select("homework_commons.name, student_works.final_score").joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#当前课程的作业列表
|
|
|
|
|
|
|
|
def homework_common_list
|
|
|
|
|
|
|
|
HomeworkCommon.where(:course_id => self.course_id)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#当前学生在指定作业内的得分
|
|
|
|
|
|
|
|
def homework_common_score homework_common
|
|
|
|
|
|
|
|
StudentWork.select("final_score").where(:homework_common_id => homework_common.id,:user_id => self.user_id)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def student_work_score_avg
|
|
|
|
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
|
|
|
|
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
|
|
|
|
end
|
|
|
|