This is a command line program that is executed by running gradebookdisplay
with some subset of specified options and corresponding values.
The set of allowed options are {-N, -K, -PA, -PS, -PF, -AN, -FN, -LN, -A, -G}.
Different sets of options and corresponding values may or may not be valid.
If a set of options/values is invalid,
gradebookdisplay
should print "invalid," and
exit with error code 255. Otherwise it will print out the requested data.
We next explain the various options and their purpose:
-N
The gradebook's filename may be specified with a string
of alphanumeric characters (including underscores and periods).
The filename
must be located in the same directory that the gradeboodadd
program
is running in. If the file does not exist, it causes an error.
-K
The key may be specified with a string of hex digits.
-PA
print-assignment Prints out grades of all students for a particular assignment.
The print out should consist of tuples (Last Name, First Name, Grade), with one tuple per line.
There will be two options that allow printing grades either
alphabetically by last name, first name, or by grade from highest to lowest.
-PS
print-student Prints out all grades for a particular student. The print out should consist of pairs (Assignment Name, Grade), with one tuple per line.
-PF
print-final Prints out final grades for all students. These are computed by multiplying the weight of each assignment
by the grade and taking the sum.
The print out should consist of tuples (Last Name, First Name, Grade), with one tuple per line.
There will be two options that allow printing grades either
alphabetically by last name, first name, or by grade from highest to lowest.
If the action is print-assignment then the following additional options must be specified:
-AN
assignment-name Name of assignement. Names are alphabetic characters (a-z, A-Z) in upper and lower case and numbers (0-9). Names may not contain spaces. Names are case sensitive.
-A
alphabetical-order Tuples are printed in alphabetical order, ordered by Last Name of student and then First Name of student (assuming there are repeat last names).
-G
grade-order Tuples are printed in grade order from highest to lowest.
If an assignment with the specified name does not exist then an error occurs.
Exactly one of -A
, -G
should be specified. Otherwise an error occurs.
If the action is print-student then the following additional options must be specified:
-FN
student-first-name First name of student. Names are alphabetic characters (a-z, A-Z) in upper and lower case. Names may not contain spaces. Names are case sensitive.
-LN
student-last-name Last name of student. Names are alphabetic characters (a-z, A-Z) in upper and lower case.
Names may not contain spaces. Names are case sensitive.
If a student with the specified first and last name does not exist then an error occurs.
If the action is print-final then the following additional options must be specified:
-A
alphabetical-order Tuples are printed in alphabetical order, ordered by Last Name of student
and then First Name of student (assuming there are repeat last names).
-G
grade-order Tuples are printed in grade order from highest to lowest.
Exactly one of -A
, -G
should be specified. Othe
rwise an error occurs.
Command line arguments may appear in the following order: (1) A gradebook name must be specified first with -N (2) A key must be specified second with -K (3) An action must be specified third with exactly one of {-PA, -PS, -PF} (4) After the action option, other arguments from the set {-AN, -FN, -LN, -A, -G} may be specified in any order and if the same argument is provided multiple times, the last value is accepted. An incorrect order of arguments results in an error.
If gradebookdisplay
must exit due to an error condition, or if the argument combination is incomplete or contradictory, the program should print "invalid" to stdout and exit, returning a 255.
If the gradebook already exists, and the supplied key does not match the expected key, "invalid" should be printed to stdout and 255 returned. (When a gradebook file is first created, the generated key becomes the valid key for all future accesses to that gradebook.)
Some examples of potentially valid orderings and combinations of command-line options:
gradebookdisplay -N mygradebook -K 45ea448f -PA -A -AN midterm
gradebookdisplay -N mygradebook -K 45ea448f -PS -FN John -LN Smith
gradebookdisplay -N mygradebook -K 45ea448f -PF -G
Some examples of conditions that would result in printing "invalid":
-PA
and -PS
-PF
with -FN
or a command line argument is missing for example -PA
is specified but no -AN
option is provided.