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 with the exam, graphicx, framed and sectsty packages and make sure latexmk is set in your system path.

pip install pyexam

For development, check the Makefile for useful commands.

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.2.0.tar.gz (75.0 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.2.0-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyexam-0.2.0.tar.gz
  • Upload date:
  • Size: 75.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.3 Linux/6.11.0-1018-azure

File hashes

Hashes for pyexam-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e95a0043b8cf1032d314ab17705c0788f9c8d5e4d75c3e7320ef21a193a506cd
MD5 cf52e128cd6c212d5862b8ac67454f20
BLAKE2b-256 60c41f654b0f288fc3784d4de059555df8f282432af5698e73e775c98da59ba2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyexam-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.3 Linux/6.11.0-1018-azure

File hashes

Hashes for pyexam-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 604c91c3b060eeae699524be0a111b01bc6d0f1da2b386573807373deb393767
MD5 2c632af09b3a1537399bb969ddc4826a
BLAKE2b-256 2e7957965fc3b7762504c1f0c49acc1178c5bdadc7f2b5fb5366801cec28d06f

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