Deploying a Module, Section or a quiz programmatically into an existing course

Deploying a Module, Section or a quiz programmatically into an existing course

by Ben Girard -
Number of replies: 4

Hello Moodle Devs...

We're new to Moodle but plan to be running 200 different Moodle instances and manage them via automation and APIs.  We will need to programmatically push activities like resources and quizzes to each instance.  I have review the Moodle API and cannot see a way to edit a course and add/create a section, module or quiz  programmatically sad

Does anyone know of a work around?

Using the Restore approach

I saw the UI allows to restore a course into another course, and only select certain components.  Makes me wonder, if I could the same via the API, where I would restore a template course that contains my Quiz, but only restore the Quiz into the existing course

As an automated process, can I use the restore functionality to programmatically restore a quiz into an existing course but limit the items that are restored?

Thanks for your guidance...

Average of ratings: -
In reply to Ben Girard

Re: Deploying a Module, Section or a quiz programmatically into an existing course

by Benjamin Ellis -
Picture of Particularly helpful Moodlers
Hi,

There are several ways to do what you want but you may require some custom plugin development using the available APIs. As far as I know, using the course backup/restore functionality - you would have to be working with the whole course and you cannot 'merge' into an existing course. Email me if you require external assistance - I might be able to help as I am a Moodle plugin development contractor.
In reply to Ben Girard

Re: Deploying a Module, Section or a quiz programmatically into an existing course

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
In reply to Marcus Green

Re: Deploying a Module, Section or a quiz programmatically into an existing course

by Ben Girard -
Thanks Marcus.  Does anyone know if Moosh can be wrapped into an API?
With 300 Moodle instances, we won't be able to to log into each instances to run Moosh Commands, we need the "add activity" command via APIs.
In reply to Ben Girard

Re: Deploying a Module, Section or a quiz programmatically into an existing course

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
You could create batch/shell files that loops through your courses to add whatever you want, or you could use the code that moosh uses as inspiration for a developer to give you something that meets your needs. For example it might be a web service.
Average of ratings: Useful (1)