moodle-mod_simplecertificate icon indicating copy to clipboard operation
moodle-mod_simplecertificate copied to clipboard

I have a need to display gradebook items on the certificate

Open goose2000 opened this issue 1 year ago • 0 comments

Describe the solution you'd like I would like to add a new token for {GRADEITEMS} in the certificate. Currently it only will show graded module activities. I many time would like to show these other items like Lab - 90, Museum - 100, Breakout Session 1 - 70

I believe this is done in the locallib.php file. I can see where it filters out only 'mod' type grades:

` protected function get_user_results($userid = null) { global $USER;

    if (empty($userid)) {
        $userid = $USER->id;
    }

    $items = grade_item::fetch_all(array('courseid' => $this->course->id));
    if (empty($items)) {
        return '';
    }

    // Sorting grade itens by sortorder.
    usort($items, function($a, $b) {
        $asortorder = $a->sortorder;
        $bsortorder = $b->sortorder;
        if ($asortorder == $bsortorder) {
            return 0;
        }
        return ($asortorder < $bsortorder) ? -1 : 1;
    });

    $retval = '';
    foreach ($items as $id => $item) {
        // Do not include grades for course itens.
        
	if ($item->itemtype != 'mod') {
            continue;
        }
		
        $cm = get_coursemodule_from_instance($item->itemmodule, $item->iteminstance);
        $usergrade = $this->get_formated_grade($this->get_mod_grade($cm->id, $userid));
        $retval = $item->itemname . ": $usergrade<br>" . $retval;
    }
    return $retval;
}`

goose2000 avatar May 31 '24 15:05 goose2000