Economics Network CHEER Virtual Edition

Volume 13, Issue 1, 1999

Appendix 1 of Guy Judge's article "The production and use of on-line Web quizzes for economics"
JavaScript used to create the DW quiz question

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Simple Multiple Choice Question</TITLE>
<! BASE HREF="http://www.chem.vt.edu/chem-ed/CHP/scripts/javascript/mcquest1.html">
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide script from old browsers
// This script generates a multiple-choice question on a web page.
// The HTML code is created by the script so the question, answer
// choices, and correct selection can be defined by variables.
// To adapt this script to different questions, change
// the variables directly below these comments. Do not use hard returns.
// If you want more than four choices you must also add more radio buttons.
// For more information see:
// http://www.chem.vt.edu/chem-ed/CHP/scripts/index.html.
// This script may be freely used for non-commercial use as long as
// the following copyright notice remains:
// Copyright 1996 by Brian M. Tissue, all rights reserved.
var header1 = 'Multiple Choice Question'; // First page heading.
var header2 = 'Sample Question'; // Second page heading.
var question1 = 'The Durbin-Watson statistic is used to test for:';
var choice1 = 'Multicollinearity.';
var choice2 = 'Heteroskedasticity.';
var choice3 = 'Normality.';
var choice4 = 'Autocorrelation.';
var correctAnswer = 4; // Indicate the best answer with this variable.
function check(input,x) {
if (x==0) {
alert("Please make a choice.");
} else {
if (x==correctAnswer) {
input.result.value = "Correct Answer!";
} else {
input.result.value = "Please Try Again.";
}
}
}
function cleartext(input) {
input.result.value = ''; // Clear text field.
}
// Initialize answer to 0 to trap no selection.
answer=0;
// Generate the HTML code for the top of the web page.
document.write('<H1 ALIGN="center">',header1,'</H1>');
document.write('<H2 ALIGN="center">',header2,'</H2><HR>');
document.write(question1);
// Generate the HTML code for the radio button choices.
document.write('<FORM NAME="questn1">');
document.write('<OL>');
document.write('<LI><input type="radio" name="answera" onClick="answer=1">',choice1);
document.write('<LI><input type="radio" name="answera" onClick="answer=2">',choice2);
document.write('<LI><input type="radio" name="answera" onClick="answer=3">',choice3);
document.write('<LI><input type="radio" name="answera" onClick="answer=4">',choice4);
document.write('</OL>');
// Generate the HTML code for the buttons and response text area.
document.write('<INPUT TYPE="button" VALUE="Check Answer" onClick="check(this.form,answer)"> ');
document.write('<INPUT TYPE="reset" VALUE=" Clear " onClick="answer=0"> ');
document.write('<INPUT TYPE="text" NAME="result" SIZE="20"> ');
document.write('</FORM>');
document.write('<HR>');
cleartext(document.questn1); // Clear text field on reload.
// End of script.
// End of hide script comment. -->
</SCRIPT>
</HEAD>
<BODY>
<!-- The script-generated HTML code will appear on the web page
as if it was placed here. -->
<H3>Notes</H3>
<UL>
<LI>If there is nothing legible on your screen above these notes,
then your browser does not support JavaScript.
<LI>Netscape 2.0x does not print the script-generated portion of the web page
<LI>Please let me know if you find any bugs. Thanks.
</UL>
<FORM>
<INPUT TYPE="button" VALUE="About MCQuest" onClick="alert('MCQuest1.html
is a demo from the forthcoming book: Using the WWW in Science and Education,
by B. M. Tissue and S. M. Dana') ">
</FORM>
<HR>
<P>Copyright &#169; 1996 by <A HREF="MAILTO:tissue@vt.edu">Brian
M. Tissue</A>, all rights reserved.</P>
<PRE>http://www.chem.vt.edu/chem-ed/CHP/scripts/javascript/mcquest1.html
updated 7/20/96</PRE>
</BODY></HTML>
Top | CHEER Home

Copyright 1989-2007