#126 Use the course full name in emails
This commit is contained in:
parent
b189236b6e
commit
572025716b
3 changed files with 25 additions and 14 deletions
|
@ -44,6 +44,11 @@ class email_certificate implements \renderable, \templatable {
|
||||||
*/
|
*/
|
||||||
public $userfullname;
|
public $userfullname;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string The course short name.
|
||||||
|
*/
|
||||||
|
public $courseshortname;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string The course full name.
|
* @var string The course full name.
|
||||||
*/
|
*/
|
||||||
|
@ -64,13 +69,15 @@ class email_certificate implements \renderable, \templatable {
|
||||||
*
|
*
|
||||||
* @param bool $isstudent Are we emailing the student?
|
* @param bool $isstudent Are we emailing the student?
|
||||||
* @param string $userfullname The name of the user who owns the certificate.
|
* @param string $userfullname The name of the user who owns the certificate.
|
||||||
* @param string $coursefullname The name of the course.
|
* @param string $courseshortname The short name of the course.
|
||||||
|
* @param string $coursefullname The full name of the course.
|
||||||
* @param string $certificatename The name of the certificate.
|
* @param string $certificatename The name of the certificate.
|
||||||
* @param string $cmid The course module id.
|
* @param string $cmid The course module id.
|
||||||
*/
|
*/
|
||||||
public function __construct($isstudent, $userfullname, $coursefullname, $certificatename, $cmid) {
|
public function __construct($isstudent, $userfullname, $courseshortname, $coursefullname, $certificatename, $cmid) {
|
||||||
$this->isstudent = $isstudent;
|
$this->isstudent = $isstudent;
|
||||||
$this->userfullname = $userfullname;
|
$this->userfullname = $userfullname;
|
||||||
|
$this->courseshortname = $courseshortname;
|
||||||
$this->coursefullname = $coursefullname;
|
$this->coursefullname = $coursefullname;
|
||||||
$this->certificatename = $certificatename;
|
$this->certificatename = $certificatename;
|
||||||
$this->cmid = $cmid;
|
$this->cmid = $cmid;
|
||||||
|
@ -89,6 +96,7 @@ class email_certificate implements \renderable, \templatable {
|
||||||
$info = new \stdClass();
|
$info = new \stdClass();
|
||||||
$info->userfullname = $this->userfullname;
|
$info->userfullname = $this->userfullname;
|
||||||
$info->certificatename = $this->certificatename;
|
$info->certificatename = $this->certificatename;
|
||||||
|
$info->courseshortname = $this->courseshortname;
|
||||||
$info->coursefullname = $this->coursefullname;
|
$info->coursefullname = $this->coursefullname;
|
||||||
|
|
||||||
if ($this->isstudent) {
|
if ($this->isstudent) {
|
||||||
|
|
|
@ -51,7 +51,7 @@ class email_certificate_task extends \core\task\scheduled_task {
|
||||||
|
|
||||||
// Get all the certificates that have requested someone get emailed.
|
// Get all the certificates that have requested someone get emailed.
|
||||||
$sql = "SELECT c.*, ct.id as templateid, ct.name as templatename, ct.contextid, co.id as courseid,
|
$sql = "SELECT c.*, ct.id as templateid, ct.name as templatename, ct.contextid, co.id as courseid,
|
||||||
co.shortname as coursename
|
co.fullname as coursefullname, co.shortname as courseshortname
|
||||||
FROM {customcert} c
|
FROM {customcert} c
|
||||||
JOIN {customcert_templates} ct
|
JOIN {customcert_templates} ct
|
||||||
ON c.templateid = ct.id
|
ON c.templateid = ct.id
|
||||||
|
@ -78,12 +78,15 @@ class email_certificate_task extends \core\task\scheduled_task {
|
||||||
$userfrom = get_admin();
|
$userfrom = get_admin();
|
||||||
}
|
}
|
||||||
|
|
||||||
$coursename = format_string($customcert->coursename, true, array('context' => $context));
|
$courseshortname = format_string($customcert->courseshortname, true, array('context' => $context));
|
||||||
|
$coursefullname = format_string($customcert->coursefullname, true, array('context' => $context));
|
||||||
$certificatename = format_string($customcert->name, true, array('context' => $context));
|
$certificatename = format_string($customcert->name, true, array('context' => $context));
|
||||||
|
|
||||||
// Used to create the email subject.
|
// Used to create the email subject.
|
||||||
$info = new \stdClass;
|
$info = new \stdClass;
|
||||||
$info->coursename = $coursename;
|
$info->coursename = $courseshortname; // Added for BC, so users who have edited the string don't lose this value.
|
||||||
|
$info->courseshortname = $courseshortname;
|
||||||
|
$info->coursefullname = $coursefullname;
|
||||||
$info->certificatename = $certificatename;
|
$info->certificatename = $certificatename;
|
||||||
|
|
||||||
// Get a list of all the issues.
|
// Get a list of all the issues.
|
||||||
|
@ -166,7 +169,7 @@ class email_certificate_task extends \core\task\scheduled_task {
|
||||||
$filecontents = $template->generate_pdf(false, $user->id, true);
|
$filecontents = $template->generate_pdf(false, $user->id, true);
|
||||||
|
|
||||||
// Set the name of the file we are going to send.
|
// Set the name of the file we are going to send.
|
||||||
$filename = $coursename . '_' . $certificatename;
|
$filename = $courseshortname . '_' . $certificatename;
|
||||||
$filename = \core_text::entities_to_utf8($filename);
|
$filename = \core_text::entities_to_utf8($filename);
|
||||||
$filename = strip_tags($filename);
|
$filename = strip_tags($filename);
|
||||||
$filename = rtrim($filename, '.');
|
$filename = rtrim($filename, '.');
|
||||||
|
@ -177,8 +180,8 @@ class email_certificate_task extends \core\task\scheduled_task {
|
||||||
file_put_contents($tempfile, $filecontents);
|
file_put_contents($tempfile, $filecontents);
|
||||||
|
|
||||||
if ($customcert->emailstudents) {
|
if ($customcert->emailstudents) {
|
||||||
$renderable = new \mod_customcert\output\email_certificate(true, $userfullname, $coursename,
|
$renderable = new \mod_customcert\output\email_certificate(true, $userfullname, $courseshortname,
|
||||||
$certificatename, $customcert->contextid);
|
$coursefullname, $certificatename, $customcert->contextid);
|
||||||
|
|
||||||
$subject = get_string('emailstudentsubject', 'customcert', $info);
|
$subject = get_string('emailstudentsubject', 'customcert', $info);
|
||||||
$message = $textrenderer->render($renderable);
|
$message = $textrenderer->render($renderable);
|
||||||
|
@ -187,8 +190,8 @@ class email_certificate_task extends \core\task\scheduled_task {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($customcert->emailteachers) {
|
if ($customcert->emailteachers) {
|
||||||
$renderable = new \mod_customcert\output\email_certificate(false, $userfullname, $coursename,
|
$renderable = new \mod_customcert\output\email_certificate(false, $userfullname, $courseshortname,
|
||||||
$certificatename, $customcert->contextid);
|
$coursefullname, $certificatename, $customcert->contextid);
|
||||||
|
|
||||||
$subject = get_string('emailnonstudentsubject', 'customcert', $info);
|
$subject = get_string('emailnonstudentsubject', 'customcert', $info);
|
||||||
$message = $textrenderer->render($renderable);
|
$message = $textrenderer->render($renderable);
|
||||||
|
@ -204,8 +207,8 @@ class email_certificate_task extends \core\task\scheduled_task {
|
||||||
foreach ($others as $email) {
|
foreach ($others as $email) {
|
||||||
$email = trim($email);
|
$email = trim($email);
|
||||||
if (validate_email($email)) {
|
if (validate_email($email)) {
|
||||||
$renderable = new \mod_customcert\output\email_certificate(false, $userfullname, $coursename,
|
$renderable = new \mod_customcert\output\email_certificate(false, $userfullname,
|
||||||
$certificatename, $customcert->contextid);
|
$courseshortname, $coursefullname, $certificatename, $customcert->contextid);
|
||||||
|
|
||||||
$subject = get_string('emailnonstudentsubject', 'customcert', $info);
|
$subject = get_string('emailnonstudentsubject', 'customcert', $info);
|
||||||
$message = $textrenderer->render($renderable);
|
$message = $textrenderer->render($renderable);
|
||||||
|
|
|
@ -65,11 +65,11 @@ $string['elementwidth_help'] = 'Specify the width of the element - \'0\' means t
|
||||||
$string['emailnonstudentbody'] = 'Attached is the certificate \'{$a->certificatename}\' for \'{$a->userfullname}\' for the course \'{$a->coursefullname}\'.';
|
$string['emailnonstudentbody'] = 'Attached is the certificate \'{$a->certificatename}\' for \'{$a->userfullname}\' for the course \'{$a->coursefullname}\'.';
|
||||||
$string['emailnonstudentcertificatelinktext'] = 'View certificate report';
|
$string['emailnonstudentcertificatelinktext'] = 'View certificate report';
|
||||||
$string['emailnonstudentgreeting'] = 'Hi';
|
$string['emailnonstudentgreeting'] = 'Hi';
|
||||||
$string['emailnonstudentsubject'] = '{$a->coursename}: {$a->certificatename}';
|
$string['emailnonstudentsubject'] = '{$a->coursefullname}: {$a->certificatename}';
|
||||||
$string['emailstudentbody'] = 'Attached is your certificate \'{$a->certificatename}\' for the course \'{$a->coursefullname}\'.';
|
$string['emailstudentbody'] = 'Attached is your certificate \'{$a->certificatename}\' for the course \'{$a->coursefullname}\'.';
|
||||||
$string['emailstudentcertificatelinktext'] = 'View certificate';
|
$string['emailstudentcertificatelinktext'] = 'View certificate';
|
||||||
$string['emailstudentgreeting'] = 'Dear {$a}';
|
$string['emailstudentgreeting'] = 'Dear {$a}';
|
||||||
$string['emailstudentsubject'] = '{$a->coursename}: {$a->certificatename}';
|
$string['emailstudentsubject'] = '{$a->coursefullname}: {$a->certificatename}';
|
||||||
$string['emailstudents'] = 'Email students';
|
$string['emailstudents'] = 'Email students';
|
||||||
$string['emailstudents_help'] = 'If set this will email the students a copy of the certificate when it becomes available.';
|
$string['emailstudents_help'] = 'If set this will email the students a copy of the certificate when it becomes available.';
|
||||||
$string['emailteachers'] = 'Email teachers';
|
$string['emailteachers'] = 'Email teachers';
|
||||||
|
|
Loading…
Reference in a new issue