Skip to content

Commit

Permalink
feat: Adds idnumber to extensions for courses and course modules to c…
Browse files Browse the repository at this point in the history
…lose #230. (#272 - thanks @trewq)
  • Loading branch information
trewq authored and ryasmi committed Sep 26, 2018
1 parent 8191b8b commit bdaa16b
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 24 deletions.
1 change: 1 addition & 0 deletions classes/log/store.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public function process_events(array $events) {
'send_mbox' => $this->get_config('mbox', false),
'send_response_choices' => $this->get_config('sendresponsechoices', false),
'send_short_course_id' => $this->get_config('shortcourseid', false),
'send_course_and_module_idnumber' => $this->get_config('sendidnumber', false),
'send_username' => $this->get_config('send_username', false),
'plugin_url' => 'https://github.com/xAPI-vle/moodle-logstore_xapi',
'plugin_version' => $plugin->release,
Expand Down
2 changes: 2 additions & 0 deletions lang/en/logstore_xapi.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@
$string['send_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';
$string['sendidnumber'] = 'Send course and activity ID number';
$string['sendidnumber_desc'] = 'Statements will include the ID number (admin defined) for courses and activities in the object extensions';
$string['send_response_choices'] = 'Send response choices';
$string['send_response_choices_desc'] = 'Statements for multiple choice question answers will be sent to the LRS with the correct response and potential choices';
4 changes: 4 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
get_string('shortcourseid', 'logstore_xapi'),
get_string('shortcourseid_desc', 'logstore_xapi'), 0));

$settings->add(new admin_setting_configcheckbox('logstore_xapi/sendidnumber',
get_string('sendidnumber', 'logstore_xapi'),
get_string('sendidnumber_desc', 'logstore_xapi'), 0));

$settings->add(new admin_setting_configcheckbox('logstore_xapi/send_username',
get_string('send_username', 'logstore_xapi'),
get_string('send_username_desc', 'logstore_xapi'), 0));
Expand Down
41 changes: 18 additions & 23 deletions src/transformer/utils/get_activity/course.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,25 @@
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
]
],
];
$object = [
'id' => $config['app_url'].'/course/view.php?id='.$course->id,
'definition' => [
'type' => 'http://id.tincanapi.com/activitytype/lms/course',
'name' => [
$courselang => $coursename,
],
],
];

if (utils\is_enabled_config($config, 'send_short_course_id')) {
$object['definition']['extensions']['https://w3id.org/learning-analytics/learning-management-system/short-id'] = $course->shortname;
}

if (utils\is_enabled_config($config, 'send_course_and_module_idnumber')) {
$courseidnumber = property_exists($course, 'idnumber') ? $course->idnumber : null;
$object['definition']['extensions']['https://w3id.org/learning-analytics/learning-management-system/external-id'] = $courseidnumber;
}

return [
'id' => $config['app_url'].'/course/view.php?id='.$course->id,
'definition' => [
'type' => 'http://id.tincanapi.com/activitytype/lms/course',
'name' => [
$courselang => $coursename,
],
],
];
return $object;
}
9 changes: 8 additions & 1 deletion src/transformer/utils/get_activity/course_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function course_module(array $config, $course, $cmid, $xapitype) {
$courselang = utils\get_course_lang($course);
$instancename = property_exists($instance, 'name') ? $instance->name : $module->name;

return [
$object = [
'id' => $coursemoduleurl,
'definition' => [
'type' => $xapitype,
Expand All @@ -38,4 +38,11 @@ function course_module(array $config, $course, $cmid, $xapitype) {
],
],
];

if (utils\is_enabled_config($config, 'send_course_and_module_idnumber')) {
$moduleidnumber = property_exists($coursemodule, 'idnumber') ? $coursemodule->idnumber : null;
$object['definition']['extensions']['https://w3id.org/learning-analytics/learning-management-system/external-id'] = $moduleidnumber;
}

return $object;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ protected function get_transformer_config() {
'send_mbox' => false,
'send_response_choices' => true,
'send_short_course_id' => false,
'send_course_and_module_idnumber' => false,
'send_username' => false,
'plugin_url' => 'https://github.com/xAPI-vle/moodle-logstore_xapi',
'plugin_version' => '0.0.0-development',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ protected function get_transformer_config() {
'send_mbox' => false,
'send_response_choices' => true,
'send_short_course_id' => false,
'send_course_and_module_idnumber' => false,
'send_username' => false,
'plugin_url' => 'https://github.com/xAPI-vle/moodle-logstore_xapi',
'plugin_version' => '0.0.0-development',
Expand Down
1 change: 1 addition & 0 deletions tests/xapi_test_case.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ protected function get_transformer_config() {
'send_mbox' => false,
'send_response_choices' => false,
'send_short_course_id' => false,
'send_course_and_module_idnumber' => false,
'send_username' => false,
'plugin_url' => 'https://github.com/xAPI-vle/moodle-logstore_xapi',
'plugin_version' => '0.0.0-development',
Expand Down

0 comments on commit bdaa16b

Please sign in to comment.