问卷得分统计

This commit is contained in:
huang 2015-11-20 15:13:53 +08:00
parent cb3f0d1c97
commit db46e5e4af
2 changed files with 10 additions and 2 deletions

View File

@ -467,7 +467,7 @@ class ExerciseController < ApplicationController
standard_answer = get_user_standard_answer(question, user)
# 问答题有多个答案
if question.question_type == 3
if standard_answer.exercise_choice_id.include?(answer.exercise_choice_id)
if standard_answer.include?(answer.exercise_choice_id)
score += question.question_score unless question.question_score.empty?
end
else
@ -510,7 +510,14 @@ class ExerciseController < ApplicationController
# 获取问题的标准答案
def get_user_standard_answer(question,user)
standard_answer = question.exercise_standard_answers
if question.question_type == 3
standard_answer =[]
question.exercise_standard_answers.each do |answer|
standard_answer << answer.answer_text
end
else
standard_answer = question.exercise_standard_answers
end
standard_answer
end

View File

@ -28,6 +28,7 @@ module ExerciseHelper
answer.join("")
end
#
def fill_standart_answer(params, standart_answer)
params.each do |param|
standart_answer.answer_text = param.value