Commit d7a47cf7 authored by Gaston Morales's avatar Gaston Morales

Implementa quantidade de opções dinâmica por pergunta

parent 66468208
......@@ -16,7 +16,7 @@
// maxScore: 2, // número máximo de pontos que podem ser obtidos ao responder a pergunta
//
const quizArrayTeste = [
const quizArrayOLD = [
{
id: "01.01",
type: "noAnswer",
......@@ -55,7 +55,7 @@ const quizArrayTeste = [
type: "answer",
theme: "Conhecimentos",
question: "Which is the most widely spoken language in the world?",
options: [{ text:"Spanish", score:0}, { text:"Mandarin", score:1}, { text:"English", score:0}],
options: [{text:"Spanish", score:0}, {text:"Mandarin", score:1}, {text:"English", score:0}, {text:"Portuguese", score:0}],
correct: "Mandarin",
maxScore: 1,
},
......@@ -64,7 +64,7 @@ const quizArrayTeste = [
type: "answer",
theme: "Conhecimentos",
question: "Which is the only continent in the world without a desert?",
options: [{text:"North America", score:0}, { text:"Asia", score:0}, { text:"Europe", score:1}],
options: [{text:"North America", score:0}, {text:"Asia", score:0}, {text:"Europe", score:1}, {text:"Africa", score:0}],
correct: "Europe",
maxScore: 1,
},
......@@ -73,7 +73,7 @@ const quizArrayTeste = [
type: "answer",
theme: "Conhecimentos",
question: "Who invented Computer?",
options: [{ text:"Charles Babbage", score:1}, { text:"Henry Babbage", score:0}, { text:"Charles Luce", score:0}],
options: [{ text:"Charles Babbage", score:1}, { text:"Henry Babbage", score:0}, { text:"Charles Luce", score:0}, { text:"Charles Openheimer", score:0}, { text:"Charles De Gaulle", score:0}],
correct: "Charles Babbage",
maxScore: 1,
}
......
......@@ -122,12 +122,12 @@ function quizCreator() {
question_DIV.classList.add("question");
question_DIV.innerHTML = i.question;
div.appendChild(question_DIV);
//options - #TODO, automatizar as opções de acordo com a quantidade no array
div.innerHTML += `
<button class="option-div" onclick="checker(this)">${i.options[0].text}</button>
<button class="option-div" onclick="checker(this)">${i.options[1].text}</button>
<button class="option-div" onclick="checker(this)">${i.options[2].text}</button>
`;
//options - get the avaiable options
let options = "";
i.options.forEach( (option) => {
options += `<button class="option-div" onclick="checker(this)">${option.text}</button>`;
});
div.innerHTML += options;
quizContainer.appendChild(div);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment