From aa8b8accc11ffcab96a4c92979da0984e8ab07c2 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 26 Jun 2019 17:08:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BF=E8=AF=84=E4=BD=9C=E5=93=81=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/student_work.rb | 10 ++++++++++ .../homework_commons/works_list.json.jbuilder | 18 ++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 0e674dd4c..8acc2e098 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -59,6 +59,16 @@ class StudentWork < ApplicationRecord group_by(&:user_id).count : 0 end + # 当前用户该作品的匿评申诉总条数 + def my_appeal_all_count user_id + student_works_scores.where("reviewer_role = 3 and appeal_status != 0 and user_id = #{user_id}").size + end + + # 当前用户该作品的匿评申诉总条数 + def my_appeal_deal_count user_id + student_works_scores.where("reviewer_role = 3 and appeal_status = 1 and user_id = #{user_id}").size + end + # 分组名 def work_group_name self.group_id == 0 ? "--" : "分组#{self.group_id}" diff --git a/app/views/homework_commons/works_list.json.jbuilder b/app/views/homework_commons/works_list.json.jbuilder index 42d4abf48..716b12190 100644 --- a/app/views/homework_commons/works_list.json.jbuilder +++ b/app/views/homework_commons/works_list.json.jbuilder @@ -106,6 +106,12 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal" json.student_score work_score_format(anon_comments(@current_user, work.id).last.try(:score), false, true) # json.student_comment_count anon_comments(@current_user, work.id).count + + # 申诉条数 + if @homework.anonymous_appeal + json.appeal_all_count work.my_appeal_all_count @current_user.id + json.appeal_deal_count work.my_appeal_deal_count @current_user.id + end else json.(work, :id, :work_status, :update_time, :work_score, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :ultimate_score) @@ -134,13 +140,13 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal" end json.work_group work.work_group_name end - end - # 申诉条数 - if @homework.anonymous_appeal - json.appeal_all_count work.appeal_all_count - json.appeal_deal_count work.appeal_deal_count - json.appeal_penalty work.appeal_penalty + # 申诉条数 + if @homework.anonymous_appeal + json.appeal_all_count work.appeal_all_count + json.appeal_deal_count work.appeal_deal_count + json.appeal_penalty work.appeal_penalty + end end json.user_login @is_evaluation ? "--" : work.user.try(:login)