CS 315 Homework 4: PHP

Assigned: 28 October 2009   Due: 6 November 2009

This homework problem is to be done individually, not in pairs or other groups. I really mean it. Your quiz should look noticably different from every other quiz that is submitted. And from every quiz that was submitted last year. Your completed assignment should be submitted using the Assignment Submission Page. You should submit (in one submission) both the URL of the actual PHP that runs and the URL of a .phps file with your source.

Write a program using a single PHP file that gives the user a five question quiz concerning whatever topic you choose. Initially your PHP program should present the user with a form containing the five questions and giving them the ability to indicate their answers. Once the user has answered at least one question on the quiz and submitted their responses, your PHP program should grade their answers and tell them the result. Specific requirements:

  1. Radio buttons are the most obvious way to ask for input for multiple-choice questions, but other possibilities can also be used, such as menus. Up to 3 of your questions can be of this form, where all of the possible answers are presented to the user and they choose one.
  2. At least 2 of your questions must be of a more open-ended form, where the user types text. When you grade these questions, you should allow a reasonable range of possible responses to be counted as correct. You will need to use regular expressions to match correct responses. Exactly what counts as a correct answer is up to you, but you should try to be flexible. For example, if your question is "Who was the last Dean of the Math/CS Division at Truman?", reasonable answers might include Dr. Morley, Lanny Morley, Dr. Lanny Morley, Prof. Morley, "that nice guy with the big office", but unreasonable answers should not be allowed (including Mrs. Morley or Larry Morley).
  3. Document your code well, so that it is obvious to me what kind of right answers you are trying to accept and what kind of wrong answers you are attempting to reject. If you aren't clear about this, I will make my own assumptions and grade you down if you don't live up to them.
  4. All of your code should be contained in one .php file. Of course, be sure to have a .phps file as well.