CS 315 Homework 3: PHP

Assigned: 24 September 2018   Due: 4 October 2018

This homework problem is to be done individually, not in pairs or other groups. 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, so you might submit the URL of a page that has both of those URLs on it.

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, including which questions they got right and which they got wrong and a summary of their score. 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 the question is "What is the best public liberal arts and sciences university in the Midwest?", reasonable answers include Truman State University, Truman State, TSU, Northeast Missouri State University, etc. . ., but unreasonable answers should not be allowed (e.g., Northwest Missouri State University or Northern Iowa University).
  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. Recall that you can create a .phps file (once) by typing:
    ln -s hw3.php hw3.phps
    
    for example.