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
|
// ce code est pour le graphique que j'ai mis au debut du js
var radarChartData = {
labels: ["ATT", "SPD", "POW"],
datasets: [ {
fillColor: "rgba(0,120,0,0.2)",
strokeColor: "rgba(0,120,0,1)",
pointColor: "rgba(10,10,10,1)",
pointStrokeColor: "#ccc",
pointHighlightFill: "#333",
pointHighlightStroke: "rgba(255,255,0,1)",
data: [
12,15,17] } ] };
window.onload = function(){
var ctx = document.getElementById("radarCanvas").getContext("2d");
window.myRadar = new Chart(ctx).Radar(radarChartData, {
responsive: true,
scaleStartValue: 0
}); }
//code pour le quizz je mets l'essentiel pour ne pas avoir trop de chose
function loadQuestion (questionIndex) {
var q = questions[questionIndex];
var input = document.querySelector('[name="option3"]');
questionEl.textContent = (questionIndex + 1) + '. ' + q.question;
opt1.textContent = q.option1;
opt2.textContent = q.option2;
opt3.textContent = q.option3;
opt4.textContent = q.option4;
}
};
function loadNextQuestion () {
var selectedOption = document.querySelector('input[type=radio]:checked');
if(!selectedOption){
alert('Please select your answer!');
return;
}
var pts=selectedOption.value;
var answer = selectedOption.value;
if(questions[currentQuestion].answer == answer){
selectedOption.checked = false;
currentQuestion++;
if(currentQuestion == totQuestions - 1){
nextButton.textContent = 'Finish';
}
if(currentQuestion == 5){
score2=score;
}
if(currentQuestion == totQuestions){
container.style.display = 'none';
resultCont.style.display = '';
resultCont.textContent = 'Your Score: ' + score+
return;
}
}
loadQuestion(currentQuestion);
}
loadQuestion(currentQuestion); |
Partager