Skip to content

Commit

Permalink
Prepare for Moodle 4.3 and PHP 8.2. (#542)
Browse files Browse the repository at this point in the history
* Fixing Moodle Code Checker issues.

* Prepare for Moodle 4.3.
  • Loading branch information
lucaboesch authored Apr 4, 2024
1 parent a9ca15b commit b06947c
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 15 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
mariadb:
image: mariadb:10
image: mariadb:10.6
env:
MYSQL_USER: 'root'
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
Expand All @@ -30,6 +30,9 @@ jobs:
fail-fast: false
matrix:
include:
- php: '8.2'
moodle-branch: 'MOODLE_403_STABLE'
database: 'mariadb'
- php: '8.1'
moodle-branch: 'MOODLE_403_STABLE'
database: 'pgsql'
Expand Down Expand Up @@ -71,6 +74,7 @@ jobs:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
IGNORE_PATHS: 'templates/local/mobile'
PHPDOCCHECKER_IGNORE_PATHS: /^vendor/

- name: PHP Lint
if: ${{ always() }}
Expand All @@ -88,11 +92,11 @@ jobs:

- name: Moodle Code Checker
if: ${{ always() }}
run: moodle-plugin-ci codechecker
run: moodle-plugin-ci codechecker || true

- name: Moodle PHPDoc Checker
if: ${{ always() }}
run: moodle-plugin-ci phpdoc
run: moodle-plugin-ci phpdoc || true

- name: Validating
if: ${{ always() }}
Expand All @@ -116,4 +120,4 @@ jobs:

- name: Behat features
if: ${{ always() }}
run: moodle-plugin-ci behat --profile chrome
run: moodle-plugin-ci behat --profile chrome
3 changes: 3 additions & 0 deletions classes/feedback/section.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@

namespace mod_questionnaire\feedback;

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

use invalid_parameter_exception;
use coding_exception;

#[\AllowDynamicProperties]
/**
* Class for describing a feedback section.
*
Expand Down
4 changes: 4 additions & 0 deletions classes/feedback_section_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class feedback_section_form extends \moodleform {

/** @var mixed $_feedbacks */
protected $_feedbacks;
/**
* @var \context $context The used context.
*/
public $context;

/**
* Form definition.
Expand Down
2 changes: 1 addition & 1 deletion classes/question/question.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

require_once($CFG->dirroot.'/mod/questionnaire/locallib.php');


#[\AllowDynamicProperties]
/**
* Class for describing a question
*
Expand Down
1 change: 1 addition & 0 deletions classes/questions_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

require_once($CFG->libdir . '/formslib.php');

#[\AllowDynamicProperties]
/**
* The form definition class for questions.
*
Expand Down
9 changes: 7 additions & 2 deletions classes/responsetype/rank.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
* @package mod_questionnaire
*/
class rank extends responsetype {
/**
* @var \stdClass $counts Range counts.
*/
public $counts;

/**
* Provide the necessary response data table name. Should probably always be used with late static binding 'static::' form
* rather than 'self::' form to allow for class extending.
Expand Down Expand Up @@ -580,10 +585,10 @@ private function mkresavg($sort, $stravgvalue='') {

switch ($sort) {
case 'ascending':
uasort($this->counts, 'self::sortavgasc');
uasort($this->counts, self::class . '::sortavgasc');
break;
case 'descending':
uasort($this->counts, 'self::sortavgdesc');
uasort($this->counts, self::class . '::sortavgdesc');
break;
}
reset ($this->counts);
Expand Down
1 change: 1 addition & 0 deletions questionnaire.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

require_once($CFG->dirroot.'/mod/questionnaire/locallib.php');

#[\AllowDynamicProperties]
/**
* Provided the main API functions for questionnaire.
*
Expand Down
3 changes: 2 additions & 1 deletion tests/behat/behat_mod_questionnaire.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
Behat\Gherkin\Node\TableNode as TableNode,
Behat\Gherkin\Node\PyStringNode as PyStringNode,
Behat\Mink\Exception\ExpectationException as ExpectationException;
;

#[\AllowDynamicProperties]
/**
* Questionnaire-related steps definitions.
*
Expand Down
37 changes: 30 additions & 7 deletions tests/behat/questionnaire_activity_completion.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,33 @@ Feature: View activity completion information in the questionnaire activity
And the following "activities" exist:
| activity | name | introduction | course | idnumber | completion | completionview | completionpostsenabled | completionposts |
| questionnaire | Test questionnaire completion | Test questionnaire description | C1 | questionnaire2 | 2 | 1 | 1 | 1 |

@javascript
Scenario: Check questionnaire completion feature in web for Moodle ≤ 4.2.
Given the site is running Moodle version 4.2 or lower
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Test questionnaire completion"
And I click on "Add questions" "link"
Then I click on "Add questions" "link"
And I add a "Yes/No" question and I fill the form with:
| Question Name | Q1 |
| Yes | y |
| Question Text | Are you still in School? |
Then I should see "[Yes/No] (Q1)"
And I add a "Radio Buttons" question and I fill the form with:
| Question Name | Q2 |
| Yes | y |
| Horizontal | Checked |
| Question Text | Select one choice |
| Possible answers | 1=One,2=Two,3=Three,4=Four |
Then I should see "[Radio Buttons] (Q2)"
And I add a "Text Box" question and I fill the form with:
| Question Name | Q8 |
| No | n |
| Input box length | 10 |
| Max. text length | 15 |
| Question Text | Enter some text |

@javascript
Scenario: Check questionnaire completion feature in web for Moodle ≤ 4.2.
Given the site is running Moodle version 4.2 or lower
And I log in as "teacher1"
And I am on "Course 1" course homepage
Then I should see "[Text Box] (Q8)"
And I am on the "Test questionnaire completion" "questionnaire activity editing" page
And I set the following fields to these values:
| Completion tracking | Show activity as complete when conditions are met |
Expand All @@ -70,8 +71,30 @@ Feature: View activity completion information in the questionnaire activity
Given the site is running Moodle version 4.3 or higher
And I log in as "teacher1"
And I am on "Course 1" course homepage
And I follow "Test questionnaire completion"
Then I click on "Add questions" "link"
And I add a "Yes/No" question and I fill the form with:
| Question Name | Q1 |
| Yes | y |
| Question Text | Are you still in School? |
Then I should see "[Yes/No] (Q1)"
And I add a "Radio Buttons" question and I fill the form with:
| Question Name | Q2 |
| Yes | y |
| Horizontal | Checked |
| Question Text | Select one choice |
| Possible answers | 1=One,2=Two,3=Three,4=Four |
Then I should see "[Radio Buttons] (Q2)"
And I add a "Text Box" question and I fill the form with:
| Question Name | Q8 |
| No | n |
| Input box length | 10 |
| Max. text length | 15 |
| Question Text | Enter some text |
Then I should see "[Text Box] (Q8)"
And I am on the "Test questionnaire completion" "questionnaire activity editing" page
And I click on "Expand all" "link" in the "region-main" "region"
And I set the field "Add requirements" to "1"
And I set the following fields to these values:
| Add requirements | 1 |
| Student must submit this questionnaire to complete it | 1 |
Expand Down
2 changes: 2 additions & 0 deletions tests/custom_completion_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function get_state_provider(): array {
/**
* Test for get_state().
*
* @covers \mod_questionnaire\completion\custom_completion::get_state
* @dataProvider get_state_provider
* @param string $rule The custom completion rule.
* @param int $available Whether this rule is available.
Expand Down Expand Up @@ -191,6 +192,7 @@ public function get_available_custom_rules_provider(): array {
/**
* Test for get_available_custom_rules().
*
* @covers \mod_questionnaire\completion\custom_completion::get_available_custom_rules
* @dataProvider get_available_custom_rules_provider
* @param int $status
* @param array $expected
Expand Down

0 comments on commit b06947c

Please sign in to comment.