Skip to content

export_mobius.py

Introduction

export_mobius.py is the main export script from the Nobius toolset. It converts sheet folders into .xml and .zip files which can be imported directly into Mobius. Its main function is to populate the different template files with the question and sheet content you've made in JSON format. It also validates the input using a schema so the rendered content is structurally sound before import.

Prerequisites

Info

A list of requirements is available in requirements.txt. Install them with pip install -r requirements.txt.

In order to use this tool, Python 3.6 or higher is required. The main modules used by this script are:

  • jinja2 - This is the templating engine used by the script to generate the HTML and XML Mobius content. For more information on templating, you can visit Templating and Jinja.
  • jsonschema - This package is used to check the format and structure of data coming into the templating engine so it renders properly and, most importantly, does not crash Mobius.

Usage

To use this tool, run it from the Nobius repository root or from inside the Nobius/ directory:

python export_mobius.py FILEPATH [--reset-uid or -uid] [--write-missing-uids] [--config CONFIG] [--profile PROFILE] [--render-mode {assignment,exercise}] [-h]
  • FILEPATH is a required positional argument corresponding to the absolute or relative path to where you have stored the sheet folder you'd like to render.
    • Note: if the path is susceptible to have spaces in folder names (like with certain OneDrive paths), be sure to encapsulate it in double quotes as shown in the example command
  • --reset-uid or -uid is an optional flag that will cause all the UIDs from your sheet files to be re-generated (SheetInfo.json and question files). Use this flag when you've already uploaded a version of the sheet to Mobius and you do not want the new render to overwrite it.
    • If you have changed the order or names of some of the questions, it is usually a good idea to set this flag and delete the previous version of that sheet from Mobius.
  • --write-missing-uids is an optional flag that initializes and persists missing UIDs into the source JSON files. This is intended for first-time setup of a sheet.
  • --config is an optional path to a Nobius config file. By default the tool looks for nobius.json in the repo root.
  • --profile selects the named Nobius profile. If omitted, the config's default_profile is used.
  • --render-mode selects the manifest shape. Use assignment for assignment/course-module style output and exercise for question-bank style output.

Warning

Rendering now requires stable UIDs. If uid values are missing, the script will fail unless you explicitly pass --write-missing-uids.

Tip

If you ever forget which arguments are accepted, and what they mean, you can run python export_mobius.py -h to bring up the help menu for this script.

Example command

python export_mobius.py "C:\Users\bob\Desktop\My new sheet" --write-missing-uids

Using a different profile

Exam-style rendering now uses the same workflow with a different profile:

python export_mobius.py "C:\Users\bob\Desktop\My exam sheet" --profile exam --write-missing-uids

Configuration

export_mobius.py now reads Mobius resource paths from nobius.json by default. See Nobius Configuration for the full configuration structure and override behavior.