|
|
JavaScript Demos:
|
|
Please try this simple Internet quiz. Discussion.This example is an easily modified example of a quiz. The quiz layout is done as an HTML Form. Checking the answers is completely done with JavaScript. No CGI script on the server is involved to do the checking and the results are not recorded. To add a fourth question, you need to modify both the JavaScript in the HTML HEAD and to add a Form in the HTML BODY, following the code and comments. Specifically, at each place in the JavaScript there is an "//Addition" comment, that should be replaced as:
I've closely followed an example by Doug Popeney, but omitting some of his annotation and changing the quiz specifics. His JavaScript examples Web page is at: http://www.calpoly.edu/~dpopeney/javascript.html. There are other ways this could be done, e.g., the questions and answers could be stored in arrays and for a quiz substantially longer than this example, that would make the JavaScript code somewhat more compact. There is a similar quiz example in the Heinle [1997] book, pp. 194-201, that uses an array. You could also design the form and script so that the student must succeed on each question before they are allowed to proceed to the next question. ;^) Note - at this time the computation of the correct score is not working. |
|