gradelib.preprocessing - Preprocessing gradebooks

Functionality for preprocessing Gradebooks.

gradelib.preprocessing.combine_assignment_parts(gb, parts: Mapping[str, Collection[str]])

Combine the assignment parts into one assignment with the new name.

Sometimes assignments may have several parts which are recorded separately in the grading software. For instance, a homework might have a written part and a programming part. This method makes it easy to combine these parts into a single assignment.

The individual assignment parts are removed from the gradebook.

The new marked points and possible points are calculated by addition. The lateness of the new assignment is the maximum lateness of any of its parts.

It is unclear what the result should be if any of the assignments to be unified has been dropped, but other parts have not. For this reason, this method will raise a ValueError if any of the parts have been dropped.

Assignment groups are automatically reset to prevent errors. It is suggested that the gradebook’s assignments be finalized before setting the assignment groups.

Parameters:

parts (Mapping[str, Collection[str]]) – A mapping from the new assignment name to the collection of assignments to be unified under that name.

Raises:

ValueError – If any of the assignments to be unified is marked as dropped. See above for rationale.

Example

Assume the gradebook has assignments named homework 01, homework 01 - programming, homework 02, homework 02 - programming, etc., the following will “combine” the assignments into homework 01, homework 02, etc. In order to unify the programming parts with the rest of the homework, we can write:

>>> gradelib.preprocessing.combine_assignment_parts(gradebook, {
...     "homework 01": ["homework 01", "homework 01 - programming"],
...     "homework 02": ["homework 02", "homework 02 - programming"],
... })

or, equivalently:

>>> gradelib.preprocessing.combine_assignment_parts(gradebook,
...     gradebook.assignments.group_by(lambda s: s.split(" - ")[0].strip())
... )
gradelib.preprocessing.combine_assignment_versions(gb, versions: Mapping[str, Collection[str]])

Combine the assignment versions into one single assignment with the new name.

Sometimes assignments may have several versions which are recorded separately in the grading software. For instance, multiple versions of a midterm may be distributed to mitigate cheating.

The individual assignment versions are removed from the gradebook and are unified into a single new version.

It is assumed that all assignment versions have the same number of points possible. If this is not the case, a ValueError is raised.

Similarly, it is assumed that no student earns points for more than one of the versions. If this is not true, a ValueError is raised.

If a student’s submission for a version is late, the lateness of that submission is used for the student’s submission in the unified assignment.

It is unclear what the result should be if any of the assignments to be unified is dropped, but other parts are not. Therefore, if any version is dropped, this method will raise a ValueError.

Assignment groups are automatically reset to prevent errors. It is suggested that the gradebook’s assignments be finalized before setting the assignment groups.

Parameters:

versions (Mapping[str, Collection[str]]) – A mapping whose keys are new assignment names, and whose values are collections of assignments that should be unified.

Raises:

ValueError – If any of the assumptions are violated. See above.

Example

Assuming the gradebook has assignments named midterm - version a, midterm - version b, midterm - version c, etc., the following will “combine” the assignments into midterm:

>>> gradelib.preprocessing.combine_assignment_versions(gradebook,
...     {'midterm': ['midterm - version a', 'midterm - version b', 'midterm - version c']}
... )

or, equivalently:

>>> gradelib.preprocessing.combine_assignment_versions(gradebook,
...     gradebook.assignments.group_by(lambda s: s.split('-')[0].strip())
... )