When working on
MDL-26841, I detected one inconsistency/missing feature in the enrollment api: It seems that the detection/permission to create multiple instances is somehow incomplete. So for example:
- In one course already having one "guest" plugin, the get_newinstance_link() method properly detects it and avoids to return one link to create a new instance.
- But in the same course, the add_instance() method does not detect it and creates one new instance without problems.
So, I think we should implement/extend the API to:
1) Define, for each enrol plugin, if multiple instances are allowed for a given context. And provide public getter for that.
2) Define another method, ideally public too, to perform all the checks necessary to detect if one new instance can be added (returns true/false).
3) Optional: make add_instance() to use 1 & 2 above and return null if the instance was not created (there are code relying on this right now).
That is, for your consideration. Surely we should offer BC defaults to current behavior and perhaps it's one new feature/bugfix so I'd consider backporting it to 21_STABLE.