Skip to content

Commit

Permalink
h5p cmv (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
milt authored Oct 25, 2024
1 parent 8ec991b commit ae95743
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/transformer/get_event_function_map.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function get_event_function_map() {
'\core\event\user_loggedout' => 'core\user_loggedout',
'\core\event\course_module_created' => 'core\course_module_created',
'\core\event\course_module_completion_updated' => 'core\course_module_completion_updated',
'\core_h5p\event\h5p_viewed' => 'all\course_module_viewed',
'\core\event\search_results_viewed' => 'core\search_results_viewed',
'\core\event\question_created' => 'core\question_created',
'\mod_assign\event\assessable_submitted' => 'mod_assign\assignment_submitted',
Expand Down
14 changes: 14 additions & 0 deletions tests/core_h5p/course_module_viewed/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"modules": [
{
"id": 1,
"name": "h5pactivity"
}
],
"h5pactivity": [
{
"id": 1,
"name": "test_name"
}
]
}
8 changes: 8 additions & 0 deletions tests/core_h5p/course_module_viewed/event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": 1,
"userid": 1,
"courseid": 1,
"timecreated": 1433946701,
"contextinstanceid": 1,
"eventname": "\\core_h5p\\event\\h5p_viewed"
}
71 changes: 71 additions & 0 deletions tests/core_h5p/course_module_viewed/statements.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[
{
"actor": {
"name": "test_fullname",
"account": {
"homePage": "http://www.example.org",
"name": "1"
}
},
"verb": {
"id": "http://id.tincanapi.com/verb/viewed",
"display": {
"en": "viewed"
}
},
"object": {
"id": "http://www.example.org/mod/h5pactivity/view.php?id=1",
"definition": {
"type": "http://adlnet.gov/expapi/activities/media",
"name": {
"en": "test_name"
}
}
},
"context": {
"language": "en",
"extensions": {
"http://lrs.learninglocker.net/define/extensions/info": {
"http://moodle.org": "1.0.0",
"https://github.com/xAPI-vle/moodle-logstore_xapi": "0.0.0-development",
"event_name": "\\core_h5p\\event\\h5p_viewed",
"event_function": "\\src\\transformer\\events\\all\\course_module_viewed"
}
},
"contextActivities": {
"parent": [
{
"id": "http://www.example.org/course/section.php?id=1",
"objectType": "Activity",
"definition": {
"name": {
"en": "test_name Section 0"
},
"type": "http://id.tincanapi.com/activitytype/section"
}
},
{
"id": "http://www.example.org/course/view.php?id=1",
"definition": {
"type": "https://w3id.org/xapi/cmi5/activitytype/course",
"name": {
"en": "test_name"
}
}
}
],
"category": [
{
"id": "http://www.example.org",
"definition": {
"type": "http://id.tincanapi.com/activitytype/lms",
"name": {
"en": "test_name"
}
}
}
]
}
}
}
]
70 changes: 70 additions & 0 deletions tests/core_h5p/course_module_viewed/user_viewed_h5p_test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?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 logstore_xapi\core_h5p\course_module_viewed\user_viewed_h5p;

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

global $CFG;

require_once($CFG->dirroot . '/admin/tool/log/store/xapi/tests/xapi_test_case.php');

/**
* Unit test for h5p module viewed event.
*
* @package logstore_xapi
* @copyright Milt Reder <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class user_viewed_h5p_test extends \logstore_xapi\xapi_test_case {

/**
* Retrieve the directory of the unit test.
*
* @return string
*/
protected function get_test_dir() {
return __DIR__;
}

/**
* Retrieve the plugin type being tested.
*
* @return string
*/
protected function get_plugin_type() {
return "mod";
}

/**
* Retrieve the plugin name being tested.
*
* @return string
*/
protected function get_plugin_name() {
return "h5pactivity";
}

/**
* Appease auto-detecting of test cases. xapi_test_case has default test cases.
*
* @covers ::course_module_viewed
* @return void
*/
public function test_init() {

}
}

0 comments on commit ae95743

Please sign in to comment.