2018-11-24 12:34:30 +01:00
|
|
|
<?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)
|
|
|
|
{
|
2019-10-09 22:08:44 +02:00
|
|
|
$pointstotal = round($skill->get_levelset_grade($usr->id),1);
|
2018-11-24 12:34:30 +01:00
|
|
|
$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>";
|
2019-08-21 23:13:23 +02:00
|
|
|
|
|
|
|
if($level_info->levelup_total > 0)
|
|
|
|
{
|
2019-09-13 18:45:14 +02:00
|
|
|
print "<div class='pointinfo'>".get_string('levelup_at','block_gradelevel')." <span class='currentpoints'>{$pointstotal}</span>/<span class='leveluppoints'>{$level_info->next_at}</span></div>";
|
2019-08-21 23:13:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-13 18:45:14 +02:00
|
|
|
print "<div class='pointinfo complete'>".get_string('levelup_done','block_gradelevel')."</div>";
|
2019-08-21 23:13:23 +02:00
|
|
|
}
|
|
|
|
|
2018-11-24 12:34:30 +01:00
|
|
|
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;
|
|
|
|
} );
|
2019-09-13 18:45:14 +02:00
|
|
|
|
2018-11-24 12:34:30 +01:00
|
|
|
print "<ul class='skill_results other'>";
|
|
|
|
foreach($remaining_users as $usr)
|
|
|
|
{
|
2019-10-09 22:08:44 +02:00
|
|
|
$pointstotal = round($skill->get_levelset_grade($usr->id),1);
|
2018-11-24 12:34:30 +01:00
|
|
|
$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>";
|
2019-08-21 23:13:23 +02:00
|
|
|
if($level_info->levelup_total > 0)
|
|
|
|
{
|
2019-09-13 18:45:14 +02:00
|
|
|
print "<div class='pointinfo'>".get_string('levelup_at','block_gradelevel')." <span class='currentpoints'>{$pointstotal}</span>/<span class='leveluppoints'>{$level_info->next_at}</span></div>";
|
2019-08-21 23:13:23 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-13 18:45:14 +02:00
|
|
|
print "<div class='pointinfo complete'>".get_string('levelup_done','block_gradelevel')."</div>";
|
2019-08-21 23:13:23 +02:00
|
|
|
}
|
2018-11-24 12:34:30 +01:00
|
|
|
print "</li>";
|
|
|
|
|
|
|
|
}
|
|
|
|
print "</ul>";
|
|
|
|
|
|
|
|
print "</div>";
|
|
|
|
|
|
|
|
print $OUTPUT->footer();
|