Skip to content
Snippets Groups Projects
Commit d5d9bf29 authored by Ryan Smith's avatar Ryan Smith
Browse files

feat: Adds setting for sending by username to close #35.

parent abd28a85
No related branches found
No related tags found
No related merge requests found
......@@ -96,6 +96,7 @@ class store extends php_obj implements log_writer {
'source_version' => $CFG->release,
'source_lang' => 'en',
'send_mbox' => $this->get_config('mbox', false),
'send_username' => $this->get_config('username', false),
'plugin_url' => 'https://github.com/xAPI-vle/moodle-logstore_xapi',
'plugin_version' => $plugin->release,
'repo' => new \src\transformer\repos\MoodleRepository($DB),
......
......@@ -39,5 +39,7 @@ $string['routes'] = 'Include actions with these routes';
$string['filters'] = 'Filter logs';
$string['logguests'] = 'Log guest actions';
$string['filters_help'] = 'Enable filters that INCLUDE some actions to be logged.';
$string['mbox'] = 'Send user email';
$string['mbox_desc'] = 'Statements identify the user with its email (mbox) or with its userid on the moodle platform (account). Checking this will send the email (mbox).';
\ No newline at end of file
$string['mbox'] = 'Identify users by email';
$string['mbox_desc'] = 'Statements will identify users with their email (mbox) when this box is ticked.';
$string['username'] = 'Identify users by id';
$string['username_desc'] = 'Statements will identify users with their username when this box is ticked, but only if identifying users by email is disabled.';
\ No newline at end of file
......@@ -42,6 +42,10 @@ if ($hassiteconfig) {
$settings->add(new admin_setting_configcheckbox('logstore_xapi/mbox',
get_string('mbox', 'logstore_xapi'),
get_string('mbox_desc', 'logstore_xapi'), 0));
$settings->add(new admin_setting_configcheckbox('logstore_xapi/username',
get_string('username', 'logstore_xapi'),
get_string('username_desc', 'logstore_xapi'), 0));
// Filters.
$settings->add(new admin_setting_heading('filters',
......
......@@ -19,18 +19,29 @@ defined('MOODLE_INTERNAL') || die();
function get_user(array $config, \stdClass $user) {
$fullname = get_full_name($user);
if (array_key_exists('sendmbox', $config) && $config['sendmbox'] == true) {
if (array_key_exists('send_mbox', $config) && $config['send_mbox'] == true) {
return [
'name' => $fullname,
'mbox' => $user->email,
];
} else {
}
if (array_key_exists('send_username', $config) && $config['send_username'] === true) {
return [
'name' => $fullname,
'account' => [
'homePage' => $config['app_url'],
'name' => strval($user->id),
'name' => $user->username,
],
];
}
return [
'name' => $fullname,
'account' => [
'homePage' => $config['app_url'],
'name' => strval($user->id),
],
];
}
......@@ -75,6 +75,7 @@ abstract class xapi_test_case extends PhpUnitTestCase {
'source_version' => '1.0.0',
'source_lang' => 'en',
'send_mbox' => false,
'send_username' => false,
'plugin_url' => 'https://github.com/xAPI-vle/moodle-logstore_xapi',
'plugin_version' => '0.0.0-development',
'repo' => new \src\transformer\repos\TestRepository($testdata),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment