gradelib.policies.lates - Handle late assignments

gradelib.policies.lates.penalize(gradebook: ~gradelib.core._gradebook.Gradebook, within: ~typing.Sequence[str] | None = None, policy: ~typing.Callable[[~gradelib.policies.lates.LateInfo], ~gradelib.core._amounts.Points | ~gradelib.core._amounts.Percentage | None] = <gradelib.policies.lates.Deduct object>, order_by: str | ~typing.Callable[[~gradelib.core._gradebook.Gradebook, ~gradelib.core._student.Student, ~typing.Sequence[str]], ~typing.Sequence[str]] = 'value')

Penalize late assignments.

Parameters:
  • gradebook (Gradebook) – The gradebook containing the assignments.

  • within (Optional[Sequence[str]]) – The assignments within which to look for late submissions. If None, all assignments will be considered.

  • policy (Callable[[LateInfo], Penalty]) – The policy to apply to late assignments. This should be a function that accepts a LateInfo object and returns a Penalty object. By default, this is a policy that deducts 100% of the points for any late assignment. For alternative policies, see Deduct and Forgive.

  • order_by (Union[str, Callable[[Gradebook, Student, Sequence[str]], Sequence[str]]]) – Determines the order in which assignments are considered (e.g., disambiguates what is meant by “first late assignment”). By default, this is “value”, which means that assignments will be considered in order of decreasing value. Also accepted is “index”, which means that assignments will be considered in the order in which they appear in within. Finally, a function can be passed that accepts a gradebook, a student, and the sequence of assignments determined by the within argument, and returns a sequence of assignments in the order in which they should be considered.

class gradelib.policies.lates.LateInfo(gradebook: Gradebook, student: Student, assignment: str, number: int)

Contains information about a single late assignment.

gradebook

The gradebook containing the late assignment.

Type:

Gradebook

student

The student who submitted the late assignment.

Type:

Student

assignment

The name of the late assignment.

Type:

str

number

The number of late assignments submitted by the student that have been seen so far, including this one.

Type:

int

class gradelib.policies.lates.Deduct(amount: Points | Percentage)

A late policy that deducts a fixed amount from the grade.

Parameters:

amount (Union[Points, Percentage]) – The amount to deduct from the grade. This can be a fixed number of points, or a percentage of the total points possible.

class gradelib.policies.lates.Forgive(number: int, then: ~typing.Callable[[~gradelib.policies.lates.LateInfo], ~gradelib.core._amounts.Points | ~gradelib.core._amounts.Percentage | None] = <gradelib.policies.lates.Deduct object>)

A late policy that forgives the first N late assignments.

Parameters:
  • number (int) – The number of late assignments to forgive.

  • then (Callable[[LateInfo], Penalty]) – The policy to apply to late assignments after the first N. By default, this is a policy that deducts 100% of the points.

gradelib.policies.lates.Penalty

A type alias for a penalty returned by a late policy.

This can be a fixed number of points (gradelib.Points), a percentage of the total points possible (gradelib.Percentage), or None to indicate that no penalty should be applied.

alias of Points | Percentage | None