Other supporting code
Tools for demos and semi-automated testing
Scribbling on papers
Plom tools for scribbling fake answers on PDF files.
- plom.create.scribble_utils.fill_in_fake_data_on_exams(paper_dir, classlist, outfile, *, which=None)[source]
Fill-in exams with fake data for demo or testing.
- Parameters:
paper_dir (str/pathlib.Path) – Directory containing the blank exams.
classlist (list) – list of dicts with keys id and name. See also Issue #1646: deprecate student_number by id
outfile (str/pathlib.Path) – write results into this concatenated PDF file.
- Keyword Arguments:
which (iterable) – By default we scribble on all exams or specify something like
which=range(10, 16)here to scribble on a subset. (default: None)- Returns:
None
- plom.create.scribble_utils.make_colliding_pages(paper_dir, outfile)[source]
Build two colliding pages - last pages of papers 2 and 3.
- Parameters:
paper_dir (str/pathlib.Path) – Directory containing the blank exams.
outfile (pathlib.Path) – modify this pdf file, appending the colliding pages.
Intended for testing.
- plom.create.scribble_utils.make_garbage_pages(pdf_file, number_of_garbage_pages=2)[source]
Randomly generates and inserts garbage pages into a PDF document.
- Parameters:
pdf_file (pathlib.Path) – a pdf file we add pages to.
- Keyword Arguments:
number_of_garbage_pages (int) – how many junk pages to add (default: 2)
- Returns:
None
Intended for testing.
- plom.create.scribble_utils.make_scribbles(basedir=PosixPath('.'), *, msgr)[source]
Fake exam writing by scribbling on the pages of the blank exams.
After Plom exam PDF files have been generated, this can be used to scribble on them to simulate random student work. Note this tool does not upload those files, it just makes some PDF files for you to play with or for testing purposes.
- Parameters:
basedir (str/pathlib.Path) – the blank tests (for scribbling) will be taken from basedir/papersToPrint. The pdf files with scribbles will be created in basedir. Defaults to current directory.
- Keyword Arguments:
msgr (plom.Messenger/tuple) – either a connected Messenger or a tuple appropriate for credientials.
- Returns:
None
Read in the existing papers.
Create the fake data filled pdfs
Do some things to make the data unpleasant:
delete the last page of the first test.
Randomly add some extra pages
- plom.create.scribble_utils.scribble_mcq_answer_in_box(pdf_doc, page_number, choice_index, yf, *, style='fill', shade=None)[source]
Mark one multiple-choice question (MCQ) checkbox on a fake exam PDF page.
- Parameters:
pdf_doc – a PyMuPDF document to modify.
page_number – 1-based page number containing the MCQ row.
choice_index – choice box to mark, where 0 means A, 1 means B, etc.
yf – y-position as a fraction of the page height, where 0.0 is the top edge of the page and 1.0 is the bottom edge.
style – one of “fill”, “tick”, “cross”, “circle”.
shade – optional gray value from 0.0 (black) to 1.0 (white).
- plom.create.scribble_utils.scribble_name_and_id(pdf_doc, student_id, student_name, *, pagenum=0, seed=None, y_offset: int = 0)[source]
Write name/number on coverpage of pymupdf pdf_doc.
- Parameters:
pdf_doc (pymupdf.Document) – an open pdf file, we’ll modify it implicitly but not close it.
student_id (str) – student id number to write on page.
student_name (str) – student name to write on page.
- Keyword Arguments:
pagenum (int) – which page is the coverpage, default 0 (1st page).
seed (None/int) – seed the random number generator with this value. Default of None means don’t. This can be used to ensure the same digit images are chosen each time, useful for testing.
y_offset – how far to offset the scribbles from their ‘default’ position in the version-1 assessment paper.
- Returns:
but modifies the open document as a side effect.
- Return type:
None
- plom.create.scribble_utils.scribble_pages(pdf_doc, exclude=(0, 1))[source]
Scribble on most pages of pymupdf pdf_doc.
- Parameters:
pdf_doc (pymupdf.Document) – an open pdf file, we’ll modify it implicitly but not close it.
- Keyword Arguments:
exclude – which pages to exclude. By default exclude pages 0 and 1 (the ID page and DNM page in our demo data).
- Returns:
but modifies the open document as a side effect.
- Return type:
None
- plom.create.scribble_utils.scribble_random_mcq_answers(pdf_doc: Document, page_number: int, correct_choices: Sequence[int], ycoords: Sequence[float]) None[source]
Randomly mark multiple-choice question (MCQ) responses on a fake exam PDF.
Each item may be correct, incorrect, or blank. Nonblank responses use a random visual style: filled square, tick, cross, or circle.
- Parameters:
pdf_doc – a PyMuPDF document to modify.
page_number – 1-based page number containing the MCQ rows.
correct_choices – zero-based correct choice index for each MCQ row.
ycoords – y-positions for the MCQ rows, in the same order as
correct_choices. These are page-height fractions, where 0.0 is the top edge of the page and 1.0 is the bottom edge; this is not the QR-code coordinate system.
Random grading: plom.client.randoMarker
Command-line script
Module docs
Random identifying: plom.client.randoIDer
Command-line script
Module docs
TeX Tools
Tools for working with TeX.