Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ajax/moveback_to_log.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Prepare events to replay.
*
Expand Down
17 changes: 9 additions & 8 deletions classes/log/moveback.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* @subpackage log
* @author Záborski László <[email protected]>
* @copyright 2020 Learning Pool Ltd (http://learningpool.com)
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class moveback {

Expand All @@ -40,7 +41,7 @@ class moveback {
*
* @var array event ids[]
*/
protected $eventids = array();
protected $eventids = [];

/**
* The table where the process works
Expand Down Expand Up @@ -68,7 +69,7 @@ class moveback {
*
* @var string
*/
protected $params = array();
protected $params = [];

/**
* Standard constructor for class.
Expand Down Expand Up @@ -123,9 +124,9 @@ protected function move_event($event) {
$event->type = $this->type;

if ($this->historical) {
$params = array(
'logstorestandardlogid' => $event->id
);
$params = [
'logstorestandardlogid' => $event->id,
];

$event->logstorestandardlogid = $event->id;

Expand All @@ -136,9 +137,9 @@ protected function move_event($event) {
} else {
unset($event->errortype, $event->response);

$params = array(
'id' => $event->id
);
$params = [
'id' => $event->id,
];
}

if (!$skipinsert) {
Expand Down
24 changes: 12 additions & 12 deletions classes/log/store.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
require_once($CFG->dirroot . '/admin/tool/log/store/xapi/lib.php');

use core_plugin_manager;
use \tool_log\log\writer as log_writer;
use \tool_log\log\manager as log_manager;
use \tool_log\helper\store as helper_store;
use \tool_log\helper\reader as helper_reader;
use \tool_log\helper\buffered_writer as helper_writer;
use \core\event\base as event_base;
use \stdClass as php_obj;
use tool_log\log\writer as log_writer;
use tool_log\log\manager as log_manager;
use tool_log\helper\store as helper_store;
use tool_log\helper\reader as helper_reader;
use tool_log\helper\buffered_writer as helper_writer;
use core\event\base as event_base;
use stdClass as php_obj;
/**
* Processes events and enables them to be sent to a logstore.
*
Expand Down Expand Up @@ -80,8 +80,8 @@ protected function is_event_ignored(event_base $event) {
protected function get_event_id($event) {
global $DB;

$sqlparams = array();
$where = array('1 = 1');
$sqlparams = [];
$where = ['1 = 1'];

if (!empty($event->eventname)) {
$sqlparams['eventname'] = $event->eventname;
Expand Down Expand Up @@ -292,13 +292,13 @@ protected function get_handler_config() {
$source = [
'source_url' => 'http://totaralearning.com',
'source_name' => 'Totara Learn',
'source_version' => $CFG->totara_version
'source_version' => $CFG->totara_version,
];
} else {
$source = [
'source_url' => 'http://moodle.org',
'source_name' => 'Moodle',
'source_version' => $CFG->release
'source_version' => $CFG->release,
];
}

Expand All @@ -322,7 +322,7 @@ public function is_logging() {
* @return array of objects of events.
*/
protected function convert_array_to_objects($events) {
$return = array();
$return = [];

if (!empty($events)) {
foreach ($events as $event) {
Expand Down
4 changes: 2 additions & 2 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class provider implements
* @param collection $collection a reference to the collection to use to store the metadata.
* @return collection the updated collection of metadata items.
*/
public static function get_metadata(collection $collection) : collection {
public static function get_metadata(collection $collection): collection {
$collection->add_database_table(
'logstore_xapi_log',
[
Expand All @@ -75,7 +75,7 @@ public static function get_metadata(collection $collection) : collection {
* @param int $userid The user to search.
* @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin.
*/
public static function get_contexts_for_userid(int $userid) : contextlist {
public static function get_contexts_for_userid(int $userid): contextlist {
return new contextlist();
}

Expand Down
2 changes: 1 addition & 1 deletion classes/task/sendfailednotifications_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private function get_failed_last_id($lastsentid) {

$params = [
'threshold' => get_config('logstore_xapi', 'errornotificationtrigger'),
'lastsentid' => $lastsentid
'lastsentid' => $lastsentid,
];

$lastnotification = $DB->get_record_sql($sql, $params);
Expand Down
4 changes: 2 additions & 2 deletions cli/testdataseeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ function create_user($username, $firstname, $lastname) {
global $DB;

// Check if user exists.
$user = $DB->get_record('user', array('username' => $username), "id,username");
$user = $DB->get_record('user', ['username' => $username], "id,username");
if ($user) {
return $user->id;
}
Expand All @@ -285,7 +285,7 @@ function create_user($username, $firstname, $lastname) {
$user = $generator->create_user([
'username' => $username,
'firstname' => $firstname,
'lastname' => $lastname
'lastname' => $lastname,
]);
} catch (Exception $e) {
echo $e->getMessage() . PHP_EOL;
Expand Down
52 changes: 26 additions & 26 deletions db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,29 @@

defined('MOODLE_INTERNAL') || die();

$capabilities = array(
'logstore/xapi:viewerrorlog' => array(
'riskbitmask' => RISK_CONFIG,
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'manager' => CAP_ALLOW
)
),
'logstore/xapi:manageerrors' => array(
'riskbitmask' => RISK_CONFIG,
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'manager' => CAP_ALLOW
)
),
'logstore/xapi:managehistoric' => array(
'riskbitmask' => RISK_CONFIG,
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'manager' => CAP_ALLOW
)
)
);
$capabilities = [
'logstore/xapi:viewerrorlog' => [
'riskbitmask' => RISK_CONFIG,
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => [
'manager' => CAP_ALLOW,
],
],
'logstore/xapi:manageerrors' => [
'riskbitmask' => RISK_CONFIG,
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => [
'manager' => CAP_ALLOW,
],
],
'logstore/xapi:managehistoric' => [
'riskbitmask' => RISK_CONFIG,
'captype' => 'read',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => [
'manager' => CAP_ALLOW,
],
],
];
28 changes: 14 additions & 14 deletions db/tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,41 @@

defined('MOODLE_INTERNAL') || die();

$tasks = array(
array(
$tasks = [
[
'classname' => '\logstore_xapi\task\emit_task',
'blocking' => 0,
'minute' => '*/1',
'hour' => '*',
'day' => '*',
'dayofweek' => '*',
'month' => '*'
),
array(
'month' => '*',
],
[
'classname' => '\logstore_xapi\task\failed_task',
'blocking' => 0,
'minute' => '*/30',
'hour' => '*',
'day' => '*',
'dayofweek' => '*',
'month' => '*'
),
array(
'month' => '*',
],
[
'classname' => '\logstore_xapi\task\historical_task',
'blocking' => 0,
'minute' => '0',
'hour' => '*',
'day' => '*',
'dayofweek' => '*',
'month' => '*'
),
array(
'month' => '*',
],
[
'classname' => '\logstore_xapi\task\sendfailednotifications_task',
'blocking' => 0,
'minute' => '*',
'hour' => '*/2',
'day' => '*',
'dayofweek' => '*',
'month' => '*'
),
);
'month' => '*',
],
];
32 changes: 16 additions & 16 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ function create_xapi_log_table($dbman, $tablename) {
$table->add_field('realuserid', XMLDB_TYPE_INTEGER, '10', null, null, null, null);

// Adding keys to table.
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);

// Adding indexes to table.
$table->add_index('timecreated', XMLDB_INDEX_NOTUNIQUE, array('timecreated'));
$table->add_index('course-time', XMLDB_INDEX_NOTUNIQUE, array('courseid', 'anonymous', 'timecreated'));
$table->add_index('user-module', XMLDB_INDEX_NOTUNIQUE, array(
$table->add_index('timecreated', XMLDB_INDEX_NOTUNIQUE, ['timecreated']);
$table->add_index('course-time', XMLDB_INDEX_NOTUNIQUE, ['courseid', 'anonymous', 'timecreated']);
$table->add_index('user-module', XMLDB_INDEX_NOTUNIQUE, [
'userid',
'contextlevel',
'contextinstanceid',
'crud',
'edulevel',
'timecreated'
));
'timecreated',
]);

// Conditionally launch create table.
if (!$dbman->table_exists($table)) {
Expand All @@ -97,12 +97,12 @@ function create_xapi_sent_log_table($dbman, $tablename) {
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);

// Adding keys to table.
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);

// Adding indexes to table.
$table->add_index('logstorestandardlogid', XMLDB_INDEX_NOTUNIQUE, array('logstorestandardlogid'));
$table->add_index('type', XMLDB_INDEX_NOTUNIQUE, array('type'));
$table->add_index('timecreated', XMLDB_INDEX_NOTUNIQUE, array('timecreated'));
$table->add_index('logstorestandardlogid', XMLDB_INDEX_NOTUNIQUE, ['logstorestandardlogid']);
$table->add_index('type', XMLDB_INDEX_NOTUNIQUE, ['type']);
$table->add_index('timecreated', XMLDB_INDEX_NOTUNIQUE, ['timecreated']);

// Conditionally launch create table.
if (!$dbman->table_exists($table)) {
Expand All @@ -127,7 +127,7 @@ function add_logstorestandardlogid_type_to_table($dbman, $tablename) {
$dbman->add_field($table, $field);
}

$index = new xmldb_index("logstorestandardlogid", XMLDB_INDEX_NOTUNIQUE, array('logstorestandardlogid'));
$index = new xmldb_index("logstorestandardlogid", XMLDB_INDEX_NOTUNIQUE, ['logstorestandardlogid']);
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
Expand All @@ -138,7 +138,7 @@ function add_logstorestandardlogid_type_to_table($dbman, $tablename) {
$dbman->add_field($table, $field);
}

$index = new xmldb_index("type", XMLDB_INDEX_NOTUNIQUE, array('type'));
$index = new xmldb_index("type", XMLDB_INDEX_NOTUNIQUE, ['type']);
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
Expand Down Expand Up @@ -173,12 +173,12 @@ function create_xapi_notification_table($dbman, $tablename) {
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);

// Adding keys to table.
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);

// Adding indexes to table.
$table->add_index('failedlogid', XMLDB_INDEX_NOTUNIQUE, array('failedlogid'));
$table->add_index('email', XMLDB_INDEX_NOTUNIQUE, array('email'));
$table->add_index('timecreated', XMLDB_INDEX_NOTUNIQUE, array('timecreated'));
$table->add_index('failedlogid', XMLDB_INDEX_NOTUNIQUE, ['failedlogid']);
$table->add_index('email', XMLDB_INDEX_NOTUNIQUE, ['email']);
$table->add_index('timecreated', XMLDB_INDEX_NOTUNIQUE, ['timecreated']);

// Conditionally launch create table.
if (!$dbman->table_exists($table)) {
Expand Down
Loading
Loading