Skip to main content

Make input files for gift-wrapper programmatically

Project description

py2gift

Write GIFT (Moodle-compatible quizzes) files using Python.

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 all the pieces in action.

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, the solution and, optionally, the feedback, each one on a different notebook cell. In every 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) changes from question to question. Then, you can instruct py2gift to call your run your python code a number of times, each one giving rise to a different version of the same question.

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 to 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).

Beside 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 the sample notebook, minimal. 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.

Files for py2gift, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size py2gift-0.0.2-py3-none-any.whl (40.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size py2gift-0.0.2.tar.gz (36.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page