From 7a9a78d918390aa84854347ecca19ec296fd70dc Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 2 Jul 2019 17:34:21 +0800 Subject: [PATCH] =?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/courses_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index bae37d92a..2d379b555 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1169,7 +1169,7 @@ class CoursesController < ApplicationController #实训作业 if shixun_homeworks.count > 0 shixun_homeworks.each do |s| - user_student_work = s.score_student_works.find_by_user_id(user.id) #当前用户的对该作业的回答 + user_student_work = s.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答 if user_student_work.nil? h_score = 0.0 #该作业的得分为0 else @@ -1185,7 +1185,7 @@ class CoursesController < ApplicationController #普通作业 if common_homeworks.count > 0 common_homeworks.each do |c| - user_student_work_1 = c.score_student_works.find_by_user_id(user.id) #当前用户的对该作业的回答 + user_student_work_1 = c.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答 if user_student_work_1.nil? h_score_1 = 0.0 #该作业的得分为0 else @@ -1201,7 +1201,7 @@ class CoursesController < ApplicationController #分组作业 if group_homeworks.count > 0 group_homeworks.each do |g| - user_student_work_3 = g.score_student_works.find_by_user_id(user.id) #当前用户的对该作业的回答 + user_student_work_3 = g.score_student_works.select{|work| work.user_id == user.id}.first #当前用户的对该作业的回答 if user_student_work_3.nil? h_score_3 = 0.0 #该作业的得分为0 else @@ -1217,7 +1217,7 @@ class CoursesController < ApplicationController #毕设作业 if tasks.count > 0 tasks.each do |task| - graduation_work = task.score_graduation_works.find_by_user_id(user.id) + graduation_work = task.score_graduation_works.select{|work| work.user_id == user.id}.first if graduation_work.nil? t_score = 0.0 else @@ -1233,7 +1233,7 @@ class CoursesController < ApplicationController #试卷 if exercises.count > 0 exercises.each do |ex| - exercise_work = ex.score_exercise_users.find_by_user_id(user.id) + exercise_work = ex.score_exercise_users.select{|work| work.user_id == user.id}.first if exercise_work.nil? e_score = 0.0 else