Skip to content

Moodle 5 #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/moodle-plugin-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

services:
postgres:
image: postgres:13
image: postgres:14
env:
POSTGRES_USER: 'postgres'
POSTGRES_HOST_AUTH_METHOD: 'trust'
Expand All @@ -31,7 +31,7 @@ jobs:
fail-fast: false
matrix:
php: ['8.1', '8.2', '8.3']
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE', 'MOODLE_404_STABLE', 'MOODLE_405_STABLE']
moodle-branch: ['MOODLE_401_STABLE', 'MOODLE_402_STABLE', 'MOODLE_403_STABLE', 'MOODLE_404_STABLE', 'MOODLE_405_STABLE', 'MOODLE_500_STABLE']
database: [pgsql, mariadb]
exclude:
- php: '8.2'
Expand All @@ -42,6 +42,8 @@ jobs:
moodle-branch: 'MOODLE_402_STABLE'
- php: '8.3'
moodle-branch: 'MOODLE_403_STABLE'
- php: '8.1'
moodle-branch: 'MOODLE_500_STABLE'

steps:
- name: Check out repository code
Expand Down
2 changes: 1 addition & 1 deletion src/transformer/repos/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ abstract public function read_records(string $type, array $query, string $sort =
*/
public function read_record(string $type, array $query) {
$records = $this->read_records($type, $query);
$record = $records[0];
$record = $records[0] ?? null;
if (!$record) {
throw new \Exception("$type not found.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
require_once($CFG->dirroot . '/admin/tool/log/store/xapi/tests/xapi_test_case.php');

/**
* Unit test for mod_quiz attempt submitted (multichoice set with choices) event.
* Unit test for user forfeited badge event.
*
* @package logstore_xapi
* @copyright Daniel Bell <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class user_achieved_badge_test extends \logstore_xapi\xapi_test_case {
class user_forfeited_badge_test extends \logstore_xapi\xapi_test_case {

/**
* Retrieve the directory of the unit test.
Expand All @@ -48,7 +48,7 @@ protected function get_test_dir() {
protected function get_plugin_type() {
return "core";
}

/**
* Retrieve the plugin name being tested.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* @copyright Milt Reder <[email protected]>
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class existing_course_resource_list_viewed extends \logstore_xapi\xapi_test_case {
class existing_course_resources_list_viewed_test extends \logstore_xapi\xapi_test_case {

/**
* Retrieve the directory of the unit test.
Expand Down
89 changes: 51 additions & 38 deletions tests/mod_lesson/essay_assessed/essay_assessed_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,47 +31,60 @@
*/
class essay_assessed_test extends \logstore_xapi\xapi_test_case {

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

/**
* Retrieve the plugin type being tested.
*
* @return string
*/
protected function get_plugin_type() {
return "mod";
if (!defined('LESSON_PAGE_SHORTANSWER')) {
define('LESSON_PAGE_SHORTANSWER', 1);
define('LESSON_PAGE_ESSAY', 10);
define('LESSON_PAGE_TRUEFALSE', 2);
define('LESSON_PAGE_MULTICHOICE', 3);
define('LESSON_PAGE_MATCHING', 5);
define('LESSON_PAGE_NUMERICAL', 8);
}
}

/**
* Retrieve the plugin name being tested.
*
* @return string
*/
protected function get_plugin_name() {
return "glossary";
}
/**
* 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 ::essay_assessed
* @return void
*/
public function test_init() {
if (!defined('LESSON_PAGE_SHORTANSWER')) {
define('LESSON_PAGE_SHORTANSWER', 1);
define('LESSON_PAGE_ESSAY', 10);
define('LESSON_PAGE_TRUEFALSE', 2);
define('LESSON_PAGE_MULTICHOICE', 3);
define('LESSON_PAGE_MATCHING', 5);
define('LESSON_PAGE_NUMERICAL', 8);
}
/**
* Appease auto-detecting of test cases. xapi_test_case has default test cases.
*
* @covers ::essay_assessed
* @return void
*/
public function test_init() {
if (!defined('LESSON_PAGE_SHORTANSWER')) {
define('LESSON_PAGE_SHORTANSWER', 1);
define('LESSON_PAGE_ESSAY', 10);
define('LESSON_PAGE_TRUEFALSE', 2);
define('LESSON_PAGE_MULTICHOICE', 3);
define('LESSON_PAGE_MATCHING', 5);
define('LESSON_PAGE_NUMERICAL', 8);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,40 +33,55 @@
*/
class existing_module_test extends \logstore_xapi\xapi_test_case {

/**
* Retrieve the directory of the unit test.
*
* @return string
*/
protected function get_test_dir() {
return __DIR__;
}
/**
* Initialize, skipping if mod_survey is not present.
*
* @return void
*/
public function setUp(): void {
global $CFG;
parent::setUp();

/**
* Retrieve the plugin type being tested.
*
* @return string
*/
protected function get_plugin_type() {
return "mod";
// Skip tests if mod_survey is not present (i.e., Moodle 5.0+).
if (!is_dir($CFG->dirroot . '/mod/survey')) {
$this->markTestSkipped('mod_survey is not available in Moodle 5.0 and above.');
}
}

/**
* Retrieve the plugin name being tested.
*
* @return string
*/
protected function get_plugin_name() {
return "survey";
}
/**
* Retrieve the directory of the unit test.
*
* @return string
*/
protected function get_test_dir() {
return __DIR__;
}

/**
* Appease auto-detecting of test cases. xapi_test_case has default test cases.
*
* @covers ::course_module_viewed
* @return void
*/
public function test_init() {
/**
* 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 "survey";
}

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

}
}
77 changes: 46 additions & 31 deletions tests/mod_survey/report_viewed/report_viewed_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,55 @@
*/
class report_viewed_test extends \logstore_xapi\xapi_test_case {

/**
* Retrieve the directory of the unit test.
*
* @return string
*/
protected function get_test_dir() {
return __DIR__;
}
/**
* Initialize, skipping if mod_survey is not present.
*
* @return void
*/
public function setUp(): void {
global $CFG;
parent::setUp();

/**
* Retrieve the plugin type being tested.
*
* @return string
*/
protected function get_plugin_type() {
return "core";
// Skip tests if mod_survey is not present (i.e., Moodle 5.0+).
if (!is_dir($CFG->dirroot . '/mod/survey')) {
$this->markTestSkipped('mod_survey is not available in Moodle 5.0 and above.');
}
}

/**
* Retrieve the plugin name being tested.
*
* @return string
*/
protected function get_plugin_name() {
return "mod_survey";
}
/**
* Retrieve the directory of the unit test.
*
* @return string
*/
protected function get_test_dir() {
return __DIR__;
}

/**
* Appease auto-detecting of test cases. xapi_test_case has default test cases.
*
* @covers ::report_viewed
* @return void
*/
public function test_init() {
/**
* Retrieve the plugin type being tested.
*
* @return string
*/
protected function get_plugin_type() {
return "core";
}

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

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

}
}
Loading
Loading