Hi,
I want to create assignments inside a course via the core API but when I look at the available functions inside the API there is no such function. Can anyone advise?
Hi,
I want to create assignments inside a course via the core API but when I look at the available functions inside the API there is no such function. Can anyone advise?
I've not double-checked the available API functions (but I'd quite believe there isn't a specific function to do what you want). However, it is fairly straightforward to create a plugin (probably a "local" plugin) and define your own API functions, so that is a route you could go down (as you're posting in the developer forum, I'm assuming that would be a possibility for you - if not, there are various Moodle Partners who can offer development services to help with that).
As it stands, you're going to have to create your own API. It would be good if each activity had an add_instance api, but sadly they don't, yet. Adding in assignments is a little complicated because there are submission and feedback sub-plugins which you may need to consider when adding a new instance.
For my org we have assignments created automatically via our student records system, for which we have a web service. You won't be able to use it out of the box, because it was designed for our own needs, but you're welcome to browse the code for inspiration.
Because we're creating assignments from some outside event that triggers their creation, we actually store the data in a separate table, so we can recreate it if necessary from within Moodle without needing to go back to our SRS (a task actually creates the assignment). We also have some predefined defaults, such as the section we put the assignment in, so checkout the settings.
Here's the link: https://github.com/ltu-solent/moodle-local_solsits