Kumi
e3fd691910
Extracts and refactors user selection logic by moving user selector and form functionality into separate class files. This enhances code modularity and reusability across different parts of the application. Adds a detailed user grades report page that displays quiz attempts and grades for selected users, improving user grade reporting. Updates admin settings to include detailed report page link for navigation ease.
29 lines
906 B
PHP
29 lines
906 B
PHP
<?php
|
|
|
|
class user_selector extends user_selector_base
|
|
{
|
|
|
|
public function find_users($search)
|
|
{
|
|
global $DB;
|
|
|
|
// Define the fields you want to select.
|
|
$fields = 'id, firstname, lastname, email';
|
|
|
|
// Create an SQL query to find users based on the search criteria.
|
|
$sql = "SELECT $fields
|
|
FROM {user}
|
|
WHERE CONCAT(firstname, ' ', lastname) LIKE ? OR email LIKE ?";
|
|
|
|
// Execute the SQL query and retrieve the users.
|
|
$users = $DB->get_records_sql($sql, array('%' . $search . '%', '%' . $search . '%'));
|
|
|
|
// Format the users into a format expected by the user selector.
|
|
$options = [];
|
|
foreach ($users as $user) {
|
|
$options[$user->id] = $user->firstname . ' ' . $user->lastname . ' (' . $user->email . ')';
|
|
}
|
|
|
|
return array(get_string('users') => $options);
|
|
}
|
|
}
|