administer.html
The objects are now in place. Let’s put them to work for us. This is another application where the JavaScript brains reside in the upper frame, and the lower frame is used for interaction. You can break down the application into a series of processes. Table 2.1 lists and describes these processes and includes the JavaScript variables and functions associated with each.
Table 2-1. Test Processes and Associated JavaScript Functions
Process |
Description |
Associated JavaScript |
---|---|---|
Setting the environment |
Declare and initialize global variables, shuffle the question-answer sets. |
variables arrays functions |
Administering the test |
Write each question-answer set to the window, record each user choice. |
functions |
Grading the test |
Compare student answers with correct answers. |
function |
Printing out results |
Print out all answers, right and wrong, to the window along with a ranking. |
function |
Displaying explanations |
Printing and clearing explanations to
|
functions |
Resetting the environment |
Set all necessary variables to their original values. |
variables array functions |
We’ll look at
each of these in a moment. For now, check out the code for
administer.html
in Example ...
Get JavaScript Application Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.