MDL-36733 qtype_calculated: Wildcards in calculated question hints

The placeholders for the hints are properly replaced by this change and any formulas present are replaced.

The validation is performed by the existing function qtype_calculated_find_formula_errors(),
which is called by the calculate() function,
which in turn is called by the variable substituter "vs" using the replace_expressions_in_text() function.

vs -> replace_expressions_in_text() -> calculate() -> qtype_calculated_find_formula_errors().
This commit is contained in:
Pascal Hamar
2023-11-28 19:02:27 +01:00
parent 6374475dc3
commit 38ac75d674
+6
View File
@@ -73,6 +73,12 @@ class qtype_calculated_question extends qtype_numerical_question
$ans->feedback = $this->vs->replace_expressions_in_text($ans->feedback,
$ans->correctanswerlength, $ans->correctanswerformat);
}
// Replace expressions in hints referring MDL-36733.
// Calculation through calculation() function in replace_expressions_in_text() function.
// Validation through qtype_calculated_find_formula_errors() function in calculate() function.
foreach ($this->hints as $hint) {
$hint->hint = $this->vs->replace_expressions_in_text($hint->hint);
}
}
public function get_num_variants() {