This is a command line program that is executed by running gradebookadd
with some subset of specified options and corresponding values.
The set of allowed options is {-N, -K, -AA, -DA, -AS, -DS, -AG, -AN, -FN, -LN, -P, -W, -G}.
Different sets of options and corresponding values may or may not be valid.
If a set of options/values is invalid,
gradebookadd
should print "invalid," and
exit with error code 255. Otherwise it will add the data to the gradebook.
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.
-AA
add-assignment Add a new assignment.
-DA
delete-assignment Delete an assignment for all students.
-AS
add-student Add a new student.
-DS
delete-student Delete a student.
-AG
add-grade Add a new grade for an existing student and assignment.
If the action is add-assignment then the following additional options must be specified:
-AN
assignment-name Name of assignment. 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.
-P
assignment-points Number of points assignment is out of (required to be a non-negative integer)
-W
assignment-weight Weight of assignment when computing total grade (required to be a real number in [0,1])
If an assignment with the same name already exists then an error occurs.
If the sum of the weights of the new assignment and all the current assignments adds up to more than 1 then an error occurs.
If the action is delete-assignment then the following additional options must be specified:
-AN
assignment-name Name of assignment. 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.
If an assignment with the specified name does not exist then an error occurs.
If the action is add-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 same first and last name already exists then an error occurs.
If the action is delete-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 add-grade 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.
-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.
-G
grade Number of points student received (required to be a non-negative integer).
If a student with the provided first name/last name does not exist or an assignment with the provided name does not exist then an error occurs.
If a grade for this student and this assignment was previously specified, then the newly supplied grade should replace the previously specified grade. This should not cause an error.
Command line arguments must 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 {-AA, -DA, -AS, -DS, -AG} (4) After the action option, other arguments from the set {-AN, -FN, -LN, -P, -W, -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.
Empty gradebook names, assignment names, first names, lastnames are always invalid.
After gradebookadd
exits, the gradebook specified by the -N
argument should be updated. The added information should be accessible to the gradebookdisplay
tool when the key provided to both programs is the same, and not available (e.g., by inspecting the file directly) otherwise.
If gradebookadd
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 to be appended 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:
gradebookadd -N mygradebook -K 45ea448f -AA -AN midterm -P 100 -W 0.25
gradebookadd -N mygradebook -K 45ea448f -AS -FN John -LN Smith
gradebookadd -N mygradebook -K 45ea448f -AG -AN midterm -FN John -LN Smith -G 95
Some examples of conditions that would result in printing "invalid" and doing nothing to the gradebook:
-AA
and -AS
-AA
with -FN
or a command line argument is missing for example -AA
is specified but no -AN
option is provided.