Skip to main content

Convert simple YAML documents to LaTeX and PDF exams

Project description

pyexam

A Python package and CLI application to convert simple YAML documents to LaTeX and PDF exams. You can use custom templates to change the visual design of the exam or even export it to a new format.

Setup

Install a LaTeX distribution and make sure latexmk is set in your system path.

pip install pyexam

Usage

You need to define an YAML file for each exam. Here's a minimal example:

name: CS 101
header: |
  Name: \rule{4in}{.4pt} \quad Student I.D.:\enspace\hrulefill
  \vspace{.4in}
# sections: []
questions:
  - type: long-answer
    text: Who developed Python?
    lines: 1.5cm
    answer: Guido van Rossum
  - type: fill-in
    text: The Go language was developed at \fillin[Google].
  - type: multiple-choice
    text: Which of the following programming languages is interpreted?
    options:
      - text: R
        correct: yes
      - text: C++

For a more complete example with the full schema, check the example document and try the following commands:

# Export exam
python -m pyexam -i examples/cs-101-exam.yml -f pdf -o examples/output-exam

# Export exam solution
pyexam -i examples/cs-101-exam.yml -f pdf -o examples/output-exam-solution -s

# All arguments
pyexam [-h] -i FILE [-o OUT] [-t TEMPLATE] [-s | --solution | --no-solution] [-f {latex,pdf}] [-l LEVEL]
optional arguments:
  -h, --help            show this help message and exit
  -i FILE, --input-file FILE
  -o OUT, --output-dir OUT
  -t TEMPLATE, --template-dir TEMPLATE
  -s, --solution, --no-solution
  -f {latex,pdf}, --format {latex,pdf}
  -l LEVEL, --log-level LEVEL

The final result will look like this:

exam example

You can also import this package to use in your own Python code, as demonstrated in tests. Some new possible features include generating exams from a question bank or randomize the questions to produce multiple exam versions.

Beware that all input is trusted to increase customizability and keep the code simpler, you should sanitize the input for unstrusted clients.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyexam-0.1.1.tar.gz (76.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyexam-0.1.1-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file pyexam-0.1.1.tar.gz.

File metadata

  • Download URL: pyexam-0.1.1.tar.gz
  • Upload date:
  • Size: 76.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pyexam-0.1.1.tar.gz
Algorithm Hash digest
SHA256 317aa6ca625c7721a9f56f8e213f843705e39cf035351a1372c990b76861c79f
MD5 8a46d1f1924fce27d4768780399bcb77
BLAKE2b-256 c8c5b60cb4d4b562d2c56a40c43553c4d3a758ad739870aa07ede4043e60109a

See more details on using hashes here.

File details

Details for the file pyexam-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyexam-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for pyexam-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4b046e4be39f03f7548f05c1433ae9ef829a788de9295dc81f033b840249e825
MD5 f00c941083057948b432a3f37b9cea0c
BLAKE2b-256 264b0894ef43fbb3b904cfb275ede353a0bc7542b746d159fe600a9351268edc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page