Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
948ae65
Student e2e and quiz admin
oparareda-at-wiris Sep 16, 2025
e749a73
Student e2e and quiz admin
oparareda-at-wiris Sep 16, 2025
442eb05
Student e2e and quiz admin
oparareda-at-wiris Sep 16, 2025
fe7d207
Student e2e and quiz admin
oparareda-at-wiris Sep 16, 2025
3b0cf35
Student e2e and quiz admin
oparareda-at-wiris Sep 16, 2025
8f3f12d
Student e2e and quiz admin
oparareda-at-wiris Sep 16, 2025
7f2de62
Link qase
oparareda-at-wiris Sep 18, 2025
d0cff27
Ci fixing try 1
oparareda-at-wiris Sep 22, 2025
e331a89
Ci fixing try 1
oparareda-at-wiris Sep 22, 2025
a6b8474
Ci fixing try 2
oparareda-at-wiris Sep 22, 2025
3b0112b
Ci fixing try 2
oparareda-at-wiris Sep 22, 2025
d99064d
Ci fixing try 2
oparareda-at-wiris Sep 22, 2025
dba57b0
Ci fixing try 2
oparareda-at-wiris Sep 22, 2025
48ab92f
Ci fixing try 2
oparareda-at-wiris Sep 22, 2025
d6a659c
Ci fixing try 2
oparareda-at-wiris Sep 22, 2025
bb41f9b
CI try 3
oparareda-at-wiris Sep 23, 2025
65a0c49
CI try 3
oparareda-at-wiris Sep 23, 2025
c1aeba1
CI try 4
oparareda-at-wiris Sep 23, 2025
90edc65
CI try 5
oparareda-at-wiris Sep 23, 2025
040c6d0
Testing int upgrade
oparareda-at-wiris Sep 30, 2025
b22b1ba
Testing int upgrade
oparareda-at-wiris Sep 30, 2025
a98d488
Adding definitions
oparareda-at-wiris Oct 8, 2025
8d77689
Adding definitions
oparareda-at-wiris Oct 8, 2025
fd97bd2
Adding definitions
oparareda-at-wiris Oct 8, 2025
b937ca9
Adding definitions
oparareda-at-wiris Oct 8, 2025
ddba3b2
Adding definitions
oparareda-at-wiris Oct 8, 2025
c191308
Remove old behat tests
oparareda-at-wiris Oct 8, 2025
c473402
Fixing errors
oparareda-at-wiris Oct 9, 2025
d45a8fd
Fixing errors
oparareda-at-wiris Oct 9, 2025
269f74d
Fixing errors
oparareda-at-wiris Oct 9, 2025
2dfe887
Fixing errors
oparareda-at-wiris Oct 9, 2025
7d3f8b8
Fixing errors
oparareda-at-wiris Oct 9, 2025
1c79c8f
Fixing errors
oparareda-at-wiris Oct 9, 2025
f45e427
Fixing errors
oparareda-at-wiris Oct 9, 2025
a975d49
Fixing errors
oparareda-at-wiris Oct 9, 2025
49640a7
update cloze and short
oparareda-at-wiris Oct 10, 2025
e80a5cb
added 501 to the matrix
oparareda-at-wiris Oct 10, 2025
93732e6
verbose report in wq
oparareda-at-wiris Oct 15, 2025
7c5e9e6
verbose report in wq
oparareda-at-wiris Oct 15, 2025
58185f7
chore: mark non-nullable param as non-nullable and required
ptorrent-at-wiris Oct 22, 2025
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
216 changes: 146 additions & 70 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: Moodle Plugin CI

on: [push, pull_request]

# Automatically triggered on push to main branch, on pull requests
on: ['push', 'pull_request']
jobs:
test:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:13
image: postgres:17
env:
POSTGRES_USER: "postgres"
POSTGRES_HOST_AUTH_METHOD: "trust"
Expand All @@ -18,129 +18,205 @@ jobs:

strategy:
fail-fast: false

