mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
fixing an error when no grade item is listed for this course
This commit is contained in:
parent
739196ba10
commit
f208e0e1d1
1 changed files with 104 additions and 99 deletions
|
@ -12,6 +12,9 @@ if (!$userid = optional_param('user', 0, PARAM_INT)) {
|
|||
$userid = $USER->id;
|
||||
}
|
||||
|
||||
// get the user (for full name)
|
||||
$user = get_record('user', 'id', $userid);
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
// find total number of participants
|
||||
$numusers = count(get_role_users(@implode(',', $CFG->gradebookroles), $context));
|
||||
|
@ -51,7 +54,10 @@ $numusers = count(get_role_users(@implode(',', $CFG->gradebookroles), $context))
|
|||
|
||||
$table->setup();
|
||||
|
||||
$all_grade_items = grade_item::fetch_all(array('courseid'=>$courseid));
|
||||
// print the page
|
||||
print_heading(get_string('userreport', 'grades'). " - ".fullname($user));
|
||||
|
||||
if ($all_grade_items = grade_item::fetch_all(array('courseid'=>$courseid))) {
|
||||
$grade_items = array();
|
||||
foreach ($all_grade_items as $item) {
|
||||
$grade_items[$item->sortorder] = $item;
|
||||
|
@ -158,9 +164,8 @@ $numusers = count(get_role_users(@implode(',', $CFG->gradebookroles), $context))
|
|||
|
||||
$table->add_data($data);
|
||||
}
|
||||
|
||||
// print the page
|
||||
print_heading(get_string('userreport', 'grades'));
|
||||
$table->print_html();
|
||||
|
||||
} else {
|
||||
notify(get_string('nogradeitem', 'grades'));
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue