Skip to content
Snippets Groups Projects
Unverified Commit d6d987bf authored by David Pesce's avatar David Pesce Committed by GitHub
Browse files

Merge pull request #182 from xAPI-vle/send_shortid_setting

feat: Adds setting for sending short course id to close #65.
parents 57a05cbe 6be1dac6
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_short_course_id' => $this->get_config('shortcourseid', false),
'send_username' => $this->get_config('username', false),
'plugin_url' => 'https://github.com/xAPI-vle/moodle-logstore_xapi',
'plugin_version' => $plugin->release,
......
......@@ -42,4 +42,6 @@ $string['filters_help'] = 'Enable filters that INCLUDE some actions to be logged
$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
$string['username_desc'] = 'Statements will identify users with their username when this box is ticked, but only if identifying users by email is disabled.';
$string['shortcourseid'] = 'Send short course name';
$string['shortcourseid_desc'] = 'Statements will contain the shortname for a course as a short course id extension';
......@@ -43,6 +43,10 @@ if ($hassiteconfig) {
get_string('mbox', 'logstore_xapi'),
get_string('mbox_desc', 'logstore_xapi'), 0));
$settings->add(new admin_setting_configcheckbox('logstore_xapi/shortcourseid',
get_string('shortcourseid', 'logstore_xapi'),
get_string('shortcourseid_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));
......
......@@ -22,6 +22,22 @@ use src\transformer\utils as utils;
function course(array $config, \stdClass $course) {
$coursename = $course->fullname ? $course->fullname : 'A Moodle course';
$courselang = utils\get_course_lang($course);
$sendshortid = utils\is_enabled_config($config, 'send_short_course_id');
if ($sendshortid) {
return [
'id' => $config['app_url'].'/course/view.php?id='.$course->id,
'definition' => [
'type' => 'http://id.tincanapi.com/activitytype/lms/course',
'name' => [
$courselang => $coursename,
],
'extensions' => [
'https://w3id.org/learning-analytics/learning-management-system/short-id' => $course->shortname
]
],
];
}
return [
'id' => $config['app_url'].'/course/view.php?id='.$course->id,
......
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace src\transformer\utils;
defined('MOODLE_INTERNAL') || die();
function is_enabled_config($config, $configname) {
return array_key_exists($configname, $config) && $config[$configname] == true;
}
......@@ -75,6 +75,7 @@ abstract class xapi_test_case extends PhpUnitTestCase {
'source_version' => '1.0.0',
'source_lang' => 'en',
'send_mbox' => false,
'send_short_course_id' => false,
'send_username' => false,
'plugin_url' => 'https://github.com/xAPI-vle/moodle-logstore_xapi',
'plugin_version' => '0.0.0-development',
......
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