Commit 978c58e1 authored by Gaston Morales's avatar Gaston Morales

Implementa seleção de temas (parcial)

parent df61af35
...@@ -14,11 +14,32 @@ ...@@ -14,11 +14,32 @@
</head> </head>
<body> <body>
<div class="start-screen"> <div class="start-screen">
<h4> <div class="header">
Tela inicial - blá blá blá inicial Tela inicial - blá blá blá inicial
</h4> </div>
<div class="content">
</div>
<button id="start-button">Iniciar</button> <button id="start-button">Iniciar</button>
</div> </div>
<div class="select-theme-screen">
<div class="header">
Tela seleção de temas
</div>
<div class="content">
</div>
<button id="select-theme-button">Selecionar</button>
</div>
<div class="start-theme-screen">
<div class="header">
Tela inicial de tema
</div>
<div class="content">
</div>
<button id="start-theme-button">Iniciar</button>
</div>
<div id="display-container"> <div id="display-container">
<div class="header"> <div class="header">
<div class="number-of-count"> <div class="number-of-count">
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
// maxScore: 2, // número máximo de pontos que podem ser obtidos ao responder a pergunta // maxScore: 2, // número máximo de pontos que podem ser obtidos ao responder a pergunta
// //
const quizArray = [ const quizDataBase = [
{ {
id: "01.01", id: "01.01",
type: "noAnswer", type: "noAnswer",
...@@ -93,7 +93,7 @@ const quizArray = [ ...@@ -93,7 +93,7 @@ const quizArray = [
} }
]; ];
const quizArrayBASE = [ const quizDataBaseComplete = [
{ {
id: "01.01", id: "01.01",
type: "noAnswer", type: "noAnswer",
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
// Configurações // Configurações
const time4Question = 0 // tempo em segundos (+1) para cada pergunta ser respondida, se 0 (zero) não tem tempo const time4Question = 0 // tempo em segundos (+1) para cada pergunta ser respondida, se 0 (zero) não tem tempo
const porTemas = false // perguntas apresentadas agrupadas por tema (true) ou não (false) const porTemas = true // perguntas apresentadas agrupadas por tema (true) ou não (false)
//References //References
let timerOnIcon = document.getElementById("timer-on-icon"); let timerOnIcon = document.getElementById("timer-on-icon");
...@@ -20,17 +20,22 @@ let userScore = document.getElementById("user-score"); ...@@ -20,17 +20,22 @@ let userScore = document.getElementById("user-score");
let themeScore = document.getElementById("theme-score"); let themeScore = document.getElementById("theme-score");
let startScreen = document.querySelector(".start-screen"); let startScreen = document.querySelector(".start-screen");
let startButton = document.getElementById("start-button"); let startButton = document.getElementById("start-button");
let selThemeScreen = document.querySelector(".select-theme-screen");
let selThemeButton = document.getElementById("select-theme-button");
let startThemeScreen = document.querySelector(".start-theme-screen");
let startThemeButton = document.getElementById("start-theme-button");
let questionCount; let questionCount;
let themeCount;
let scoreCount = 0; let scoreCount = 0;
let count = time4Question; let count = time4Question;
let countdown; let countdown;
let selectedThemes = [];
let themeList = []; let themeList = [];
let quizArray = [];
//Restart Quiz //Restart Quiz
restart.addEventListener("click", () => { restart.addEventListener("click", () => {
initial(); startQuiz();
displayContainer.classList.remove("hide");
scoreContainer.classList.add("hide");
}); });
//Next Button //Next Button
...@@ -186,7 +191,9 @@ function checker(userOption) { ...@@ -186,7 +191,9 @@ function checker(userOption) {
themeList[quizArray[questionCount].themeIndex].maxScoreTheme += quizArray[questionCount].maxScore; themeList[quizArray[questionCount].themeIndex].maxScoreTheme += quizArray[questionCount].maxScore;
//clear interval(stop timer) //clear interval(stop timer)
if ( time4Question > 0 ) {
clearInterval(countdown); clearInterval(countdown);
}
//disable all options //disable all options
options.forEach((element) => { options.forEach((element) => {
element.disabled = true; element.disabled = true;
...@@ -220,11 +227,38 @@ function themeListCreator() { ...@@ -220,11 +227,38 @@ function themeListCreator() {
}); });
} }
//initial setup function runQuiz() {
function initial() {
quizContainer.innerHTML = ""; quizContainer.innerHTML = "";
questionCount = 0; questionCount = 0;
scoreCount = 0; quizCreator();
quizDisplay(questionCount);
}
// Processes que select theme screen
startThemeButton.addEventListener("click", () => {
startThemeScreen.classList.add("hide");
displayContainer.classList.remove("hide");
runQuiz();
});
// Shows theme start screen
function themeDisplay(themeCount) {
// Carrega o html do tema para a tela
// questionCount = 0
// Filtra o quizArray para as perguntas do tema
// Mostra a tela do tema
startThemeScreen.classList.remove("hide");
}
// Processes que select theme screen
selThemeButton.addEventListener("click", () => {
selThemeScreen.classList.add("hide");
themeCount = 0;
themeDisplay(themeCount)
});
//initial setup
function initial() {
// if time to answer question is enabled // if time to answer question is enabled
if ( time4Question > 0 ) { if ( time4Question > 0 ) {
count = time4Question; count = time4Question;
...@@ -239,21 +273,48 @@ function initial() { ...@@ -239,21 +273,48 @@ function initial() {
timeLeft.classList.add("hide"); timeLeft.classList.add("hide");
timerOffIcon.classList.remove("hide"); timerOffIcon.classList.remove("hide");
} }
scoreCount = 0;
// Renomear no nome do array quizArray do perguntas.js para quizDataBase -- ele continua CONST
quizArray = quizDataBase;
// Cria a lista de temas (completa)
themeList = []; themeList = [];
themeListCreator(); themeListCreator();
quizCreator();
quizDisplay(questionCount); // Se for "por Tema", apresenta a tela de seleção de temas
// para cada tema selecionado, mostra tela introdutória do tema
// , filtra as questões do banco buscando as questões do tema colocando em quizArray
// , limpa quizContainer e zera questionCount
// , chama quizCreator e quizDisplay
// Se não for "por Tema"... segue como está
//
if ( porTemas ) {
// mostra tela seleção de temas e
selThemeScreen.classList.remove("hide");
}
else {
displayContainer.classList.remove("hide");
runQuiz();
}
} }
//when user click on start button //when user click on start button
startButton.addEventListener("click", () => { startButton.addEventListener("click", () => {
startScreen.classList.add("hide"); startScreen.classList.add("hide");
displayContainer.classList.remove("hide");
initial(); initial();
}); });
//hide quiz and display start screen function startQuiz() {
window.onload = () => {
startScreen.classList.remove("hide"); startScreen.classList.remove("hide");
displayContainer.classList.add("hide"); displayContainer.classList.add("hide");
selThemeScreen.classList.add("hide");
startThemeScreen.classList.add("hide");
scoreContainer.classList.add("hide");
}
//hide quiz and display start screen
window.onload = () => {
startQuiz();
}; };
...@@ -7,7 +7,22 @@ ...@@ -7,7 +7,22 @@
body { body {
background-color: #0a69ed; background-color: #0a69ed;
} }
.start-screen, .start-screen,
.select-theme-screen,
.start-theme-screen {
background-color: #ffffff;
padding: 3.1em 1.8em;
width: 80%;
max-width: 37.5em;
margin: 0 auto;
position: absolute;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
border-radius: 0.6em;
}
.score-container { .score-container {
position: absolute; position: absolute;
top: 0; top: 0;
...@@ -32,15 +47,20 @@ button { ...@@ -32,15 +47,20 @@ button {
outline: none; outline: none;
cursor: pointer; cursor: pointer;
} }
#start-button, #start-button,
#select-theme-button,
#start-theme-button,
#restart { #restart {
font-size: 1.3em; font-size: 1.3em;
padding: 0.5em 1.8em; padding: 0.5em 1.8em;
border-radius: 0.2em; border-radius: 0.2em;
} }
#restart { #restart {
margin-top: 0.9em; margin-top: 0.9em;
} }
#display-container { #display-container {
background-color: #ffffff; background-color: #ffffff;
padding: 3.1em 1.8em; padding: 3.1em 1.8em;
......
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