mdjnelson / moodle-mod_customcert

Enables the creation of dynamically generated certificates with complete customisation via the web browser.
https://moodle.org/plugins/mod_customcert
GNU General Public License v3.0
93 stars 159 forks source link

Feature Request: Display "graderid" (teacher name) for specific activity on a course on certificate #535

Closed nthetrack closed 6 months ago

nthetrack commented 1 year ago

Hi, This plugin is great. It would be even greater if as well as Teacher name, you could select the teacher that graded that student in a specific activity in that course. e.g.:

Qualification 1. Grade A. Graded by: Teacher 1 Qualification 2. Grade C. Graded by: Teacher 2

ChatGPT suggested this: <?php function customcert_assignment_graderid($certificate, $course, $cm, $customcert, $userid) { // Get the submission record for the user and assignment $submission = $DB->get_record('assign_submission', array('assignment' => $cm->instance, 'userid' => $userid));

// If the submission record exists, get the grader ID and display it on the certificate
if ($submission) {
    $grader = $DB->get_record('user', array('id' => $submission->grader));
    $graderid = $grader ? $grader->idnumber : '';
    $pdf->Cell(0, 0, "Graded by: $graderid", 0, 1, 'C');
}

} ?>

mdjnelson commented 6 months ago

ChatGPT is doing some bad practices by directly talking to the assign database tables in the module that is not related. If it was via the grading API instead that would be better. I suggest however creating another element and then you are free to do what you want and you can use the above example code as a starting point.