Patch suggestion: External database enrolment: Creation of new courses using different templates

Patch suggestion: External database enrolment: Creation of new courses using different templates

by John Salatas -
Number of replies: 2

I'm using moodle 3 and I have configured external database enrolments and also auto creation of new courses.
Currently it seems that the "New course template" is a static value and it would be nice to have the ability to define the template through a database's field.

I have already created an initial (quick n' dirty) patch available at

https://github.com/jsalatas/moodle/commit/b73c7829de48097c346817a50c3404d07ba4f718

which treats this template name as a database field. Obviously it isn't backward compatible (for existing installations) for users who already had the the "New course template" set up, but I'm planning to fix it.

As I commented in the bug tracker
https://tracker.moodle.org/browse/MDL-54792

I see two possible ways to go here
1) Having two fields one as it is now that the user can enter a template's name and a second one that the user can enter a database field name containing the template's name
2) Just one template field and one checkbox something like "Template is database field". The checkbox's default value would be unchecked (so that it works as it currently does) and when checked the template's textbox would map to a database field.

IMHO, 2nd ways (a single textbox and a checkbox) would make more sense than having two different textboxes which only one could contain a value.

I would appreciate your feedback.

Thanks!



Average of ratings: Useful (1)
In reply to John Salatas

Re: Patch suggestion: External database enrolment: Creation of new courses using different templates

by John Salatas -

OK. I believe I did it!

I implemented the 2nd option (a single textbox and a checkbox) as it makes more sense to me.

The checkbox (named templateisdbfield) is by default unchecked and the template field acts as the shortname of the template. If this checkbox is checked then the template field is considered as the name of a field in the database which contains the shortname of the template.

You can find the changes at
https://github.com/jsalatas/moodle/commit/de357fe06084205ab1c1eacd5fd1f614b5ab0890

Please notice that this commit sits in top of my previous quick n dirty commit.

Also at
https://github.com/moodle/moodle/compare/MOODLE_30_STABLE...jsalatas:MOODLE_30_STABLE
you can see compare my changes with the original moodle's repository.

Finally (just in case) here is a screenshot from the enrolments external database administration



Thanks!

In reply to John Salatas

Re: Patch suggestion: External database enrolment: Creation of new courses using different templates

by Miguel González Laredo -
Picture of Plugin developers

Hello. Great job!

 Just linking that we're working according to this issue (https://tracker.moodle.org/browse/MDL-40031) on similar improvements.

 Exactly, we found that Enrol DB Plugin is missing to copy/propagate every resource whitin when use a Course Template to create newer ones. We think that the propagation from template apply only to some settings so far.

 
 Comments, testings and so on are welcome!

 Thanks in advance
 Migue