总平均分改为总分

活跃度排名 总分排名  在首页 和 在具体的页面 排序不一致的bug
This commit is contained in:
lizanle 2015-07-13 11:10:04 +08:00
parent 7850795bf0
commit c05a87ca37
1 changed files with 4 additions and 4 deletions

View File

@ -700,12 +700,12 @@ class CoursesService
latest_course_dynamics.sort! { |order, newer| newer[:time] <=> order[:time] } latest_course_dynamics.sort! { |order, newer| newer[:time] <=> order[:time] }
# 课程学霸 学生总分数排名靠前的5个人 # 课程学霸 学生总分数排名靠前的5个人
homework_count = course.homework_commons.count 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" << 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 limit 0,4" " 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) better_students = User.find_by_sql(sql)
# 找出在课程讨论区发帖回帖数最多的 # 找出在课程讨论区发帖回帖数最多的
active_students = [] 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 " << " LEFT JOIN users on messages.author_id = users.id " <<
" where messages.board_id in (select id from boards where boards.course_id = #{course.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 " << " GROUP BY messages.author_id ORDER BY count(author_id) desc " <<
@ -735,7 +735,7 @@ class CoursesService
max_size = 0 max_size = 0
if params[:type] == 1 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" " 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) ) " << sql_count = " select count(distinct(student_works.user_id) ) " <<
" from student_works left outer join users on student_works.user_id = users.id " << " from student_works left outer join users on student_works.user_id = users.id " <<