Content marketplace developer documentation

The content marketplace provides a way for content providers to integrate access to their learning content directly into Totara Learn. Content marketplaces are implemented as a new plugin type and installed and enabled plugins are listed on the Site Administration > Content Marketplace page.

Current Totara ships with a single marketplace plugin for GO1 content, however partners can implement their own marketplace plugins using the instructions on this page.

Code overview

Content marketplace plugins should be created inside the totara/contentmarketplace/contentmarketplaces/ directory as a sub-folder. The plugin should use the type 'contentmarketplace' e.g. the $plugin->component in version.php should be 'contentmarketplace_[foldername]'.

The plugin should implement a class in totara/contentmarketplace/contentmarketplaces/[foldername]/classes/contentmarketplace.php which extends the base content marketplace class (totara/contentmarketplace/classes/local/contentmarketplace/contentmarketplace.php), implementing the required abstract methods and optionally overriding other methods in that class. See the PHPDocs for the base class for more information on each method.

The plugin will also need to create it's own language file in totara/contentmarketplace/contentmarketplaces/[foldername]/lang/en/contentmarketplace_[foldername].php. At a minimum it should define keys for 'pluginname' and 'plugin_description_html'.

The design of content marketplace plugins is such that the majority of the logic for the behaviour is defined by the specific plugin type, so once a basic plugin is in place it is up to the plugin to define the screens to show and actions to perform. The GO1 plugin provides a good reference implementation which shows what is possible and can be copied where it is useful.

Implementation approach

The general approach to implementing a contentmarketplace plugin might be:

  1. Create a generic 'contentmarketplace' plugin in the relevant location and implement the required methods
  2. Develop a 'setup' process specific to your marketplace. This could involve authenticating and storing an API token locally for example. Any configuration that is required as a prerequisite before using the content should go here.
  3. Add any plugin specific settings you want to the plugin. This could include options you want to present to the administrators, such as deciding who can use your plugin and what behaviour they can change.
  4. Develop an 'Explore' page for your content. This could potentially be as simple as an iframe to your 'catalog' or you could implement a dedicated local catalog that accesses the content via your APIs. This page should allow you to browse and search for content and select it for inclusion as local content.
  5. Implement a process for taking some selected content and generating local courses that make use of that content. That might involve programmatically creating a Totara course with a specific SCORM activity within it. You may choose to request specific information from the user and/or automatically pull in metadata from your learning content item via your API.

In many cases the GO1 reference implementation could be used as a starting point for implementing the steps above. You should also look at the totara/contentmarketplace/classes/plugininfo.php class as this defines some methods that return class instances used by the explorer.php page.

Workflows

You may also want to make use of workflows in your plugin.

In particular:

  • The coursecreate workflow manager allows you to hook into the process of creating a course and redirect the user to a flow which includes creation from your marketplace. See the implementation in totara/contentmarketplace/contentmarketplaces/goone/classes/workflow/core_course/coursecreate/contentmarketplace.php.
  • The exploremarketplace workflow manager allows you to make your plugin available as an option when you click the 'Explore marketplace' button from the Catalogue screen. See the implementation in totara/contentmarketplace/contentmarketplaces/goone/classes/workflow/totara_contentmarketplace/exploremarketplace/goone.php.