So after the flat file enrollment, it was generated the following email notifications:
1) For useridnumber1 (that is editingteacher + teacher + student): 3 notifications all with the full message of "welcometocoursetext" (so directed to STUDENT), and the following FROM destinations:
- 1 FROM useridnumber3 - that is manager on the category, which is correct;
- 2 FROM System administrator - I suspect that those 2 were wrongly generated due to a missing test condition (please see it below);
- Also there was missing 3 notifications, one for each student enrollment, with the full message of "enrolmentnewuser", informing the teacher of the new flat file enrolments.
2) For useridnumber2 (that is student): 1 notification which is correctly generated with the STUDENT message, but had been wrongly attached with the FROM, since the FROM was useridnumber3 (that is the manager of category) instead of what would be more correct, i.e., the useridnumber1 (that is the editingteacher and teacher over the course).
3) For useridnumber3 (that is manager + student): 4 notifications were sent to that user with the following:
- 1 notification to STUDENT - with the full message of "welcometocoursetext, which is correct, but with the FROM useridnumber3, instead of what would be more correct, i.e., the useridnumber1 (since it is the editingteacher and teacher over the course);
- 3 notifications, one for each student enrollment, with the full message of "enrolmentnewuser", which is correct.
After some search for solutions I found the place where it may be required some bug fix:
I believe that the if ( empty($elog) and ($action== "add")), found on line 254 of \enrol\flatfile\lib.php file, is the responsible for the behavour above referred. And specifically, it may help the following bug fixs:
1) It appears that there is missing the followng test condition on the if of line 274, in order to add the following:
Instead of:
if (!empty($mailstudents))
Pass to be something like:
if (!empty($mailstudents) && ($role->archetype == "student"))
2) It may also need some refatoring of the TODO of line 259, which may be responsible for not detecting correctly the teachers (See (1) For useridnumber1, since it appears that that user, being a teacher, should received the 3 missing notifications with the full message of "enrolmentnewuser", focused to teachers.