moodle-block_mytreestudyplan/view-results.php

91 lines
3.2 KiB
PHP
Raw Normal View History

<?php
require_once("../../config.php");
global $DB;
global $CFG;
const BADGE_SIZE = 100;
// Do sanity and access checks on course
$courseid = required_param('courseid', PARAM_INT);
$COURSE = get_course($courseid);
$coursecontext = context_course::instance($courseid);
$skill = block_gradelevel_levelset::find_by_course($courseid);
require_login($COURSE);
require_capability('block/gradelevel:viewresults', $coursecontext);
$PAGE->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 "<p>".get_string('course', 'core')." " . $COURSE->fullname."</p>";
//retrieve groups
$course_groups = groups_get_all_groups($COURSE->id);
// retrieve users
$remaining_users = get_enrolled_users($coursecontext);
print "<div class='block_gradelevel_results'>";
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 "<ul class='skill_results'>";
foreach($members as $usr)
{
$pointstotal = $skill->get_levelset_grade($usr->id);
$level_info = $skill->calculate_level($pointstotal);
print "<li class='result_badge'>";
print $skill->render_badge($pointstotal,BADGE_SIZE);
print "<figcaption><span class='namepart'>{$usr->firstname}</span> <span class='namepart'>{$usr->lastname}</span></figcaption>";
print "<div class='pointinfo'>".get_string('levelup_at','block_gradelevel')." <span class='currentpoints'>{$level_info->points_in_level}</span>/<span class='leveluppoints'>{$level_info->levelup_total}</span></div>";
print "</li>";
unset($remaining_users[$usr->id]);
}
print "</ul>";
}
$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 "<ul class='skill_results other'>";
foreach($remaining_users as $usr)
{
$pointstotal = $skill->get_levelset_grade($usr->id);
$level_info = $skill->calculate_level($pointstotal);
print "<li class='result_badge'>";
print $skill->render_badge($pointstotal,BADGE_SIZE);
print "<figcaption><span class='namepart'>{$usr->firstname}</span> <span class='namepart'>{$usr->lastname}</span></figcaption>";
print "<div class='pointinfo'>".get_string('levelup_at','block_gradelevel')." <span class='currentpoints'>{$level_info->points_in_level}</span>/<span class='leveluppoints'>{$level_info->levelup_total}</span></div>";
print "</li>";
}
print "</ul>";
print "</div>";
print $OUTPUT->footer();