diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index cec6dd0ff..3595b5866 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -630,14 +630,16 @@ module ExercisesHelper user_score = nil shixun_type = 0 question_comment = [] - if q.question_type == 5 + if ques_type == 5 exercise_answers = q.exercise_shixun_answers.search_shixun_answers("user_id",ex_answerer_id) else exercise_answers = q.exercise_answers.search_exercise_answer("user_id",ex_answerer_id) #试卷用户的回答 end if student_status == 2 #当前为老师,或为学生且已提交 - user_score = exercise_answers.score_reviewed.pluck(:score).sum + user_score_pre = exercise_answers.score_reviewed.pluck(:score).sum + user_score = user_score_pre.present? ? user_score_pre.pluck(:score).sum : nil end + if user_score.present? && (user_score > q.question_score) user_score = q.question_score end @@ -667,7 +669,7 @@ module ExercisesHelper question_comment = q.exercise_answer_comments.search_answer_comments("exercise_answer_id",q_answer_id) end { - "user_score": user_score.present? ? user_score.round(1) : nil, + "user_score": (user_score.present? ? user_score.round(1).to_s : nil), "answered_content":answered_content, "shixun_type":shixun_type, "question_comment":question_comment diff --git a/app/jobs/homework_evaluation_comment_assgin_job.rb b/app/jobs/homework_evaluation_comment_assgin_job.rb index 2579ea18b..5921386f2 100644 --- a/app/jobs/homework_evaluation_comment_assgin_job.rb +++ b/app/jobs/homework_evaluation_comment_assgin_job.rb @@ -16,7 +16,7 @@ class HomeworkEvaluationCommentAssginJob < ApplicationJob student_work_projects = homework_common.student_works.where("work_status != 0").shuffle student_work_projects.each do |pro_work| n = homework_detail_manual.evaluation_num - n = (n < student_works.size && n != -1) ? n : student_works.size - 1 + n = (n < student_works.length && n != -1) ? n : student_works.length - 1 work_index = -1 student_works.each_with_index do |stu_work, stu_index| if stu_work.group_id.to_i == pro_work.group_id.to_i diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index c0882ec6f..6512c3f1d 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -170,7 +170,7 @@ class HomeworkCommon < ApplicationRecord #删除时更新题库中的引用数 def update_homework_bank_quotes old_bank = self.homework_bank - old_bank.update_attributes(quotes: (old_bank.quotes - 1) > 0 ? (old_bank.quotes - 1) : 0, homework_common_id: nil) + old_bank.update_attributes(quotes: (old_bank.quotes - 1) > 0 ? (old_bank.quotes - 1) : 0, homework_common_id: nil) if old_bank.present? end # 查重是否有新结果 diff --git a/app/views/exercises/_user_exercise_info.json.jbuilder b/app/views/exercises/_user_exercise_info.json.jbuilder index cc10f5bb7..1ff929897 100644 --- a/app/views/exercises/_user_exercise_info.json.jbuilder +++ b/app/views/exercises/_user_exercise_info.json.jbuilder @@ -47,14 +47,13 @@ end json.exercise_questions do json.array! exercise_questions do |q| - user_ques_answers = user_question_answers(q,ex_answerer.id,student_status,is_teacher_or,exercise_status,q.question_type,ex_type) user_ques_comments = user_ques_answers[:question_comment] if all_question_status.size > 0 this_ques_status = all_question_status.detect {|f| f[:q_id] == q.id} json.answer_status this_ques_status[:stand_status] end - json.user_score user_ques_answers[:user_score].present? ? user_ques_answers[:user_score].to_s : nil + json.user_score user_ques_answers[:user_score] json.partial! "exercise_questions/exercise_questions", question: q, ex_answerer: ex_answerer,