matrix:
php: ["7.4", "8.0", 8.1', "8.2", "8.3"]
moodle-branch:
php: ["7.4", "8.0", "8.1", "8.2", "8.3", "8.4"]
moodle_branch:
[
"MOODLE_401_STABLE",
"MOODLE_402_STABLE",
"MOODLE_403_STABLE",
"MOODLE_404_STABLE",
"MOODLE_405_STABLE",
"MOODLE_500_STABLE",
"MOODLE_501_STABLE",
"main",
]
database: [pgsql]
browser: ["chrome", "firefox"]
exclude:
# Exclude Moodle+PHP incompatible versions
# See: https://moodledev.io/general/development/policies/php
- moodle-branch: "MOODLE_401_STABLE"
php: "8.2"
- moodle-branch: "MOODLE_401_STABLE"
php: "8.3"
- moodle-branch: "MOODLE_402_STABLE"
# See: https://docs.moodle.org/dev/Moodle_and_PHP

- moodle_branch: "MOODLE_402_STABLE"
php: "7.4"
- moodle-branch: "MOODLE_402_STABLE"
php: "8.3"
- moodle-branch: "MOODLE_403_STABLE"
- moodle_branch: "MOODLE_403_STABLE"
php: "7.4"
- moodle-branch: "MOODLE_403_STABLE"
php: "8.3"
- moodle-branch: "MOODLE_404_STABLE"
- moodle_branch: "MOODLE_404_STABLE"
php: "7.4"
- moodle_branch: "MOODLE_405_STABLE"
php: "7.4"
- moodle_branch: "MOODLE_500_STABLE"
php: "7.4"
- moodle-branch: "MOODLE_404_STABLE"
- moodle_branch: "MOODLE_501_STABLE"
php: "7.4"


- moodle_branch: "MOODLE_404_STABLE"
php: "8.0"
- moodle-branch: "main"
- moodle_branch: "MOODLE_405_STABLE"
php: "8.0"
- moodle_branch: "MOODLE_500_STABLE"
php: "8.0"
- moodle_branch: "MOODLE_501_STABLE"
php: "8.0"

- moodle_branch: "MOODLE_500_STABLE"
php: "8.1"
- moodle_branch: "MOODLE_501_STABLE"
php: "8.1"

- moodle_branch: "MOODLE_401_STABLE"
php: "8.2"

- moodle_branch: "MOODLE_401_STABLE"
php: "8.3"
- moodle_branch: "MOODLE_402_STABLE"
php: "8.3"
- moodle_branch: "MOODLE_403_STABLE"
php: "8.3"

- moodle_branch: "MOODLE_401_STABLE"
php: "8.4"
- moodle_branch: "MOODLE_402_STABLE"
php: "8.4"
- moodle_branch: "MOODLE_403_STABLE"
php: "8.4"
- moodle_branch: "MOODLE_404_STABLE"
php: "8.4"
- moodle_branch: "MOODLE_405_STABLE"
php: "8.4"

- moodle_branch: "main"


include:
# Only test master against latest PHP until we know which
# versions are supported in the next release
- moodle-branch: "main"
php: "8.3"
- moodle_branch: "main"
php: "8.4"
database: "pgsql"
continue-on-error: ${{ matrix.branch == 'main' }}

steps:
- name: Check out repository code
uses: actions/checkout@v4
with:
path: plugin

# 0.1 Detect branch name based on event type.
- name: Set branch name
id: get_branch
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV
else
echo "BRANCH_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
fi

# 0.2 Log current matrix info.
- name: Log info
run: |
echo "PHP: ${{ matrix.php }}"
echo "Moodle: ${{ matrix.moodle_branch }}"
echo "Browser: ${{ matrix.browser }}"
echo "Branch: ${{ env.BRANCH_NAME }}"

# 0.3 Cache Composer for faster builds.
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.composer/cache
${{ github.workspace }}/.npm
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.moodle_branch }}
restore-keys: ${{ runner.os }}-composer-${{ matrix.php }}-${{ matrix.moodle_branch }}

# 1. Setup PHP for the current matrix.
- name: Setup PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: ${{ matrix.extensions }}
ini-values: max_input_vars=5000
# If you are not using code coverage, keep "none". Otherwise, use "pcov" (Moodle 3.10 and up) or "xdebug".
# If you try to use code coverage with "none", it will fallback to phpdbg (which has known problems).
ini-values: max_input_vars=10000
coverage: none

