完成更新功能
This commit is contained in:
parent
f3614999da
commit
02f6b636cd
|
@ -190,9 +190,9 @@ class ExerciseController < ApplicationController
|
|||
@exercise_question.question_score = params[:question_score]
|
||||
# 处理选项:如果选了某个选项,那么则要删除之前的选项
|
||||
if params[:question_answer]
|
||||
# @exercise_question.exercise_choices.each do |answer|
|
||||
# answer.destroy unless params[:question_answer].keys.include? answer.id.to_s
|
||||
# end
|
||||
@exercise_question.exercise_choices.each do |answer|
|
||||
answer.destroy unless params[:question_answer].keys.include? answer.id.to_s
|
||||
end
|
||||
for i in 1..params[:question_answer].count
|
||||
question = @exercise_question.exercise_choices.find_by_id params[:question_answer].keys[i-1]
|
||||
answer = (params[:question_answer].values[i-1].nil? || params[:question_answer].values[i-1].empty?) ? l(:label_new_answer) : params[:question_answer].values[i-1]
|
||||
|
@ -229,7 +229,7 @@ class ExerciseController < ApplicationController
|
|||
end
|
||||
else
|
||||
answer_standart = @exercise_question.exercise_standard_answers.first
|
||||
answer_standart.exercise_choice_id = params[:exercise_choice]
|
||||
answer_standart.exercise_choice_id = @exercise_question.question_type == 1 ? sigle_selection_standard_answer(params[:exercise_choice]) : multiselect_standard_answer(params[:exercise_choice])
|
||||
answer_standart.save
|
||||
end
|
||||
@exercise_question.save
|
||||
|
|
Loading…
Reference in New Issue