pykubegrader.grade_reports namespace#
Submodules#
pykubegrader.grade_reports.assignments module#
- class pykubegrader.grade_reports.assignments.Assignment(name: str, weekly: bool, weight: float, score: float, grade_adjustment_func=None, **kwargs)[source]#
Bases:
assignment_type
Class for storing and updating assignment scores.
- due_date#
The due date of the assignment.
- Type:
datetime, optional
- grade_adjustment_func#
Function to adjust the grade for late or exempted submissions.
- Type:
callable, optional
- add_exempted_students(students)[source]#
Add students to the exempted list. :param students: List of student IDs to exempt from the assignment. :type students: list
- grade_adjustment(submission, **kwargs)[source]#
Applies adjustments to the submission score based on grading policies.
This method applies any provided grade adjustment function to the raw score. If no custom function is given, it determines the final score by considering lateness penalties based on the submission timestamp and due date.
- Parameters:
submission (dict) – A dictionary containing: - “raw_score” (float): The initial unadjusted score. - “timestamp” (str): The submission timestamp in a parsable format.
- Returns:
- The adjusted score, incorporating lateness penalties if applicable.
Returns 0 for late submissions if no late adjustment policy is defined.
- Return type:
- update_score(submission=None, **kwargs)[source]#
Updates the assignment score based on the given submission.
This method adjusts the score using the grade_adjustment function if a submission is provided. If the submission results in a higher score than the current score, the assignment score is updated. If no submission is provided and the student is not exempted, the score is set to zero. If the student is exempted, the score is set to NaN.
pykubegrader.grade_reports.class_grade_report module#
- class pykubegrader.grade_reports.class_grade_report.ClassGradeReport(user, password, **kwargs)[source]#
Bases:
object
Generates and manages a class-wide grade report.
This class retrieves a list of students, initializes a structured grade report, and populates it with individual student grade data. The final report includes both assignment-specific grades and a weighted average grade.
- all_student_grades_df#
A DataFrame storing grades for each student, including assignment scores and a weighted average.
- Type:
pd.DataFrame
- setup_class_grades()[source]#
Initializes an empty DataFrame with assignment names and weighted average columns.
- update_student_grade(student)[source]#
Fetches and updates an individual student’s weighted average grades in the DataFrame.
- fill_class_grades()[source]#
Populates the class-wide grade report with data from all students.
Iterates through the student_list and updates the DataFrame by fetching and storing each student’s weighted average grades.
- get_class_stats()[source]#
Calculates and stores descriptive statistics for the class-wide grade report. Requires filling class grades first
- make_report(**kwargs)[source]#
Makes the class grade report.
- Parameters:
**kwargs – Additional keyword arguments.
- setup_class_grades()[source]#
Creates an empty DataFrame to store grades for all students.
The DataFrame contains assignment columns and a “Weighted Average Grade” column, with students as index labels.
pykubegrader.grade_reports.grade_report module#
- class pykubegrader.grade_reports.grade_report.GradeReport(start_date='2025-01-06', verbose=True, params=None, display_=True)[source]#
Bases:
object
Class to generate a grade report for a course and perform grade calculations for each student.
- build_assignments()[source]#
Generates a list of Assignment objects for each week, applying custom adjustments where needed.
- calculate_grades()[source]#
Calculates the grades for each student based on the graded assignments. If there are filtered assignments, the score is updated based on the submission. Otherwise,
- compute_final_average()[source]#
Computes the final average by combining the running average from weekly assignments and the midterm/final exam scores.
- drop_lowest_n_for_types(n, assignments_=None)[source]#
Exempts the lowest n assignments for each specified assignment type. If the lowest dropped score is from week 1, an additional lowest score is dropped.
- Parameters:
assignments – List of assignment types (names) to process.
n – Number of lowest scores to exempt per type.
- get_non_weekly_assignments()[source]#
Get all weekly assignments from the assignment list configuration
- graded_assignment_constructor(assignment_type: assignment_type, **kwargs)[source]#
Constructs a graded assignment object and appends it to the graded_assignments list.
- Parameters:
assignment_type (str) – Type of assignment. Options: readings, lecture, practicequiz, quiz, homework, lab, labattendance, practicemidterm, midterm, practicefinal, final.
- static highlight_nans(nan_df, display_df, color='red')[source]#
Highlights NaN values from nan_df on display_df.
Parameters: nan_df (pd.DataFrame): DataFrame containing NaNs to be highlighted. display_df (pd.DataFrame): DataFrame to be recolored. color (str): Background color for NaNs. Default is ‘red’.
Returns: pd.io.formats.style.Styler: Styled DataFrame with NaNs highlighted.
- update_assignments_not_due_yet()[source]#
Updates the score of assignments that are not due yet to NaN.