5.1. Introduction

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:

  1. 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.
  2. Provide a simple interface through which to interact with the question.
  3. 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:

  1. The module must be located in the questions/q/ folder - questions are found from this folder.
  2. The entrypoint to the module (__init__.py) must export the question class.
  3. The question class should have the same name as the module.
  4. The entrypoint JSX file (if needed) should have the same name as the module.

For example, a SortingQuestion would have the following directory layout:


The templates folder is not required. The template names are acquired from two special methods in the question class. However, the default behavior of those methods are to load templates from the above layout.

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 core.interfaces.QuestionInterface class, which dictates the interface for all questions. Your question class will implement this interface, so you should get to know it well.