Skip to main content

Make input files for gift-wrapper programmatically

Project description

py2gift

py2gift is a library meant to write question banks in GIFT format (Moodle) programmatically in Python. Ultimately, questions can be written (though this is not a requirement) from a Jupyter notebook. The advantages are:

  • you can use all your Python skills to compute whatever is required for the statement, solution and feedback of a question
  • it makes easy to write different (random) versions of the same question
  • questions can be previewed (pictures, $\LaTeX$…) in the notebook
  • no need to install anything: you can click this mybinder badge, Binder , open any of the provided examples, and start writing your questions right now from the browser (the file generated at the end of the notebook, accesible through a link, can be imported in Moodle).

This library relies on gift-wrapper and it has been created using nbdev. The latter fact means you can explore the actual source code through jupyter notebooks and see the inner workings of each individual piece.

Setup

Since the library is in PyPI

pip install py2gift

should do.

Manual

If you’d rather clone this repository, the command below should install all the required packages

pip install pandas numpy matplotlib ruamel.yaml gift-wrapper

How to use it

Writing a question involves specifying the statement and, optionally, the feedback in different notebook cells. In any case, variables, specified with the prefix !, can be included, and those are meant to be filled in from within a Python class. This comes very handy when you want to create different versions of a single question in which some input data (maybe in the form of a picture) randomly changes from question to question. Then, you can instruct py2gift to call your Python code a number of times, each one giving rise to a different version of the same question (as long as some variable is set at random, e.g., by exploiting the functionality in np.random). The solution, whose format depends on the question type, must also be set from within the code.

Underneath, images are handled by gift-wrapper, and hence paths (e.g., images/scheme.svg) to either .tex (that can be compiled with pdflatex) or .svg files can be included in the statement, solution or feedback of a question. Moreover, they can be included through one of the variables (prefix !), and hence random (but nonetheless meaningful) pictures are a possibility.

Notice that the difference between two instances of the same question can be minor or significant. Ultimately, it depends on how sophisticated your Python code is (if the latter can solve the question/problem in a very general form, and you are also able to present it in the statement, then it is fine).

Besides the above mentioned core functionality, py2gift provides some extra functions to ease the process of writing questions (modules tex, util, time, hash). However, a thorough description of the functionality would be very dry and you are probably better off by taking a look at one of the sample notebooks (minimal or example_1). Also, you can take a look at the documentation.

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

py2gift-0.0.6.1.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

py2gift-0.0.6.1-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

Details for the file py2gift-0.0.6.1.tar.gz.

File metadata

  • Download URL: py2gift-0.0.6.1.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/6.0.0 pkginfo/1.9.6 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.65.0 CPython/3.11.2

File hashes

Hashes for py2gift-0.0.6.1.tar.gz
Algorithm Hash digest
SHA256 ccd93e979e3c58e02f095403a6d645ba3e1d7b21370f951fa41d9a0e594fe37c
MD5 2266e072adf02ea4488d0b6be188f530
BLAKE2b-256 d3d638dafa0fd653435252ae01b91ad41aaa04a97527a9491c41a63dce0ed2cd

See more details on using hashes here.

File details

Details for the file py2gift-0.0.6.1-py3-none-any.whl.

File metadata

  • Download URL: py2gift-0.0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 30.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/6.0.0 pkginfo/1.9.6 requests/2.28.1 requests-toolbelt/0.9.1 tqdm/4.65.0 CPython/3.11.2

File hashes

Hashes for py2gift-0.0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a8de8dfb940e959f94d1bfe4119c4d09eb583355c90eef67afc1a7e94706722f
MD5 8920345747bba6a6a02ed13ccba5cb18
BLAKE2b-256 44c80e27322c33231ba0689b38905a273523431962222a75de0399eb6914afbe

See more details on using hashes here.

Supported by

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