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 @@