From c05a87ca3769bbf65f8b7a068a1f6894dc247d68 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 13 Jul 2015 11:10:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=BB=E5=B9=B3=E5=9D=87=E5=88=86=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E6=80=BB=E5=88=86=20=E6=B4=BB=E8=B7=83=E5=BA=A6?= =?UTF-8?q?=E6=8E=92=E5=90=8D=20=E6=80=BB=E5=88=86=E6=8E=92=E5=90=8D=20=20?= =?UTF-8?q?=E5=9C=A8=E9=A6=96=E9=A1=B5=20=E5=92=8C=20=E5=9C=A8=E5=85=B7?= =?UTF-8?q?=E4=BD=93=E7=9A=84=E9=A1=B5=E9=9D=A2=20=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E4=B8=8D=E4=B8=80=E8=87=B4=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/courses_service.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index e8b0b6a5e..1439f961d 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -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 " <<