Skip to content

Commit

Permalink
Merge pull request #110 from xAPI-vle/v2.0.0
Browse files Browse the repository at this point in the history
V2.0.0 - Merge Repositories into one, resolve (easy) codeclimate issues
  • Loading branch information
davidpesce authored Jun 13, 2017
2 parents 0ced99e + 8627571 commit 36da01e
Show file tree
Hide file tree
Showing 196 changed files with 11,665 additions and 195 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Build Status](https://travis-ci.org/xAPI-vle/moodle-logstore_xapi.svg?branch=master)](https://travis-ci.org/xAPI-vle/moodle-logstore_xapi)
[![Code Climate](https://codeclimate.com/github/xAPI-vle/moodle-logstore_xapi.png)](https://codeclimate.com/github/xAPI-vle/moodle-logstore_xapi)
[![Moodle Plugin Directory](http://img.shields.io/badge/moodle-plugin-orange.svg)](https://moodle.org/plugins/view/logstore_xapi)
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/LearningLocker/learninglocker?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/LearningLocker/learninglocker?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

- [Installation](docs/installation.md)
- [Report bugs, enhancements, and questions](contributing.md#issue-templates)
Expand Down
48 changes: 24 additions & 24 deletions classes/log/store.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct(log_manager $manager) {
*
*/
protected function is_event_ignored(event_base $event) {
if ((!CLI_SCRIPT || PHPUNIT_TEST) && !$this->logguests && (!isloggedin() || isguestuser())) {
if ((!CLI_SCRIPT || PHPUNIT_TEST) && !$this->logguests && isguestuser()) {
// Always log inside CLI scripts because we do not login there.
return true;
}
Expand Down Expand Up @@ -109,9 +109,9 @@ protected function insert_event_entries(array $events) {
public function process_events(array $events) {

// Initializes required services.
$xapicontroller = new xapi_controller($this->connect_xapi_repository());
$moodlecontroller = new moodle_controller($this->connect_moodle_repository());
$translatorcontroller = new translator_controller();
$xapiController = new xapi_controller($this->connect_xapi_repository());
$moodleController = new moodle_controller($this->connect_moodle_repository());
$translatorController = new translator_controller();

// Emits events to other APIs.
foreach ($events as $index => $event) {
Expand All @@ -120,45 +120,45 @@ public function process_events(array $events) {

$this->error_log('');
$this->error_log_value('events', $events);
$moodleevents = $moodlecontroller->createEvents($events);
$moodleEvents = $moodleController->createEvents($events);

// Clear the user email if mbox setting is not set to mbox
$mbox = get_config('logstore_xapi', 'mbox');
foreach(array_keys($moodleevents) as $event_key) {
$moodleevents[$event_key]['sendmbox'] = $mbox;
foreach(array_keys($moodleEvents) as $event_key) {
$moodleEvents[$event_key]['sendmbox'] = $mbox;
}

$this->error_log_value('moodleevent', $moodleevents);
$translatorevents = $translatorcontroller->createEvents($moodleevents);
$this->error_log_value('translatorevents', $translatorevents);
$this->error_log_value('moodleevent', $moodleEvents);
$translatorEvents = $translatorController->createEvents($moodleEvents);
$this->error_log_value('translatorevents', $translatorEvents);

if (empty($translatorevents)) {
if (empty($translatorEvents)) {
return [];
}

// Split statements into batches.
$eventbatches = array($translatorevents);
$maxbatchsize = get_config('logstore_xapi', 'maxbatchsize');
$eventBatches = array($translatorEvents);
$maxBatchSize = get_config('logstore_xapi', 'maxbatchsize');

if (!empty($maxbatchsize) && $maxbatchsize < count($translatorevents)) {
$eventbatches = array_chunk($translatorevents, $maxbatchsize);
if (!empty($maxBatchSize) && $maxBatchSize < count($translatorEvents)) {
$eventBatches = array_chunk($translatorEvents, $maxBatchSize);
}

$translator_event = new Event();
$translator_event_read_return = @$translator_event->read([]);
$translatorEvent = new Event();
$translatorEventReadReturn = @$translatorEvent->read([]);

$sent_events = [];
foreach ($eventbatches as $translatoreventsbatch) {
$xapievents = $xapicontroller->createEvents($translatoreventsbatch);
foreach(array_keys($xapievents) as $key) {
$sentEvents = [];
foreach ($eventBatches as $translatorEventsBatch) {
$xapiEvents = $xapiController->createEvents($translatorEventsBatch);
foreach(array_keys($xapiEvents) as $key) {
if (is_numeric($key)) {
$sent_events[$xapievents[$key]['context']['extensions'][$translator_event_read_return[0]['context_ext_key']]['id']] = $xapievents['last_action_result'];
$sentEvents[$xapiEvents[$key]['context']['extensions'][$translatorEventReadReturn[0]['context_ext_key']]['id']] = $xapiEvents['last_action_result'];
}
}
$this->error_log_value('xapievents', $xapievents);
$this->error_log_value('xapievents', $xapiEvents);
}

return $sent_events;
return $sentEvents;
}

private function error_log_value($key, $value) {
Expand Down
15 changes: 9 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
{
"name": "jlowe64/moodle-logstore-xapi",
"name": "xAPI-vle/moodle-logstore-xapi",
"license": "GPL v3",
"autoload": {
"psr-4": {
"logstore_xapi\\": "classes/",
"Tests\\": "tests/"
"Tests\\": "tests/",
"XREmitter\\": "lib/emitter/src/",
"XREmitter\\Tests\\": "lib/emitter/tests/",
"LogExpander\\": "lib/expander/src/",
"LogExpander\\Tests\\": "lib/expander/tests/",
"MXTranslator\\": "lib/translator/src/",
"MXTranslator\\Tests\\": "lib/translator/tests/"
}
},
"require-dev": {
Expand All @@ -13,10 +19,7 @@
},
"require": {
"php": "~5.5 || ^7.0.3",
"rusticisoftware/tincan": "1.0.0",
"learninglocker/moodle-log-expander": "~1.5",
"learninglocker/moodle-xapi-translator": "~1.7",
"learninglocker/xapi-recipe-emitter": "~1.6"
"rusticisoftware/tincan": "1.0.0"
},
"prefer-stable": true,
"minimum-stability": "dev"
Expand Down
121 changes: 13 additions & 108 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions docs/developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ If you've read the [plugin design](design.md) you should understand what each of
- [Moodle to xAPI Translator](https://github.com/LearningLocker/Moodle-xAPI-Translator/blob/master/docs/readme.md#adding-events)
- [xAPI Recipe Emitter](https://github.com/LearningLocker/xAPI-Recipe-Emitter/blob/master/docs/readme.md#adding-events)

##PHPUnit Test Filter
All PHPUnit tests should pass, but if you'd like to only run the tests for specific events, add the 'filter' option.
```
vendor/bin/phpunit --filter <Test_Name>
```

## Release Process
This process has been documented for collaborators (users that have write access to the repository) who are releasing new versions of this plugin.

Expand Down
Loading

0 comments on commit 36da01e

Please sign in to comment.