Skip to content

Commit

Permalink
Merge pull request #158 from davidpesce/mikemcgowan_context_key_fix
Browse files Browse the repository at this point in the history
re-did mikemcgowans fix for the context key in translator
  • Loading branch information
davidpesce authored Feb 22, 2018
2 parents 0e528ff + 4a9d7e2 commit 373dea9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 1 addition & 4 deletions classes/log/store.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,14 @@ public function process_events(array $events) {
$eventbatches = array_chunk($translatorevents, $maxbatchsize);
}

$translatorevent = new Event();
$translatoreventreadreturn = @$translatorevent->read([]);

$sentevents = [];
foreach ($eventbatches as $translatoreventsbatch) {
$xapievents = $xapicontroller->create_events($translatoreventsbatch);
$statements = $xapievents['statements'];
$response = $xapievents['response'];
foreach (array_keys($statements) as $key) {
if (is_numeric($key)) {
$k = $statements[$key]['context']['extensions'][$translatoreventreadreturn[0]['context_ext_key']]['id'];
$k = $xapievents[$key]['context']['extensions'][Event::CONTEXT_EXT_KEY]['id'];
$sentevents[$k] = $this->getlast_action_result($response);
}
}
Expand Down
8 changes: 7 additions & 1 deletion lib/translator/src/Events/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
use \stdClass as PhpObj;

class Event extends PhpObj {

/**
* @var string
*/
const CONTEXT_EXT_KEY = 'http://lrs.learninglocker.net/define/extensions/moodle_logstore_standard_log';

protected static $xapitype = 'http://lrs.learninglocker.net/define/type/moodle/';

/**
Expand All @@ -41,7 +47,7 @@ public function read(array $opts) {
|| $opts['course']->lang == '' ? "en" : $opts['course']->lang,
'context_platform' => 'Moodle',
'context_ext' => $opts['event'],
'context_ext_key' => 'http://lrs.learninglocker.net/define/extensions/moodle_logstore_standard_log',
'context_ext_key' => self::CONTEXT_EXT_KEY,
'context_info' => $opts['info'],
'time' => date('c', $opts['event']['timecreated']),
'app_url' => $opts['app']->url,
Expand Down

0 comments on commit 373dea9

Please sign in to comment.