Merge branch 'sw_new_course' of http://repository.trustie.net/xianbo/trustie2 into sw_new_course
This commit is contained in:
commit
d83e2e36ae
|
@ -146,7 +146,13 @@ 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 = sigle_selection_standard_answer(params[:exercise_choice])
|
if @exercise_questions.question_type == 1
|
||||||
|
standart_answer.exercise_choice_id = sigle_selection_standard_answer(params[:exercise_choice])
|
||||||
|
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])
|
||||||
|
end
|
||||||
standart_answer.save
|
standart_answer.save
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
|
|
|
@ -4,7 +4,7 @@ module ExerciseHelper
|
||||||
# 单选
|
# 单选
|
||||||
def sigle_selection_standard_answer(params)
|
def sigle_selection_standard_answer(params)
|
||||||
size = params.ord - 96
|
size = params.ord - 96
|
||||||
if size > 0
|
if size > 0 # 小写字母答案
|
||||||
answer = params.ord - 96
|
answer = params.ord - 96
|
||||||
else
|
else
|
||||||
answer = params.ord - 64
|
answer = params.ord - 64
|
||||||
|
@ -13,7 +13,18 @@ module ExerciseHelper
|
||||||
|
|
||||||
# 多选
|
# 多选
|
||||||
def multiselect_standard_answer(params)
|
def multiselect_standard_answer(params)
|
||||||
answer = params.ord
|
size = params.ord - 96
|
||||||
|
answer = ""
|
||||||
|
if size > 0 # 小写字母答案
|
||||||
|
for i in 0..(params.length-1)
|
||||||
|
answer += (params[i].ord - 96).to_s
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for i in 0..(params.length-1)
|
||||||
|
answer += (params[i].ord - 64).to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
answer.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
#判断用户是否已经提交了问卷
|
#判断用户是否已经提交了问卷
|
||||||
|
|
Loading…
Reference in New Issue