From f3614999da1927e565b550f79889f0ac4bebf2a6 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 19 Nov 2015 16:38:46 +0800 Subject: [PATCH] gi --- app/controllers/exercise_controller.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index faaae4997..5510b1539 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -213,8 +213,19 @@ class ExerciseController < ApplicationController if params[:exercise_choice] if @exercise_question.question_type == 3 for i in 1..params[:exercise_choice].count - question_standart = @exercise_question.exercise_standard_answers.find_by_id params[:exercise_choice].keys[i] - answer_standart = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1] + # 找到对应的标准答案 + question_standart = @exercise_question.exercise_standard_answers.find_by_id params[:exercise_choice].keys[i-1] + # 标准答案值 + answer_standart = (params[:exercise_choice].values[i-1].nil? || params[:exercise_choice].values[i-1].empty?) ? l(:label_new_answer) : params[:exercise_choice].values[i-1] + if question_standart + question_standart.answer_text = answer_standart + question_standart.save + else + standart_answer_option = { + :answer_text => question_standart + } + @exercise_question.exercise_standard_answers.new standart_answer_option + end end else answer_standart = @exercise_question.exercise_standard_answers.first