Skip to content

Commit

Permalink
Run CI for Moodle up to 4.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaboesch committed Jan 8, 2024
1 parent 6c0244c commit c60a324
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 3 deletions.
32 changes: 31 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,47 @@ jobs:
matrix:
include:
- php: '8.1'
moodle-branch: 'master'
moodle-branch: 'MOODLE_403_STABLE'
database: 'pgsql'
- php: '8.1'
moodle-branch: 'MOODLE_403_STABLE'
database: 'mariadb'
- php: '8.2'
moodle-branch: 'MOODLE_403_STABLE'
database: 'pgsql'
- php: '8.2'
moodle-branch: 'MOODLE_403_STABLE'
database: 'mariadb'
- php: '8.1'
moodle-branch: 'MOODLE_402_STABLE'
database: 'pgsql'
- php: '8.1'
moodle-branch: 'MOODLE_402_STABLE'
database: 'mariadb'
- php: '8.2'
moodle-branch: 'MOODLE_402_STABLE'
database: 'pgsql'
- php: '8.2'
moodle-branch: 'MOODLE_402_STABLE'
database: 'mariadb'
- php: '8.0'
moodle-branch: 'MOODLE_401_STABLE'
database: 'pgsql'
- php: '8.0'
moodle-branch: 'MOODLE_401_STABLE'
database: 'mariadb'
- php: '7.4'
moodle-branch: 'MOODLE_401_STABLE'
database: 'pgsql'
- php: '7.4'
moodle-branch: 'MOODLE_401_STABLE'
database: 'mariadb'
- php: '7.3'
moodle-branch: 'MOODLE_400_STABLE'
database: 'pgsql'
- php: '7.3'
moodle-branch: 'MOODLE_400_STABLE'
database: 'mariadb'

steps:
- name: Check out repository code
Expand Down
41 changes: 39 additions & 2 deletions tests/question_list_fetcher_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

namespace availability_quizquestion;

use mod_quiz\quiz_settings;
use mod_quiz\structure;
use qbank_managecategories\category_condition;

/**
* Tests for the code that gets a list of questions in a quiz.
*
Expand All @@ -24,10 +28,19 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \availability_quizquestion\question_list_fetcher
*/

class question_list_fetcher_test extends \advanced_testcase {

/**
* @return void
* @throws \coding_exception
* @throws \invalid_parameter_exception
* @covers \availability_quizquestion
*/
public function test_list_questions_in_quiz() {
global $DB;
global $CFG, $DB;

require_once($CFG->dirroot . '/question/editlib.php');

$this->resetAfterTest();
$this->setAdminUser();
Expand Down Expand Up @@ -56,7 +69,31 @@ public function test_list_questions_in_quiz() {
quiz_add_quiz_question($tf->id, $quiz);

// Add a random question (does not matter that there are not enough questions in the bank).
quiz_add_random_questions($quiz, 0, $category->id, 1, false);
if (class_exists('\mod_quiz\structure') && class_exists('\qbank_tagquestion\tag_condition')) {
$filter = [
'category' => [
'jointype' => 1,
'values' => [$category->id],
'filteroptions' => ['includesubcategories' => false],
],
];
// Generate default filter condition for the random question to be added in the new category.
$filtercondition = [
'qpage' => 0,
'cat' => "{$category->id},{$coursecontext->id}",
'qperpage' => DEFAULT_QUESTIONS_PER_PAGE,
'tabname' => 'questions',
'sortdata' => [],
'filter' => $filter,
];
// Add random question to the quiz.
[$quiz, ] = get_module_from_cmid($quiz->cmid);
$settings = quiz_settings::create_for_cmid($quiz->cmid);
$structure = structure::create_for_quiz($settings);
$structure->add_random_questions(0, 1, $filtercondition);
} else {
quiz_add_random_questions($quiz, 0, $category->id, 1, false);
}

// Add an essay question.
$essay = $questiongenerator->create_question('essay', null,
Expand Down

0 comments on commit c60a324

Please sign in to comment.