Open ricardoh34 opened 3 years ago
Maybe we can change in template.php, when the PDF is generated, and add the name of the student/user?
Closing as a copy of #132. Please leave any comments there.
Unfortunately there is currently no one else except myself working on this module and I do it in my free time. If you want you could contact https://catalyst-au.net/contact-us to get a quote on the work required, otherwise you will have to wait for me to implement the feature. Sorry.
Reopening as this could be a quick solution to the certificate name confusion.
Solution from @ricardoh34.
< $filename = clean_filename($filename . '.pdf');
---
> $filename = clean_filename($filename . '_' . fullname($USER) . '.pdf');
@ricardoh34 Do you want to create a MR?
I assume this won't break on some user names, has that been tested?
Hello @mdjnelson
No need to create a MR, I think the change is really small. I´m working on including the course name also, when I got it, I´ll tell you. I have tested some names, also null names should simply not appear. As it is included in clean_filename function I think it will also protect against strange name combinations. I will try strange names, with quotes and similar to assure it.
Thanks! Ricardo
I have tested with quotes simple, double and with < > in the full name of $USER and it seems like clean_filename erases strange symbols and allows characters and numbers.
Hello @mdjnelson
No need to create a MR, I think the change is really small. I´m working on including the course name also, when I got it, I´ll tell you. I have tested some names, also null names should simply not appear. As it is included in clean_filename function I think it will also protect against strange name combinations. I will try strange names, with quotes and similar to assure it.
Thanks! Ricardo
I just wanted to credit you for the fix that's why I asked about the MR. :)
Thanks! I would love that! I have updated this change and included the name of the course after a sql query to customcert table. This afternoon I send you the patch to check if it is worth to use.
Hello @mdjnelson
I have added the name of the course, considering the template id is unique and univocally related to the courseid. This is the patch:
300a301,308
> $sql = "SELECT course,fullname
> FROM {customcert} c,
> {course} cr
> WHERE c.id = :templateid
> AND c.course = cr.id";
> $course = $DB->get_record_sql($sql, array('templateid' => $this->id));
>
> $filename = clean_filename($filename .'_'. fullname($USER) .'_'. $course->fullname . '.pdf');
302d309
< $filename = clean_filename($filename . '_' . fullname($USER) . '.pdf');
Hope it is useful, Ricardo
Are you able to do this as a merge request @ricardoh34?
I think I have done it now, sorry, but I have to update myself to github behaviour!
Tell me if it is ok, Regards, Ricardo
Hello, this does not apply to the pdf file name in the mail that will be send to other users. Any suggegtions?
The code for the single download is good. But mail feature is missing.
I think that the name of the PDF file generated for each student should be different if the certificate name uses a variable like "student name" in it. Maybe it could also be an option (checkbox)? Anyone is working on this? Thanks!