Skip to content

Commit b16653b

Browse files
committed
Enhance Behat tests.
1 parent f2b8039 commit b16653b

16 files changed

+794
-340
lines changed

.github/workflows/moodle-ci.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88

99
services:
1010
postgres:
11-
image: postgres:14
11+
image: postgres:15
1212
env:
1313
POSTGRES_USER: 'postgres'
1414
POSTGRES_HOST_AUTH_METHOD: 'trust'
@@ -30,6 +30,30 @@ jobs:
3030
fail-fast: false
3131
matrix:
3232
include:
33+
- php: 8.4
34+
moodle-branch: MOODLE_501_STABLE
35+
database: pgsql
36+
plugin-ci: 4
37+
- php: 8.4
38+
moodle-branch: MOODLE_501_STABLE
39+
database: mariadb
40+
plugin-ci: 4
41+
- php: 8.3
42+
moodle-branch: MOODLE_501_STABLE
43+
database: pgsql
44+
plugin-ci: 4
45+
- php: 8.3
46+
moodle-branch: MOODLE_501_STABLE
47+
database: mariadb
48+
plugin-ci: 4
49+
- php: 8.2
50+
moodle-branch: MOODLE_501_STABLE
51+
database: pgsql
52+
plugin-ci: 4
53+
- php: 8.2
54+
moodle-branch: MOODLE_501_STABLE
55+
database: mariadb
56+
plugin-ci: 4
3357
- php: 8.4
3458
moodle-branch: MOODLE_500_STABLE
3559
database: pgsql

