diff --git a/ajax.php b/ajax.php index f13f38cf9b0d5e05ac17b5dd158d56f9fd3e5371..2ed06374e6157ae2efcd592e108c7197ff3b1d4c 100644 --- a/ajax.php +++ b/ajax.php @@ -251,37 +251,6 @@ switch($action) { $file->printResult(); break; - case 'logxapievent': - // Trigger a Moodle log event for each xAPI statement - // that is dispatched by the H5P (hvp) object. - if (!\H5PCore::validToken('logxapievent', required_param('token', PARAM_RAW))) { - \H5PCore::ajaxError(get_string('invalidtoken', 'hvp')); - exit; - } - - $hvpid = optional_param('hvpid', null, PARAM_INT); - $courseid = optional_param('courseid', null, PARAM_INT); - $jsonxapistatement = optional_param('xapistatement', null, PARAM_RAW); - $xapistatement = json_decode($jsonxapistatement, true); - - $context = \context_module::instance($hvpid); - - $event = \mod_hvp\event\hvp_xapi::create(array( - 'objectid' => $hvpid, - 'context' => $context, - 'other' => array('statement' => $xapistatement['data']['statement']), - 'courseid' => $courseid - )); - $event->trigger(); - - // Debugging... - if (!empty($CFG->debug) and $CFG->debug >= DEBUG_DEVELOPER) { - $msg = "xAPI '" . $xapistatement['data']['statement']['verb']['display']['en-US'] . "' statement dispatched"; - \H5PCore::ajaxSuccess($msg); - http_response_code(200); - } - break; - /* * Throw error if AJAX isnt handeled */ diff --git a/amd/build/xapi-stmt-dispatcher.min.js b/amd/build/xapi-stmt-dispatcher.min.js deleted file mode 100644 index bcae33eb1b82feea904a2d7d525f7ec145a79c6c..0000000000000000000000000000000000000000 --- a/amd/build/xapi-stmt-dispatcher.min.js +++ /dev/null @@ -1 +0,0 @@ -define(["jquery"],function(a){return{init:function(b){0!==b.debug&&console.log("Module hvp xAPI event dispatcher initialising"),H5P.externalDispatcher.on("xAPI",function(c){a.post(M.cfg.wwwroot+"/mod/hvp/ajax.php",{token:b.token,action:"logxapievent",hvpid:b.hvpid,courseid:b.courseid,xapistatement:JSON.stringify(c)},function(a){0!==b.debug&&console.log('Result : "'+a.data+'" status='+a.success)})})}}}); \ No newline at end of file diff --git a/amd/src/xapi-stmt-dispatcher.js b/amd/src/xapi-stmt-dispatcher.js deleted file mode 100644 index 88047dc3fffee0063b9e56b23a63347b3f59f22c..0000000000000000000000000000000000000000 --- a/amd/src/xapi-stmt-dispatcher.js +++ /dev/null @@ -1,27 +0,0 @@ -// Capture H5P (hvp) dispatched xAPI statement, -// And send them (ajax) to Moodle log by triggering a Moodle log event. -define(['jquery'], function ($) { - /*jshint -W117 */ - - return { - init: function (params) { - if (params.debug !== 0) { - console.log('Module hvp xAPI event dispatcher initialising'); - } - H5P.externalDispatcher.on('xAPI', function (event) { - $.post(M.cfg.wwwroot + '/mod/hvp/ajax.php', { - 'token': params.token, - 'action': 'logxapievent', - 'hvpid': params.hvpid, - 'courseid': params.courseid, - 'xapistatement': JSON.stringify(event) - }, function (data) { - if (params.debug !== 0) { - console.log('Result : "' + data.data + '" status=' + data.success); - } - }); - }); - } - }; - -}); diff --git a/classes/event/hvp_xapi.php b/classes/event/hvp_xapi.php deleted file mode 100644 index 34c7922c7bfbbab8858952364b9241b05bee7055..0000000000000000000000000000000000000000 --- a/classes/event/hvp_xapi.php +++ /dev/null @@ -1,71 +0,0 @@ -<?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_hvp xapi statement event. - * - * @package mod_hvp - * @copyright @copyright 2016 Joubel AS <contact@joubel.com> - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace mod_hvp\event; -defined('MOODLE_INTERNAL') || die(); - -/** - * The mod_hvp xapi statement event class. - * - * @package mod_hvp - * @copyright @copyright 2016 Joubel AS <contact@joubel.com> - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class hvp_xapi extends \core\event\base -{ - protected function init() - { - $this->data['crud'] = 'r'; - $this->data['edulevel'] = self::LEVEL_PARTICIPATING; - $this->data['objecttable'] = 'hvp'; - } - - /* - protected function validate_data() { - $this->data['action'] .= '_' . $this->data['other']->data->statement->verb->display->{'en-US'}; - } - */ - - /** - * Get URL related to the action. - * - * @return \moodle_url - */ - public function get_url() - { - return new \moodle_url('/mod/hvp/view.php', array('id' => $this->contextinstanceid)); - } - - /** - * Returns description of what happened. - * - * @return string - */ - public function get_description() - { - $verb = $this->data['other']->data->statement->verb->display->{'en-US'}; - return "The user with id '$this->userid' triggered an xAPI '$verb' statement " . - "on H5P activity with instance id '$this->objectid' "; - } -} diff --git a/package.json b/package.json deleted file mode 100644 index b6ced013aeb547cd86cb2da25fbd4eb9fa4be8db..0000000000000000000000000000000000000000 --- a/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "moodle-mod_hvp" -} \ No newline at end of file diff --git a/view.php b/view.php index ce754926d27e49287ad127011330c368fa152b31..651cffde28a117fc6c236dffbf70391c3dd9c658 100644 --- a/view.php +++ b/view.php @@ -135,11 +135,6 @@ if ($embedtype === 'div') { // Print JavaScript settings to page. $PAGE->requires->data_for_js('H5PIntegration', $settings, true); -// H5P JS xAPI event listener & Moodle event log dispatcher. -$jsparams = array('hvpid' => $id, 'courseid' => $course->id, - 'debug' => $CFG->debug, 'token' => \H5PCore::createToken('logxapievent')); -$PAGE->requires->js_call_amd('mod_hvp/xapi-stmt-dispatcher', 'init', array($jsparams)); - // Print page HTML. echo $OUTPUT->header(); echo '<div class="clearer"></div>';