diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index f88217f7b..f64688deb 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -230,7 +230,7 @@ class HomeworkCommonsController < ApplicationController limit = params[:limit] || 20 @student_works = @student_works.page(page).per(limit) if @homework.homework_type == "practice" - @student_works = @student_works.includes(:student_works_scores, :shixun_work_comments, user: :user_extension, myshixun: :games) + @student_works = @student_works.includes(:student_works_scores, :shixun_work_comments, :challenge_work_scores, user: :user_extension, myshixun: :games) else @student_works = @student_works.includes(:student_works_scores, :project, user: :user_extension) end diff --git a/app/models/student_work.rb b/app/models/student_work.rb index d695a6b00..d7d24c9ed 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -223,6 +223,11 @@ class StudentWork < ApplicationRecord end end + # 实训作品是否已被评阅过 + def shixun_has_comment? + shixun_work_comments.size > 0 || student_works_scores.size > 0 || challenge_work_scores.size > 0 + end + def scored? student_works_scores.where.not(reviewer_role: 3, score: nil).exists? end diff --git a/app/views/homework_commons/works_list.json.jbuilder b/app/views/homework_commons/works_list.json.jbuilder index 7c51432d0..e545253c0 100644 --- a/app/views/homework_commons/works_list.json.jbuilder +++ b/app/views/homework_commons/works_list.json.jbuilder @@ -114,7 +114,7 @@ if @homework.homework_type == "practice" json.student_id work.user.try(:student_id) json.group_name @students.select{|student| student.user_id == work.user_id}.first.try(:course_group_name) json.work_status work.compelete_status - json.has_comment work.shixun_work_comments.size > 0 + json.has_comment work.shixun_has_comment? end elsif @homework.homework_type == "group" || @homework.homework_type == "normal" json.anonymous_comment @homework.anonymous_comment