gradelib.policies.attempts#

Allow multiple attempts on assignments.

gradelib.policies.attempts.take_best(gradebook: ~gradelib.core._gradebook.Gradebook, attempts: ~collections.abc.Mapping[str, ~collections.abc.Sequence[str]], *, remove=True, penalty_strategy: ~collections.abc.Callable[[~pandas.core.series.Series], ~pandas.core.series.Series] | None = None, lateness_strategy: ~collections.abc.Callable[[~pandas.core.series.Series, str], ~pandas._libs.tslibs.timedeltas.Timedelta] = <function max_lateness>, points_possible: int | float = 1.0)#

Replaces multiple attempts at an assignment with the best.

Parameters:
  • gradebook (Gradebook) – The gradebook that will be modified.

  • attempts (Mapping[str, Sequence[str]]) – A mapping from the name of the new assignment to a sequence of existing assignments that will be used to determine the score on the new assignment.

  • remove (bool, optional) – Whether to remove the existing assignments, by default True.

  • penalty_strategy (Optional[Callable[[pd.Series], pd.Series]], optional) – A function that takes a Series of the student’s previous scores and returns a Series of the effective scores after applying any penalties. The index of the new Series should match that of the input Series. A value of None indicates that no penalties should be applied; this is the default.

  • lateness_strategy (Callable[[pd.Series, str], pd.Timedelta], optional) –

    A function that determines the overall lateness of the new assignment based on the lateness of individual attempts. The function takes two arguments: a Series of Timedelta objects (one per attempt) and a string indicating which attempt was selected as best. It returns a single Timedelta representing the overall lateness.

    Built-in strategies:

    • max_lateness() (default): Returns the maximum lateness across all attempts

    • lateness_of_best(): Returns the lateness of whichever attempt scored best

    • min_lateness(): Returns the minimum lateness across all attempts

    Default: max_lateness()

  • points_possible (Union[int, float], optional) – The number of points possible on the new assignment, by default 1.