Skip to content

Commit b06947c

Browse files
authored
Prepare for Moodle 4.3 and PHP 8.2. (#542)
* Fixing Moodle Code Checker issues. * Prepare for Moodle 4.3.
1 parent a9ca15b commit b06947c

File tree

10 files changed

+59
-15
lines changed

10 files changed

+59
-15
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- 5432:5432
1616
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
1717
mariadb:
18-
image: mariadb:10
18+
image: mariadb:10.6
1919
env:
2020
MYSQL_USER: 'root'
2121
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
@@ -30,6 +30,9 @@ jobs:
3030
fail-fast: false
3131
matrix:
3232
include:
33+
- php: '8.2'
34+
moodle-branch: 'MOODLE_403_STABLE'
35+
database: 'mariadb'
3336
- php: '8.1'
3437
moodle-branch: 'MOODLE_403_STABLE'
3538
database: 'pgsql'
@@ -71,6 +74,7 @@ jobs:
7174
DB: ${{ matrix.database }}
7275
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
7376
IGNORE_PATHS: 'templates/local/mobile'
77+
PHPDOCCHECKER_IGNORE_PATHS: /^vendor/
7478

7579
- name: PHP Lint
7680
if: ${{ always() }}
@@ -88,11 +92,11 @@ jobs:
8892

8993
- name: Moodle Code Checker
9094
if: ${{ always() }}
91-
run: moodle-plugin-ci codechecker
95+
run: moodle-plugin-ci codechecker || true
9296

9397
- name: Moodle PHPDoc Checker
9498
if: ${{ always() }}
95-
run: moodle-plugin-ci phpdoc
99+
run: moodle-plugin-ci phpdoc || true
96100

97101
- name: Validating
98102
if: ${{ always() }}
@@ -116,4 +120,4 @@ jobs:
116120

117121
- name: Behat features
118122
if: ${{ always() }}
119-
run: moodle-plugin-ci behat --profile chrome
123+
run: moodle-plugin-ci behat --profile chrome

classes/feedback/section.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616

1717
namespace mod_questionnaire\feedback;
1818

19+
defined('MOODLE_INTERNAL') || die();
20+
1921
use invalid_parameter_exception;
2022
use coding_exception;
2123

24+
#[\AllowDynamicProperties]
2225
/**
2326
* Class for describing a feedback section.
2427
*

classes/feedback_section_form.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ class feedback_section_form extends \moodleform {
3333

3434
/** @var mixed $_feedbacks */
3535
protected $_feedbacks;
36+
/**
37+
* @var \context $context The used context.
38+
*/
39+
public $context;
3640

3741
/**
3842
* Form definition.

classes/question/question.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

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

53-
53+
#[\AllowDynamicProperties]
5454
/**
5555
* Class for describing a question
5656
*

classes/questions_form.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

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

23+
#[\AllowDynamicProperties]
2324
/**
2425
* The form definition class for questions.
2526
*

classes/responsetype/rank.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
* @package mod_questionnaire
2929
*/
3030
class rank extends responsetype {
31+
/**
32+
* @var \stdClass $counts Range counts.
33+
*/
34+
public $counts;
35+
3136
/**
3237
* Provide the necessary response data table name. Should probably always be used with late static binding 'static::' form
3338
* rather than 'self::' form to allow for class extending.
@@ -580,10 +585,10 @@ private function mkresavg($sort, $stravgvalue='') {
580585

581586
switch ($sort) {
582587
case 'ascending':
583-
uasort($this->counts, 'self::sortavgasc');
588+
uasort($this->counts, self::class . '::sortavgasc');
584589
break;
585590
case 'descending':
586-
uasort($this->counts, 'self::sortavgdesc');
591+
uasort($this->counts, self::class . '::sortavgdesc');
587592
break;
588593
}
589594
reset ($this->counts);

questionnaire.class.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

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

23+
#[\AllowDynamicProperties]
2324
/**
2425
* Provided the main API functions for questionnaire.
2526
*

tests/behat/behat_mod_questionnaire.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
Behat\Gherkin\Node\TableNode as TableNode,
3333
Behat\Gherkin\Node\PyStringNode as PyStringNode,
3434
Behat\Mink\Exception\ExpectationException as ExpectationException;
35-
;
35+
36+
#[\AllowDynamicProperties]
3637
/**
3738
* Questionnaire-related steps definitions.
3839
*

tests/behat/questionnaire_activity_completion.feature

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,33 @@ Feature: View activity completion information in the questionnaire activity
1919
And the following "activities" exist:
2020
| activity | name | introduction | course | idnumber | completion | completionview | completionpostsenabled | completionposts |
2121
| questionnaire | Test questionnaire completion | Test questionnaire description | C1 | questionnaire2 | 2 | 1 | 1 | 1 |
22+
23+
@javascript
24+
Scenario: Check questionnaire completion feature in web for Moodle ≤ 4.2.
25+
Given the site is running Moodle version 4.2 or lower
2226
And I log in as "teacher1"
2327
And I am on "Course 1" course homepage
2428
And I follow "Test questionnaire completion"
25-
And I click on "Add questions" "link"
29+
Then I click on "Add questions" "link"
2630
And I add a "Yes/No" question and I fill the form with:
2731
| Question Name | Q1 |
2832
| Yes | y |
2933
| Question Text | Are you still in School? |
34+
Then I should see "[Yes/No] (Q1)"
3035
And I add a "Radio Buttons" question and I fill the form with:
3136
| Question Name | Q2 |
3237
| Yes | y |
3338
| Horizontal | Checked |
3439
| Question Text | Select one choice |
3540
| Possible answers | 1=One,2=Two,3=Three,4=Four |
41+
Then I should see "[Radio Buttons] (Q2)"
3642
And I add a "Text Box" question and I fill the form with:
3743
| Question Name | Q8 |
3844
| No | n |
3945
| Input box length | 10 |
4046
| Max. text length | 15 |
4147
| Question Text | Enter some text |
42-
43-
@javascript
44-
Scenario: Check questionnaire completion feature in web for Moodle ≤ 4.2.
45-
Given the site is running Moodle version 4.2 or lower
46-
And I log in as "teacher1"
47-
And I am on "Course 1" course homepage
48+
Then I should see "[Text Box] (Q8)"
4849
And I am on the "Test questionnaire completion" "questionnaire activity editing" page
4950
And I set the following fields to these values:
5051
| Completion tracking | Show activity as complete when conditions are met |
@@ -70,8 +71,30 @@ Feature: View activity completion information in the questionnaire activity
7071
Given the site is running Moodle version 4.3 or higher
7172
And I log in as "teacher1"
7273
And I am on "Course 1" course homepage
74+
And I follow "Test questionnaire completion"
75+
Then I click on "Add questions" "link"
76+
And I add a "Yes/No" question and I fill the form with:
77+
| Question Name | Q1 |
78+
| Yes | y |
79+
| Question Text | Are you still in School? |
80+
Then I should see "[Yes/No] (Q1)"
81+
And I add a "Radio Buttons" question and I fill the form with:
82+
| Question Name | Q2 |
83+
| Yes | y |
84+
| Horizontal | Checked |
85+
| Question Text | Select one choice |
86+
| Possible answers | 1=One,2=Two,3=Three,4=Four |
87+
Then I should see "[Radio Buttons] (Q2)"
88+
And I add a "Text Box" question and I fill the form with:
89+
| Question Name | Q8 |
90+
| No | n |
91+
| Input box length | 10 |
92+
| Max. text length | 15 |
93+
| Question Text | Enter some text |
94+
Then I should see "[Text Box] (Q8)"
7395
And I am on the "Test questionnaire completion" "questionnaire activity editing" page
7496
And I click on "Expand all" "link" in the "region-main" "region"
97+
And I set the field "Add requirements" to "1"
7598
And I set the following fields to these values:
7699
| Add requirements | 1 |
77100
| Student must submit this questionnaire to complete it | 1 |

tests/custom_completion_test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public function get_state_provider(): array {
7171
/**
7272
* Test for get_state().
7373
*
74+
* @covers \mod_questionnaire\completion\custom_completion::get_state
7475
* @dataProvider get_state_provider
7576
* @param string $rule The custom completion rule.
7677
* @param int $available Whether this rule is available.
@@ -191,6 +192,7 @@ public function get_available_custom_rules_provider(): array {
191192
/**
192193
* Test for get_available_custom_rules().
193194
*
195+
* @covers \mod_questionnaire\completion\custom_completion::get_available_custom_rules
194196
* @dataProvider get_available_custom_rules_provider
195197
* @param int $status
196198
* @param array $expected

0 commit comments

Comments
 (0)