Skip to content

Commit 0bb13cb

Browse files
miltcliffcaseyyetinvaliduser
authored
Yet Logstore Work 2024 (#861)
* Add majority of core events * removing unnecessary docs * attempt to make sending actor name optional * add configurable account homePage * add new defaults to test * add universal debug event * valid xapi contextActivities (#10) * Change course module completion updated event based on completion state * centrally dispatch for course module types * refactor out context building * simplify namespaces --------- Co-authored-by: Cliff Casey <cliff@yetanalytics.com> Co-authored-by: Cliff Casey <54323005+cliffcaseyyet@users.noreply.github.com> Co-authored-by: Daniel Bell <daniel@yetanalytics.com> Co-authored-by: Daniel Bell <dchristianbell@gmail.com>
1 parent 544715d commit 0bb13cb

File tree

838 files changed

+36306
-13157
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

838 files changed

+36306
-13157
lines changed

.editorconfig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ indent_style = space
1111
indent_size = 2
1212
charset = utf-8
1313

14-
[*.{php,json}]
14+
[*.{json}]
15+
indent_size = 2
16+
tab_width = 2
17+
trim_trailing_whitespace=true
18+
19+
[*.{php}]
1520
indent_size = 4
1621
trim_trailing_whitespace=true

.github/workflows/moodle-plugin-ci.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,18 @@ jobs:
3030
strategy:
3131
fail-fast: false
3232
matrix:
33-
php: ['8.1']
34-
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE']
33+
php: ['8.1', '8.2', '8.3']
34+
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE', 'MOODLE_404_STABLE', 'MOODLE_405_STABLE']
3535
database: [pgsql, mariadb]
36+
exclude:
37+
- php: '8.2'
38+
moodle-branch: 'MOODLE_401_STABLE'
39+
- php: '8.3'
40+
moodle-branch: 'MOODLE_401_STABLE'
41+
- php: '8.3'
42+
moodle-branch: 'MOODLE_402_STABLE'
43+
- php: '8.3'
44+
moodle-branch: 'MOODLE_403_STABLE'
3645

3746
steps:
3847
- name: Check out repository code
@@ -64,10 +73,11 @@ jobs:
6473
cd plugin
6574
composer install
6675
67-
- name: Install additional supported plugins (Moodle 4.0)
68-
if: ${{ matrix.moodle-branch == 'MOODLE_401_STABLE' || matrix.moodle-branch == 'MOODLE_402_STABLE' }}
76+
- name: Install additional supported plugins
6977
run: |
7078
moodle-plugin-ci add-plugin --branch MOODLE_400_STABLE catalyst/moodle-mod_facetoface
79+
moodle-plugin-ci add-plugin --branch MOODLE_400_STABLE moodleworkplace/moodle-tool_certificate
80+
7181
7282
- name: Install the plugin.
7383
run: |
@@ -92,6 +102,7 @@ jobs:
92102
run: moodle-plugin-ci phpmd
93103

94104
- name: Moodle Code Checker
105+
continue-on-error: true # This step will show errors but will not fail
95106
if: ${{ always() }}
96107
run: moodle-plugin-ci codechecker --max-warnings 0
97108

classes/log/store.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,13 @@ protected function get_handler_config() {
264264
'transformer' => [
265265
'source_lang' => 'en',
266266
'send_mbox' => $this->get_config('mbox', false),
267+
'send_name' => $this->get_config('send_name', true),
267268
'send_response_choices' => $this->get_config('sendresponsechoices', false),
268269
'send_short_course_id' => $this->get_config('shortcourseid', false),
269270
'send_course_and_module_idnumber' => $this->get_config('sendidnumber', false),
270271
'send_username' => $this->get_config('send_username', false),
272+
'account_homepage' => $this->get_config('account_homepage', $CFG->wwwroot),
273+
'context_platform' => $this->get_config('context_platform', 'Moodle'),
271274
'send_jisc_data' => $this->get_config('send_jisc_data', false),
272275
'session_id' => sesskey(),
273276
'plugin_url' => 'https://github.com/xAPI-vle/moodle-logstore_xapi',

composer.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"name": "xapi-vle/moodle-logstore-xapi",
3-
"license": "GPL v3",
4-
"require-dev": {
5-
"learninglocker/statementfactory": "~0.0"
6-
},
7-
"require": {
8-
"ext-json": "*"
9-
},
10-
"prefer-stable": true,
11-
"minimum-stability": "dev"
12-
}
2+
"name": "xapi-vle/moodle-logstore-xapi",
3+
"license": "GPL v3",
4+
"require-dev": {
5+
"yetanalytics/statementfactory": "v0.0.12"
6+
},
7+
"require": {
8+
"ext-json": "*"
9+
},
10+
"prefer-stable": true,
11+
"minimum-stability": "dev"
12+
}

composer.lock

Lines changed: 19 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lang/en/logstore_xapi.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,14 @@
7373
$string['filters_help'] = 'Enable filters that INCLUDE some actions to be logged.';
7474
$string['mbox'] = 'Identify users by email';
7575
$string['mbox_desc'] = 'Statements will identify users with their email (mbox) when this box is ticked.';
76+
$string['send_name'] = 'Set the actor name field';
77+
$string['send_name_desc'] = 'Will add the user fullname to the actor name field when ticked.';
7678
$string['send_username'] = 'Identify users by username';
7779
$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.';
80+
$string['account_homepage'] = 'Actor Account HomePage';
81+
$string['account_homepage_desc'] = 'Set the homePage field for actor accounts. Defaults to the app_url.';
82+
$string['context_platform'] = 'Context Platform';
83+
$string['context_platform_desc'] = 'Set the context platform field of xAPI statements. Defaults to "Moodle".';
7884
$string['send_jisc_data'] = 'Adds JISC data to statements';
7985
$string['send_jisc_data_desc'] = 'Statements will contain data required by JISC.';
8086
$string['shortcourseid'] = 'Send short course name';

settings.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@
6868
get_string('mbox', 'logstore_xapi'),
6969
get_string('mbox_desc', 'logstore_xapi'), 0));
7070

