moocloze
Python library to populate Moodle question banks using a Cloze/XML format.
It aims to provide a functionality similar to that of PyCloze, but reducing the necessity of specific knowledge about the Moodle XML or Cloze formats.
Contents:
Installation
The moocloze library is available as a pip package:
pip install moocloze
You can then import it as a normal package in any python code:
import moocloze
Minimal example
The following code (download source)
import moocloze
questions = [moocloze.Question(
name=f"How much is {i}+{i}",
contents=f"What is the result of {i}+{i}? "
f"{moocloze.Numerical(i + i)}")
for i in range(3)]
moocloze.questions_to_xml_file(questions=questions, output_path="example_quiz.xml")
generates a file in Cloze/XML format (download XML file) that can be imported in Moodle. Once imported, 3 questions are added to the bank, one of which is shown next:
Creating questions and importing into Moodle
The following workflow is proposed to add questions to a Moodle category
-
In your computer:
- Create a list of (related) Question instances.
import moocloze questions = [moocloze.Question(name="...", contents="..."), ...]
- Export the set of questions into an .xml file with Moodle XML/Cloze format
moocloze.questions_to_xml_file(questions=questions, output_path="my_questions.xml")
- Create a list of (related) Question instances.
-
In Moodle:
-
Go to your course's Question bank
-
(Optional) Go to the question Categories page and add your category
-
Go to the question Import page, select the category where questions are to be imported (here "Raw audio file size", shown under the "General" section), upload your xml file (e.g., "my_questions.xml" in the example below) and press "Import":
-
You will be shown a confirmation page. If no errors are found, you are done!
-
Full example with all field types
You can find a complete example that produces a single question using all supported field (response) types:
moocloze.Numerical(integers or floats, with arbitrary error tolerance)moocloze.Multiresponse(one or more valid options using checkboxes)moocloze.Multichoice(one valid option among several, using dropdown menus or radio buttons)moocloze.ShortAnswer(short text)
A screenshot of the question is shown next (see full size):
Adding feedback to the questions
Whenever you instantiate the moocloze.Question, you can pass a general_feedback parameter to it,
as in:
import moocloze
question = moocloze.Question(
name=f"Simple question",
contents=f"How many sides does a dodecahedron have?"
f"{moocloze.Numerical(answer=12, show_tolerance=False)}",
general_feedback="Do not confuse it with the icosahedron (20 faces).")
References
-
See https://docs.moodle.org/402/en/Embedded_Answers_(Cloze)_question_type for more information on the Cloze question format.
-
Check out the PyCloze library and specifically this importing tutorial for more details about how to import your XML files into Moodle and loading them into a Quiz/Questionnaire.
Metadata
Release files for moocloze 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| moocloze-1.0.2.tar.gz | 7.2 kB | Without provenance | Details for moocloze-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| moocloze-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for moocloze-1.0.2-py3-none-any.whl |
Total release size: 14.2 kB
Release files / moocloze-1.0.2.tar.gz
| Download URL | moocloze-1.0.2.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4072367be53502ef295837903e99b9fa9f9f729f626cdf7124ad9e675d1671d1
|
|
BLAKE2b-256 checksum How to use checksums |
e5927ef892d35688a7d38e41cba37e76e7eb3fd89c0774b0a042ff9b45ba2d3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Release files / moocloze-1.0.2-py3-none-any.whl
| Download URL | moocloze-1.0.2-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef35312ba1aac5d4c42eddabaf9fc79f78ad55a1e92c961e00ccbb9a302fda43
|
|
BLAKE2b-256 checksum How to use checksums |
7c600df4c52299ed0db98be4d1c77b5255cf81d6ce39359f7cc3a15c732835e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for moocloze 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.