theshell.ch/quiz/example_quiz_java/main.js
maggicl d7c53b350f team-leader: Added back code for quizzes in separate directory for grading (by Marwan Announ)
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@241 a672b425-5310-4d7a-af5c-997e18724b81
2018-11-16 22:52:06 +00:00

41 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];
}