From 3dc7c55aef6278be6a06364469562c976f608b7d Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 31 Dec 2014 10:45:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E8=AF=84=E5=88=86=E6=97=B6?= =?UTF-8?q?=E9=83=A8=E5=88=86=E9=87=8D=E5=A4=8D=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 347c8e11f..e6b50e695 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -435,6 +435,7 @@ class HomeworkAttachController < ApplicationController @is_teacher,@is_anonymous_comments,@m_score = params[:is_teacher]=="true",params[:is_anonymous_comments]=="true",params[:stars_value] @cur_page,@cur_type = params[:cur_page] || 1,params[:cur_type] || 5 @homework = HomeworkAttach.find(params[:homework_id]) + @stars_reates = @homework.rates(:quality) homework = @homework is_teacher = @is_teacher ? 1 : 0 #保存评分@homework.rate(@m_score.to_i,User.current.id,:quality, (@is_teacher ? 1 : 0)) @@ -446,12 +447,13 @@ class HomeworkAttachController < ApplicationController else @homework.rates(:quality).new(:stars => @m_score, :rater_id => User.current.id, :is_teacher_score => is_teacher).save! end + if homework.is_teacher_score == 0 if is_teacher == 1 homework.score = @m_score homework.is_teacher_score = 1 else - homework.score = homework.rates(:quality).select("avg(stars)") + homework.score = @stars_reates.select("avg(stars)") end else if is_teacher == 1 @@ -468,7 +470,6 @@ class HomeworkAttachController < ApplicationController @homework.addjours User.current.id, params[:new_form][:user_message],0,@is_comprehensive_evaluation end - @stars_reates = @homework.rates(:quality) @teacher_stars = @stars_reates.where("is_teacher_score = 1") #老师评分列表 @student_stars = @stars_reates.where("is_teacher_score = 0") #学生评分列表 jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC")#jours留言 is null条件用以兼容历史数据