Question modules were designed so that each question could be neatly packaged and interacted with in a set manner while providing flexibility to each question module’s designer.
The primary goals of establishing a modular question system are:
- Isolate all components of the question in a central location, such that modifying it requires changes in just that location. This greatly simplifies maintenance and encourages reusability.
- Provide a simple interface through which to interact with the question.
- Allow the question designer to determine internal data format and design of question.
A lot of the implementation is heavily inspired from Django’s app structure - apps can be easily added and removed without affecting the rest of the system. Similarly, app components often follow a simple interface laid out by Django that is used in a predetermined manner. Although the implementation of the interface is left up to the app, the usage of those components can be well- defined.
With those goals in mind, Quizzera’s question module structure has a few simple requirements that each module should follow:
- The module must be located in the questions/q/ folder - questions are found from this folder.
- The entrypoint to the module (
__init__.py) must export the question class.
- The question class should have the same name as the module.
- The entrypoint JSX file (if needed) should have the same name as the module.
For example, a
SortingQuestion would have the following directory layout:
questions/q/ SortingQuestion templates/ question.html answer.html __init__.py question.py SortingQuestion.jsx
If using React, it’s very possible (and perhaps simpler) to only require a single template which handles both the question prompt and displaying the answer. All the examples provided use only one template - I recommend it over other approaches.
Next, we’ll walk through the
which dictates the interface for all questions. Your question class will
implement this interface, so you should get to know it well.