parent
7850795bf0
commit
c05a87ca37
|
@ -700,12 +700,12 @@ class CoursesService
|
|||
latest_course_dynamics.sort! { |order, newer| newer[:time] <=> order[:time] }
|
||||
# 课程学霸 学生总分数排名靠前的5个人
|
||||
homework_count = course.homework_commons.count
|
||||
sql = "select users.*,sum(IFNULL(0,student_works.final_score))/#{homework_count} score from student_works left outer join users on student_works.user_id = users.id" <<
|
||||
" where homework_common_id in ( select id from homework_commons where homework_commons.course_id = #{course.id}) GROUP BY student_works.user_id ORDER BY score limit 0,4"
|
||||
sql = "select users.*,ROUND(sum(student_works.final_score),2) score from student_works left outer join users on student_works.user_id = users.id" <<
|
||||
" where homework_common_id in ( select id from homework_commons where homework_commons.course_id = #{course.id}) GROUP BY student_works.user_id ORDER BY score desc limit 0,4"
|
||||
better_students = User.find_by_sql(sql)
|
||||
# 找出在课程讨论区发帖回帖数最多的
|
||||
active_students = []
|
||||
sql1 = " select users.*,count(author_id) active_count from messages " <<
|
||||
sql1 = " select users.*,count(author_id)*2 active_count from messages " <<
|
||||
" LEFT JOIN users on messages.author_id = users.id " <<
|
||||
" where messages.board_id in (select id from boards where boards.course_id = #{course.id} ) " <<
|
||||
" GROUP BY messages.author_id ORDER BY count(author_id) desc " <<
|
||||
|
@ -735,7 +735,7 @@ class CoursesService
|
|||
max_size = 0
|
||||
if params[:type] == 1
|
||||
|
||||
sql = "select users.*,sum(student_works.final_score) score from student_works left outer join users on student_works.user_id = users.id" <<
|
||||
sql = "select users.*,ROUND(sum(student_works.final_score),2) score from student_works left outer join users on student_works.user_id = users.id" <<
|
||||
" where homework_common_id in ( select id from homework_commons where homework_commons.course_id = #{params[:course_id]}) GROUP BY student_works.user_id ORDER BY score desc limit #{page*10},10"
|
||||
sql_count = " select count(distinct(student_works.user_id) ) " <<
|
||||
" from student_works left outer join users on student_works.user_id = users.id " <<
|
||||
|
|
Loading…
Reference in New Issue