|
|
|
@ -497,13 +497,16 @@ class ExerciseQuestionsController < ApplicationController
|
|
|
|
|
ex_obj_score = @exercise_current_user.objective_score #全部客观题得分
|
|
|
|
|
ex_subj_score = @exercise_current_user.subjective_score < 0.0 ? 0.0 : @exercise_current_user.subjective_score #全部主观题得分
|
|
|
|
|
ex_answers = @exercise_question.exercise_answers.search_answer_users("user_id",@user_id) #当前用户答案的得分
|
|
|
|
|
ex_answer_create = nil
|
|
|
|
|
if @exercise_question.question_type == Exercise::MULTIPLE
|
|
|
|
|
if ex_answers.present? #学生有回答时 取学生的答题得分,否则0分
|
|
|
|
|
answer_choice_array = []
|
|
|
|
|
ex_answers.each do |a|
|
|
|
|
|
answer_choice_array.push(a.exercise_choice.choice_position) #学生答案的位置
|
|
|
|
|
if a.try(:exercise_choice).try(:choice_position).present?
|
|
|
|
|
answer_choice_array.push(a&.exercise_choice&.choice_position) #学生答案的位置
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
user_answer_content = answer_choice_array.sort
|
|
|
|
|
user_answer_content = answer_choice_array.reject(&:blank?).sort
|
|
|
|
|
standard_answer = @exercise_question.exercise_standard_answers.pluck(:exercise_choice_id).sort
|
|
|
|
|
if standard_answer.size == 1 # 老数据需要判断学生答题是否正确, 正确取原题得分,否则是0分
|
|
|
|
|
standard_answer = standard_answer.first.to_s.split("").map(&:to_i).sort
|
|
|
|
@ -523,7 +526,8 @@ class ExerciseQuestionsController < ApplicationController
|
|
|
|
|
:score => @c_score,
|
|
|
|
|
:answer_text => ""
|
|
|
|
|
}
|
|
|
|
|
ExerciseAnswer.create(answer_option)
|
|
|
|
|
ex_answer_create = ExerciseAnswer.new(answer_option)
|
|
|
|
|
ex_answer_create.save
|
|
|
|
|
ex_answer_old = 0
|
|
|
|
|
end
|
|
|
|
|
if ex_obj_score <= 0.0
|
|
|
|
@ -623,7 +627,7 @@ class ExerciseQuestionsController < ApplicationController
|
|
|
|
|
@exercise_current_user.update_attributes(ex_scores)
|
|
|
|
|
end
|
|
|
|
|
comments = params[:comment]
|
|
|
|
|
question_comment = @exercise_question.exercise_answer_comments.first
|
|
|
|
|
question_comment = @exercise_question.exercise_answer_comments&.first
|
|
|
|
|
if question_comment.present?
|
|
|
|
|
comment_option = {
|
|
|
|
|
:comment => comments.present? ? comments : question_comment.comment,
|
|
|
|
@ -633,13 +637,21 @@ class ExerciseQuestionsController < ApplicationController
|
|
|
|
|
question_comment.update_attributes(comment_option)
|
|
|
|
|
@exercise_comments = question_comment
|
|
|
|
|
else
|
|
|
|
|
if ex_answers.present?
|
|
|
|
|
ex_answer_comment_id = ex_answers.first.id
|
|
|
|
|
elsif ex_answer_create.present?
|
|
|
|
|
ex_answer_comment_id = ex_answer_create.id
|
|
|
|
|
else
|
|
|
|
|
ex_answer_comment_id = nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
comment_option = {
|
|
|
|
|
:user_id => current_user.id,
|
|
|
|
|
:comment => comments,
|
|
|
|
|
:score => @c_score,
|
|
|
|
|
:exercise_question_id => @exercise_question.id,
|
|
|
|
|
:exercise_shixun_answer_id => @shixun_a_id.present? ? @shixun_a_id : nil,
|
|
|
|
|
:exercise_answer_id => ex_answers.present? ? ex_answers.first.id : nil
|
|
|
|
|
:exercise_answer_id => ex_answer_comment_id
|
|
|
|
|
}
|
|
|
|
|
@exercise_comments = ExerciseAnswerComment.new(comment_option)
|
|
|
|
|
@exercise_comments.save
|
|
|
|
|