Assignment 2 involves the creation of a simple single-user online parachutist's log application. The starting point for this application is the form you (hopefully) created in the last part of Assignment 1.
The assignment is to be done in Perl using the cgi-lib.pl module. A copy of this module has already been
placed in your ~/public_html/cgi-bin/XXXXXX/
directory. Note
that the cgi program you create will have to be executable.
You can mark a program as executable using the command chmod +x
myfile.cgi
. Due to security constraints, your program can only
be writeable by the owner (you) so you can use chmod og-w
myfile.cgi
to achieve this. To get you started you can work with either the
Simple Content Management System, the Weight Watcher Application, or
(preferably) the Blood Pressure Monitor,
available on the Snippets
Page.
For full marks, all Perl code should use strict
and there
is no need to use any module other than the cgi-lib.pl
module mentioned above and the DateManip module that is already
installed in the system directories.
All HTML and CSS generated by your application
should validate without any errors or warnings. All web pages should
conform to the CRAP principles of graphic design. All input should be
validated by your CGI script before it is used.
Your application has 3 modes (screens):
This mode lists all jumps completed so far. For each jump, it shows the jump number, date, time, location, and altitude. Note that the jump number is not explicitly stored it is computed by sorting the jumps according to date and time.
The list of jumps should be sorted by the date and time of the jump with the most recent jumps appearing first. Refer to information about the Perl sort function to learn how to do this.
This mode also provides a mechanism for viewing the details of a particular jump, editing the details of a particular jump, or editing the details of a new jump (see requirements 2 and 3 below).
Keep in mind that some skydivers have logged thousands of jumps, so the layout of this list should be compact, ideally with one line per jump. To make this easier to read, you are asked to use the alternating row colors pattern.
The information associated with a jump is the information from the
form you created in Part 4 of Assignment 1. However, you should
deactivate the input field jumpnum
as this field is
derived from the ordering of the jumps (by date).
This form should have
two buttons, one labelled Accept Jump Data
and the other
labelled Cancel
. The former causes the jump data to be
stored and the latter doesn't. Both buttons cause the application
to return to the summary mode.
This form, when submitted, should check all input fields. The date, time, and location fields are mandatory. The exit altitude field is also mandatory. All other fields are optional. Any numerical field that contains a value must contain a non-negative number. If the user submits a form with invalid information, the error should be reported to them and the form should be presented to them again with all the previously submitted information included.
You should take special care to handle the date and time fields in
a particularly robust way. In particular, use the package
Date::Manip
to correctly handle dates like today
, yesterday
, last
thursday
and so on. Internally, you should store dates
using the ISO date and
time format. You should also use the format when displaying dates
back to the user.
The information displayed in this mode should be laid out in almost the same manner as the information in the data entry mode, but it is not editable.
This mode should also have a button labelled Edit Jump Data
that takes the user to the data entry mode for this jump. This mode
should also have links labelled Next Jump
, Previous
Jump
, and Summary
that do the obvious things. Be
careful with the boundary cases that occur when the current jump is
the most recent or the first jump in the log.
jump_id
that is a unique
code generated for that jump when the jump is first added
to the system (by adding a new jump in the summary mode).
jump_id:fieldname:data
where fieldname
is either
one of the fields associated with
the jump, and data
is the value of that field.
It should be easy to edit these fields by editing your file
with a text editor.
Note that some fields (in particular those with comments) may contain multiple lines of text. To deal with this, you should escape newlines and carriage returns so that, in your data file, they are stored as a single line. When rendering them back to the screen, the data can be unescaped to restore the newlines.
jump_id
has the nice effect that, when
the user edits the information for a jump or creates a new
jump,
this can be handled by simply appending the new information to
the end of your file.