first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,98 @@
<?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/>.
/**
* The mod_scorm attempt deleted event.
*
* @package mod_scorm
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_scorm\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_scorm attempt deleted event class.
*
* @property-read array $other {
* Extra information about event properties.
*
* - int attemptid: Attempt id.
* }
*
* @package mod_scorm
* @since Moodle 2.7
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class attempt_deleted extends \core\event\base {
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' deleted the attempt with id '{$this->other['attemptid']}' " .
"for the scorm activity with course module id '$this->contextinstanceid'.";
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventattemptdeleted', 'mod_scorm');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/scorm/report.php', array('id' => $this->contextinstanceid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->other['attemptid'])) {
throw new \coding_exception('The \'attemptid\' must be set in other.');
}
}
public static function get_other_mapping() {
// Nothing to map.
return false;
}
}
@@ -0,0 +1,105 @@
<?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/>.
/**
* The mod_scorm generic CMI element submitted event.
*
* @package mod_scorm
* @copyright 2016 onwards Matteo Scaramuccia
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_scorm\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_scorm generic CMI element submitted event class.
*
* @property-read array $other {
* Extra information about event properties.
*
* - int attemptid: Attempt id.
* - string cmielement: CMI element.
* - string cmivalue: CMI value.
* }
*
* @package mod_scorm
* @since Moodle 3.1
* @copyright 2016 onwards Matteo Scaramuccia
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class cmielement_submitted extends \core\event\base {
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'scorm_scoes_value';
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with the id '$this->userid' submitted the element '{$this->other['cmielement']}' " .
"with the value of '{$this->other['cmivalue']}' " .
"for the attempt with the id '{$this->other['attemptid']}' " .
"for a scorm activity with the course module id '$this->contextinstanceid'.";
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/scorm/report/userreport.php',
array('id' => $this->contextinstanceid, 'user' => $this->userid, 'attempt' => $this->other['attemptid']));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->other['attemptid'])) {
throw new \coding_exception("The 'attemptid' must be set in other.");
}
if (empty($this->other['cmielement'])) {
throw new \coding_exception("The 'cmielement' must be set in other.");
}
// Trust that 'cmielement' represents a valid CMI datamodel element:
// just check that the given value starts with 'cmi.'.
if (strpos($this->other['cmielement'], 'cmi.', 0) !== 0) {
throw new \coding_exception(
"A valid 'cmielement' must start with 'cmi.' ({$this->other['cmielement']}).");
}
// Warning: 'cmivalue' could be also "0" e.g. when 'cmielement' represents a score.
if (!isset($this->other['cmivalue'])) {
throw new \coding_exception("The 'cmivalue' must be set in other.");
}
}
}
@@ -0,0 +1,38 @@
<?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/>.
/**
* The mod_scorm instance list viewed event.
*
* @package mod_scorm
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_scorm\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_scorm instance list viewed event class.
*
* @package mod_scorm
* @since Moodle 2.7
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed {
}
@@ -0,0 +1,51 @@
<?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/>.
/**
* The mod_scorm course module viewed event.
*
* @package mod_scorm
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_scorm\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_scorm course module viewed event class.
*
* @package mod_scorm
* @since Moodle 2.7
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_module_viewed extends \core\event\course_module_viewed {
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'scorm';
}
public static function get_objectid_mapping() {
return array('db' => 'scorm', 'restore' => 'scorm');
}
}
@@ -0,0 +1,114 @@
<?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/>.
/**
* The mod_scorm interactions viewed event.
*
* @package mod_scorm
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_scorm\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_scorm interactions viewed event class.
*
* @property-read array $other {
* Extra information about event properties.
*
* - int attemptid: Attempt id.
* - int instanceid: Instance id of the scorm activity.
* }
*
* @package mod_scorm
* @since Moodle 2.7
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class interactions_viewed extends \core\event\base {
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the interactions for the user with id '$this->relateduserid' " .
"for the scorm activity with course module id '$this->contextinstanceid'.";
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventinteractionsviewed', 'mod_scorm');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
$params = array(
'id' => $this->contextinstanceid,
'user' => $this->relateduserid,
'attempt' => $this->other['attemptid']
);
return new \moodle_url('/mod/scorm/userreportinteractions.php', $params);
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (empty($this->other['attemptid'])) {
throw new \coding_exception('The \'attemptid\' must be set in other.');
}
if (empty($this->other['instanceid'])) {
throw new \coding_exception('The \'instanceid\' must be set in other.');
}
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['instanceid'] = array('db' => 'scorm', 'restore' => 'scorm');
return $othermapped;
}
}
+105
View File
@@ -0,0 +1,105 @@
<?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/>.
/**
* The mod_scorm report viewed event.
*
* @package mod_scorm
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_scorm\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_scorm report viewed event class.
*
* @property-read array $other {
* Extra information about event properties.
*
* - int scormid: The ID of the scorm.
* - string mode: Mode of the report viewed.
* }
*
* @package mod_scorm
* @since Moodle 2.7
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class report_viewed extends \core\event\base {
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the scorm report '{$this->other['mode']}' for the scorm with " .
"course module id '$this->contextinstanceid'.";
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventreportviewed', 'mod_scorm');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/scorm/report.php', array('id' => $this->contextinstanceid, 'mode' => $this->other['mode']));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->other['scormid'])) {
throw new \coding_exception('The \'scormid\' value must be set in other.');
}
if (empty($this->other['mode'])) {
throw new \coding_exception('The \'mode\' value must be set in other.');
}
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['scormid'] = array('db' => 'scorm', 'restore' => 'scorm');
return $othermapped;
}
}
+106
View File
@@ -0,0 +1,106 @@
<?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/>.
/**
* The mod_scorm sco launched event.
*
* @package mod_scorm
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_scorm\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_scorm sco launched event class.
*
* @property-read array $other {
* Extra information about event properties.
*
* - string loadedcontent: A reference to the content loaded.
* - int instanceid: (optional) Instance id of the scorm activity.
* }
*
* @package mod_scorm
* @since Moodle 2.7
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class sco_launched extends \core\event\base {
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'scorm_scoes';
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' launched the sco with id '$this->objectid' for the scorm with " .
"course module id '$this->contextinstanceid'.";
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventscolaunched', 'mod_scorm');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/scorm/player.php', array('cm' => $this->contextinstanceid, 'scoid' => $this->objectid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (empty($this->other['loadedcontent'])) {
throw new \coding_exception('The \'loadedcontent\' value must be set in other.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'scorm_scoes', 'restore' => 'scorm_sco');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['instanceid'] = array('db' => 'scorm', 'restore' => 'scorm');
return $othermapped;
}
}
@@ -0,0 +1,71 @@
<?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/>.
/**
* The mod_scorm raw score submitted event.
*
* @package mod_scorm
* @copyright 2016 onwards Matteo Scaramuccia
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_scorm\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_scorm raw score submitted event class.
*
* @property-read array $other {
* Extra information about event properties.
*
* - int attemptid: Attempt id.
* - string cmielement: CMI element representing a raw score.
* - string cmivalue: CMI value.
* }
*
* @package mod_scorm
* @since Moodle 3.1
* @copyright 2016 onwards Matteo Scaramuccia
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class scoreraw_submitted extends cmielement_submitted {
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventscorerawsubmitted', 'mod_scorm');
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!strstr($this->other['cmielement'], '.score.raw')) {
throw new \coding_exception(
"The 'cmielement' must represents a valid CMI raw score ({$this->other['cmielement']}).");
}
// Note: we trust that 'cmivalue' represents a valid SCORM CMI score value.
}
}
@@ -0,0 +1,76 @@
<?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/>.
/**
* The mod_scorm status submitted event.
*
* @package mod_scorm
* @copyright 2016 onwards Matteo Scaramuccia
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_scorm\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_scorm status submitted event class.
*
* @property-read array $other {
* Extra information about event properties.
*
* - int attemptid: Attempt id.
* - string cmielement: CMI element representing a status.
* - string cmivalue: CMI value.
* }
*
* @package mod_scorm
* @since Moodle 3.1
* @copyright 2016 onwards Matteo Scaramuccia
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class status_submitted extends cmielement_submitted {
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventstatussubmitted', 'mod_scorm');
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!in_array($this->other['cmielement'],
array('cmi.completion_status', 'cmi.core.lesson_status', 'cmi.success_status'))) {
throw new \coding_exception(
"The 'cmielement' must represents a valid CMI status element ({$this->other['cmielement']}).");
}
if (!in_array($this->other['cmivalue'],
array('passed', 'completed', 'failed', 'incomplete', 'browsed', 'not attempted', 'unknown'))) {
throw new \coding_exception(
"The 'cmivalue' must represents a valid CMI status value ({$this->other['cmivalue']}).");
}
}
}
+118
View File
@@ -0,0 +1,118 @@
<?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/>.
/**
* The mod_scorm tracks viewed event.
*
* @package mod_scorm
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_scorm\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_scorm tracks viewed event class.
*
* @property-read array $other {
* Extra information about event properties.
*
* - int attemptid: Attempt id.
* - int instanceid: Instance id of the scorm activity.
* - int scoid: Sco Id for which the trackes are viewed.
* }
*
* @package mod_scorm
* @since Moodle 2.7
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tracks_viewed extends \core\event\base {
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the tracks for the user with id '$this->relateduserid' " .
"for the scorm activity with course module id '$this->contextinstanceid'.";
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventtracksviewed', 'mod_scorm');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
$params = array(
'id' => $this->contextinstanceid,
'user' => $this->relateduserid,
'attempt' => $this->other['attemptid'],
'scoid' => $this->other['scoid']
);
return new \moodle_url('/mod/scorm/userreporttracks.php', $params);
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (empty($this->other['attemptid'])) {
throw new \coding_exception('The \'attemptid\' value must be set in other.');
}
if (empty($this->other['instanceid'])) {
throw new \coding_exception('The \'instanceid\' value must be set in other.');
}
if (empty($this->other['scoid'])) {
throw new \coding_exception('The \'scoid\' value must be set in other.');
}
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['instanceid'] = array('db' => 'scorm', 'restore' => 'scorm');
$othermapped['scoid'] = array('db' => 'scorm_scoes', 'restore' => 'scorm_scoe');
return $othermapped;
}
}
@@ -0,0 +1,111 @@
<?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/>.
/**
* The mod_scorm tracks user report viewed event.
*
* @package mod_scorm
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_scorm\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_scorm tracks user report viewed event class.
*
* @property-read array $other {
* Extra information about event properties.
*
* - int attemptid: Attempt id.
* - int instanceid: Instance id of the scorm activity.
* }
*
* @package mod_scorm
* @since Moodle 2.7
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class user_report_viewed extends \core\event\base {
/**
* Init method.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the scorm user report for the user with id '$this->relateduserid'.";
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventuserreportviewed', 'mod_scorm');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
$params = array(
'id' => $this->contextinstanceid,
'user' => $this->relateduserid,
'attempt' => $this->other['attemptid']
);
return new \moodle_url('/mod/scorm/userreport.php', $params);
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (empty($this->other['attemptid'])) {
throw new \coding_exception('The \'attemptid\' value must be set in other.');
}
if (empty($this->other['instanceid'])) {
throw new \coding_exception('The \'instanceid\' value must be set in other.');
}
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['instanceid'] = array('db' => 'scorm', 'restore' => 'scorm');
return $othermapped;
}
}