Skip to content

Commit

Permalink
Add student idnumber to quiz report header
Browse files Browse the repository at this point in the history
  • Loading branch information
ngandrass committed Oct 29, 2024
1 parent 04f8d4d commit a21dae3
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions classes/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,17 +393,26 @@ public function generate(int $attemptid, array $sections): string {

// Section: Quiz header.
if ($sections['header']) {

$quizheaderdata = [];

// User name and link
$attemptuser = $DB->get_record('user', ['id' => $attemptobj->get_userid()]);
$userpicture = new \user_picture($attemptuser);
$userpicture->courseid = $attemptobj->get_courseid();
$userlink = new \action_link(
new \moodle_url('/user/view.php', ['id' => $attemptuser->id, 'course' => $attemptobj->get_courseid()]),
fullname($attemptuser, true)
);
global $OUTPUT;
$quizheaderdata['user'] = [
'title' => $userpicture,
'content' => new \action_link(
new \moodle_url('/user/view.php', ['id' => $attemptuser->id, 'course' => $attemptobj->get_courseid()]),
fullname($attemptuser, true)
),
'title' => get_string('user'),
'content' => $OUTPUT->render($userpicture) . ' ' . $OUTPUT->render($userlink),
];

// User ID number.
$quizheaderdata['useridnumber'] = [
'title' => get_string('idnumber'),
'content' => $attemptuser->idnumber ?: '<i>'.get_string('none').'</i>',
];

// Quiz metadata.
Expand Down

0 comments on commit a21dae3

Please sign in to comment.