Skip to content

Commit

Permalink
tests for first 5 events
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffcaseyyet committed Nov 14, 2024
1 parent b95ed96 commit e2c379c
Show file tree
Hide file tree
Showing 21 changed files with 745 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/transformer/events/mod_lesson/lesson_ended.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function lesson_ended(array $config, \stdClass $event) {
'verb' => [
'id' => 'http://adlnet.gov/expapi/verbs/completed',
'display' => [
$lang => 'Completed'
'en' => 'Completed'
],
],
'result' => utils\get_lesson_result(
Expand Down
2 changes: 1 addition & 1 deletion src/transformer/events/mod_lesson/lesson_restarted.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function lesson_restarted(array $config, \stdClass $event) {
'verb' => [
'id' => 'https://xapi.edlm/profiles/edlm-lms/concepts/verbs/restarted',
'display' => [
$lang => 'Restarted'
'en' => 'Restarted'
],
],
'object' => utils\get_activity\lesson(
Expand Down
2 changes: 1 addition & 1 deletion src/transformer/events/mod_lesson/lesson_resumed.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function lesson_resumed(array $config, \stdClass $event) {
'verb' => [
'id' => 'https://w3id.org/xapi/tla/verbs/resumed',
'display' => [
$lang => 'Resumed'
'en' => 'Resumed'
],
],
'object' => utils\get_activity\lesson(
Expand Down
2 changes: 1 addition & 1 deletion src/transformer/events/mod_lesson/lesson_started.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function lesson_started(array $config, \stdClass $event) {
'verb' => [
'id' => 'http://activitystrea.ms/start',
'display' => [
$lang => 'Started'
'en' => 'Started'
],
],
'object' => utils\get_activity\lesson(
Expand Down
3 changes: 1 addition & 2 deletions src/transformer/get_event_function_map.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ function get_event_function_map() {
'\mod_lesson\event\lesson_started' => 'mod_lesson\lesson_started',
'\mod_lesson\event\lesson_resumed' => 'mod_lesson\lesson_resumed',
'\mod_lesson\event\lesson_restarted' => 'mod_lesson\lesson_restarted',

'\mod_lesson\event\lesson_ended' => 'mod_lesson\lesson_ended', #db for score stuff
'\mod_lesson\event\lesson_ended' => 'mod_lesson\lesson_ended',

'\mod_lesson\event\essay_assessed' => 'debug\debug_event', #works
'\mod_lesson\event\question_answered' => 'debug\debug_event', #works
Expand Down
33 changes: 33 additions & 0 deletions tests/mod_lesson/lesson_ended/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"modules": [
{
"id": 1,
"name": "lesson"
}
],
"lesson": [
{
"id": 1,
"name": "test_lesson",
"intro": "test_lesson_intro"
}
],
"grade_items": [
{
"id": 1,
"itemmodule": "lesson",
"iteminstance": 1,
"gradepass": 50
}
],
"grade_grades": [
{
"itemid": 1,
"userid": 1,
"timemodified": 1731595610,
"rawgrademin": 0,
"rawgrademax": 100,
"rawgrade": 75
}
]
}
10 changes: 10 additions & 0 deletions tests/mod_lesson/lesson_ended/event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": 1,
"userid": 1,
"courseid": 1,
"timecreated": 1433946701,
"objecttable": "lesson",
"objectid": 1,
"contextinstanceid": 1,
"eventname": "\\mod_lesson\\event\\lesson_ended"
}
70 changes: 70 additions & 0 deletions tests/mod_lesson/lesson_ended/lesson_ended_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\mod_lesson;

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

global $CFG;

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

/**
* Unit test for mod_lesson lesson ended.
*
* @package logstore_xapi
* @copyright Cliff Casey <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class lesson_ended_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 "glossary";
}

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

}
}
93 changes: 93 additions & 0 deletions tests/mod_lesson/lesson_ended/statements.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
[
{
"actor": {
"name": "test_fullname",
"account": {
"homePage": "http://www.example.org",
"name": "1"
}
},
"verb": {
"id": "http://adlnet.gov/expapi/verbs/completed",
"display": {
"en": "Completed"
}
},
"object": {
"id": "http://www.example.org/mod/lesson/view.php?id=1#lesson",
"definition": {
"type": "http://adlnet.gov/expapi/activities/lesson",
"name": {
"en": "test_lesson"
},
"description": {
"en": "test_lesson_intro"
}
}
},
"result": {
"completion": true,
"success": true,
"score": {
"min": 0,
"max": 100,
"raw": 75,
"scaled": 0.5
}
},
"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": "\\mod_lesson\\event\\lesson_ended",
"event_function": "\\src\\transformer\\events\\mod_lesson\\lesson_ended"
}
},
"contextActivities": {
"parent": [
{
"id": "http://www.example.org/mod/lesson/view.php?id=1",
"definition": {
"type": "http://adlnet.gov/expapi/activities/lesson",
"name": {
"en": "test_lesson"
}
}
},
{
"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"
}
}
}
]
}
}
}
]
15 changes: 15 additions & 0 deletions tests/mod_lesson/lesson_restarted/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"modules": [
{
"id": 1,
"name": "lesson"
}
],
"lesson": [
{
"id": 1,
"name": "test_lesson",
"intro": "test_lesson_intro"
}
]
}
10 changes: 10 additions & 0 deletions tests/mod_lesson/lesson_restarted/event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": 1,
"userid": 1,
"courseid": 1,
"timecreated": 1433946701,
"objecttable": "lesson",
"objectid": 1,
"contextinstanceid": 1,
"eventname": "\\mod_lesson\\event\\lesson_restarted"
}
70 changes: 70 additions & 0 deletions tests/mod_lesson/lesson_restarted/lesson_restarted_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\mod_lesson;

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

global $CFG;

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

/**
* Unit test for mod_lesson lesson restarted.
*
* @package logstore_xapi
* @copyright Cliff Casey <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class lesson_restarted_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 "glossary";
}

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

}
}
Loading

0 comments on commit e2c379c

Please sign in to comment.