Creating a Multiple Choice Quiz System with CGI
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 firstname.lastname@example.org or email@example.com.
- The Tiny Internet Project, Part I
- Machine Learning with Python
- Free Today: September Issue of Linux Journal (Retail value: $5.99)
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Bitcoin on Amazon! Sort of...
- Epiq Solutions' Sidekiq M.2
- Android Browser Security--What You Haven't Been Told
- Securing the Programmer
- The Many Paths to a Solution
Pick up any e-commerce web or mobile app today, and you’ll be holding a mashup of interconnected applications and services from a variety of different providers. For instance, when you connect to Amazon’s e-commerce app, cookies, tags and pixels that are monitored by solutions like Exact Target, BazaarVoice, Bing, Shopzilla, Liveramp and Google Tag Manager track every action you take. You’re presented with special offers and coupons based on your viewing and buying patterns. If you find something you want for your birthday, a third party manages your wish list, which you can share through multiple social- media outlets or email to a friend. When you select something to buy, you find yourself presented with similar items as kind suggestions. And when you finally check out, you’re offered the ability to pay with promo codes, gifts cards, PayPal or a variety of credit cards.Get the Guide