From 6ff86e899a1e0f2beac785a1fd9c01aa03d5ac6d Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 20 Mar 2020 19:51:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E6=98=AF=E5=90=A6=E5=B7=B2?= =?UTF-8?q?=E8=AF=84=E9=98=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 7 +++++++ app/views/exercises/_exercise_user.json.jbuilder | 3 ++- app/views/exercises/exercise_lists.json.jbuilder | 6 ++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 26125ae23..1c101ad52 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -993,4 +993,11 @@ module ExercisesHelper } exercise_user.update!(commit_option) end + + def has_comment? exercise_user, question_ids + exercise_answer_ids = exercise_user.user.exercise_answers.where(exercise_question_id: question_ids).pluck(:id) + exercise_shixun_answer_ids = exercise_user.user.exercise_shixun_answers.where(exercise_question_id: question_ids).pluck(:id) + exercise_user.exercise_user_scores.size > 0 || exercise_user.subjective_score >= 0.0 || + ExerciseAnswerComment.where(exercise_answer_id: exercise_answer_ids).or(ExerciseAnswerComment.where(exercise_shixun_answer_id: exercise_shixun_answer_ids)).exists? + end end diff --git a/app/views/exercises/_exercise_user.json.jbuilder b/app/views/exercises/_exercise_user.json.jbuilder index 5f00bbd70..acaa07e98 100644 --- a/app/views/exercises/_exercise_user.json.jbuilder +++ b/app/views/exercises/_exercise_user.json.jbuilder @@ -14,4 +14,5 @@ if subjective_type == 1 json.subjective_score ex_user_info[:ex_subject_score] end json.score ex_user_info[:score] -json.review_status ex_user_info[:teacher_review] #教师是否评阅,评阅则为true,否则为false \ No newline at end of file +json.review_status ex_user_info[:teacher_review] #教师是否评阅,评阅则为true,否则为false +json.has_comment has_comment?(exercise_user, question_ids) \ No newline at end of file diff --git a/app/views/exercises/exercise_lists.json.jbuilder b/app/views/exercises/exercise_lists.json.jbuilder index 8230ef7c7..5cbb63595 100644 --- a/app/views/exercises/exercise_lists.json.jbuilder +++ b/app/views/exercises/exercise_lists.json.jbuilder @@ -37,7 +37,8 @@ end if @current_user_ex_answers.present? json.current_answer_user do json.partial! "exercises/exercise_user",locals: {exercise_user:@current_user_ex_answers.first, subjective_type:@subjective_type, - user_status:@exercise_current_user_status, exercise:@exercise} + user_status:@exercise_current_user_status, exercise:@exercise, + question_ids: @exercise.exercise_questions.pluck(:id)} end end @@ -45,7 +46,8 @@ if @exercise_users_list.present? json.exercise_users do json.array! @exercise_users_list.each do |exercise_user| json.partial! "exercises/exercise_user",locals: {exercise_user:exercise_user, subjective_type:@subjective_type, - user_status:@exercise_current_user_status, exercise:@exercise} + user_status:@exercise_current_user_status, exercise:@exercise, + question_ids: @exercise.exercise_questions.pluck(:id)} end end else