# 2. Install moodle-plugin-ci tool.
- name: Initialise moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
sudo locale-gen en_AU.UTF-8
echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV
echo NVM_DIR=$NVM_DIR >> $GITHUB_ENV
env:
IGNORE_PATHS: classes/privacy,ignore,node_modules,integration,render
COVERAGE: false
CODECHECKER_IGNORE_PATHS: classes/privacy,ignore,node_modules,integration,render
PHPUNIT_IGNORE_PATHS: classes/privacy,ignore,node_modules,integration,render

# 3. Install filter
- name: Add Wiris filter
run: |
moodle-plugin-ci add-plugin wiris/moodle-filter_wiris

# 3.5. Install Wiris Quizzes plugin.
- name: Add Wiris Quizzes plugin
id: install-plugin-quizzes
if: ${{ always() }}
continue-on-error: true
run: |
moodle-plugin-ci add-plugin --branch test/rework-e2e-tests wiris/moodle-qtype_truefalsewiris
moodle-plugin-ci add-plugin --branch test/rework-e2e-tests wiris/moodle-qtype_shortanswerwiris
moodle-plugin-ci add-plugin --branch test/rework-e2e-tests wiris/moodle-qtype_multichoicewiris
moodle-plugin-ci add-plugin --branch test/rework-e2e-tests wiris/moodle-qtype_multianswerwiris
moodle-plugin-ci add-plugin --branch test/rework-e2e-tests wiris/moodle-qtype_matchwiris
moodle-plugin-ci add-plugin --branch test/rework-e2e-tests wiris/moodle-qtype_essaywiris
- name: Add Wiris Quizzes plugin using the main branch
if: ${{ steps.install-plugin-quizzes.outcome != 'success' }}
run: |
moodle-plugin-ci add-plugin --branch main wiris/moodle-qtype_truefalsewiris
moodle-plugin-ci add-plugin --branch main wiris/moodle-qtype_shortanswerwiris
moodle-plugin-ci add-plugin --branch main wiris/moodle-qtype_multichoicewiris
moodle-plugin-ci add-plugin --branch main wiris/moodle-qtype_multianswerwiris
moodle-plugin-ci add-plugin --branch main wiris/moodle-qtype_matchwiris
moodle-plugin-ci add-plugin --branch main wiris/moodle-qtype_essaywiris
# 4. Install plugin and configure DB.
- name: Install moodle-plugin-ci
run: moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1
env:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
MOODLE_BRANCH: ${{ matrix.moodle_branch }}

- name: PHP Lint
if: ${{ !cancelled() }}
run: moodle-plugin-ci phplint

- name: PHP Mess Detector
continue-on-error: true # This step will show errors but will not fail
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpmd

- name: Moodle Code Checker
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpcs --max-warnings 0

- name: Moodle PHPDoc Checker
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpdoc --max-warnings 0
# 5. Run PHPUnit tests.
- name: PHPUnit tests
if: ${{ always() }}
run: moodle-plugin-ci phpunit ./plugin
continue-on-error: true

# 5.1 Run Moodle code validation.
- name: Validating
if: ${{ !cancelled() }}
run: moodle-plugin-ci validate

- name: Check upgrade savepoints
if: ${{ !cancelled() }}
run: moodle-plugin-ci savepoints

- name: Mustache Lint
if: ${{ !cancelled() }}
run: moodle-plugin-ci mustache
if: ${{ always() }}
run: moodle-plugin-ci validate ./plugin
continue-on-error: true

- name: Grunt
if: ${{ !cancelled() }}
run: moodle-plugin-ci grunt --max-lint-warnings 0

- name: PHPUnit tests
if: ${{ !cancelled() }}
run: moodle-plugin-ci phpunit --fail-on-warning

- name: Behat features
# 6. Run Behat tests.
- name: Behat features for ( ${{ matrix.moodle_branch }} on PHP ${{ matrix.php }} )
id: behat
if: ${{ !cancelled() }}
run: moodle-plugin-ci behat --profile chrome

