Teachers to receive new self-enrolled emails

Teachers to receive new self-enrolled emails

by Chris Jay -
Number of replies: 9

I'm using Moodle 3.3, and needed our teachers to receive an email each time a new student self-enrolled into a course.

I'm also running a heavily customised 1.9 version of Moodle, but the code doesn't work in the same way.

I have figured it out, and wanted to share my edits below, in case someone else needs the same.

/enrol/self/lib.php

Around line 406, replace:

email_to_user($user, $contact, $subject, $messagetext, $messagehtml);

with

//New text below to send self-enrol emails to teachers too
email_to_user($contact, $contact, $subject, $messagetext, $messagehtml);
email_to_user($user, $contact, $subject, $messagetext, $messagehtml);
You'll also want to make sure the 'Send course welcome message' in the self enrol , enrolment method is set to Course Contact.

I've also customised the 'Welcome' email to have the following code in:

{$a->profileurl}

This will display the student's profile in the email, in the footer. This way the duplicated email (which the teacher now receives) can view the student's profile page from the email.


Average of ratings: -
In reply to Chris Jay

Re: Teachers to receive new self-enrolled emails

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Just for the record, I wouldn't recommend modifying core code. 

The right way to do this (although more complicated) would be to develop a local plugin that catches the enrolled events. Then you don't have to remember to do this again every time you upgrade.

In reply to Chris Jay

Re: Teachers to receive new self-enrolled emails

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

 As an alternative, might you just simply suggest to the teachers to look at their course enrollment each day to see who has logged in? 


In reply to Rick Jerz

Re: Teachers to receive new self-enrolled emails

by Derek Chirnside -

Nice fix Chris.  Well done!!

Rick, we call this the "fix the user" response to a feature request.  "Something may happen once a week, but you need to check every day to see if it has happened, on all the seven courses you teach." black eye

Here is the tracker item for this (8 years ago) https://tracker.moodle.org/browse/MDL-20647  Chris, you may like to post your code there, or reference this thread.  Or vote.  

This request is in limbo, in the tracker waiting for something to happen.  Lots of us like the idea of this - an email notification.  But many don't.  So it needs to be a setting, a choice for the user (the poor tutor).  So: yet another setting.  Just a little bit too far down the priority level for someone to fix it.  Easier to do some core code like Chris's fix, and just remember to update it when we upgrade.

The best way to actually fix this is to use the new event monitoring, but while we have the technology, it is not easy to implement if you are not cognoski.  

Cheers

-Derek

Average of ratings: Useful (1)
In reply to Derek Chirnside

Re: Teachers to receive new self-enrolled emails

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

Here is the user documentation on Event monitoring with examples. 

In reply to Mary Cooch

Re: Teachers to receive new self-enrolled emails

by Chris Jay -

Thanks Mary,


I did originally look into this route, but the emails themselves aren't detailed enough. It doesn't show me the student's name/email etc. Just that someone has enrolled in a course.


My workaround duplicates the welcome email, so we know the course and student info (name/email/link to profile). So from one email, we can click one link and view the student info to update our CRM with.

In reply to Derek Chirnside

Re: Teachers to receive new self-enrolled emails

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

I hear you Derek.  smile

I have loved how forum posts are emailed to me.  But then, this summer, I had some big classes and I was getting over 700 emails per week, so I switched to "digests" (one a day.)  But it wasn't the same.  So I realized that it was just easier to read the forum posts within each forum for my three courses.  The emails were not helpful.  I found this also to be true with email notifications of uploaded assignments.

So as much as I love emails, I found that some things were easier to do by just going into the course.

I have always used self-enrollment, and have always just gone into each course to see who arrived.  I can also see their last login, and activity (if I want.)  However, I do support the idea of email notifications for self-enrolled students, so I voted for the tracker item.

In reply to Derek Chirnside

Re: Teachers to receive new self-enrolled emails

by Chris Jay -

Thanks Derek, I've voted and commented on that tracker. I think it's incredibly useful. 

The Event Monitoring isn't good enough for my situation. 

In reply to Rick Jerz

Re: Teachers to receive new self-enrolled emails

by Chris Jay -

Thanks Rick. The issue we have is, each time a student enrolls (it's open to the public), we can't keep logging in and checking to see who's new on each course. We get around 10 new sign ups a day, so it's easier to receive an email for our reference. 

In reply to Chris Jay

Re: Teachers to receive new self-enrolled emails

by LUIS FERNANDES -

Hi all,

I'm looking for a similar solution on how to notify a manager (role) using email_to_user on function send_confirmation_email, telling that a new user had self registrated. 

I'm using this to notify admin: email_to_user($supportuser, $supportuser, $subject, $messageadmin, $messagehtmladmin);

but I would like to use a line like this to notify one manager or to a simple email address.

Can someone help me with this?

Best regards