gem install bundler
bundle install
rails db:create db:migrate
brew install [email protected]
(macos)sudo apt install mongodb
(linux)brew install redis-cli
brew services start mongodb/brew/mongodb-community
(macos)mongod --fork --logpath /var/log/mongod.log
(linux)rails s
redis-server
sidekiq
(or bin/serv s
)
docker-compose build && docker-compose up
docker-compose run app rails db:create db:migrate
one,text
one,img
one,img-text
some,text
some,img
some,img-text
1to1,text
1to1,img
1to1,img-text
1toN,text
1toN,img
1toN,img-text
[
"answer 1 or img url", "[img url, answer text]",
"answer 2 or img url", "[img url, answer text]",
"answer 3 or img url", "[img url, answer text]"
]
{
"up": {
"A": "<block 1 or img url, [img url, block text]>",
"B": "<block 1 or img url, [img url, block text]>",
"C": "<block 1 or img url, [img url, block text]>"
},
"down":{
"0": "<answer 1 or img url, [img url, answer text]>",
"1": "<answer 1 or img url, [img url, answer text]>",
"2": "<answer 1 or img url, [img url, answer text]>"
}
}
Default test has simple count of right answers (one error in 1toN will be 0). User can create own logic of results calculating.
in fact it counts inside ruby because of performance but I want to show principle of counting
local result = 0
for key, _ in pairs(USER_ANSWERS) do
if TRUE_ANSWERS[key] == 'true' then
result = 1
end
end
return result
local result = 0
for key, _ in pairs(user_answers) do
if true_answers[key] == 'true' then
result = 1
end
end
if compare_dates(DATE_NOW, '05/08/2021') == -1 then
return result/2
else
if compare_dates(DATE_NOW, '05/08/2021') == 1 then
return result/3
end
end
return result
In the future, it will be possible to create your own profile variables and use from instead of inline values
Examples was used global varibales (G_DATE_NOW, G_TRUE_ANSWERS, G_ALL_USER_ANSWERS) and helper functions (to_date). More about them in testlance-script
MIT license Copyright (c) 2021 Alexander Storozhenko