pyaota.grader.autograder module

autograder.py

Given a multi-page PDF (one answer sheet per page):

  • Convert each page to an image

  • Detect fiducials, warp, read bubbles + QR version label

  • Look up the correct answers for that version from a CSV

  • Grade each page

The answer-key CSV should be generated by make_exams.py and have columns:

version_label, Q1, Q2, Q3, …

Example row:

01234567,a,b,c,d,a,…

Dependencies:
  • pdf2image

  • answer_sheet_reader.LayoutConfig

  • answer_sheet_reader.read_answer_sheet_with_version

class pyaota.grader.autograder.Autograder(layout_config)[source]

Bases: object

Autograder for multi-page PDF answer sheets.

grade_pdf(pdf_file_path, output_dir_path=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/pyaota/checkouts/latest/docs/source'), failed_pages_dir_path=None, gradebook_paths=None, score_column='score', num_counted=None, question_tally_path=None, debug_output_dir_path=None, interactive=False, column_id=None)[source]

Grade the given PDF of answer sheets.

Parameters:
  • pdf_file_path (Path | str) – Path to the input PDF file.

  • output_dir_path ([pathlib.Path | str]) – Path of directory in which to save graded overlay PDFs. If None, no graded overlays are written.

  • failed_pages_dir_path (Union[Path, str, None]) – Directory to save single-page PDFs and the report for pages that could not be fully read/graded. If None, defaults to output_dir_path.

  • gradebook_paths (Optional[List[Path | str]]) – Paths to one or more non-overlapping gradebook CSV files. Each must contain a Student ID column. Grading results (version_label, num_questions, num_correct, score, status) are written into the row whose Student ID matches the detected student ID. If None, no gradebooks are updated.

  • score_column (str) – Column name in the gradebook(s) where the score should be written. Defaults to "score".

  • num_counted (Optional[int]) – Number of questions that count toward the score. If None, defaults to the total number of questions. Must be <= total questions.

  • question_tally_path (Union[Path, str, None]) – Path to output CSV file summarizing question tallies. If None, no CSV is written

  • debug_output_dir_path (Union[Path, str, None]) – Directory to save debug output images. If None, no debug images are saved.

load_version_keys_csv(keys_csv_path)[source]