From ba66cde8406a47a1a3449ef962ca1bdc0725e8c8 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sat, 19 Jul 2014 16:38:29 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E4=BD=9C=E4=B8=9A=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E7=95=8C=E9=9D=A2=E5=8A=A0=E8=BD=BD=E6=95=88=E7=8E=87?= =?UTF-8?q?=202.=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=9A=84=E4=BA=92=E8=AF=84=E5=BE=97=E5=88=86=E3=80=81=E7=BB=BC?= =?UTF-8?q?=E8=AF=84=E5=BE=97=E5=88=86=E3=80=81=E6=95=99=E5=B8=88=E8=AF=84?= =?UTF-8?q?=E5=88=86=E4=B8=8D=E5=87=86=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 36 +++++++++++++++++++------- app/views/bids/_homework_list.html.erb | 9 ++++--- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 033b6405c..e971970bc 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -357,26 +357,44 @@ module CoursesHelper #获取作业的互评得分 def student_score_for_homework homework - member = searchTeacherAndAssistant(homework.bid.courses.first).first#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first - if member.nil? - return "0.00" + #member = searchTeacherAndAssistant(homework.bid.courses.first).first#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first + #if member.nil? + # return "0.00" + #end + #student_stars = homework.rates(:quality).where("rater_id <> #{member.user_id}").select("stars") + members = searchStudent(homework.bid.courses.first) + user_ids = [] + members.each do |user| + user_ids << user.user_id end - student_stars = homework.rates(:quality).where("rater_id <> #{member.user_id}").select("stars") + student_stars = homework.rates(:quality).where("rater_id in (:user_ids)",{:user_ids => user_ids}).select("stars") student_stars_count = 0 student_stars.each do |star| student_stars_count = student_stars_count + star.stars end return format("%.2f",student_stars_count / (student_stars.count == 0 ? 1 : student_stars.count)) + + + end #获取作业的教师评分 + #多个教师只获取一份教师评分 def teacher_score_for_homework homework - member = searchTeacherAndAssistant(homework.bid.courses.first).first#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first - if member.nil? - return "0.00" + members = searchTeacherAndAssistant(homework.bid.courses.first)#searchPeopleByRoles(homework.bid.courses.first,TeacherRoles).first + #if member.nil? + # return "0.00" + #end + teacher_ids = [] + members.each do |user| + teacher_ids << user.user_id end - teacher_stars = homework.rates(:quality).where("rater_id = #{member.user_id}").select("stars").first - return format("%.2f",teacher_stars == nil ? 0 : teacher_stars.stars) + teacher_stars = homework.rates(:quality).where("rater_id in (:teacher_ids)",{:teacher_ids => teacher_ids}).select("stars") + teacher_stars_count = 0 + teacher_stars.each do |star| + teacher_stars_count = teacher_stars_count + star.stars + end + return format("%.2f",teacher_stars_count) end #获取指定项目的得分 diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index a8f1f4356..8b241030a 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -117,9 +117,9 @@