diff --git a/classes/log/store.php b/classes/log/store.php index e80358007..89381470f 100755 --- a/classes/log/store.php +++ b/classes/log/store.php @@ -148,9 +148,6 @@ 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); @@ -158,7 +155,7 @@ public function process_events(array $events) { $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); } } diff --git a/lib/translator/src/Events/Event.php b/lib/translator/src/Events/Event.php index a2b8c7cdf..aa076a300 100644 --- a/lib/translator/src/Events/Event.php +++ b/lib/translator/src/Events/Event.php @@ -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/'; /** @@ -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,