多选顺序按小到大排序

This commit is contained in:
huang 2015-11-20 10:05:34 +08:00
parent d583ca1d70
commit 21694daa59
1 changed files with 5 additions and 4 deletions

View File

@ -14,17 +14,18 @@ module ExerciseHelper
# 多选
def multiselect_standard_answer(params)
size = params.ord - 96
answer = ""
answer = []
if size > 0 # 小写字母答案
for i in 0..(params.length-1)
answer += (params[i].ord - 96).to_s
answer << (params[i].ord - 96).to_s
end
else
for i in 0..(params.length-1)
answer += (params[i].ord - 64).to_s
answer << (params[i].ord - 64)
end
end
answer.to_i
answer = answer.sort
answer.join("")
end
def fill_standart_answer(params, standart_answer)