From 4e65aaa214c647efbe92945fcd2ae92dde4e292b Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Fri, 21 Jun 2019 17:09:44 +0800 Subject: [PATCH] fix bug --- app/controllers/exercises_controller.rb | 16 +++++++++++----- app/helpers/exercises_helper.rb | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index e2d6110bd..e4204d9d1 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -1023,7 +1023,7 @@ class ExercisesController < ApplicationController if @t_user_exercise_status == 3 get_each_student_exercise(@exercise.id,@exercise_questions,@exercise_current_user_id) end - get_user_answer_status(@exercise_questions,@exercise_current_user_id) + get_user_answer_status(@exercise_questions,@exercise_current_user_id,@exercise,@t_user_exercise_status) rescue Exception => e uid_logger_error(e.message) @@ -1117,7 +1117,7 @@ class ExercisesController < ApplicationController @student_status = 0 else @student_status = 1 - get_user_answer_status(@exercise_questions,@exercise_current_user_id) + get_user_answer_status(@exercise_questions,@exercise_current_user_id,@exercise,get_exercise_status) end end end @@ -1685,11 +1685,17 @@ class ExercisesController < ApplicationController end end - def get_user_answer_status(exercise_questions,user_id) + def get_user_answer_status(exercise_questions,user_id,exercise,exercise_user_status) @question_status = [] @exercise_all_questions = [] + ex_question_random = exercise.question_random question_answered = 0 exercise_questions.each_with_index do |q,index| + if ex_question_random && exercise_user_status != 3 + ques_number = index + 1 + else + ques_number = q.question_number + end if q.question_type != 5 ques_vote = q.exercise_answers.search_exercise_answer("user_id",user_id) else @@ -1725,12 +1731,12 @@ class ExercisesController < ApplicationController end question_status = { :ques_id => q.id, - :ques_number => index+1, #仅问题的显示位置变化,但是问题的question_number 不会变化,与之相关的choice/standard_answer/answer不会变化 + :ques_number => ques_number, #仅问题的显示位置变化,但是问题的question_number 不会变化,与之相关的choice/standard_answer/answer不会变化 :ques_status => ques_status, } question_options = { :question => q, - :ques_number => index+1, + :ques_number => ques_number, } @question_status = @question_status.push(question_status).sort_by {|k| k[:ques_number]} @exercise_all_questions = @exercise_all_questions.push(question_options).sort_by {|k| k[:ques_number]} diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index 95ec0ac24..53b2fa4c1 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -323,6 +323,7 @@ module ExercisesHelper else show_unreview_count = nil end + logger.info("##########__________exercise_end_time__________###############{exercise_end_time}") if exercise_status == 2 && exercise_end_time.present? ex_left_time = how_much_time(exercise_end_time)