From 2f67425e2a4675c2bd5a1e47f42b388bc64d9f93 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Tue, 20 Aug 2019 18:59:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E7=9A=84=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E5=92=8C=E6=A0=87=E5=87=86=E7=AD=94=E6=A1=88?= =?UTF-8?q?=E7=9A=84=E7=AE=97=E5=88=86=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/exercises_helper.rb | 6 ++++++ ...190820102040_change_exercise_1930_position.rb | 16 ++++++++++++++++ lib/tasks/excellent_course_exercise.rake | 7 +++++++ 3 files changed, 29 insertions(+) create mode 100644 db/migrate/20190820102040_change_exercise_1930_position.rb diff --git a/app/helpers/exercises_helper.rb b/app/helpers/exercises_helper.rb index ace9e062e..baf594a42 100644 --- a/app/helpers/exercises_helper.rb +++ b/app/helpers/exercises_helper.rb @@ -403,6 +403,12 @@ module ExercisesHelper end user_answer_content = answer_choice_array.sort standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 + + #TODO: 旧版多选题的标准答案是放在一个里面的,新版又做成了一个题有多个标准答案(exercise_choice_id存放的是标准答案的位置..) + if q.question_type == 1 && standard_answer.size == 1 + standard_answer = standard_answer.first.to_s.split("").map(&:to_i) + end + if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 if standard_answer.size > 0 q_score_1 = q.question_score diff --git a/db/migrate/20190820102040_change_exercise_1930_position.rb b/db/migrate/20190820102040_change_exercise_1930_position.rb new file mode 100644 index 000000000..601fb4eed --- /dev/null +++ b/db/migrate/20190820102040_change_exercise_1930_position.rb @@ -0,0 +1,16 @@ +class ChangeExercise1930Position < ActiveRecord::Migration[5.2] + def change + + #正式版的1930试卷的位置出现问题 + # + ex = Exercise.find_by(id:1930) + ex.exercise_questions.each_with_index do |q,index| + q.update_attributes(question_number:index+1) + end + + ex_q_bank = ex.exercise_bank.exercise_bank_questions + ex_q_bank.each_with_index do |q,index| + q.update_attributes(question_number:index+1) + end + end +end diff --git a/lib/tasks/excellent_course_exercise.rake b/lib/tasks/excellent_course_exercise.rake index d337fbd73..0d8875806 100644 --- a/lib/tasks/excellent_course_exercise.rake +++ b/lib/tasks/excellent_course_exercise.rake @@ -103,6 +103,13 @@ namespace :excellent_course_exercise do end user_answer_content = answer_choice_array.sort standard_answer = q.exercise_standard_answers.pluck(:exercise_choice_id).sort #该问题的标准答案,可能有多个 + + #TODO: 旧版多选题的标准答案是放在一个里面的,新版又做成了一个题有多个标准答案(exercise_choice_id存放的是标准答案的位置..) + + if q.question_type == 1 && standard_answer.size == 1 + standard_answer = standard_answer.first.to_s.split("").map(&:to_i) + end + if user_answer_content == standard_answer #答案一致,多选或单选才给分,答案不对不给分 if standard_answer.size > 0 q_score_1 = q.question_score