BSquared18
09-19-2003, 02:23 PM
Folks,
Below is the Javascript code for a sample multiple-choice test item. It is set up so that if you make the correct choice, the message is green, and if you make a wrong choice, the message is red. It is also set up so that a separate html page is used per test item.
It's intended as a learning tool, not a measurement tool, so keeping track of the student's score isn't important.
I was wondering, however, if there is a way to set the test up so that each time the user tries it, the sequence in which the items occur is randomized. In that way, test order would not become a factor in remembering the answer to a particular item. If possible, I'd like to keep it as a client-side test.
Please Note: I'm not a programmer, so I'd need specific code.
Thanks!
Bill B.
______________________________________________
<html>
<head>
<title>JavaScript Multichoice Question</title>
</head>
<body BGCOLOR=66ccff>
<!-- Start Border -->
<script language="JavaScript">
<!--
if (document.all)
document.body.style.cssText="border: 10 #3300ff solid"
//-->
</script>
<!-- End Border -->
<!-- Start Header Insert -->
<script language="javascript" type="text/javascript"
src="test_header.txt"></script>
<br>
<br>
<!-- End Header Insert -->
<!--NB: The following SCRIPT block is only needed once per page-->
<SCRIPT LANGUAGE="JavaScript">
<!--
function getrad(radob, qns)
{
var value = null
for (var i=0; i<qns;i++){
if (radob[i].checked) {
value = i
break}
}
return value
}
function update(form)
{
var msg = ""
var cherce = getrad(form.answer, form.questions.value)
if(cherce == null)
{msg = "You need to select one of the choices."}
else {
if(cherce == "1")
{
msg = form.comment1.value
} else {
if(cherce == "2")
{
msg = form.comment2.value
} else {
if(cherce == "3")
{
msg = form.comment3.value
} else {
if(cherce == "4")
{
msg = form.comment4.value
} else {
if(cherce == "0")
{
msg = form.comment0.value
}
}
}
}
}
}
<!--THE INFO BETWEEN THE " " BELOW NEEDS TO BE THE SAME AS THE INFO ON THE FEEDBACK COMMENT LINE FOR THE CORRECT RESPONSE. THAT'S HOW YOU GET THE GREEN COLOR.-->
form.Response.value = msg
if (msg.indexOf("Correct! If you head west from California, you'll need a boat until your reach your first island.") != -1)
form.Response.style.color="green";
else
form.Response.style.color="red";
}
// -->
</SCRIPT>
<!--NB: The above SCRIPT block is only needed once per page-->
<p><font face="arial" size="3">What borders California on the west?</font></p>
<form>
<!-- TO USE AN IMAGE AS AN ANSWER, ENTER ITS URL IN THE APPROPRIATE "CHOICE" SPACE. -->
<!-- COPY/PASTE A CORRECT ANSWER RESPONSE. SAME ONE NEEDS TO GO ON LINE 57:
That's right!
Correct!
Right on!
Yes, you're right!
-->
<!-- COPY/PASTE INCORRECT ANSWER RESPONSES:
Sorry, try again.
Afraid not. Try again.
No. Try again.
-->
<input type=hidden name=questions value=5 />
<input name="comment0" type=hidden value="Sorry, but Mexico borders California on the SOUTH. TRY ANOTHER CHOICE." />
<input name="comment1" type=hidden value="Correct! If you head west from California, you'll need a boat until your reach your first island." />
<input name="comment2" type=hidden value="Nope. The Atlantic Ocean is EAST of California. TRY ANOTHER CHOICE." />
<input name="comment3" type=hidden value="Try again. Nevada borders California on the EAST. TRY ANOTHER CHOICE." />
<input name="comment4" type=hidden value="Wrong choice. Oregon is California's NORTHERN neighbor. TRY ANOTHER CHOICE." />
<input name="answer" type="radio" value="0" /><font face="arial" size="3">Mexico<br />
<br>
<input name="answer" type="radio" value="1" /><font face="arial" size="3">Pacific Ocean<br />
<br>
<input name="answer" type="radio" value="2" /><font face="arial" size="3">Altantic Ocean<br />
<br>
<input name="answer" type="radio" value="3" /><font face="arial" size="3">Nevada<br />
<br>
<input name="answer" type="radio" value="4" /><font face="arial" size="3">Oregon</font><br />
<br>
<br>
<input name="upDateBut" type=button
value="Check Your Answer" onClick="update(this.form)" /><!--<input name="redo"
type="Reset" value="Try Again" /> --></p><p>
<textarea name="Response" rows="6" cols="40"
wrap="virtual" style="font-family : Arial; font-weight : bold;"></textarea><br /></p>
</form>
<br>
<!-- Link to the next question -->
<A HREF="xxxx.html"><FONT FACE="arial" SIZE="3" COLOR="#7C0019" onmouseover="this.style.color='#FF796D'"
onmouseout="this.style.color='#7C0019'">
NEXT ITEM</FONT></A>
</body>
</html>
Below is the Javascript code for a sample multiple-choice test item. It is set up so that if you make the correct choice, the message is green, and if you make a wrong choice, the message is red. It is also set up so that a separate html page is used per test item.
It's intended as a learning tool, not a measurement tool, so keeping track of the student's score isn't important.
I was wondering, however, if there is a way to set the test up so that each time the user tries it, the sequence in which the items occur is randomized. In that way, test order would not become a factor in remembering the answer to a particular item. If possible, I'd like to keep it as a client-side test.
Please Note: I'm not a programmer, so I'd need specific code.
Thanks!
Bill B.
______________________________________________
<html>
<head>
<title>JavaScript Multichoice Question</title>
</head>
<body BGCOLOR=66ccff>
<!-- Start Border -->
<script language="JavaScript">
<!--
if (document.all)
document.body.style.cssText="border: 10 #3300ff solid"
//-->
</script>
<!-- End Border -->
<!-- Start Header Insert -->
<script language="javascript" type="text/javascript"
src="test_header.txt"></script>
<br>
<br>
<!-- End Header Insert -->
<!--NB: The following SCRIPT block is only needed once per page-->
<SCRIPT LANGUAGE="JavaScript">
<!--
function getrad(radob, qns)
{
var value = null
for (var i=0; i<qns;i++){
if (radob[i].checked) {
value = i
break}
}
return value
}
function update(form)
{
var msg = ""
var cherce = getrad(form.answer, form.questions.value)
if(cherce == null)
{msg = "You need to select one of the choices."}
else {
if(cherce == "1")
{
msg = form.comment1.value
} else {
if(cherce == "2")
{
msg = form.comment2.value
} else {
if(cherce == "3")
{
msg = form.comment3.value
} else {
if(cherce == "4")
{
msg = form.comment4.value
} else {
if(cherce == "0")
{
msg = form.comment0.value
}
}
}
}
}
}
<!--THE INFO BETWEEN THE " " BELOW NEEDS TO BE THE SAME AS THE INFO ON THE FEEDBACK COMMENT LINE FOR THE CORRECT RESPONSE. THAT'S HOW YOU GET THE GREEN COLOR.-->
form.Response.value = msg
if (msg.indexOf("Correct! If you head west from California, you'll need a boat until your reach your first island.") != -1)
form.Response.style.color="green";
else
form.Response.style.color="red";
}
// -->
</SCRIPT>
<!--NB: The above SCRIPT block is only needed once per page-->
<p><font face="arial" size="3">What borders California on the west?</font></p>
<form>
<!-- TO USE AN IMAGE AS AN ANSWER, ENTER ITS URL IN THE APPROPRIATE "CHOICE" SPACE. -->
<!-- COPY/PASTE A CORRECT ANSWER RESPONSE. SAME ONE NEEDS TO GO ON LINE 57:
That's right!
Correct!
Right on!
Yes, you're right!
-->
<!-- COPY/PASTE INCORRECT ANSWER RESPONSES:
Sorry, try again.
Afraid not. Try again.
No. Try again.
-->
<input type=hidden name=questions value=5 />
<input name="comment0" type=hidden value="Sorry, but Mexico borders California on the SOUTH. TRY ANOTHER CHOICE." />
<input name="comment1" type=hidden value="Correct! If you head west from California, you'll need a boat until your reach your first island." />
<input name="comment2" type=hidden value="Nope. The Atlantic Ocean is EAST of California. TRY ANOTHER CHOICE." />
<input name="comment3" type=hidden value="Try again. Nevada borders California on the EAST. TRY ANOTHER CHOICE." />
<input name="comment4" type=hidden value="Wrong choice. Oregon is California's NORTHERN neighbor. TRY ANOTHER CHOICE." />
<input name="answer" type="radio" value="0" /><font face="arial" size="3">Mexico<br />
<br>
<input name="answer" type="radio" value="1" /><font face="arial" size="3">Pacific Ocean<br />
<br>
<input name="answer" type="radio" value="2" /><font face="arial" size="3">Altantic Ocean<br />
<br>
<input name="answer" type="radio" value="3" /><font face="arial" size="3">Nevada<br />
<br>
<input name="answer" type="radio" value="4" /><font face="arial" size="3">Oregon</font><br />
<br>
<br>
<input name="upDateBut" type=button
value="Check Your Answer" onClick="update(this.form)" /><!--<input name="redo"
type="Reset" value="Try Again" /> --></p><p>
<textarea name="Response" rows="6" cols="40"
wrap="virtual" style="font-family : Arial; font-weight : bold;"></textarea><br /></p>
</form>
<br>
<!-- Link to the next question -->
<A HREF="xxxx.html"><FONT FACE="arial" SIZE="3" COLOR="#7C0019" onmouseover="this.style.color='#FF796D'"
onmouseout="this.style.color='#7C0019'">
NEXT ITEM</FONT></A>
</body>
</html>