backup/moodle2/backup_qtype_fileresponse_plugin.class.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2323
*/
2424
class backup_qtype_fileresponse_plugin extends backup_qtype_plugin {
25-
2625
/**
2726
* Returns the qtype information to attach to question element
2827
*/
@@ -47,8 +46,10 @@ protected function define_question_plugin_structure() {
4746
$pluginwrapper->add_child($fileresponse);
4847

4948
// Set source to populate the data.
50-
$fileresponse->set_source_table('qtype_fileresponse_options',
51-
['questionid' => backup::VAR_PARENTID]);
49+
$fileresponse->set_source_table(
50+
'qtype_fileresponse_options',
51+
['questionid' => backup::VAR_PARENTID]
52+
);
5253

5354
// Don't need to annotate ids nor files.
5455

backup/moodle2/restore_qtype_fileresponse_plugin.class.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2424
*/
2525
class restore_qtype_fileresponse_plugin extends restore_qtype_plugin {
26-
2726
/**
2827
* Returns the paths to be handled by the plugin at question level
2928
*/
@@ -54,8 +53,10 @@ public function process_fileresponse($data) {
5453
}
5554

5655
// Detect if the question is created or mapped.
57-
$questioncreated = $this->get_mappingid('question_created',
58-
$this->get_old_parentid('question')) ? true : false;
56+
$questioncreated = $this->get_mappingid(
57+
'question_created',
58+
$this->get_old_parentid('question')
59+
) ? true : false;
5960

6061
// If the question has been created by restore, we need to create its
6162
// qtype_fileresponse too.

classes/privacy/provider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3232
*/
3333
class provider implements \core_privacy\local\metadata\null_provider {
34-
3534
/**
3635
* Get the language string identifier with the component's language
3736
* file to explain why this plugin stores no data.

db/upgrade.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ function xmldb_qtype_fileresponse_upgrade($oldversion) {
3232
$dbman = $DB->get_manager();
3333

3434
if ($oldversion < 2019120200) {
35-
3635
// Add "filetypeslist" column to the question type options to save the allowed file types.
3736
$table = new xmldb_table('qtype_fileresponse_options');
3837
$field = new xmldb_field('filetypeslist', XMLDB_TYPE_TEXT, null, null, null, null, null, 'responsetemplateformat');

edit_fileresponse_form.php

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,17 @@
3232
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3333
*/
3434
class qtype_fileresponse_edit_form extends question_edit_form {
35-
36-
3735
protected function definition_inner($mform) {
3836
$qtype = question_bank::get_qtype('fileresponse');
3937

4038
/* Display the ?forcedownload=1 advice. */
41-
$mform->addElement('static', 'advice', get_string('advice', 'qtype_fileresponse'),
39+
$mform->addElement(
40+
'static',
41+
'advice',
42+
get_string('advice', 'qtype_fileresponse'),
4243
'<div style="width:496px;">' . get_string('questiontextforcedownload', 'qtype_fileresponse') .
43-
'</div>');
44+
'</div>',
45+
);
4446

4547
/* fileresponse only accepts 'formatplain' as format */
4648
$mform->setDefault('responseformat', 'plain');
@@ -52,13 +54,21 @@ protected function definition_inner($mform) {
5254

5355
/* Response required element removed from qtype_essay. */
5456

55-
$mform->addElement('select', 'responsefieldlines',
56-
get_string('responsefieldlines', 'qtype_fileresponse'), $qtype->response_sizes());
57+
$mform->addElement(
58+
'select',
59+
'responsefieldlines',
60+
get_string('responsefieldlines', 'qtype_fileresponse'),
61+
$qtype->response_sizes()
62+
);
5763
$mform->setDefault('responsefieldlines', 15);
5864

5965
/* Fileresponse has to have at least one file required */
60-
$mform->addElement('select', 'attachments',
61-
get_string('amountofexpectedfiles', 'qtype_fileresponse'), $qtype->attachment_options());
66+
$mform->addElement(
67+
'select',
68+
'attachments',
69+
get_string('amountofexpectedfiles', 'qtype_fileresponse'),
70+
$qtype->attachment_options(),
71+
);
6272
$mform->setDefault('attachments', 1);
6373

6474
/* Attachment required element removed from qtype_essay. */
@@ -68,21 +78,34 @@ protected function definition_inner($mform) {
6878
$mform->disabledIf('filetypeslist', 'attachments', 'eq', 0);
6979

7080
/* The element to allow or disallow repositories. */
71-
$mform->addElement('select', 'forcedownload',
72-
get_string('forcedownload', 'qtype_fileresponse'), $qtype->forcedownload_options());
81+
$mform->addElement(
82+
'select',
83+
'forcedownload',
84+
get_string('forcedownload', 'qtype_fileresponse'),
85+
$qtype->forcedownload_options(),
86+
);
7387
$mform->setDefault('forcedownload', 0);
7488

7589
/* The element to allow or disallow repositories. */
76-
$mform->addElement('select', 'allowpickerplugins',
77-
get_string('allowpickerplugins', 'qtype_fileresponse'), $qtype->allowpickerplugins_options());
90+
$mform->addElement(
91+
'select',
92+
'allowpickerplugins',
93+
get_string('allowpickerplugins', 'qtype_fileresponse'),
94+
$qtype->allowpickerplugins_options()
95+
);
7896
$mform->setDefault('allowpickerplugins', 0);
7997

8098
/* Response template element removed from qtype_essay. */
8199

82100
$mform->addElement('header', 'graderinfoheader', get_string('graderinfoheader', 'qtype_fileresponse'));
83101
$mform->setExpanded('graderinfoheader');
84-
$mform->addElement('editor', 'graderinfo', get_string('graderinfo', 'qtype_fileresponse'),
85-
array('rows' => 10), $this->editoroptions);
102+
$mform->addElement(
103+
'editor',
104+
'graderinfo',
105+
get_string('graderinfo', 'qtype_fileresponse'),
106+
['rows' => 10],
107+
$this->editoroptions,
108+
);
86109
}
87110

88111
protected function data_preprocessing($question) {
@@ -103,13 +126,13 @@ protected function data_preprocessing($question) {
103126
$draftid = file_get_submitted_draft_itemid('graderinfo');
104127
$question->graderinfo = array();
105128
$question->graderinfo['text'] = file_prepare_draft_area(
106-
$draftid, // Draftid.
129+
$draftid, // Draftid.
107130
$this->context->id, // Context.
108-
'qtype_fileresponse', // Component.
109-
'graderinfo', // Filarea.
131+
'qtype_fileresponse', // Component.
132+
'graderinfo', // Filearea.
110133
!empty($question->id) ? (int) $question->id : null, // Itemid.
111134
$this->fileoptions, // Options.
112-
$question->options->graderinfo // Text.
135+
$question->options->graderinfo, // Text.
113136
);
114137
$question->graderinfo['format'] = $question->options->graderinfoformat;
115138
$question->graderinfo['itemid'] = $draftid;
@@ -128,8 +151,10 @@ public function validation($fromform, $files) {
128151

129152
// Don't allow the teacher to require more attachments than they allow; as this would
130153
// create a condition that it's impossible for the student to meet.
131-
if ((isset($fromform['attachmentsrequired'])) &&
132-
($fromform['attachments'] != -1 && $fromform['attachments'] < $fromform['attachmentsrequired'])) {
154+
if (
155+
(isset($fromform['attachmentsrequired'])) &&
156+
($fromform['attachments'] != -1 && $fromform['attachments'] < $fromform['attachmentsrequired'])
157+
) {
133158
$errors['attachmentsrequired'] = get_string('mustrequirefewer', 'qtype_fileresponse');
134159
}
135160

0 commit comments

Comments
 (0)