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