Skip to content
Snippets Groups Projects
Commit 0f00cae0 authored by Ryan Smith's avatar Ryan Smith Committed by GitHub
Browse files

Merge pull request #119 from mikemcgowan/travis

Updated .travis.yml to support Moodlerooms plugin
parents 6b6f5cba 1dbf2c1b
No related branches found
No related tags found
No related merge requests found
Showing
with 432 additions and 316 deletions
<?php namespace LogExpander;
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace LogExpander;
defined('MOODLE_INTERNAL') || die();
use \stdClass as PhpObj;
class Controller extends PhpObj {
protected $repo;
public static $routes = [
......@@ -10,7 +30,7 @@ class Controller extends PhpObj {
'\mod_folder\event\course_module_viewed' => 'ModuleEvent',
'\mod_forum\event\course_module_viewed' => 'ModuleEvent',
'\mod_forum\event\discussion_viewed' => 'DiscussionEvent',
'\mod_forum\event\user_report_viewed' => 'ModuleEvent',
'\mod_forum\event\user_report_viewed' => 'ModuleEvent',
'\mod_book\event\course_module_viewed' => 'ModuleEvent',
'\mod_scorm\event\course_module_viewed' => 'ModuleEvent',
'\mod_resource\event\course_module_viewed' => 'ModuleEvent',
......@@ -41,10 +61,11 @@ class Controller extends PhpObj {
'\mod_facetoface\event\signup_success' => 'FacetofaceEvent',
'\mod_facetoface\event\cancel_booking' => 'FacetofaceEvent',
'\mod_facetoface\event\take_attendance' => 'FacetofaceAttended',
'\core\event\course_completed'=>'CourseCompleted',
'\mod_scorm\event\scoreraw_submitted'=>'ScormSubmitted',
'\mod_scorm\event\status_submitted'=>'ScormSubmitted'
'\core\event\course_completed' => 'CourseCompleted',
'\mod_scorm\event\scoreraw_submitted' => 'ScormSubmitted',
'\mod_scorm\event\status_submitted' => 'ScormSubmitted',
];
/**
* Constructs a new Controller.
* @param Repository $repo
......@@ -52,12 +73,13 @@ class Controller extends PhpObj {
public function __construct(Repository $repo) {
$this->repo = $repo;
}
/**
* Creates new events.
* @param [String => Mixed] $events
* @return [String => Mixed]
*/
public function createEvents(array $events) {
public function create_events(array $events) {
$results = [];
foreach ($events as $index => $opts) {
$route = isset($opts['eventname']) ? $opts['eventname'] : '';
......@@ -65,8 +87,7 @@ class Controller extends PhpObj {
try {
$event = '\LogExpander\Events\\'.static::$routes[$route];
array_push($results , (new $event($this->repo))->read($opts));
}
catch (\Exception $e) {
} catch (\Exception $e) { // @codingStandardsIgnoreLine
// Error processing event; skip it.
}
}
......
<?php namespace LogExpander\Events;
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace LogExpander\Events;
defined('MOODLE_INTERNAL') || die();
class AssignmentGraded extends Event {
/**
......@@ -8,15 +26,15 @@ class AssignmentGraded extends Event {
* @override Event
*/
public function read(array $opts) {
$grade = $this->repo->readObject($opts['objectid'], $opts['objecttable']);
$gradeComment = $this->repo->readGradeComment($grade->id, $grade->assignment)->commenttext;
$gradeItems = $this->repo->readGradeItems($grade->assignment, 'assign');
$grade = $this->repo->read_object($opts['objectid'], $opts['objecttable']);
$gradecomment = $this->repo->read_grade_comment($grade->id, $grade->assignment)->commenttext;
$gradeitems = $this->repo->read_grade_items($grade->assignment, 'assign');
return array_merge(parent::read($opts), [
'grade' => $grade,
'grade_comment' => $gradeComment,
'grade_items' => $gradeItems,
'graded_user' => $this->repo->readUser($grade->userid),
'module' => $this->repo->readModule($grade->assignment, 'assign'),
'grade_comment' => $gradecomment,
'grade_items' => $gradeitems,
'graded_user' => $this->repo->read_user($grade->userid),
'module' => $this->repo->read_module($grade->assignment, 'assign'),
]);
}
}
\ No newline at end of file
}
<?php namespace LogExpander\Events;
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace LogExpander\Events;
defined('MOODLE_INTERNAL') || die();
class AssignmentSubmitted extends Event {
/**
......@@ -8,10 +26,10 @@ class AssignmentSubmitted extends Event {
* @override Event
*/
public function read(array $opts) {
$submission = $this->repo->readObject($opts['objectid'], $opts['objecttable']);
$submission = $this->repo->read_object($opts['objectid'], $opts['objecttable']);
return array_merge(parent::read($opts), [
'submission' => $submission,
'module' => $this->repo->readModule($submission->assignment, 'assign'),
'module' => $this->repo->read_module($submission->assignment, 'assign'),
]);
}
}
\ No newline at end of file
}
<?php namespace LogExpander\Events;
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace LogExpander\Events;
defined('MOODLE_INTERNAL') || die();
class AttemptEvent extends Event {
/**
......@@ -8,16 +26,16 @@ class AttemptEvent extends Event {
* @override Event
*/
public function read(array $opts) {
$attempt = $this->repo->readAttempt($opts['objectid']);
$gradeItems = $this->repo->readGradeItems($attempt->quiz, 'quiz');
$attempt->questions = $this->repo->readQuestionAttempts($attempt->id);
$questions = $this->repo->readQuestions($attempt->quiz);
$attempt = $this->repo->read_attempt($opts['objectid']);
$gradeitems = $this->repo->read_grade_items($attempt->quiz, 'quiz');
$attempt->questions = $this->repo->read_question_attempts($attempt->id);
$questions = $this->repo->read_questions($attempt->quiz);
return array_merge(parent::read($opts), [
'attempt' => $attempt,
'module' => $this->repo->readModule($attempt->quiz, 'quiz'),
'grade_items' => $gradeItems,
'module' => $this->repo->read_module($attempt->quiz, 'quiz'),
'grade_items' => $gradeitems,
'questions' => $questions
]);
}
}
\ No newline at end of file
}
<?php
/**
* Created by PhpStorm.
* User: lee.kirkland
* Date: 5/20/2016
* Time: 9:12 AM
*/
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace LogExpander\Events;
defined('MOODLE_INTERNAL') || die();
class CourseCompleted extends Event
{
class CourseCompleted extends Event {
/**
* Reads data for an event.
* @param [String => Mixed] $opts
......@@ -18,7 +26,6 @@ class CourseCompleted extends Event
* @override Event
*/
public function read(array $opts) {
return array_merge(parent::read($opts), [
]);
return array_merge(parent::read($opts), []);
}
}
\ No newline at end of file
}
<?php namespace LogExpander\Events;
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace LogExpander\Events;
defined('MOODLE_INTERNAL') || die();
class DiscussionEvent extends Event {
/**
......@@ -8,10 +26,10 @@ class DiscussionEvent extends Event {
* @override Event
*/
public function read(array $opts) {
$discussion = $this->repo->readDiscussion($opts['objectid']);
$discussion = $this->repo->read_discussion($opts['objectid']);
return array_merge(parent::read($opts), [
'discussion' => $discussion,
'module' => $this->repo->readModule($discussion->forum, 'forum'),
'module' => $this->repo->read_module($discussion->forum, 'forum'),
]);
}
}
\ No newline at end of file
}
<?php namespace LogExpander\Events;
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace LogExpander\Events;
defined('MOODLE_INTERNAL') || die();
use \LogExpander\Repository as Repository;
use \stdClass as PhpObj;
......@@ -20,12 +39,12 @@ class Event extends PhpObj {
*/
public function read(array $opts) {
return [
'user' => $opts['userid'] < 1 ? null : $this->repo->readUser($opts['userid']),
'relateduser' => $opts['relateduserid'] < 1 ? null : $this->repo->readUser($opts['relateduserid']),
'course' => $this->repo->readCourse($opts['courseid']),
'app' => $this->repo->readSite(),
'user' => $opts['userid'] < 1 ? null : $this->repo->read_user($opts['userid']),
'relateduser' => $opts['relateduserid'] < 1 ? null : $this->repo->read_user($opts['relateduserid']),
'course' => $this->repo->read_course($opts['courseid']),
'app' => $this->repo->read_site(),
'info' => (object) [
'https://moodle.org/' => $this->repo->readRelease(),
'https://moodle.org/' => $this->repo->read_release(),
],
'event' => $opts,
];
......
<?php namespace LogExpander\Events;
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace LogExpander\Events;
defined('MOODLE_INTERNAL') || die();
class FacetofaceAttended extends FacetofaceEvent {
/**
......@@ -8,9 +26,9 @@ class FacetofaceAttended extends FacetofaceEvent {
* @override Event
*/
public function read(array $opts) {
$session = $this->repo->readFacetofaceSession($opts['objectid']);
$session = $this->repo->read_facetoface_session($opts['objectid']);
return array_merge(parent::read($opts), [
'signups' => $this->repo->readFacetofaceSessionSignups($opts['objectid'], $opts['timecreated'])
'signups' => $this->repo->read_facetoface_session_signups($opts['objectid'], $opts['timecreated'])
]);
}
}
\ No newline at end of file
}
<?php namespace LogExpander\Events;
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace LogExpander\Events;
defined('MOODLE_INTERNAL') || die();
class FacetofaceEvent extends Event {
/**
......@@ -9,10 +27,10 @@ class FacetofaceEvent extends Event {
*/
public function read(array $opts) {
$session = $this->repo->readFacetofaceSession($opts['objectid']);
$session = $this->repo->read_facetoface_session($opts['objectid']);
return array_merge(parent::read($opts), [
'module' => $this->repo->readModule($session->facetoface, 'facetoface'),
'module' => $this->repo->read_module($session->facetoface, 'facetoface'),
'session' => $session
]);
}
}
\ No newline at end of file
}
<?php namespace LogExpander\Events;
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace LogExpander\Events;
defined('MOODLE_INTERNAL') || die();
class FeedbackSubmitted extends Event {
/**
......@@ -8,12 +26,11 @@ class FeedbackSubmitted extends Event {
* @override Event
*/
public function read(array $opts) {
$attempt = $this->repo->readFeedbackAttempt($opts['objectid']);
$attempt->timemodified = $this->timeSelector($attempt);
$attempt = $this->repo->read_feedback_attempt($opts['objectid']);
$attempt->timemodified = $this->time_selector($attempt);
return array_merge(parent::read($opts), [
'module' => $this->repo->readModule($attempt->feedback, 'feedback'),
'questions' => $this->repo->readFeedbackQuestions($attempt->feedback),
'module' => $this->repo->read_module($attempt->feedback, 'feedback'),
'questions' => $this->repo->read_feedback_questions($attempt->feedback),
'attempt' => $attempt,
]);
}
......@@ -24,17 +41,16 @@ class FeedbackSubmitted extends Event {
* @param $attempt
* @return int
*/
private function timeSelector($attempt) {
$retValue = time();
private function time_selector($attempt) {
$retvalue = time();
if (!empty($attempt->timemodified)) {
$retValue = $attempt->timemodified;
$retvalue = $attempt->timemodified;
} else if (!empty($attempt->timefinished)) {
$retValue = $attempt->timefinished;
$retvalue = $attempt->timefinished;
} else if (!empty($attempt->timestarted)) {
$retValue = $attempt->timestarted;
$retvalue = $attempt->timestarted;
}
return $retValue;
return $retvalue;
}
}
\ No newline at end of file
}
<?php namespace LogExpander\Events;
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace LogExpander\Events;
defined('MOODLE_INTERNAL') || die();
class ModuleEvent extends Event {
/**
......@@ -9,7 +27,7 @@ class ModuleEvent extends Event {
*/
public function read(array $opts) {
return array_merge(parent::read($opts), [
'module' => $this->repo->readModule($opts['objectid'], $opts['objecttable']),
'module' => $this->repo->read_module($opts['objectid'], $opts['objecttable']),
]);
}
}
\ No newline at end of file
}
<?php namespace LogExpander\Events;
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace LogExpander\Events;
defined('MOODLE_INTERNAL') || die();
class ScormLaunched extends Event {
/**
......@@ -8,10 +26,10 @@ class ScormLaunched extends Event {
* @override Event
*/
public function read(array $opts) {
$scormScoes = $this->repo->readObject($opts['objectid'], $opts['objecttable']);
$scormscoes = $this->repo->read_object($opts['objectid'], $opts['objecttable']);
return array_merge(parent::read($opts), [
'module' => $this->repo->readModule($scormScoes->scorm, 'scorm'),
'scorm_scoes' => $scormScoes
'module' => $this->repo->read_module($scormscoes->scorm, 'scorm'),
'scorm_scoes' => $scormscoes
]);
}
}
\ No newline at end of file
}
<?php namespace LogExpander\Events;
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace LogExpander\Events;
defined('MOODLE_INTERNAL') || die();
class ScormSubmitted extends Event {
/**
......@@ -8,11 +26,11 @@ class ScormSubmitted extends Event {
* @override Event
*/
public function read(array $opts) {
$cmiUnserialized = unserialize($opts['other']);
$cmiunserialized = unserialize($opts['other']);
$scoid = $opts['contextinstanceid'];
$scormid = $opts['objectid'];
$attempt = $cmiUnserialized['attemptid'];
$scormScoesTrack = $this->repo->readScormScoesTrack(
$attempt = $cmiunserialized['attemptid'];
$scormscoestrack = $this->repo->read_scorm_scoes_track(
$opts['userid'],
$scormid,
$scoid,
......@@ -20,10 +38,10 @@ class ScormSubmitted extends Event {
);
return array_merge(parent::read($opts), [
'module' => $this->repo->readModule($scormid, 'scorm'),
'scorm_scoes_track' => $scormScoesTrack,
'scorm_scoes' => $this->repo->readScormScoes($scoid),
'cmi_data' => $cmiUnserialized,
'module' => $this->repo->read_module($scormid, 'scorm'),
'scorm_scoes_track' => $scormscoestrack,
'scorm_scoes' => $this->repo->read_scorm_scoes($scoid),
'cmi_data' => $cmiunserialized,
]);
}
}
<?php namespace LogExpander;
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace LogExpander;
defined('MOODLE_INTERNAL') || die();
use \stdClass as PhpObj;
use Exception;
......@@ -23,7 +42,7 @@ class Repository extends PhpObj {
* @throws Exception if the record was not found
* @return PhpObj
*/
protected function readStoreRecord($type, array $query) {
protected function read_store_record($type, array $query) {
$model = $this->store->get_record($type, $query);
if ($model === false) {
throw new Exception('Record not found.');
......@@ -37,7 +56,7 @@ class Repository extends PhpObj {
* @param [String => Mixed] $query
* @return PhpArr
*/
protected function readStoreRecords($type, array $query) {
protected function read_store_records($type, array $query) {
$model = $this->store->get_records($type, $query);
return $model;
}
......@@ -57,8 +76,8 @@ class Repository extends PhpObj {
* @param String $type
* @return PhpObj
*/
public function readObject($id, $type) {
$model = $this->readStoreRecord($type, ['id' => $id]);
public function read_object($id, $type) {
$model = $this->read_store_record($type, ['id' => $id]);
$model->type = $type;
return $model;
}
......@@ -69,15 +88,15 @@ class Repository extends PhpObj {
* @param String $type
* @return PhpObj
*/
public function readModule($id, $type) {
$model = $this->readObject($id, $type);
$module = $this->readStoreRecord('modules', ['name' => $type]);
$courseModule = $this->readStoreRecord('course_modules', [
public function read_module($id, $type) {
$model = $this->read_object($id, $type);
$module = $this->read_store_record('modules', ['name' => $type]);
$coursemodule = $this->read_store_record('course_modules', [
'instance' => $id,
'module' => $module->id,
'course' => $model->course
]);
$model->url = $this->cfg->wwwroot . '/mod/'.$type.'/view.php?id=' . $courseModule->id;
$model->url = $this->cfg->wwwroot . '/mod/'.$type.'/view.php?id=' . $coursemodule->id;
return $model;
}
......@@ -86,8 +105,8 @@ class Repository extends PhpObj {
* @param String $id
* @return PhpObj
*/
public function readAttempt($id) {
$model = $this->readObject($id, 'quiz_attempts');
public function read_attempt($id) {
$model = $this->read_object($id, 'quiz_attempts');
$model->url = $this->cfg->wwwroot . '/mod/quiz/attempt.php?attempt='.$id;
$model->name = 'Attempt '.$id;
return $model;
......@@ -98,57 +117,62 @@ class Repository extends PhpObj {
* @param String $id
* @return PhpArr
*/
public function readQuestionAttempts($id) {
$questionAttempts = $this->readStoreRecords('question_attempts', ['questionusageid' => $id]);
foreach ($questionAttempts as $questionIndex => $questionAttempt) {
$questionAttemptSteps = $this->readStoreRecords('question_attempt_steps', ['questionattemptid' => $questionAttempt->id]);
foreach ($questionAttemptSteps as $stepIndex => $questionAttemptStep) {
$questionAttemptStep->data = $this->readStoreRecords('question_attempt_step_data', ['attemptstepid' => $questionAttemptStep->id]);
public function read_question_attempts($id) {
$questionattempts = $this->read_store_records('question_attempts', ['questionusageid' => $id]);
foreach ($questionattempts as $questionindex => $questionattempt) {
$questionattemptsteps = $this->read_store_records(
'question_attempt_steps',
['questionattemptid' => $questionattempt->id]
);
foreach ($questionattemptsteps as $stepindex => $questionattemptstep) {
$questionattemptstep->data = $this->read_store_records(
'question_attempt_step_data',
['attemptstepid' => $questionattemptstep->id]
);
}
$questionAttempt->steps = $questionAttemptSteps;
$questionattempt->steps = $questionattemptsteps;
}
return $questionAttempts;
return $questionattempts;
}
/**
* Reads questions from the store with the given quiz id.
* @param String $id
* @param string $quizid
* @return PhpArr
*/
public function readQuestions($quizId) {
$quizSlots = $this->readStoreRecords('quiz_slots', ['quizid' => $quizId]);
public function read_questions($quizid) {
$quizslots = $this->read_store_records('quiz_slots', ['quizid' => $quizid]);
$questions = [];
foreach ($quizSlots as $index => $quizSlot) {
foreach ($quizslots as $index => $quizslot) {
try {
$question = $this->readStoreRecord('question', ['id' => $quizSlot->questionid]);
$question->answers = $this->readStoreRecords('question_answers', ['question' => $question->id]);
$question = $this->read_store_record('question', ['id' => $quizslot->questionid]);
$question->answers = $this->read_store_records('question_answers', ['question' => $question->id]);
$question->url = $this->cfg->wwwroot . '/mod/question/question.php?id='.$question->id;
if ($question->qtype == 'numerical') {
$question->numerical = (object)[
'answers' => $this->readStoreRecords('question_numerical', ['question' => $question->id]),
'options' => $this->readStoreRecord('question_numerical_options', ['question' => $question->id]),
'units' => $this->readStoreRecords('question_numerical_units', ['question' => $question->id])
'answers' => $this->read_store_records('question_numerical', ['question' => $question->id]),
'options' => $this->read_store_record('question_numerical_options', ['question' => $question->id]),
'units' => $this->read_store_records('question_numerical_units', ['question' => $question->id])
];
} else if ($question->qtype == 'match') {
$question->match = (object)[
'options' => $this->readStoreRecord('qtype_match_options', ['questionid' => $question->id]),
'subquestions' => $this->readStoreRecords('qtype_match_subquestions', ['questionid' => $question->id])
'options' => $this->read_store_record('qtype_match_options', ['questionid' => $question->id]),
'subquestions' => $this->read_store_records('qtype_match_subquestions', ['questionid' => $question->id])
];
} else if (strpos($question->qtype, 'calculated') === 0) {
$question->calculated = (object)[
'answers' => $this->readStoreRecords('question_calculated', ['question' => $question->id]),
'options' => $this->readStoreRecord('question_calculated_options', ['question' => $question->id])
'answers' => $this->read_store_records('question_calculated', ['question' => $question->id]),
'options' => $this->read_store_record('question_calculated_options', ['question' => $question->id])
];
} else if ($question->qtype == 'shortanswer') {
$question->shortanswer = (object)[
'options' => $this->readStoreRecord('qtype_shortanswer_options', ['questionid' => $question->id])
'options' => $this->read_store_record('qtype_shortanswer_options', ['questionid' => $question->id])
];
}
$questions[$question->id] = $question;
}
catch (\Exception $e) {
} catch (\Exception $e) { // @codingStandardsIgnoreLine
// Question not found; maybe it was deleted since the event.
// Don't add the question to the list, but also don't block the attempt event.
}
......@@ -158,26 +182,26 @@ class Repository extends PhpObj {
}
/**
* Reads grade metadata from the store with the given type and id.
* @param String $id
* @param String $type
* Reads grade metadata from the store with the given type and id.
* @param string $id
* @param string $type
* @return PhpObj
*/
public function readGradeItems($id, $type) {
return $this->readStoreRecord('grade_items', ['itemmodule' => $type, 'iteminstance' => $id]);
public function read_grade_items($id, $type) {
return $this->read_store_record('grade_items', ['itemmodule' => $type, 'iteminstance' => $id]);
}
/**
* Reads assignemnt grade comment from the store for a given grade and assignment id
* @param String $id
* @param string $id
* @return PhpObj
*/
public function readGradeComment($gradeId, $assignmentId) {
$model = $this->readStoreRecord(
public function read_grade_comment($gradeid, $assignmentid) {
$model = $this->read_store_record(
'assignfeedback_comments',
[
'assignment' => $assignmentId,
'grade' => $gradeId
'assignment' => $assignmentid,
'grade' => $gradeid
]
);
return $model;
......@@ -188,11 +212,11 @@ class Repository extends PhpObj {
* @param String $id
* @return PhpObj
*/
public function readFeedbackAttempt($id) {
$model = $this->readObject($id, 'feedback_completed');
public function read_feedback_attempt($id) {
$model = $this->read_object($id, 'feedback_completed');
$model->url = $this->cfg->wwwroot . '/mod/feedback/complete.php?id='.$id;
$model->name = 'Attempt '.$id;
$model->responses = $this->readStoreRecords('feedback_value', ['completed' => $id]);
$model->responses = $this->read_store_records('feedback_value', ['completed' => $id]);
return $model;
}
......@@ -201,16 +225,16 @@ class Repository extends PhpObj {
* @param String $id
* @return PhpArr
*/
public function readFeedbackQuestions($id) {
$questions = $this->readStoreRecords('feedback_item', ['feedback' => $id]);
$expandedQuestions = [];
public function read_feedback_questions($id) {
$questions = $this->read_store_records('feedback_item', ['feedback' => $id]);
$expandedquestions = [];
foreach ($questions as $index => $question) {
$expandedQuestion = $question;
$expandedQuestion->template = $this->readStoreRecord('feedback_template', ['id' => $question->template]);
$expandedQuestion->url = $this->cfg->wwwroot . '/mod/feedback/edit_item.php?id='.$question->id;
$expandedQuestions[$index] = $expandedQuestion;
$expandedquestion = $question;
$expandedquestion->template = $this->read_store_record('feedback_template', ['id' => $question->template]);
$expandedquestion->url = $this->cfg->wwwroot . '/mod/feedback/edit_item.php?id='.$question->id;
$expandedquestions[$index] = $expandedquestion;
}
return $expandedQuestions;
return $expandedquestions;
}
/**
......@@ -218,36 +242,36 @@ class Repository extends PhpObj {
* @param String $id
* @return PhpObj
*/
public function readCourse($id) {
public function read_course($id) {
if ($id == 0) {
$courses = $this->store->get_records('course',array());
$courses = $this->store->get_records('course', array());
//since get_records will return the ids as Key values for the array,
//just use key to find the first id in the course table for the index page
// Since get_records will return the ids as Key values for the array,
// just use key to find the first id in the course table for the index page.
$id = key($courses);
}
$model = $this->readObject($id, 'course');
$model = $this->read_object($id, 'course');
$model->url = $this->cfg->wwwroot.($id > 0 ? '/course/view.php?id=' . $id : '');
return $model;
}
/**
* Reads a user from the store with the given id.
* @param String $id
* @param string $id
* @return PhpObj
*/
public function readUser($id) {
$model = $this->readObject($id, 'user');
public function read_user($id) {
$model = $this->read_object($id, 'user');
$model->url = $this->cfg->wwwroot;
$model->fullname = $this->fullname($model);
if (isset($model->password)){
unset($model->password);
if (isset($model->password)) {
unset($model->password);
}
if (isset($model->secret)){
unset($model->secret);
if (isset($model->secret)) {
unset($model->secret);
}
if (isset($model->lastip)){
unset($model->lastip);
if (isset($model->lastip)) {
unset($model->lastip);
}
return $model;
}
......@@ -257,8 +281,8 @@ class Repository extends PhpObj {
* @param String $id
* @return PhpObj
*/
public function readDiscussion($id) {
$model = $this->readObject($id, 'forum_discussions');
public function read_discussion($id) {
$model = $this->read_object($id, 'forum_discussions');
$model->url = $this->cfg->wwwroot . '/mod/forum/discuss.php?d=' . $id;
return $model;
}
......@@ -267,7 +291,7 @@ class Repository extends PhpObj {
* Reads the Moodle release number.
* @return String
*/
public function readRelease() {
public function read_release() {
return $this->cfg->release;
}
......@@ -275,8 +299,8 @@ class Repository extends PhpObj {
* Reads the Moodle site
* @return PhpObj
*/
public function readSite() {
$model = $this->readCourse(1);
public function read_site() {
$model = $this->read_course(1);
$model->url = $this->cfg->wwwroot;
$model->type = "site";
return $model;
......@@ -286,9 +310,9 @@ class Repository extends PhpObj {
* Reads a face to face session
* @return PhpObj
*/
public function readFacetofaceSession($id) {
$model = $this->readObject($id, 'facetoface_sessions');
$model->dates = $this->readStoreRecords('facetoface_sessions_dates', ['sessionid' => $id]);
public function read_facetoface_session($id) {
$model = $this->read_object($id, 'facetoface_sessions');
$model->dates = $this->read_store_records('facetoface_sessions_dates', ['sessionid' => $id]);
$model->url = $this->cfg->wwwroot . '/mod/facetoface/signup.php?s=' . $id;
return $model;
}
......@@ -297,12 +321,12 @@ class Repository extends PhpObj {
* Reads face to face session signups
* @return PhpObj
*/
public function readFacetofaceSessionSignups($sessionid, $timecreated) {
$signups = $this->readStoreRecords('facetoface_signups', ['sessionid' => $sessionid]);
public function read_facetoface_session_signups($sessionid, $timecreated) {
$signups = $this->read_store_records('facetoface_signups', ['sessionid' => $sessionid]);
foreach ($signups as $index => $signup) {
$signups[$index]->statuses = $this->readStoreRecords('facetoface_signups_status', ['signupid' => $signup->id]);
$signups[$index]->attendee = $this->readUser($signup->userid);
$signups[$index]->statuses = $this->read_store_records('facetoface_signups_status', ['signupid' => $signup->id]);
$signups[$index]->attendee = $this->read_user($signup->userid);
}
return $signups;
......@@ -312,34 +336,34 @@ class Repository extends PhpObj {
* Reads Scorm tracking data
* @return PhpObj
*/
public function readScormScoesTrack($userid, $scormid, $scoid, $attempt) {
$trackingValues = [];
$scormTracking = $this->readStoreRecords('scorm_scoes_track', [
public function read_scorm_scoes_track($userid, $scormid, $scoid, $attempt) {
$trackingvalues = [];
$scormtracking = $this->read_store_records('scorm_scoes_track', [
'userid' => $userid,
'scormid'=> $scormid,
'scormid' => $scormid,
'scoid' => $scoid,
'attempt' => $attempt
]);
foreach ($scormTracking as $st) {
foreach ($scormtracking as $st) {
if ($st->element == 'cmi.core.score.min') {
$trackingValues['scoremin'] = $st->value;
$trackingvalues['scoremin'] = $st->value;
} else if ($st->element == 'cmi.core.score.max') {
$trackingValues['scoremax'] = $st->value;
$trackingvalues['scoremax'] = $st->value;
} else if ($st->element == 'cmi.core.lesson_status') {
$trackingValues['status'] = $st->value;
$trackingvalues['status'] = $st->value;
}
}
return $trackingValues;
return $trackingvalues;
}
/**
* Reads a scorm scoes
* @return PhpObj
*/
public function readScormScoes($scoid) {
$model = $this->readObject($scoid, 'scorm_scoes');
public function read_scorm_scoes($scoid) {
$model = $this->read_object($scoid, 'scorm_scoes');
return $model;
}
}
<?php namespace LogExpander\Tests;
use \LogExpander\Events\AssignmentSubmitted as Event;
class AssignmentSubmittedTest extends EventTest {
/**
* Sets up the tests.
* @override TestCase
*/
public function setup() {
$this->event = new Event($this->repo);
}
protected function constructInput() {
return array_merge(parent::constructInput(), [
'objecttable' => 'assign_submission',
'objectid' => 1,
'eventname' => '\mod_assign\event\assessable_submitted',
]);
}
protected function assertOutput($input, $output) {
parent::assertOutput($input, $output);
$this->assertModule(1, $output['module'], 'assign');
$this->assertRecord($input['objectid'], $output['submission']);
}
}
<?php namespace LogExpander\Tests;
use \LogExpander\Events\DiscussionEvent as Event;
class DiscussionEventTest extends EventTest {
/**
* Sets up the tests.
* @override TestCase
*/
public function setup() {
$this->event = new Event($this->repo);
}
protected function constructInput() {
return array_merge(parent::constructInput(), [
'objecttable' => 'forum_discussions',
'objectid' => 1,
'eventname' => '\mod_forum\event\discussion_viewed',
]);
}
protected function assertOutput($input, $output) {
parent::assertOutput($input, $output);
$this->assertModule(1, $output['module'], 'forum');
$this->assertDiscussion($input['objectid'], $output['discussion']);
}
}
<?php namespace LogExpander\Tests;
use \LogExpander\Events\FacetofaceEvent as Event;
class FacetofaceEventTest extends EventTest {
/**
* Sets up the tests.
* @override TestCase
*/
public function setup() {
$this->event = new Event($this->repo);
}
protected function constructInput() {
return array_merge(parent::constructInput(), [
'objecttable' => 'facetoface_sessions',
'objectid' => 1,
'eventname' => '\mod_facetoface\event\signup_success',
]);
}
protected function assertOutput($input, $output) {
parent::assertOutput($input, $output);
$this->assertModule(1, $output['module'], 'facetoface');
$this->assertEquals(2, $output['session']->dates[2]->id);
}
}
<?php namespace LogExpander\Tests;
use \LogExpander\Events\ModuleEvent as Event;
class ModuleEventTest extends EventTest {
/**
* Sets up the tests.
* @override TestCase
*/
public function setup() {
$this->event = new Event($this->repo);
}
protected function constructInput() {
return array_merge(parent::constructInput(), [
'objecttable' => 'page',
'objectid' => 1,
'eventname' => '\mod_page\event\course_module_viewed',
]);
}
protected function assertOutput($input, $output) {
parent::assertOutput($input, $output);
$this->assertModule($input['objectid'], $output['module'], 'page');
}
}
<?php namespace LogExpander\Tests;
use \LogExpander\Events\ScormLaunched as Event;
class ScormLaunchedTest extends EventTest {
/**
* Sets up the tests.
* @override TestCase
*/
public function setup() {
$this->event = new Event($this->repo);
}
protected function constructInput() {
return array_merge(parent::constructInput(), [
'objecttable' => 'scorm_scoes',
'objectid' => 1,
'eventname' => '\mod_scorm\event\sco_launched',
]);
}
protected function assertOutput($input, $output) {
parent::assertOutput($input, $output);
$this->assertModule(1, $output['module'], 'scorm');
$this->assertScorm(1, $output['scorm_scoes']);
}
protected function assertScorm($input, $output) {
$this->assertRecord($input, $output);
}
}
......@@ -13,7 +13,7 @@
"context_info": {
"https:\/\/moodle.org\/": "1.0.0"
},
"time": "2015-06-10T14:31:41+00:00",
"time": "2015-06-10T22:31:41+08:00",
"app_url": "http:\/\/www.example.com",
"app_name": "Test site_fullname",
"app_description": "Test site_summary",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment