Sending an e-mail when user completes a course

Sending an e-mail when user completes a course

by Jason X -
Number of replies: 6

I'm trying to send an e-mail to the user after every course he/she completes. It's just a simple e-mail such as "Congratulations on completing this course!" 

I found in an older post where someone did something similar, but when I try and replicate his method in the /course/completion_completion.php file, it breaks. Has anyone does something similar to this? I couldn't find a plugin that replicates this. Any help is appreciated. 


The code I followed as a reference is below:


- Open the file root\enrol\manual\ajax.php

- First add below code to top

 require_once($CFG->libdir.'/moodlelib.php');

$body = "You have been enrolled to course"." ".$course->fullname."<br/><br/>"."Please login to start your course."."<br/><br/>"."Thanks,"."<br/>LogicStrat Admin"; 

- Then find the code json_encode($outcome); & add below code in above this json.

Add email_to_user($user,$USER,'Enrollment Notification','The text of the message',$body);

- Then save & check when admin can manually enroll a course to student then student will get the notification.


Average of ratings: -
In reply to Jason X

Re: Sending an e-mail when user completes a course

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

First of all, I would not modify core Moodle code. This will make it difficult for you to do upgrades and that is a bad thing. 

I would create a new local plugin to do that and make that handle the course complete event. 

https://docs.moodle.org/dev/Local_plugins

https://docs.moodle.org/dev/Event_2

and very possibly...

https://docs.moodle.org/dev/Message_API

In reply to Howard Miller

Re: Sending an e-mail when user completes a course

by C Behan -

The Re-engagement plugin might do the trick. 

I haven't used it for this particular purpose myself but you can get it to send an email notification when a user has completed an activity or activities

https://docs.moodle.org/31/en/Reengagement_activity


Catherine

In reply to C Behan

Re: Sending an e-mail when user completes a course

by Jason X -

Thanks for this. I'll try it out!

In reply to C Behan

Re: Sending an e-mail when user completes a course

by Hanan alolabe -

Hello Catherine,

I just want to ask if I can use the  Re-engagement plugin to send an email to students when the doctor adds any activity or course file so they can keep tracking the course, 

Thank you ,


In reply to Hanan alolabe

Re: Sending an e-mail when user completes a course

by C Behan -

Hi Hanan,


The Resource Notification plugin would be the one for this job: https://moodle.org/plugins/view.php?id=1109


Catherine