2015-11-13 16:40:39 +08:00
|
|
|
# encoding: utf-8
|
|
|
|
module ExerciseHelper
|
2015-11-17 11:25:17 +08:00
|
|
|
|
2015-11-18 13:55:42 +08:00
|
|
|
# 单选
|
|
|
|
def translate_standard_answer(params)
|
|
|
|
answer = params.ord - 64
|
|
|
|
end
|
|
|
|
|
2015-11-17 11:25:17 +08:00
|
|
|
#判断用户是否已经提交了问卷
|
2015-11-17 15:20:59 +08:00
|
|
|
def has_commit_exercise?(exercise_id, user_id)
|
2015-11-18 10:49:57 +08:00
|
|
|
pu = ExerciseUser.find_by_excercise_id_and_user_id(exercise_id, user_id)
|
2015-11-17 11:25:17 +08:00
|
|
|
if pu.nil?
|
|
|
|
false
|
|
|
|
else
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-18 10:49:57 +08:00
|
|
|
def convert_to_char(str)
|
|
|
|
result = ""
|
|
|
|
if str.count >= 1
|
|
|
|
for i in 0 .. str.count do i
|
|
|
|
result += (str[i].to_i + 64).chr
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-13 16:40:39 +08:00
|
|
|
end
|