From 1af48be5532b540fc45b29885f0c0eedd97fbb26 Mon Sep 17 00:00:00 2001 From: Kumi Date: Thu, 21 Nov 2024 20:57:29 +0100 Subject: [PATCH] feat: Add user details display to report Introduces a user details table for displaying username, first name, last name, and email in the report. Updates language strings to support new user details headings and labels for the table fields. Increments the plugin version for release tracking. --- details.php | 17 ++++++++++++----- lang/en/report_usergrades.php | 7 +++++++ version.php | 2 +- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/details.php b/details.php index a4a3e5a..b586cef 100644 --- a/details.php +++ b/details.php @@ -29,21 +29,28 @@ if ($mform->is_cancelled()) { $courses = enrol_get_users_courses($user->id, true); $questions = $DB->get_records('question'); + // User details + + echo $OUTPUT->heading(get_string('userdetails', 'report_usergrades'), 3); + + $user_table = new html_table(); + $user_table->head = array(get_string('field'), get_string('value')); + + $user_table->data[] = array(get_string('username'), $user->username); + $user_table->data[] = array(get_string('firstname'), $user->firstname); + $user_table->data[] = array(get_string('lastname'), $user->lastname); + $user_table->data[] = array(get_string('email'), $user->email); + foreach ($courses as $course) { - // Basic information about the course echo $OUTPUT->heading($course->fullname, 3); - // Fetch all quizzes in the course $quizzes = $DB->get_records('quiz', array('course' => $course->id)); if ($quizzes) { echo $OUTPUT->heading(get_string('quizzes', 'report_usergrades'), 4); foreach ($quizzes as $quiz) { - // Fetch the quiz questions $quiz_questions = $DB->get_records('quiz_slots', array('quizid' => $quiz->id)); - - // Fetch the quiz attempts $quiz_attempts = $DB->get_records('quiz_attempts', array('quiz' => $quiz->id, 'userid' => $user->id)); if ($quiz_attempts) { diff --git a/lang/en/report_usergrades.php b/lang/en/report_usergrades.php index 9e8d5b4..986896b 100644 --- a/lang/en/report_usergrades.php +++ b/lang/en/report_usergrades.php @@ -12,3 +12,10 @@ $string['attempt'] = 'Attempt'; $string['question'] = 'Question'; $string['response'] = 'Response'; $string['totalgrade'] = 'Total Grade'; +$string['userdetails'] = 'User Details'; +$string['username'] = 'Username'; +$string['firstname'] = 'First Name'; +$string['lastname'] = 'Last Name'; +$string['email'] = 'Email'; +$string['field'] = 'Field'; +$string['value'] = 'Value'; \ No newline at end of file diff --git a/version.php b/version.php index 7b1c539..ff6d82a 100644 --- a/version.php +++ b/version.php @@ -2,7 +2,7 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = 'report_usergrades'; -$plugin->version = 2024112100; +$plugin->version = 2024112101; $plugin->requires = 2022041900; $plugin->maturity = MATURITY_ALPHA; $plugin->release = 'v1.0';