Skip to content

Commit f5f5bfc

Browse files
committed
More coding style fixes
1 parent 812094f commit f5f5bfc

8 files changed

+47
-68
lines changed

tests/behat/preview.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Feature: Preview a Variable numeric set question
3030
| Marked out of | 3 |
3131
| Question variant | 1 |
3232
| Marks | Show mark and max |
33-
And I press "Start again with these options"
33+
And I press "id_saverestart"
3434
Then I should see "What is 2 + 8?"
3535
And the state of "What is 2 + 8?" question is shown as "Tries remaining: 3"
3636
When I set the field "Answer:" to "2"

tests/calculator_test.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function test_evaluate_variables_in_text(string $variable, string $expect
8282
*
8383
* @return array List of data sets (test cases).
8484
*/
85-
public function evaluate_variables_in_text_provider(): array {
85+
public static function evaluate_variables_in_text_provider(): array {
8686

8787
return [
8888
'The argument is treated as an integer and presented as a binary number' => [

tests/form_test.php

+13-20
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@
1616

1717
namespace qtype_varnumericset;
1818

19-
/**
20-
* Unit tests for the varnumericset question edit form.
21-
*
22-
* @package qtype_varnumericset
23-
* @copyright 2023 The Open University
24-
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25-
*/
26-
2719
defined('MOODLE_INTERNAL') || die();
2820
global $CFG;
2921

@@ -33,6 +25,7 @@
3325
/**
3426
* Unit tests for the qtype_varnumericset question edit form.
3527
*
28+
* @package qtype_varnumericset
3629
* @copyright 2023 The Open University
3730
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3831
* @covers \qtype_varnumeric_edit_form_base
@@ -104,7 +97,7 @@ public function test_form_validation(array $fromform, array $expectederrors): vo
10497
*
10598
* @return array List of data sets (test cases).
10699
*/
107-
public function form_validation_testcases(): array {
100+
public static function form_validation_testcases(): array {
108101
return [
109102
'All OK' => [
110103
[
@@ -145,20 +138,20 @@ public function form_validation_testcases(): array {
145138
],
146139
[
147140
'questiontext' => get_string('errorvalidationformatnumber', 'qtype_varnumericset',
148-
'[[x.e]] - Expression evaluation error: an unexpected error occurred.'),
141+
'[[x.e]] - Expression evaluation error: an unexpected error occurred.'),
149142
'generalfeedback' => get_string('errorvalidationformatnumber', 'qtype_varnumericset',
150-
'[[x.e]] - Expression evaluation error: an unexpected error occurred.'),
143+
'[[x.e]] - Expression evaluation error: an unexpected error occurred.'),
151144
'feedback[0]' => get_string('errorvalidationformatnumber', 'qtype_varnumericset',
152-
"[[x, .e]] - The format specifier must not contain non-breaking space characters."),
145+
"[[x, .e]] - The format specifier must not contain non-breaking space characters."),
153146
'feedback[1]' => get_string('errorvalidationformatnumber', 'qtype_varnumericset',
154-
'[[x,]] - Missing format specifier at end of string.'),
147+
'[[x,]] - Missing format specifier at end of string.'),
155148
'hint[0]' => get_string('errorvalidationformatnumber', 'qtype_varnumericset',
156-
'[[x,i]] - Unknown format specifier "i".'),
149+
'[[x,i]] - Unknown format specifier "i".'),
157150
'hint[1]' => get_string('errorvalidationformatnumber', 'qtype_varnumericset',
158-
'[[x,.3\'.09 f]] - Unknown format specifier "'".'),
151+
'[[x,.3\'.09 f]] - Unknown format specifier "'".'),
159152
'hint[2]' => get_string('errorvalidationformatnumber', 'qtype_varnumericset',
160-
"<ul>\n<li>[[x,]] - Missing format specifier at end of string.</li>\n" .
161-
"<li>[[x,i]] - Unknown format specifier &quot;i&quot;.</li>\n</ul>"),
153+
"<ul>\n<li>[[x,]] - Missing format specifier at end of string.</li>\n" .
154+
"<li>[[x,i]] - Unknown format specifier &quot;i&quot;.</li>\n</ul>"),
162155
],
163156
],
164157
[
@@ -172,9 +165,9 @@ public function form_validation_testcases(): array {
172165
'variant1' => [],
173166
],
174167
[
175-
'vartype[0]' => 'At least one of the variables must be a predefined variable.'
176-
]
177-
]
168+
'vartype[0]' => 'At least one of the variables must be a predefined variable.',
169+
],
170+
],
178171
];
179172
}
180173
}

tests/helper.php

