plom.create module

Plom tools related to producing papers, and setting up servers.

plom.create.clear_manager_login(server=None, password=None)[source]

Force clear the “manager” authorisation, e.g., after a crash.

Parameters:
  • server (str) – in the form “example.com” or “example.com:41984”.

  • password (str) – if not specified, prompt on the command line.

plom.create.download_rubrics(*, msgr)[source]

Download a list of rubrics from a server.

Keyword Arguments:

msgr (plom.Messenger/tuple) – either a connected Messenger or a tuple appropriate for credientials.

Returns:

list of dicts, possibly an empty list if server has no rubrics.

Return type:

list

plom.create.download_rubrics_to_file(filename, *, msgr, verbose=True)[source]

Download the rubrics from a server and save tem to a file.

Parameters:

filename (pathlib.Path) – A filename to save to. The extension is used to determine what format, supporting: .json, .toml, and .csv. If no extension is included, default to .toml.

Keyword Arguments:

msgr (plom.Messenger/tuple) – either a connected Messenger or a tuple appropriate for credientials.

Returns:

but saves a file as a side effect.

Return type:

None

plom.create.download_version_map(*, msgr)[source]

Get the question-version map from a server.

Keyword Arguments:

msgr (plom.Messenger/tuple) – either a connected Messenger or a tuple appropriate for credientials.

Returns:

keys are the paper numbers (int) and each value is a row of the version map: another dict with questions as question number (int) and value version (int).

Return type:

dict

Raises:

PlomServerNotReady

plom.create.get_demo_classlist(spec)[source]

Get the demo classlist.

plom.create.make_PDF(spec, papernum, question_versions, extra=None, no_qr=False, fakepdf=False, xcoord=None, ycoord=None, where=None, source_versions_path=None)[source]

Make a PDF of particular versions, with QR codes, and optionally name stamped.

Take pages from each source (using questions_versions/page_versions) and add QR codes and “DNW” staple-corner indicators. Optionally stamp the student name/id from extra onto the cover page. Save the new PDF file into the paperdir (typically “papersToPrint”).

Parameters:
  • spec (dict) – A validated test specification

  • papernum (int) – the paper/test number.

  • question_versions (dict) – the version of each question for this paper. Note this is an input and must be predetermined before calling.

  • extra (dict/None) – Dictionary with student id and name or None.

  • no_qr (bool) – determine whether or not to paste in qr-codes.

  • fakepdf (bool) – when true, the build empty “pdf” files by just touching fhe files. This is could be used in testing or to save time when we have no use for the actual files. Why? Maybe later confirmation steps check these files exist or something like that…

  • xcoord (float) – horizontal positioning of the prename box.

  • ycoord (float) – vertical positioning of the prename box.

  • where (pathlib.Path/None) – where to save the files, with some default if omitted.

  • source_versions_path (pathlib.Path/str/None) – location of the source versions directory.

Returns:

the file that was just written.

Return type:

pathlib.Path

Raises:

ValueError – Raise error if the student name and number is not encodable

plom.create.make_hw_scribbles(server, password, basedir=PosixPath('.'), how_many=10)[source]

Fake homework submissions by scribbling on the pages of blank tests.

Parameters:
  • server (str) – the name and port of the server.

  • password (str) – the “manager” password.

  • 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/submittedHWByQ.

  • how_many (int) – how many hws to create

  1. Read in the existing papers.

  2. Create the fake data filled pdfs

  3. Generates second batch for first half of papers.

  4. Generates some “semiloose” bundles; those that have all questions or more than one question in a single bundle.

plom.create.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:
  • server (str) – the name and port of the server.

  • password (str) – the “manager” password.

  • 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.

  1. Read in the existing papers.

  2. Create the fake data filled pdfs

  3. Do some things to make the data unpleasant:

    • delete the last page of the first test.

    • Randomly add some extra pages

plom.create.process_classlist_file(student_csv_file_name, spec, *, ignore_warnings=False)[source]

