make several correct answer

This commit is contained in:
Alexander Popov 2021-07-06 20:36:01 +03:00
parent b8aa4b66af
commit 498ab5502a
3 changed files with 22 additions and 10 deletions

View File

@ -1,11 +1,9 @@
- loading all quest images with loading
- splash (loading) screen
- several correct answer
- change quest animation
- button hover animation
- make docs/
- google: if webpack mode production remove DEBUG code
## done
- loading all quest images with loading [b8aa4b6]
- splash (loading) screen [b8aa4b6]
- add quest progress [aac38ec]

View File

@ -1,10 +1,10 @@
{
"questions": [
{
"question": "Выбери вариант МОСТ",
"question": "Выбери вариант МОСТ или РЕКА",
"image": "image_land.jpg",
"answer": [ "Мост", "Рудник", "Река", "Солнце" ],
"rightAnswer": "мост"
"rightAnswer": [ "мОст", "РЕКА" ]
},
{
"question": "Что горит?",

View File

@ -19,11 +19,25 @@ export function imagePreloader(images, callback) {
}
export function checkAnswer(quest, answer) {
if (quest.rightAnswer.toLowerCase() == answer.toLowerCase()) {
quest.status = true;
if (Array.isArray(quest.rightAnswer)) {
let lowerCaseArray = [];
quest.rightAnswer.forEach(item => lowerCaseArray.push(item.toLowerCase()))
if (lowerCaseArray.includes(answer.toLowerCase())) {
quest.status = true;
}
else {
quest.status = false;
}
}
else {
if (quest.rightAnswer.toLowerCase() == answer.toLowerCase()) {
quest.status = true;
}
else
quest.status = false;
}
else
quest.status = false;
}
export function shuffle(array) {