set_url('/blocks/gradelevel/view-results.php', array('courseid' => $courseid));
$PAGE->set_pagelayout('standard');
$PAGE->requires->js_call_amd('block_gradelevel/renderbadge', 'init');
print $OUTPUT->header();
print $OUTPUT->heading(get_string('results_heading', 'block_gradelevel') . " " . $skill->getName());
print "
".get_string('course', 'core')." " . $COURSE->fullname."
";
//retrieve groups
$course_groups = groups_get_all_groups($COURSE->id);
// retrieve users
$remaining_users = get_enrolled_users($coursecontext);
print "";
if(count($course_groups > 0))
{
// loop through all groups first
foreach($course_groups as $grp)
{
// Get members
$members = get_enrolled_users($coursecontext,'mod/assignment:submit',$grp->id);
$count_members = count($members);
// show group name
print $OUTPUT->heading($grp->name." ({$count_members})",4,array('groupname'));
// Sort on last name
usort( $members, function( $a, $b) {
return ( $a->lastname < $b->lastname ) ? -1 : 1;
} );
print "
";
foreach($members as $usr)
{
$pointstotal = round($skill->get_levelset_grade($usr->id),1);
$level_info = $skill->calculate_level($pointstotal);
print "- ";
print $skill->render_badge($pointstotal,BADGE_SIZE);
print "{$usr->firstname} {$usr->lastname}";
if($level_info->levelup_total > 0)
{
print "
".get_string('levelup_at','block_gradelevel')." {$pointstotal}/{$level_info->next_at}
";
}
else
{
print "".get_string('levelup_done','block_gradelevel')."
";
}
print " ";
unset($remaining_users[$usr->id]);
}
print "
";
}
$count_members = count($remaining_users);
print $OUTPUT->heading(get_string('results_ungrouped','block_gradelevel')." ({$count_members})" ,4,array('groupname'));
}
usort( $remaining_users, function( $a, $b) {
return ( $a->lastname < $b->lastname ) ? -1 : 1;
} );
print "
";
foreach($remaining_users as $usr)
{
$pointstotal = round($skill->get_levelset_grade($usr->id),1);
$level_info = $skill->calculate_level($pointstotal);
print "- ";
print $skill->render_badge($pointstotal,BADGE_SIZE);
print "{$usr->firstname} {$usr->lastname}";
if($level_info->levelup_total > 0)
{
print "
".get_string('levelup_at','block_gradelevel')." {$pointstotal}/{$level_info->next_at}
";
}
else
{
print "".get_string('levelup_done','block_gradelevel')."
";
}
print " ";
}
print "
";
print "
";
print $OUTPUT->footer();