区分答案大小写

This commit is contained in:
huang 2015-11-18 14:31:35 +08:00
parent 3efae6bde2
commit de17ffa605
2 changed files with 14 additions and 4 deletions

View File

@ -146,7 +146,7 @@ class ExerciseController < ApplicationController
if @exercise_questions.save if @exercise_questions.save
standart_answer = ExerciseStandardAnswer.new standart_answer = ExerciseStandardAnswer.new
standart_answer.exercise_question_id = @exercise_questions.id standart_answer.exercise_question_id = @exercise_questions.id
@exercise_questions.question_type == 3 ? standart_answer.answer_text = translate_standard_answer(params[:exercise_choice]) : standart_answer.exercise_choice_id = translate_standard_answer(params[:exercise_choice]) @exercise_questions.question_type == 3 ? standart_answer.answer_text = translate_standard_answer(params[:exercise_choice]) : standart_answer.exercise_choice_id = sigle_selection_standard_answer(params[:exercise_choice])
standart_answer.save standart_answer.save
respond_to do |format| respond_to do |format|
format.js format.js
@ -205,7 +205,6 @@ class ExerciseController < ApplicationController
end end
end end
#发布问卷 #发布问卷
def publish_excercise def publish_excercise
@exercise.exercise_status = 2 @exercise.exercise_status = 2

View File

@ -2,8 +2,19 @@
module ExerciseHelper module ExerciseHelper
# 单选 # 单选
def translate_standard_answer(params) def sigle_selection_standard_answer(params)
answer = params.ord - 64 size = params.ord - 64
# 输入的为小写字母答案
if size > 0
answer = params.ord - 96
else
answer = params.ord
end
end
# 多选
def multiselect_standard_answer(params)
answer = params.ord
end end
#判断用户是否已经提交了问卷 #判断用户是否已经提交了问卷