Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing data when sending certificates by emails due to minor bug in email_certificate_html.mustache #574

Closed
baris83 opened this issue Jul 27, 2023 · 1 comment
Assignees

Comments

@baris83
Copy link

baris83 commented Jul 27, 2023

The variable declared as "emailcertificatelinktext" in email_certificate_html.mustache is not correct as it is declared as "emailcertificatetext" in email_certificate.php.

email_certificate_html.mustache

{{{emailgreeting}}}

{{{emailbody}}}

<a href="{{emailcertificatelink}}">{{emailcertificatelinktext}}</a>.

email_certificate.php

if ($this->isstudent) {
            $data->emailgreeting = get_string('emailstudentgreeting', 'customcert', $this->userfullname);
            $data->emailbody = get_string('emailstudentbody', 'customcert', $info);
            $data->emailbodyplaintext = get_string('emailstudentbodyplaintext', 'customcert', $info);
            $data->emailcertificatelink = new \moodle_url('/mod/customcert/view.php', array('id' => $this->cmid));
            $data->emailcertificatetext = get_string('emailstudentcertificatelinktext', 'customcert');
        } else {
            $data->emailgreeting = get_string('emailnonstudentgreeting', 'customcert');
            $data->emailbody = get_string('emailnonstudentbody', 'customcert', $info);
            $data->emailbodyplaintext = get_string('emailnonstudentbodyplaintext', 'customcert', $info);
            $data->emailcertificatelink = new \moodle_url('/mod/customcert/view.php', array('id' => $this->cmid));
            $data->emailcertificatetext = get_string('emailnonstudentcertificatelinktext', 'customcert');
        }

Also "emailcertificatelink" is not correct because "$this->cmid" in email_certificate.php returning course module context id instead of course module id.

Maybe the parameter "$customcert->contextid" below can be changed to "$context->instanceid" ?

email_certificate_task.php

if ($customcert->emailstudents) {
                    $renderable = new \mod_customcert\output\email_certificate(true, $userfullname, $courseshortname,
                        $coursefullname, $certificatename, $customcert->contextid);

                    $subject = get_string('emailstudentsubject', 'customcert', $info);
                    $message = $textrenderer->render($renderable);
                    $messagehtml = $htmlrenderer->render($renderable);
                    email_to_user($user, fullname($userfrom), html_entity_decode($subject), $message, $messagehtml,
                        $tempfile, $filename);
                }
@mdjnelson mdjnelson self-assigned this Dec 28, 2023
@mdjnelson
Copy link
Owner

Thanks, pushing fix shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants