From 77f948ea630a759869255a1bb477e73f861b6045 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 10 Jul 2015 17:58:42 +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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/courses_service.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index 3fc9fb51c..e8b0b6a5e 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -734,10 +734,9 @@ class CoursesService user_list = [] max_size = 0 if params[:type] == 1 - homework_count = Course.find(params[:course_id]).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 = #{params[:course_id]}) GROUP BY student_works.user_id ORDER BY score limit #{page*10},10" + sql = "select users.*,sum(student_works.final_score) 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 " << " where homework_common_id in " <<