|
home—lects—exams—hws
D2L—breeze (snow day)
You have been hired to help develop the game Okaymon -- a crowdsourced game of evolving monsters! You need to develop a web form with the information below; when the form is submitted, the user is shown a page which simply re-caps the submitted information.
This is one homework, but to keep you focused it will have three stages:
Write the following functions in php:
A function
We'll use this to make our testing more convenient.
For example, your
Two other requirements, to make this function even more useful:
Deliverable: on D2L, and hardcopy: the files utils.php, utils-test.php, and silly-page.php. The latter must be viewable on-line at: https://php.radford.edu/~yourUserID/itec325/hw02/silly-page.php. That file should just be a simple page which calls your others, so that you can visually confirm that the produced html for 1 & 2 render as expected. You can add on to the utils.php from your hw01, and continue to add useful utility functions over the course of the semester and your life.
Your forms don't need to look exactly like the above, but should have the same information
(and look respectable).
No validation is required for this part, but
when you print the results you must sanitize the html:
the information must render as it was entered.
In order to test your form, you must also have three files
“okaymon-edit-handle-demo-N” (for N = 0,1,2)
which populate
Of course, you should call functions from part (a) appropriately, and write any additional functions (and tests) as appropriate. You should use arrays to hold the various energy-types. (If we add twenty more types, you shouldn't need to change anything but that array, and everything else should work.)
To test your files, you should have at least three
Deliverable: Your form must be viewable on-line at: https://php.radford.edu/~yourUserID/itec325/hw02/okaymon-edit-form.php. Submit hardcopy of the form and the form-handler (named “okaymon-edit-handle.php”), and at least three “okaymon-edit-handle-demo-N” files. On D2L submit all your files (as individual files, not a .tar).
We'll add server-side input-validation. You must check for:
Include unit-tests for each function you write, of course. Also, add at least one more “form-demo” page, which has at least one error for each input field.
The page which is produced should be similar to before, except that the page should start with either “information accepted” or “information had k errors”3 (where k>0). If there are errors, it should be followed by a list of the field-name and the error message. Strive to make the error message as specific as possible (e.g. “trainer: name is more than 30 characters” is better than “trainer: name is too long” which is better than “trainer: name not valid”).
You must have a file which includes all the constants.
This file will be
Deliverable: Your form must be viewable on-line at: https://php.radford.edu/~yourUserID/itec325/hw02/okaymon-edit-form.php. Submit hardcopy of the revised form-handler and at least one new “okaymon-edit-handle-demo-N” file. On D2L submit all your files (as individual files, not a .tar).
1Why not collapse whitespace to nothing at
all?
This is tempting, since an actual&desired output of
2
You don't need to have test-cases for
3Except that if k=1, you should say “error”, not “errors”, of coruse. ↩
home—lects—exams—hws
D2L—breeze (snow day)
©2015, Ian Barland, Radford University Last modified 2015.Oct.15 (Thu) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |