From 31898cbc4f307c551054fdcae6d1fdfe1ff47643 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 29 Jun 2017 18:57:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=BB=84=E4=BD=9C=E4=B8=9A=E8=AF=84?= =?UTF-8?q?=E9=98=85=E4=B8=AD=E6=B2=A1=E6=9C=89=E6=98=BE=E7=A4=BA=E5=85=B6?= =?UTF-8?q?=E4=BB=96=E7=BB=84=E5=91=98=E7=9A=84=E5=90=8D=E5=AD=97=EF=BC=8C?= =?UTF-8?q?label=E9=9C=80=E8=A6=81=E6=9B=BF=E6=8D=A2=E6=96=B0=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/student_work_controller.rb | 7 ++-- app/helpers/student_work_helper.rb | 22 ++++++++++--- .../_student_work_score_div.html.erb | 10 +++--- .../_student_work_score_records.html.erb | 6 ++-- app/views/student_work/show.html.erb | 33 ++++++++++--------- 5 files changed, 47 insertions(+), 31 deletions(-) diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index ba6370a99..8f35d2b01 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -723,7 +723,8 @@ class StudentWorkController < ApplicationController @student_work_scores = student_work_score_record(@work) end if @homework.homework_type == 3 - ids = @work.student_work_projects.map(&:user_id) + member_work = group_member_work @work + ids = member_work.student_work_projects.map(&:user_id) if ids.include?(User.current.id) ids = ids - [User.current.id] end @@ -985,7 +986,7 @@ class StudentWorkController < ApplicationController case @new_score.reviewer_role when 1 #教师评分:最后一个教师评分为最终评分 @work.teacher_score = @new_score.score - if @is_group_leader && params[:same_score] + if params[:same_score] add_score_to_member @work, @homework, @new_score end when 2 #教辅评分 教辅评分显示平均分 @@ -996,7 +997,7 @@ class StudentWorkController < ApplicationController else @work.teaching_asistant_score = @new_score.score end - if @is_group_leader && params[:same_score] + if params[:same_score] add_score_to_member @work, @homework, @new_score end when 3 #学生评分 学生评分显示平均分 diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index fbf481dc8..65703baa7 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -240,15 +240,29 @@ module StudentWorkHelper return status end - def group_student_works student_work, homework - pros = student_work.student_work_projects.where("is_leader = 0") + def group_member_work student_work + member_work = nil + if student_work.student_work_projects.count > 0 + member_work = student_work + else + student_work_pro = StudentWorkProject.where(:user_id => student_work.user_id, :homework_common_id => student_work.homework_common_id).first + if student_work_pro + member_work = StudentWork.find student_work_pro.student_work_id + end + end + member_work + end + + def group_student_works member_work, student_work, homework + pros = member_work.student_work_projects.where("user_id != #{student_work.user_id}") user_ids = pros.empty? ? "(-1)" : "(" + pros.map{|stu|stu.user_id}.join(",") + ")" student_works = homework.student_works.where("user_id in #{user_ids}") return student_works end def add_score_to_member student_work, homework, new_score - student_works = group_student_works student_work, homework + member_work = group_member_work student_work + student_works = group_student_works member_work, student_work, homework student_works.each do |st_work| st_work.student_works_scores << StudentWorksScore.create(:user_id => new_score.user_id, :score => new_score.score, :reviewer_role => new_score.reviewer_role, :comment => new_score.comment) if new_score.reviewer_role == 1 @@ -257,7 +271,7 @@ module StudentWorkHelper ts_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{st_work.id} AND reviewer_role = 2 AND score IS NOT NULL ORDER BY created_at DESC) AS t GROUP BY user_id) AS a") st_work.teaching_asistant_score = ts_score.first.score.nil? ? nil : ts_score.first.score.try(:round, 2).to_f else - st_work.student_score = student_work.student_score + st_work.student_score = member_work.student_score end st_work.save end diff --git a/app/views/student_work/_student_work_score_div.html.erb b/app/views/student_work/_student_work_score_div.html.erb index 2bb0ecc76..82b0cf2c0 100644 --- a/app/views/student_work/_student_work_score_div.html.erb +++ b/app/views/student_work/_student_work_score_div.html.erb @@ -11,16 +11,16 @@