9cc8cd3216
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@115 a672b425-5310-4d7a-af5c-997e18724b81
40 lines
910 B
JavaScript
40 lines
910 B
JavaScript
function check(){
|
|
|
|
var question1 = document.quiz.question1.value;
|
|
var question2 = document.quiz.question2.value;
|
|
var question3 = document.quiz.question3.value;
|
|
var correct = 0;
|
|
|
|
|
|
if (question1 == "group1") {
|
|
correct++;
|
|
}
|
|
if (question2 == "A type of..") {
|
|
correct++;
|
|
}
|
|
if (question3 == "A type of..") {
|
|
correct++;
|
|
}
|
|
|
|
var pictures = ["img/win.gif", "img/meh.jpeg", "img/lose.gif"];
|
|
var messages = ["Great job!", "That's just okay", "You really need to do better"];
|
|
var score;
|
|
|
|
if (correct == 0) {
|
|
score = 2;
|
|
}
|
|
|
|
if (correct > 0 && correct < 3) {
|
|
score = 1;
|
|
}
|
|
|
|
if (correct == 3) {
|
|
score = 0;
|
|
}
|
|
|
|
document.getElementById("after_submit").style.visibility = "visible";
|
|
|
|
document.getElementById("message").innerHTML = messages[score];
|
|
document.getElementById("number_correct").innerHTML = "You got " + correct + " correct.";
|
|
document.getElementById("picture").src = pictures[score];
|
|
}
|