Skip to main content

A package to export test questions into Moodle from python or latex

Project description

moodlexport

This Python module provides code which allows to easily generate families of questions (called categories in Moodle) that can be directly exported from either Python or Latex to Moodle, and use them to create a test. The main motivation behind this module is that :

  • it is easier to define mathematical objects in Python than Moodle
  • it is more comfortable to type maths in Latex
  • generating random problems is simpler in Python and can go way beyond what Moodle proposes
  • it is easier to store/manipulate locally a Latex or Python file than doing it on the Moodle interface. It also simplifies collaborating projects.

Simple examples from Python:

from moodlexport import Question

question = Question("essay")
question.text("What is the derivative of $f(x) = e^x + 0.5 \Vert x \Vert^2$?")
question.grade(1.5)
question.save("my first question")

Simple examples from Latex

You can produce the same result as above by defining your question directly in a Latex file. Suppose for isntance that you have a Latex file myquestion.tex containing the following :

\documentclass{amsart}
\usepackage{latextomoodle}
\begin{document}
\begin{question}[essay]
What is the derivative of $f(x) = e^x + 0.5 \Vert x \Vert^2$?
\grade{1.5}
\end{question}
\end{document}

Then you can convert this myquestion.tex file directly into a readytoexport.xml file, by using the following Python commands:

from moodlexport import latextomoodle
latextomoodle('myquestion.tex','readytoexport')

Note that if you wish to compile the .tex file without errors, you will need to place the Latex package latextomoodle.sty in the same folder. This package can be found in the latex folder of this project.

Exporting many questions at once

If you want to export more than one question, you might want to gather them within a category, which will produce a single file containing all those questions. Here is how to proceed:

In Python:

from moodlexport import Question, Category

category = Category("My little catgory name")

question = Question("essay")
question.text("What is the derivative of $f(x) = e^x + 0.5 \Vert x \Vert^2$?")
question.grade(1.5)
question.addto(category)
              
question = Question("multichoice")
question.text("Is every symmetric matrix invertible?")
question.grade(2.0)
question.answer("Yes", False)
question.answer("No", True)
question.addto(category)

category.save()

In Latex, followed by the python command latextomoodle('file_name.tex') :

\documentclass{amsart}
\usepackage{latextomoodle}
\begin{document}
\begin{category}[My little catgory name]
\begin{question}[essay]
What is the derivative of $f(x) = e^x + 0.5 \Vert x \Vert^2$?
\grade{1.5}
\end{question}
\begin{question}[multichoice]
Is every symmetric matrix invertible?
\answer[0]{Yes}
\answer[100]{No}
\grade{2.0}
\end{question}
\end{category}
\end{document}

Features of this module so far :

  • Creating a question. Supported classes of questions are:
    • "essay" : the student answers in a white text box. Options are :
      • Possibility for the student to upload a file as an answer as well.
    • "multichoice" : the question comes with at least 2 possible answers. Options are :
      • Possibility to specify "multiple answers allowed" or "unique answer allowed"
  • All the options available in Moodle are available here (defining a grade, information for the grader, feedback, etc)
  • Creating a category (family) of questions
  • Adding a question to a given category
  • Export a category of questions under the format Moodle XML, which can be imported directly into Moodle.
  • Supports Unicode éàê ...
  • Supports Latex syntax : correctly supports inline latex with $e^x$, and equation with $$ f(x) = \sum_i x_i^2 $$, \begin{equation*}...\end{equation*}, \begin{cases} etc

Known issues/missing features :

  • for multichoice we never check that the sum of the fractions is equal to 100%
  • for the latex package, there is issues with newcommand and renewcommand because for instance the document class amsart defines text but it is not the case for article.

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

moodlexport-0.0.3.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

moodlexport-0.0.3-py3.7.egg (13.8 kB view details)

Uploaded Egg

File details

Details for the file moodlexport-0.0.3.tar.gz.

File metadata

  • Download URL: moodlexport-0.0.3.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.6

File hashes

Hashes for moodlexport-0.0.3.tar.gz
Algorithm Hash digest
SHA256 11ac757c2c46a316d6674371efe6a1b328ffdd0a5b01f718165e167bf0ce9a56
MD5 22c69da98b48d504a10de3e15ba11216
BLAKE2b-256 99415254015c7424ef79c769de155627646e77dcf51dbcd6c624c5a01b212d34

See more details on using hashes here.

File details

Details for the file moodlexport-0.0.3-py3.7.egg.

File metadata

  • Download URL: moodlexport-0.0.3-py3.7.egg
  • Upload date:
  • Size: 13.8 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.6

File hashes

Hashes for moodlexport-0.0.3-py3.7.egg
Algorithm Hash digest
SHA256 3b829ccdaabec2d53abbb44a75c95cbeb71125afdc971c7e8642135af90b1e2b
MD5 f9aed5270d6c7e35b41b626a9f81b30b
BLAKE2b-256 78750323845a350618719b1a32839159c3927db751cce0d01ce9c75cb814021e

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