O'Reilly logo

JavaScript Application Cookbook by Jerry Bradenbaugh

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. The Online Test

Application FeaturesJavaScript Techniques
• Interactive Multiple Choice Test• Cheating the SRC Attribute
• Thousands of Unique Tests with One Question Set• Shuffling and Array Manipulation
• Comprehensive Results Printout and Ranking• The javascript: Protocol
• Excellent App for Web Surveys and Other Information Gathering 
• Context-Sensitive Explanations of Missed Questions 

The online test application is a boilerplate for just about any multiple-choice test you’d like to administer over the Web. You have significant flexibility in the following ways:

  • You determine the number of test questions the user takes.

  • The questions and answers are randomly jumbled each time the application is loaded or the test is retaken, virtually guaranteeing each user a unique test.

  • You can add or subtract test questions anywhere in the question set; the application adjusts the shuffling, the administration, the grading, and the ranking.

  • You can easily remove the answers from the application to prevent cheating, and forward user answers to the server-side application of your choice for grading.

You can load the application by opening ch02/index.html in your browser. Figure 2.1 shows the opening screen. Now who would have guessed that the test questions included here deal with JavaScript? Try the test. It is a 50-question test that most folks find challenging. Questions cover many JavaScript issues: core JavaScript, client-side and server-side ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required