Hello developer friends. I have a script I've written for the purpose of creating new course masters from what we call "term courses". Term courses are courses for a specific school term. When the term finishes, the software I made will automatically create a new term course from a master course (consider that like a template). Because we have multiple time slots and sometimes multiple courses within a time slot, working with a master/term course setup is ideal as our staff who is tasked with making course content changes needs to work simply with the master course and then the next term courses will all have the proper content.
Now I'm asked to do something a bit different. And this is where I need some help in understanding some constants declared in Moodle's backup source. These are the following constants declared for the "target" parameter when instantiating a restore controller class.
// Target (new/existing/current/adding/deleting)
const TARGET_CURRENT_DELETING = 0;
const TARGET_CURRENT_ADDING = 1;
const TARGET_NEW_COURSE = 2;
const TARGET_EXISTING_DELETING= 3;
const TARGET_EXISTING_ADDING = 4;
In another script I have been using TARGET_EXISTING_ADDING to overwrite a course with the backup created from an alternate course. It's not an often used function so I don't quite know when but it appears (on the surface and according to my memory which might be flawed) the behavior changed to be that the course being restored to winds up having the content from the backed up course appended to the course, rather than overwriting all content. The parameter to instantiate this class calls for only one of these constants. I tend to look at TARGET_NEW_COURSE and think that's not the one because I want to overwrite an existing course. But perhaps this is indeed what I need to do. Does anyone know if TARGET_NEW_COURSE should be used to overwrite content even from an existing course? Or is it expecting a bone empty course to restore into?