Get student names/IDs from a csv file.

Student numbers come from an id column. Student names must be in a single ‘name’ column. There is some flexibility in those titles, see

  • plom.create.possible_sid_fields()

  • plom.create.possible_fullname_fields()

Alternatively, give a .csv exported from Canvas (experimental!)

Parameters:
  • student_csv_file_name (pathlib.Path/str) – class info csv file.

  • spec (dict) – validated test spec.

Keyword Arguments:

ignore_warnings (bool) – if true, proceed with classlist processing even if there are warnings. Default False.

Returns:

if successful then “(True, clist)” where clist is a list of dicts each with “id” and “name”. On failure “(False, warn_err)” where “warn_err” is a list of dicts of warnings and errors. Each dict contains “warn_or_err” which is ‘warning’ or ‘error’, “werr_line” being the line number at which the error occurs, and ‘werr_text’ being a string describing the warning/error.

Return type:

tuple

plom.create.save_version_map(filename=None, *, msgr)[source]

Get the question-version map and save to a file.

Parameters:

filename (pathlib.Path/str) – a file name and optionally path in which to save the version map. The extension is used to determine what format, supporting: .json and .csv. If no extension is included, default to .csv. If filename omitted, default to question_version_map.csv.

Keyword Arguments:

msgr (plom.Messenger/tuple) – either a connected Messenger or a tuple appropriate for credientials.

Returns:

the name of the file saved.

Return type:

pathlib.Path

Raises:

PlomServerNotReady

Note if you specify .json, the paper numbers and questions numbers will be converted to strings due to JSON limitations.

plom.create.status(*, msgr)[source]

Status information about a server.

Keyword Arguments:

msgr (plom.Messenger/tuple) – either a connected Messenger or a tuple appropriate for credientials.

plom.create.upload_classlist(classlist, *, msgr, force=False)[source]

Uploads a classlist file to the server.

Parameters:
  • classdict (list) – list of dict, each has at least keys “id” and “name”, optionally other fields too.

  • msgr (plom.Messenger/tuple) – either a connected Messenger or a tuple appropriate for credientials.

  • force (bool) – Force uploading if a classlist already exists, default False.

plom.create.upload_demo_classlist(spec, *, msgr, force=False)[source]

Uploads the demo classlist file to the server.

Keyword Arguments:
  • msgr (plom.Messenger/tuple) – either a connected Messenger or a tuple appropriate for credientials.

  • force (bool) – Force uploading if a classlist already exists, default False.

plom.create.upload_demo_rubrics(*, msgr, numquestions=3)[source]

Load some demo rubrics and upload to server.

Keyword Arguments:
  • msgr (plom.Messenger/tuple) – either a connected Messenger or a tuple appropriate for credientials.

  • numquestions (int) – how many questions should we build for. TODO: get number of questions from the server spec if omitted.

The demo data is a bit sparse: we fill in missing pieces and multiply over questions.

plom.create.upload_rubrics(rubrics, *, msgr)[source]

Upload a list of rubrics to a server.

plom.create.upload_rubrics_from_file(filename, *, msgr, verbose=True)[source]

Load rubrics from a file and upload them to a server.

Parameters:

filename (pathlib.Path) – A filename to load from. Types .json, .toml, and .csv are supported. If no suffix is included we’ll try to append .toml.

Keyword Arguments:

msgr (plom.Messenger/tuple) – either a connected Messenger or a tuple appropriate for credientials.

plom.create.version_map_from_file(f)[source]

Extract the version map from a csv or json file.

Parameters:

f (pathlib.Path) – If .csv file, must have a test_number column and some q{n}.version columns. The number of such columns is autodetected. If .json file, its a dict of dicts. Either case could, for example, be the output of save_question_version_map().

Returns:

keys are the paper numbers (int) and each value is a row of the version map: another dict with questions as question number (int) and value version (int).

Return type:

dict