1 Assignment Task
2 Language Comparison
3 Program Header
4 Quasi-Quoting
5 File I/ O
6 send/ suspend
7 Testing
8 Handin

Assignment 8, CSC430, Winter 2011

1 Assignment Task

This is a pair programming assignment. You may work with the same partner you worked with last time, or a different one. It’s up to you. As always, you need to make sure that you understand all the text and code in the project.

The assignment is similar to the last; you must use the Racket Web Server to create a quiz server. In this assignment, though, your server will be acting as an interpreter for a (very simple) language of quizzes. In particular, the language has three forms.

An element can be:
  1. A question, containing question text, answer specification, and number of points,

  2. A sequence, containing a list of elements, and

  3. A choice, containing a list of elements

(You’ll be translating this definition directly into a define-type, as on prior assignments.)

The new element here is the "choice": in order to administer a choice, the quiz engine will randomly choose one of the elements. A sequence is administered by administering each of the quiz elements in order. Finally, a question is administered by asking the question of the user. After the quiz has been completely evaluated, the user should see a page showing how many points he or she scored, followed by (at a minimum) the average score of all users on the quiz. Feel free to provide a more complete statistical analysis.

I’m going to leave the precise formatting of the answer specification open. You might choose to use a simple string for comparison, a regular expression to provide some flexibility, or possibly something even more elaborate.

You’ll need to formulate a define-type for quizzes, following the specification provided above.

If a quiz doesn’t have the same number of points along all paths, that’s not a very fair quiz. Develop the fair? predicate that accepts a quiz and returns true when the same number of points are available along all paths through the quiz.

Next, develop the quiz-run function that runs a quiz. On startup, your program should call quiz-run on an example quiz.

2 Language Comparison

Include a readme block (commented out, of course) in your submission. In it, you must contrast 3-5 language features that you used in this assignment to the language features encountered in the Raw Web assignments. Even if the members of your team used different languages in the Raw Web assignment, all of you are still responsible for understanding the presented response. The analysis should be 2 paragraphs or fewer. Grammar and word choice matter. Please don’t feel that you need to flatter Racket.

3 Program Header

In order to use PLAI-style define-types and tests, you’ll need to begin your programs like this:

  #lang web-server/insta
  (require plai/datatype
           racket/date
           plai/test-harness)
  
  (define (start initial-request)
  
      ...)

... rest of program goes here...

You may also be interested in memorizing the keystroke (on the Mac it’s ’Cmd-K’) that kills the execution of the program, and also halts the web server.

4 Quasi-Quoting

You may notice sample servlets quoting lists with ` instead of . This is called quasiquoting, as opposed to quoting. Quasiquoting lets you evaluate specific elements of a quasiquoted expression instead of directly returning the expression. To force evaluation of an element in a quasiquoted expression, prefix the element with a comma. For example, to generate the list '(1 2 3 4) you may write `(1 2 ,(+ 0 3) 4). Quasiquoting is a convenient way to insert dynamic elements into HTML templates. If you want more information or examples, the Scheme standard is a good place to look.

5 File I/O

You should not need to use any File I/O for this assignment. In particular, it’s all right with me if killing the server destroys the existing blog entries.

6 send/suspend

You’ll want to use send/suspend and send/forward to send web pages to the user, and extract-binding/single to pull the fields out of the response. You can read more about these forms using DrScheme’s help desk.

7 Testing

You do not need to formulate test cases for functions containing the I/O primitives send/suspend and send/forward. However, you should make these functions as small as possible. The rest of the program should be tested as usual. Solutions that pile tons of horrible muck into these functions will not receive full credit.

8 Handin

Hand in this program as program 8, using the standard handin mechanism.