From 87e7a51278a847747f1dbf841d193dfcee4ff390 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 19 Nov 2015 17:36:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index a48298a83..18248331c 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -213,6 +213,10 @@ class ExerciseController < ApplicationController # 更新标准答案 if params[:exercise_choice] if @exercise_question.question_type == 3 + # 删除不合理的选项 + @exercise_question.exercise_standard_answers.each do |answer| + answer.destroy unless params[:exercise_choice].keys.include? answer.id.to_s + end for i in 1..params[:exercise_choice].count # 找到对应的标准答案 question_standart = @exercise_question.exercise_standard_answers.find_by_id params[:exercise_choice].keys[i-1]