You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
trustieforge/app/helpers/exercise_helper.rb

57 lines
1.1 KiB

# encoding: utf-8
module ExerciseHelper
# 单选
def sigle_selection_standard_answer(params)
size = params.ord - 96
if size > 0
answer = params.ord - 96
else
answer = params.ord - 64
end
end
# 多选
def multiselect_standard_answer(params)
answer = params.ord
end
#判断用户是否已经提交了问卷
def has_commit_exercise?(exercise_id, user_id)
pu = ExerciseUser.find_by_exercise_id_and_user_id(exercise_id, user_id)
if pu.nil?
false
else
true
end
end
def convert_to_char(str)
result = ""
length = str.length
unless str.nil?
if length === 1
result += (str.to_i + 64).chr
return result
elsif length > 1
for i in 0...length
result += (str[i].to_i + 64).chr
end
return result
end
end
return result
end
def get_current_score exercise
score = 0
unless exercise.nil?
exercise.exercise_questions.each do |exercise_question|
score += exercise_question.question_score
end
return score
end
return score
end
end