From 5bfebb53a593b492f12a775ccfcddcc5f35216a0 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 20 Mar 2019 19:29:41 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ec_courses_controller.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/ec_courses_controller.rb b/app/controllers/ec_courses_controller.rb index ae02ea2b..15989acc 100644 --- a/app/controllers/ec_courses_controller.rb +++ b/app/controllers/ec_courses_controller.rb @@ -696,15 +696,16 @@ class EcCoursesController < ApplicationController # 毕业要求指标点达成评价 total_rate = [] total_arry = EcCourseStudentScore.find_by_sql("SELECT avg(score) as averge_score, ec_target_position as position, - ect.weigths FROM ec_student_score_targets esst, ec_course_targets ect - where esst.ec_course_target_id=ect.id group by ec_course_target_id") + ect.weigths FROM ec_student_score_targets esst, ec_course_targets ect where + esst.ec_course_target_id=ect.id and ect.ec_course_id = #{course_id.id} + group by ec_course_target_id") all_score = 0 total_arry.try(:each) do |ta| - total_rate << {:position => ta.position, :score => ta.averge_score.round(1), :rate => ta.weigths} + total_rate << {:position => ta.position, :score => ta.averge_score.round(2), :rate => ta.weigths} logger.info("##############total_rate: #{total_rate.to_json}") all_score += ta.averge_score * ta.weigths end - total_rate << {:total_score => (all_score).round(1)} + total_rate << {:total_score => (all_score).round(2)} ecg_targets = EcGraduationSubitemCourseTarget.where(:ec_course_target_id => @ec_course.ec_course_targets) ecg_targets.chunk{|c| c.ec_graduation_subitem_id}.try(:each) do |key, egs_t| From 5a4df7c4429ceb088a7b3d926d31b9af6ae01d4b Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 20 Mar 2019 19:32:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/ec_courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/ec_courses_controller.rb b/app/controllers/ec_courses_controller.rb index 15989acc..df8c24b8 100644 --- a/app/controllers/ec_courses_controller.rb +++ b/app/controllers/ec_courses_controller.rb @@ -697,7 +697,7 @@ class EcCoursesController < ApplicationController total_rate = [] total_arry = EcCourseStudentScore.find_by_sql("SELECT avg(score) as averge_score, ec_target_position as position, ect.weigths FROM ec_student_score_targets esst, ec_course_targets ect where - esst.ec_course_target_id=ect.id and ect.ec_course_id = #{course_id.id} + esst.ec_course_target_id=ect.id and ect.ec_course_id = #{course_id} group by ec_course_target_id") all_score = 0 total_arry.try(:each) do |ta|