Creating a Multiple Choice Quiz System with CGI

 in
Designing quizzes the easy way using CGI.
The Initial HTML

Now that we have defined QuizQuestions, askquestion.pl and checkanswer.pl, all that remains is to create an HTML file that acts as the initial entrance into the quiz.

<HTML>
<Head>
<Title>Play our quiz!</Title>
</Head>
<Body>
<H1>Play our quiz!</H1>
<P>You can play our cranberry quiz by clicking
<a href="/cgi-bin/askquestion.pl?cranberries">
here</a>.</P>
</Body>
</HTML>

Notice that the URL leading to the initial question must have a quiz name appended to it in the query string. Other than that, though, this is a simple HTML document.

This quiz appears to work pretty well so far, although there are certainly features that you might add—such as a scoreboard, better error-checking when reading the quiz file, or a system that ensures that users don't see the same question twice.

But more important than any of these is the fact that while the format of the question file is easy for programmers to understand, non-programmers who would like to add, delete or modify questions might find the format confusing. Next month we will work on making this system more author-friendly, so that non-programmers can modify entries in the question file via an HTML form.

Reuven M. Lerner has been playing with the Web since early 1993, when it seemed more like a fun toy than the World's Next Great Medium. He currently works as a independent Internet and Web consultant from his apartment in Haifa, Israel. When not working on the Web or volunteering in informal educational programs, he enjoys reading on just about any subject, but particularly politics and philosophy, cooking, solving crossword puzzles and hiking. You can reach him at reuven@the-tech.mit.edu or reuven@netvision.net.il.

______________________

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix