问卷添加标准答案

This commit is contained in:
huang 2015-11-17 21:13:17 +08:00
parent 9cf5a92a44
commit 02db1b7e14
2 changed files with 6 additions and 2 deletions

View File

@ -125,7 +125,7 @@ class ExerciseController < ApplicationController
for i in 1..params[:question_answer].count
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]
question_option = {
:answer_position => i,
:exercise_choice_id => i,
:answer_text => answer
}
@exercise_questions.exercise_answers.new question_option
@ -139,6 +139,10 @@ class ExerciseController < ApplicationController
@exercise_questions.question_number = params[:quest_num].to_i + 1
end
if @exercise_questions.save
standart_answer = ExerciseStandardAnswer.new
standart_answer.exercise_question_id = @exercise_questions.id
standart_answer.exercise_choice_id = params[:exercise_choice]
standart_answer.save
respond_to do |format|
format.js
end

View File

@ -43,7 +43,7 @@
<div class="cl"></div>
<li class="ur_item">
<label>标准答案<span class="ur_index"></span>&nbsp;&nbsp;&nbsp;</label>
<input placeholder="若标准答案为A在此输入A即可" type="text">
<input name="exercise_choice" placeholder="若标准答案为A在此输入A即可" type="text">
</li>
<div class="cl"></div>
</ul>