Skip to content
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

Run CI for Moodle up to 4.3. #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ jobs:
fail-fast: false
matrix:
include:
- php: '8.1'
moodle-branch: 'master'
database: 'mariadb'
- php: '8.2'
moodle-branch: 'MOODLE_403_STABLE'
database: 'pgsql'
- php: '8.1'
moodle-branch: 'MOODLE_402_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.3'
moodle-branch: 'MOODLE_400_STABLE'
database: 'pgsql'
database: 'mariadb'

steps:
- name: Check out repository code
Expand Down
35 changes: 33 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,13 @@
* @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 {

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 +63,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
Loading