问卷添加标准答案
This commit is contained in:
parent
9cf5a92a44
commit
02db1b7e14
|
@ -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
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<div class="cl"></div>
|
||||
<li class="ur_item">
|
||||
<label>标准答案<span class="ur_index"></span>: </label>
|
||||
<input placeholder="若标准答案为A,在此输入A即可" type="text">
|
||||
<input name="exercise_choice" placeholder="若标准答案为A,在此输入A即可" type="text">
|
||||
</li>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue