Query - upload bulk courses with preloaded template

Query - upload bulk courses with preloaded template

by Italo Vergara Colombo -
Number of replies: 6
Hello dears,

Along with saying hello, I would like to ask you a question that I have or if you could help me with the application.

I am currently working on Moodle 3.11.12+ (Build: 20230224) and I need to do a massive load of some courses through the database, 
but I want those courses to come with a custom template, for example when I load the courses I want that in each one of them a logo and a phrase can be seen for everyone, 
I don't want it to be created with an empty course by default, therefore, I don't know if there is any tool to be able to make this modification, or if it is done by modifying the php.

Please if you can help me.

I remain attentive to inquiries

Greetings
Atte
Italo Vergara
Average of ratings: -
In reply to Italo Vergara Colombo

Re: Query - upload bulk courses with preloaded template

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I would not try to do this directly through the database.

You can make a course from a template by restoring a Moodle course backup.

And, you can restor a backup using the command-line (php admin/cli/restore_backup.php). So, probably the way to do this is with some scripting (or with a local plugin or admin tool in your moodle).
In reply to Tim Hunt

Re: Query - upload bulk courses with preloaded template

by Italo Vergara Colombo -
Dear,

I appreciate the advice, but I need to do it with 50 courses, so once the courses are loaded in moodle, how can I assign the new format?

comment that courses are loaded using an ETL

Greetings
Italo Vergara
In reply to Italo Vergara Colombo

Re: Query - upload bulk courses with preloaded template

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
You can't do this with ETL. It's as simple as that.

You can automate this in various ways, as I suggested above. Well, acutally, my 'make a plugin' idea could work if the ETL puts the data into a temporary table, and then have a Moodle plugin which spots new rows in that table, and when that happens, create the course from the template using an autmoates restore of a backup file.
Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Query - upload bulk courses with preloaded template

by Italo Vergara Colombo -
Thanks for the answer, it had occurred to me on another occasion making a backup of the course, but I need all the teachers in their courses to be able to see it, can that be done?

Stay tuned.

Thank you
Greetings
Atte
Italo Vergara
In reply to Italo Vergara Colombo

Re: Query - upload bulk courses with preloaded template

by Tasos Koutoumanos -
Ciao Italo,

you can consider the "templatecourse" field (to use in your CSV) as well as the "Restore file" option in Moodle admin panel while running the Bulk Course Upload.

The documentation is useful and up-to-date: https://docs.moodle.org/402/en/Upload_courses
In reply to Tasos Koutoumanos

Re: Query - upload bulk courses with preloaded template

by Francis Devine -
Picture of Core developers
Note that last time i checked the templatecourse option actually only restores the course fields like date, shortname, idnumber, fullname etc, not all of the course content.

I'd say the restorefile option is your best bet, as you can specify a path to a backup file that should be applied to each course uploaded.

If you have development experience or a partner with dev experience, you can probably extend the templatecourse functionality to do an async adhoc backup/restore of the template course into the target course instead.