bozoh / moodle-mod_simplecertificate

It's NOT RECOMMENDED to install version below 2.2.6 (MOODLE_31), due a security issues See more in README
17 stars 44 forks source link

I have a need to display gradebook items on the certificate #268

Open goose2000 opened 3 months ago

goose2000 commented 3 months ago

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;
}`