/** * Prepare to print an outcome. * * @param stdClass $course * @param int $moduleid * @return mixed */ function certificate_print_outcome($course, $id) { global $USER, $DB; if ($grade_item = new grade_item(array('id' => $id))) { $outcomeinfo = new stdClass(); $outcomeinfo->name = $grade_item->get_name(); $outcome = new grade_grade(array('itemid' => $grade_item->id, 'userid' => $USER->id)); $outcomeinfo->grade = grade_format_gradevalue($outcome->finalgrade, $grade_item, true, GRADE_DISPLAY_TYPE_REAL); return $outcomeinfo; } return false; }
/** * Returns the outcome to display on the certificate * * @param stdClass $certificate * @param stdClass $course * @return string the outcome */ function certificate_get_outcome($certificate, $course) { global $USER; if ($certificate->printoutcome > 0) { if ($grade_item = new grade_item(array('id' => $certificate->printoutcome))) { $outcomeinfo = new stdClass(); $outcomeinfo->name = $grade_item->get_name(); $outcome = new grade_grade(array('itemid' => $grade_item->id, 'userid' => $USER->id)); $outcomeinfo->grade = grade_format_gradevalue($outcome->finalgrade, $grade_item, true, GRADE_DISPLAY_TYPE_REAL); return $outcomeinfo->name . ': ' . $outcomeinfo->grade; } } return ''; }
/** * Returns the outcome to display on the certificate * * @return string the outcome */ protected function get_outcome($userid) { global $USER, $DB; if (empty($userid)) { $userid = $USER->id; } if ($this->get_instance()->outcome > 0) { if ($grade_item = new grade_item(array('id' => $this->get_instance()->outcome))) { $outcomeinfo = new stdClass(); $outcomeinfo->name = $grade_item->get_name(); $outcome = new grade_grade(array('itemid' => $grade_item->id, 'userid' => $userid)); $outcomeinfo->grade = grade_format_gradevalue($outcome->finalgrade, $grade_item, true, GRADE_DISPLAY_TYPE_REAL); return $outcomeinfo->name . ': ' . $outcomeinfo->grade; } } return ''; }
} $sitewide_html = '<td class="cell c2" rowspan="' . $rowspan . '">' . $sitewide . "</td>\n"; $outcomedata['outcome']->sum = 0; $scale = new grade_scale(array('id' => $outcomedata['outcome']->scaleid), false); $print_tr = false; $items_html = ''; if (!empty($outcomedata['items'])) { foreach ($outcomedata['items'] as $itemid => $item) { if ($print_tr) { $row++; $items_html .= "<tr class=\"r{$row}\">\n"; } $grade_item = new grade_item($item, false); if ($item->itemtype == 'mod') { $cm = get_coursemodule_from_instance($item->itemmodule, $item->iteminstance, $item->courseid); $itemname = '<a href="' . $CFG->wwwroot . '/mod/' . $item->itemmodule . '/view.php?id=' . $cm->id . '">' . $grade_item->get_name() . '</a>'; } else { $itemname = $grade_item->get_name(); } $outcomedata['outcome']->sum += $item->avg; $gradehtml = $scale->get_nearest_item($item->avg); $items_html .= "<td class=\"cell c3\">{$itemname}</td>" . "<td class=\"cell c4\">{$gradehtml} ({$item->avg})</td>" . "<td class=\"cell c5\">{$item->count}</td></tr>\n"; $print_tr = true; } } else { $items_html .= "<td class=\"cell c3\"> - </td><td class=\"cell c4\"> - </td><td class=\"cell c5\"> 0 </td></tr>\n"; } // Calculate outcome average if (is_array($outcomedata['items'])) { $count = count($outcomedata['items']); if ($count > 0) {
$outcomedata['outcome']->sum = 0; $scale = new grade_scale(array('id' => $outcomedata['outcome']->scaleid), false); $print_tr = false; $items_html = ''; if (!empty($outcomedata['items'])) { foreach ($outcomedata['items'] as $itemid => $item) { if ($print_tr) { $row++; $items_html .= "<tr class=\"r{$row}\">\n"; } $grade_item = new grade_item($item, false); if ($item->itemtype == 'mod') { $cm = get_coursemodule_from_instance($item->itemmodule, $item->iteminstance, $item->courseid); $itemname = '<a href="' . $CFG->wwwroot . '/mod/' . $item->itemmodule . '/view.php?id=' . $cm->id . '">' . format_string($cm->name, true, $cm->course) . '</a>'; } else { $itemname = $grade_item->get_name(); } $outcomedata['outcome']->sum += $item->avg; $gradehtml = $scale->get_nearest_item($item->avg); $items_html .= "<td class=\"cell c3\">{$itemname}</td>" . "<td class=\"cell c4\">{$gradehtml} ({$item->avg})</td>" . "<td class=\"cell c5\">{$item->count}</td></tr>\n"; $print_tr = true; } } else { $items_html .= "<td class=\"cell c3\"> - </td><td class=\"cell c4\"> - </td><td class=\"cell c5\"> 0 </td></tr>\n"; } // Calculate outcome average if (is_array($outcomedata['items'])) { $count = count($outcomedata['items']); if ($count > 0) { $avg = $outcomedata['outcome']->sum / $count; } else {