run: |
case "${{ matrix.moodle_branch }}" in
"MOODLE_401_STABLE"|"MOODLE_402_STABLE"|"MOODLE_403_STABLE"|"MOODLE_404_STABLE"|"MOODLE_405_STABLE"|"MOODLE_500_STABLE"|"MOODLE_501_STABLE"|"main")
TAG="@qtype_wq"
;;
esac
moodle-plugin-ci behat --tags=$TAG --profile ${{ matrix.browser }} --auto-rerun=2 --verbose -vvv

# 6.1 Upload Behat fail dumps when errors occur.
- name: Upload Behat Faildump
if: ${{ failure() && steps.behat.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: Behat Faildump (${{ join(matrix.*, ', ') }})
name: Behat Faildump (${{ matrix.php }}, ${{ matrix.moodle_branch }}, ${{ matrix.browser }})
path: ${{ github.workspace }}/moodledata/behat_dump
retention-days: 7
retention-days: 1
if-no-files-found: ignore

- name: Mark cancelled jobs as failed.
if: ${{ cancelled() }}
run: exit 1
2 changes: 1 addition & 1 deletion renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class qtype_wq_renderer extends qtype_renderer {

protected $base;

public function __construct(qtype_renderer $base = null, moodle_page $page, $target) {
public function __construct(qtype_renderer $base, moodle_page $page, $target) {
parent::__construct($page, $target);
$this->base = $base;
}
Expand Down
43 changes: 43 additions & 0 deletions tests/behat/behat_qtype_wq.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

use Behat\Behat\Context\Step\Given;
use Behat\Behat\Context\Step\When;
use Behat\Behat\Context\Step\Then;
use Behat\Gherkin\Node\TableNode;

/**
* Steps definitions related to qtype_wq.
*/
class behat_qtype_wq extends behat_base {

/**
* @Given I open the action menu for :elementtype :identifier
*/
public function i_open_the_action_menu_for($elementtype, $identifier) {
// Find the action menu button for the specified element
$xpath = "//div[contains(@class, '{$elementtype}') and contains(., '{$identifier}')]//button[contains(@class, 'action-menu-trigger')]";

$this->execute('behat_general::i_click_on', [$xpath, 'xpath_element']);
}

/**
* @Then I should see :count elements matching :selector
*/
public function i_should_see_elements_matching($count, $selector) {
// Convert count to integer
$expectedcount = (int)$count;

// Find elements matching the selector
$elements = $this->find_all('css_element', $selector);

if (count($elements) !== $expectedcount) {
$session = $this->getSession();
$currentUrl = $session->getCurrentUrl();

throw new Exception(
"Expected {$expectedcount} elements matching '{$selector}', but found " . count($elements) .
". Current URL: {$currentUrl}"
);
}
}
}
17 changes: 10 additions & 7 deletions tests/behat/behat_wq_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ public function i_should_have_a_readonly_input() {
$session = $this->getSession();
$readonly = $session->getPage()->find('css', '.wrsUI_readOnly');
if (empty($readonly)) {
throw new Exception('Readonly field not found.');
$currentUrl = $session->getCurrentUrl();
throw new Exception("Readonly field not found. Current URL: {$currentUrl}");
}
}

Expand All @@ -121,9 +122,10 @@ public function i_add_the_variable_with_value($varname, $value) {
*/
public function feedback_should_exist() {
$session = $this->getSession();
$readonly = $session->getPage()->find('css', '.feedback');
if (empty($readonly)) {
throw new Exception('Readonly field not found.');
$feedback = $session->getPage()->find('css', '.feedback');
if (empty($feedback)) {
$currentUrl = $session->getCurrentUrl();
throw new Exception("Feedback element not found. Current URL: {$currentUrl}");
}
}

Expand All @@ -132,9 +134,10 @@ public function feedback_should_exist() {
*/
public function generalfeedback_should_exist() {
$session = $this->getSession();
$readonly = $session->getPage()->find('css', '.generalfeedback');
if (empty($readonly)) {
throw new Exception('Readonly field not found.');
$generalfeedback = $session->getPage()->find('css', '.generalfeedback');
if (empty($generalfeedback)) {
$currentUrl = $session->getCurrentUrl();
throw new Exception("General feedback element not found. Current URL: {$currentUrl}");
}
}

Expand Down
Loading
Loading