我必须为学校项目创建一个数学测验。我已经创建了问题和答案。我只是不知道如何让他们一次显示一个问题。当你回答问题时,我必须一一展示。
我还需要使用不同类型的问题,例如多项选择、带有叙述反应的问题、带有图像选择的问题、填空等。
所以我需要帮助,一次显示一个问题,显示记分牌,在下一个问题出现之前向用户显示他们的问题是对还是错,如果他们至少得到 80% 或没有得到通过或失败的消息,并为用户提供最后重新参加测验的选项。
这是我的 HTML
<!DOCTYPE html>
<html>
<head>
<title>Math Quiz!</title>
<link href ="quizCSS.css" rel ="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<script src = "MathQuiz.js" defer></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<h1>Take the Quiz!</h1>
<form id = "quiz" name = "quiz">
<div id="q1">
<p class = "questions">1) What is 2 + 2?</p>
<input id = "textbox" type = "text" name = "question1">
<input type="button" onclick="myAnswer1()" value="Submit Answer">
<script>
var question1 = document.quiz.question1.value;
function myAnswer1() {
if(question1 == 4){
document.write("You are correct!");
}
else{
document.write("Wrong Answer!");
}
}
</script>
</div>
<input type="button" onclick="myFunction1()" value="Start Question 1">
<script>
function myFunction1() {
document.getElementById("q1").style.display = "block";
}
</script>
<div id="q2">
<p class = "questions">2) What is 3 to the power of 2?</p>
<input type = "radio" id = "mc" name = "question2" value = "9"> 9<br>
<input type = "radio" id = "mc" name = "question2" value = "6"> 6<br>
<input type = "radio" id = "mc" name = "question2" value = "3"> 3<br>
</div>
<input type="button" onclick="myFunction2()" value="Start Question 2">
<script>
function myFunction2() {
document.getElementById("q2").style.display = "block";
document.getElementById("q1").style.display = "none";
}
</script>
<div id="q3">
<p class = "questions">3) What is the square root of 25?</p>
<input type = "radio" id = "mc" name = "question3" value = "5"> 5<br>
<input type = "radio" id = "mc" name = "question3" value = "525"> 525<br>
</div>
Cats萌萌
慕的地6264312
相关分类