本文介绍了如何显示幻灯片测验的正确分数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I have a multiple choice quiz for speed test. Each question appears
after every five seconds and then the next, like a slide show. The
timer runs simultaneously. The last page that appears is score summary.
I can't figure out how to show the correct score though I have written
codes for it. The summary page shows the score 0 each time.
Could you please help me. Thanks a lot.
我的尝试:
What I have tried:
<body>
<div id="container">
<text> Time : <text id="time001"> 30 </text> </text> <br />
<h1> Speed Test </h1>
<button id="btn" onclick="begin001()"> Start </button>
<form id="form">
<div class="speed">
<h2> Q.1 Who is the Prime Minister of India? </h2>
<label> <input type="radio" name="q1" value="a" id="q1a"> Atal
Bihari </label> <br>
<label> <input type="radio" name="q1" value="b" id="q1b">
Narendra Modi </label> <br>
<label> <input type="radio" name="q1" value="c" id="q1c">
Rahul Gandhi </label> <br>
<label> <input type="radio" name="q1" value="d" id="q1d">
Soniya Gandhi </label> <br>
</div>
<div id="summary">
<p> Score Summary </p>
</div>
</form>
</div>
</body>
```
$('document').ready(function() {
$(function() {
$("#btn").click(function() {
var interval = setInterval(function() {
$("#form > div:first")
.fadeIn(500)
.next()
.fadeOut(500)
.end()
.appendTo("#form");
}, 5000);
```
window.setTimeout(function() {
clearInterval(interval);
}, 35000);
});
});
});
```
function begin001() {
c = 30;
}
var a = 0;
a++;
var b = 0;
b++;
```
function timer001() {
c = c - 1;
if (c < 30)
{
time001.innerHTML = c;
}
if (c < 1)
{
window.clearInterval(update);
}
}
update = setInterval("timer001()", 1000);
```
var q1 = document.getElementById("form")["q1"].value;
var q2 = document.getElementById("form")["q2"].value;
var q3 = document.getElementById("form")["q3"].value;
var q4 = document.getElementById("form")["q4"].value;
var q5 = document.getElementById("form")["q5"].value;
```
var answers = ["b", "c", "a", "d", "c"];
var score = 0;
var total = 5;
if (q1 == answers[0]) {
score++
}
if (q2 == answers[1]) {
score++
}
if (q3 == answers[2]) {
score++
}
if (q4 == answers[3]) {
score++
}
if (q5 == answers[4]) {
score++
}
```
var result = document.getElementById("summary");
result.innerHTML = "<p><p> You scored "+score+" out of "+total+" </p>
</p>";
```
Expected: You scored 2 out of 5.
Currently showing: You scored 0 out of 5.'
推荐答案
这篇关于如何显示幻灯片测验的正确分数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!