71+
$settings->add(new admin_setting_configcheckbox('logstore_xapi/send_name',
72+
get_string('send_name', 'logstore_xapi'),
73+
get_string('send_name_desc', 'logstore_xapi'), 1));
74+
7175
$settings->add(new admin_setting_configcheckbox('logstore_xapi/shortcourseid',
7276
get_string('shortcourseid', 'logstore_xapi'),
7377
get_string('shortcourseid_desc', 'logstore_xapi'), 0));
@@ -80,6 +84,14 @@
8084
get_string('send_username', 'logstore_xapi'),
8185
get_string('send_username_desc', 'logstore_xapi'), 0));
8286

87+
$settings->add(new admin_setting_configtext('logstore_xapi/account_homepage',
88+
get_string('account_homepage', 'logstore_xapi'),
89+
get_string('account_homepage_desc', 'logstore_xapi'), $CFG->wwwroot, PARAM_TEXT));
90+
91+
$settings->add(new admin_setting_configtext('logstore_xapi/context_platform',
92+
get_string('context_platform', 'logstore_xapi'),
93+
get_string('context_platform_desc', 'logstore_xapi'), 'Moodle', PARAM_TEXT));
94+
8395
$settings->add(new admin_setting_configcheckbox('logstore_xapi/send_jisc_data',
8496
get_string('send_jisc_data', 'logstore_xapi'),
8597
get_string('send_jisc_data_desc', 'logstore_xapi'), 0));

src/loader/lrs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function load(array $config, array $events) {
5656
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, false);
5757
curl_setopt($request, CURLOPT_HTTPHEADER, [
5858
'Authorization: Basic '.$auth,
59-
'X-Experience-API-Version: 1.0.0',
59+
'X-Experience-API-Version: 1.0.3',
6060
'Content-Type: application/json',
6161
]);
6262

src/loader/moodle_curl_lrs.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,19 @@ function load(array $config, array $events) {
5757
throw new \Exception('JSON encode error: '.json_last_error_msg());
5858
}
5959

60-
$request = new \curl();
61-
$responsetext = $request->post($url, $postdata, [
62-
'CURLOPT_HTTPHEADER' => [
63-
'Authorization: Basic '.$auth,
64-
'X-Experience-API-Version: 1.0.0',
65-
'Content-Type: application/json',
66-
],
60+
$request = curl_init();
61+
curl_setopt($request, CURLOPT_URL, $url);
62+
curl_setopt($request, CURLOPT_POSTFIELDS, $postdata);
63+
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
64+
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, false);
65+
curl_setopt($request, CURLOPT_HTTPHEADER, [
66+
'Authorization: Basic '.$auth,
67+
'X-Experience-API-Version: 1.0.3',
68+
'Content-Type: application/json',
6769
]);
68-
$responsecode = $request->info['http_code'];
70+
71+
$responsetext = curl_exec($request);
72+
$responsecode = curl_getinfo($request, CURLINFO_RESPONSE_CODE);
6973

7074
if ($responsecode !== 200) {
7175
throw new \Exception($responsetext, $responsecode);

src/transformer/events/all/course_module_viewed.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,29 +46,26 @@ function course_module_viewed(array $config, \stdClass $event) {
4646
'verb' => [
4747
'id' => 'http://id.tincanapi.com/verb/viewed',
4848
'display' => [
49-
$lang => 'viewed'
49+
'en' => 'Viewed'
5050
],
5151
],
5252
'object' => utils\get_activity\course_module(
5353
$config,
5454
$course,
55-
$event->contextinstanceid,
56-
'http://id.tincanapi.com/activitytype/lms/module'
55+
$event->contextinstanceid
5756
),
58-
'timestamp' => utils\get_event_timestamp($event),
5957
'context' => [
60-
'platform' => $config['source_name'],
6158
'language' => $lang,
6259
'extensions' => utils\extensions\base($config, $event, $course),
6360
'contextActivities' => [
64-
'grouping' => [
61+
'parent' => utils\context_activities\get_parent(
62+
$config,
63+
$event->contextinstanceid
64+
),
65+
'category' => [
6566
utils\get_activity\site($config),
66-
utils\get_activity\course($config, $course),
6767
],
68-
'category' => [
69-
utils\get_activity\source($config),
70-
]
7168
],
72-
]
69+
],
7370
]];
7471
}

0 commit comments

Comments
 (0)