This commit is contained in:
huang 2015-11-18 18:28:17 +08:00
parent 1d5ae6d561
commit 1606e9ddab
2 changed files with 7 additions and 1 deletions

View File

@ -136,6 +136,7 @@ class ExerciseController < ApplicationController
:question_score => params[:question_score]
}
@exercise_questions = @exercise.exercise_questions.new option
# params[:question_answer] 题目选项
if params[:question_answer]
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]
@ -154,6 +155,7 @@ class ExerciseController < ApplicationController
@exercise_questions.question_number = params[:quest_num].to_i + 1
end
if @exercise_questions.save
# params[:exercise_choice] 标准答案参数
standart_answer = ExerciseStandardAnswer.new
standart_answer.exercise_question_id = @exercise_questions.id
if @exercise_questions.question_type == 1
@ -161,7 +163,7 @@ class ExerciseController < ApplicationController
elsif @exercise_questions.question_type == 2
standart_answer.exercise_choice_id = multiselect_standard_answer(params[:exercise_choice])
else
standart_answer.answer_text = sigle_selection_standard_answer(params[:exercise_choice])
standart_answer.answer_text = fill_standart_answer(params[:exercise_choice])
end
standart_answer.save
respond_to do |format|

View File

@ -27,6 +27,10 @@ module ExerciseHelper
answer.to_i
end
def fill_standart_answer(params)
end
#判断用户是否已经提交了问卷
def has_commit_exercise?(exercise_id, user_id)
pu = ExerciseUser.find_by_exercise_id_and_user_id(exercise_id, user_id)