How to write and integrate a custom plugin in tutor

Yes, you need to create project and then write the plugin separately.
Here’s how you can decide what goes where:

  1. Project
    • All your functionality goes here.
  2. Plugin
    Think of this part like a bridge between your project and your openedx platform. Use this part to
    • Get whatever you might need from your platform to make your project work as a plugin.
    • Configure your platform to make your project to work as a plugin (I find it easier to use patches for this).

This may look complicated at first but this actually gives you freedom to use your project as a standalone app if you want to and it also allows you to use any project in any language to be used as a plugin.

Consider another repository for your plugin code.

Patch files are meant to add code to files in your platform whatever you put into a patch file will get appended at the bottom of it’s target file. A target file can be Dockerfile, docker-compose, env files, config.yml to name a few. You need to run tutor config save to apply the patches and adding code to these files is not recommended because all your changes will get overwritten if you run tutor local quickstart.

Template files are the files that you use to tell tutor how to setup your project

You can see Template patch catalog to see which patch file will make changes to which file in your platform.

One way is to follow these steps from Creating a Tutor plugin tutorial (I recommend you read this thoroughly):
(run tutor plugins printroot to see your root folder for plugins. Any python file in this folder will be treated as a plugin and you don’t even need to reindex)

  1. mkdir -p “$(tutor plugins printroot)”
  2. touch “$(tutor plugins printroot)/myplugin.py”
  3. tutor plugins list
  4. tutor plugins enable myplugin

Or, if you don’t want to go this way, check tutor version in your aws image. Plugin indexing was not there in versions <15.

I don’t have a definite answer to this but I think you can make direct db calls if you get the db configurations from your platform. I’ll post again if I find some more information on it.

I hope this was of some help.

2 Likes