+14-14
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,12 @@ public function get_varnumericset_question_form_data_sci_notation_formatted() {
322322
$form->fraction = ['0' => '1.0', '1' => '0.0', '2' => '0.0'];
323323
$form->feedback = [
324324
'0' => ['format' => FORMAT_HTML, 'text' => 'Well done!'],
325-
'1' => ['format' => FORMAT_HTML, 'text' => 'Sorry, no.']
325+
'1' => ['format' => FORMAT_HTML, 'text' => 'Sorry, no.'],
326326
];
327327
$form->penalty = '0.3333333';
328328
$form->hint = [
329329
['text' => 'Please try again.', 'format' => FORMAT_HTML],
330-
['text' => 'You may use a calculator if necessary.', 'format' => FORMAT_HTML]
330+
['text' => 'You may use a calculator if necessary.', 'format' => FORMAT_HTML],
331331
];
332332

333333
return $form;
@@ -340,19 +340,19 @@ public function make_varnumericset_question_sci_notation_formatted() {
340340
$vs = $this->make_varnumericset_question_no_accepted_error();
341341

342342
$vs->answers = [1 => new qtype_varnumericset_answer(
343-
'1', // Id.
344-
'12', // Answer.
345-
1.0000000, // Fraction.
343+
'1', // Id.
344+
'12', // Answer.
345+
1.0000000, // Fraction.
346346
'<p>Your answer is correct.</p>', // Feedback.
347-
FORMAT_HTML,// Feedbackformat.
348-
'0', // Sigfigs.
349-
'', // Error.
350-
'0.25', // Syserrorpenalty.
351-
'0', // Checknumerical.
352-
'1', // Checkscinotation.
353-
'0', // Checkpowerof10.
354-
'0', // Checkrounding.
355-
'1', // Checkscinotationformat.
347+
FORMAT_HTML, // Feedbackformat.
348+
'0', // Sigfigs.
349+
'', // Error.
350+
'0.25', // Syserrorpenalty.
351+
'0', // Checknumerical.
352+
'1', // Checkscinotation.
353+
'0', // Checkpowerof10.
354+
'0', // Checkrounding.
355+
'1', // Checkscinotationformat.
356356
)];
357357
$vs->requirescinotation = true;
358358
$vs->usesupeditor = true;

tests/number_interpreter_test.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
/**
2424
* Unit tests for the number interpreter classes .
2525
*
26-
* @package qtype_varnumericset
2726
* @copyright 2012 The Open University
2827
* @author Jamie Pratt me@jamiep.org
2928
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -39,9 +38,11 @@
3938
/**
4039
* Unit tests for the number interpreter classes .
4140
*
41+
* @package qtype_varnumericset
4242
* @copyright 2012 The Open University
4343
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
44-
* @group qtype_varnumericset
44+
* @covers \qtype_varnumericset_number_interpreter_number_with_optional_decimal_place
45+
* @covers \qtype_varnumericset_number_interpreter_number_with_optional_sci_notation
4546
*/
4647
class number_interpreter_test extends basic_testcase {
4748
public function test_interpret_number_with_optional_decimal_place() {

tests/question_test.php

+11-9
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
1616

17-
/**
18-
* Unit tests for the varnumericset question definition class.
19-
*
20-
* @package qtype_varnumericset
21-
* @copyright 2012 The Open University
22-
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23-
*/
17+
namespace qtype_varnumericset;
2418

19+
use advanced_testcase;
20+
use qtype_varnumeric_question_base;
21+
use qtype_varnumericset_answer;
22+
use qtype_varnumericset_question;
23+
use question_attempt_step;
24+
use test_question_maker;
2525

2626
defined('MOODLE_INTERNAL') || die();
2727
global $CFG;
@@ -33,10 +33,11 @@
3333
/**
3434
* Unit tests for the varnumericset question definition class.
3535
*
36+
* @package qtype_varnumericset
3637
* @copyright 2012 The Open University
3738
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38-
* @covers \qtype_varnumeric_question_base
39-
* @covers \qtype_varnumericset_question
39+
* @covers \qtype_varnumeric_question_base
40+
* @covers \qtype_varnumericset_question
4041
*/
4142
class question_test extends advanced_testcase {
4243

@@ -369,6 +370,7 @@ public function test_compare_num_as_string_with_answer() {
369370
$this->assertEquals(1, $penalty);
370371

371372
// Test check scinotation format.
373+
/** @var qtype_varnumericset_question $question */
372374
$question = test_question_maker::make_question('varnumericset', 'sci_notation_formatted');
373375
$answer = new qtype_varnumericset_answer(12345, // Id.
374376
'12', // Answer.

tests/questiontype_test.php

+1-10
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@
2121
use question_possible_response;
2222
use stdClass;
2323

24-
/**
25-
* Unit tests for the varnumericset question type class.
26-
*
27-
* @package qtype
28-
* @subpackage varnumericset
29-
* @copyright 2012 The Open University
30-
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31-
*/
32-
33-
3424
defined('MOODLE_INTERNAL') || die();
3525
global $CFG;
3626

@@ -40,6 +30,7 @@
4030
/**
4131
* Unit tests for the varnumericset question type class.
4232
*
33+
* @package qtype_varnumericset
4334
* @copyright 2012 The Open University
4435
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
4536
* @covers \qtype_varnumericset

tests/walkthrough_test.php

+3-11
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@
2323
use question_state;
2424
use test_question_maker;
2525

26-
/**
27-
* This file contains overall tests of varnumericset questions.
28-
*
29-
* @package qtype_varnumericset
30-
* @copyright 2011 The Open University
31-
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32-
*/
33-
34-
3526
defined('MOODLE_INTERNAL') || die();
3627

3728
global $CFG;
@@ -42,10 +33,11 @@
4233
/**
4334
* Walk through Unit tests for varnumericset questions.
4435
*
36+
* @package qtype_varnumericset
4537
* @copyright 2011 The Open University
4638
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
47-
* @covers \qtype_varnumeric_question_base
48-
* @covers \qtype_varnumericset_question
39+
* @covers \qtype_varnumeric_question_base
40+
* @covers \qtype_varnumericset_question
4941
*/
5042
class walkthrough_test extends qbehaviour_walkthrough_test_base {
5143
public function test_validation_and_interactive_with_one_try_for_3_sig_figs() {

0 commit comments

Comments
 (0)