diff --git a/classes/observation_manager.php b/classes/observation_manager.php index ce453ce..682c362 100644 --- a/classes/observation_manager.php +++ b/classes/observation_manager.php @@ -383,6 +383,44 @@ public static function submit_point_response(int $sessionid, int $pointid, $data } } + /** + * Renders a labelled info box showing the observee's details to the grader. + * @param int $observeeid ID of the observee being observed in this session + * @param context $context context to check permissions against for which fields to show + * @return string HTML string + */ + public static function render_observee_details(int $observeeid, \context $context) { + global $OUTPUT; + + // Display the learner (observee) being observed. + $observee = \core_user::get_user($observeeid, '*', MUST_EXIST); + + // Determine which identity fields the current user (grader) is permitted to see. + $identityfields = \core_user\fields::get_identity_fields($context, false); + + // Variable fullname() respects $CFG->fullnamedisplay / $CFG->alternativefullnameformat. + $canviewfullnames = has_capability('moodle/site:viewfullnames', $context); + + $out = $OUTPUT->container_start('my-2'); + $out .= $OUTPUT->heading(get_string('observee', 'observation') . ': ' . fullname($observee, $canviewfullnames), 5); + + // Build secondary details line - only include fields the admin has enabled and the + // Current user is permitted to view. + $observeedetails = []; + if (in_array('email', $identityfields) && !empty($observee->email)) { + $observeedetails[] = get_string('email') . ': ' . + \html_writer::tag('a', $observee->email, ['href' => 'mailto:' . $observee->email]); + } + if (in_array('username', $identityfields) && !empty($observee->username)) { + $observeedetails[] = get_string('username') . ': ' . s($observee->username); + } + if (!empty($observeedetails)) { + $out .= \html_writer::tag('p', implode('  |  ', $observeedetails), ['class' => 'text-muted mb-0']); + } + $out .= $OUTPUT->container_end(); + return $out; + } + /** * Generates a HTML table that summarises the observation points and their responses * @param int $observationid ID of the observation instance diff --git a/session.php b/session.php index 587c50b..7fd5076 100644 --- a/session.php +++ b/session.php @@ -187,6 +187,9 @@ echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('markingobservation', 'observation'), 2); +// Display the learner (observee) being observed. +echo \mod_observation\observation_manager::render_observee_details($sessiondata['observee'], $PAGE->context); + if ($markingform->no_submit_button_pressed()) { $fromform = $markingform->get_submitted_data(); diff --git a/sessionsummary.php b/sessionsummary.php index 1af9a89..e918faf 100644 --- a/sessionsummary.php +++ b/sessionsummary.php @@ -103,6 +103,9 @@ echo $OUTPUT->heading(get_string('sessionsummary', 'observation'), 2); +// Display the learner (observee) being observed. +echo \mod_observation\observation_manager::render_observee_details($sessioninfo['observee'], $PAGE->context); + // Summary of points and responses. echo \mod_observation\observation_manager::format_points_and_responses($obid, $sessionid);