theshell.ch/site/pages/fs/java_ab_re.js
annoum ff5e534173 added a version of javascript to implement quiz
git-svn-id: svn+ssh://atelier.inf.usi.ch/home/bevilj/group-1@161 a672b425-5310-4d7a-af5c-997e18724b81
2018-11-13 15:02:30 +00:00

51 lines
1.2 KiB
JavaScript

function check(){
var question1 = document.quiz.question1.value;
var question2 = document.quiz.question2.value;
var question3 = document.quiz.question3.value;
var question4 = document.quiz.question4.value;
var question5 = document.quiz.question5.value;
var correct = 0;
if (question1 == "Is a location to a folder or file in a file system of a Operating System") {
correct++;
}
if (question2 == "Is defined as specifying the location of a file or directory from the root directory(/)") {
correct++;
}
if (question3 == "YES") {
correct++;
}
if (question4 == "") {
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 = 3;
}
if (correct > 0 && correct < 4) {
score = 2;
}
if (correct == 4) {
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];
}
v0dfsew