-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
120 lines (105 loc) · 3.29 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
const caixaPrincipal = document.querySelector('.caixa-principal');
const caixaPergunta = document.querySelector('.caixa-perguntas');
const caixaAlternativas = document.querySelector('.caixa-alternativas');
const caixaResultado = document.querySelector('.caixa-resultado');
const textoResultado = document.querySelector('.texto-resultado');
const pergunta = [
{
enunciado: "pergunta 1",
alternativas: [
{
texto:"voçê descobriu que recentemente o racismo e a discriminação vem aumentando?",
afirmacao: "Nos cenário atual, o preconceito e as práticas discriminação "
},
{
texto:"Mais voçê não liga para esse assunto porque voçê acha que isso não e importante para voçê?",
afirmacao: "resultado 2"
}
]
},
{
enunciado: "",
alternativas: [
{
texto:"Aos 30 anos voçê viu pessoas fazendo racismo e discriminação pela cor da pele?",
afirmacao: "resultado3"
},
{
texto:"Aos 33 anos voçê decidiu se juntar a um grupo contra o racismo e a discriminação?",
afirmacao: "resultado 4"
}
]
},
{
enunciado: "Pergunta 3",
alternativas: [
{
texto:"Alternativas 5",
afirmacao: "resultado 5"
},
{
texto:"Alternativas 6",
afirmacao: "resultado 6"
}
]
},
{
enunciado: "Pergunta 4",
alternativas: [
{
texto:"Alternativas 5",
afirmacao: "resultado 5"
},
{
texto:"Alternativas 6",
afirmacao: "resultado 6"
}
]
},
{
enunciado: "Pergunta 5",
alternativas: [
{
texto:"Alternativas 5",
afirmacao: "resultado 5"
},
{
texto:"Alternativas 6",
afirmacao: "resultado 6"
}
]
},
]
let atual = 0;
let perguntaAtual;
let historiaFinal = ""
function mostraPergunta() {
if (atual >= pergunta.length){
mostraResultado();
return;
}
perguntaAtual = pergunta[atual];
caixaPergunta.textContent = pergunta.enunciado;
caixaAlternativas.textContent="";
mostraAlternativas();
}
function mostraAlternativas(){
for(const alternativa of perguntaAtual.alternativas){
const botaoAlternativas = document.createElement("button");
botaoAlternativas.textContent = alternativa.texto;
botaoAlternativas.addEventListener("click", () => respostaSelacionada(alternativa))
caixaAlternativas.appendChild(botaoAlternativas)
}
}
function respostaSelacionada(opcaoSelacionada){
const afirmacao = opcaoSelacionada.afirmacao;
historiaFinal += afirmacao + " "
atual++;
mostraPergunta();
}
function mostraResultado(){
caixaPergunta.textContent =" Inicio do texto..."
textoResultado.textContent = historiaFinal;
caixaAlternativas.textContent = "";
}
mostraPergunta();