Skip to content

Commit 9fad8c2

Browse files
committed
Allow case sensitive validator/feedback function names. Issue #1792.
1 parent de33fb8 commit 9fad8c2

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

stack/input/inputbase.class.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,12 @@ protected function internal_construct() {
209209
if (trim($options ?? '') != '') {
210210
$options = explode(',', $options);
211211
foreach ($options as $option) {
212-
$option = strtolower(trim($option));
213212
[$option, $arg] = stack_utils::parse_option($option);
213+
// Maintain back compatibility following fix to #1792.
214+
$option = strtolower(trim($option));
215+
if (!($option == 'validator' || $option == 'feedback')) {
216+
$arg = strtolower(trim($arg));
217+
}
214218
// Only accept those options specified in the array for this input type.
215219
if (array_key_exists($option, $this->extraoptions)) {
216220
if ($arg === '') {

tests/helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4325,7 +4325,7 @@ public static function make_stack_question_validator() {
43254325
// We need to check that local variable names within the block are not invalid for student's input.
43264326
// We need to chack mathematics within the castext is correctly displayed.
43274327
$q->questionvariables = 'texput(foo,lambda([e],[a,b]:args(e), sconcat("\\\\frac{", tex1(a), "}{", tex1(b), "}")));' .
4328-
'ta:phi^2-1;myvalidityidea(ex):=block(if ev(subsetp(setify(listofvars(ex)),' .
4328+
'ta:phi^2-1;myvalidityIdea(ex):=block(if ev(subsetp(setify(listofvars(ex)),' .
43294329
'setify(listofvars(ta))), simp) then return(""),castext("[[lang code=\'fi\']]Vastauksesi sisältää ' .
43304330
'vääriä muuttujia.[[/lang]][[lang code=\'en,other\']]Your answer {@ex@} contains the wrong variables.[[/lang]]"));';
43314331
// This question is also used to test the lang blocks at the top level.
@@ -4346,7 +4346,7 @@ public static function make_stack_question_validator() {
43464346
null,
43474347
[
43484348
'boxWidth' => 20, 'forbidWords' => '', 'allowWords' => 'foo',
4349-
'options' => 'validator:myvalidityidea',
4349+
'options' => 'validator:myvalidityIdea',
43504350
]
43514351
);
43524352

0 commit comments

Comments
 (0)