Create Custom Modules

If you want customizations that cannot be satisfied by adding new links, pages, or components, you can add custom modules. Custom modules are collections of files that add functionality to Course Builder without modifying Course Builder code. Custom modules have unique names and exist alongside Course Builder’s own modules.

In Course Builder, the modules are located in the modules/ directory and they are registered in main.py.

To create a custom module, at the very least you must do a few things:

  • Create a directory under modules/ to contain your new module. For maximum compatibility with future Course Builder releases, try to keep all your work in this directory.
  • If you find that you absolutely must modify core functionality, consider adding it in terms of a list of hooks that are called back by the core code. Use common.utils.run_hooks() to call the registered callbacks.
  • Create a Python file containing a function named register_module(), which returns a custom_modules.Module instance.
  • Add the name of that Python file to the GCB_REGISTERED_MODULES section of the app.yaml file (in the top-level Course Builder directory).
  • Create a manifest.yaml file that describes the contents of your module as well as naming any functional and/or integration tests.

For more information, check out an example at https://github.com/google/coursebuilder-core/tree/master/coursebuilder/modules/certificate.