Skip to content
Snippets Groups Projects
Commit 2ec99c2b authored by Matti Harjula's avatar Matti Harjula
Browse files

Change logic for checking for lost placeholders to deal with multi-lang and...

Change logic for checking for lost placeholders to deal with multi-lang and intenttionally lost placeholders.

Instead of checking if we have the same before and after the filttering check if we have every type present in any order.

This will also lead to an error when running multi-lang materials without multi-lang.
parent 80ca87f4
Branches
No related tags found
No related merge requests found
......@@ -43,8 +43,10 @@ class qtype_stack_renderer extends qtype_renderer {
$inputstovaldiate = array();
// Get the list of placeholders before format_text.
$originalinputplaceholders = stack_utils::extract_placeholders($questiontext, 'input');
$originalfeedbackplaceholders = stack_utils::extract_placeholders($questiontext, 'feedback');
$originalinputplaceholders = array_unique(stack_utils::extract_placeholders($questiontext, 'input'));
sort($originalinputplaceholders);
$originalfeedbackplaceholders = array_unique(stack_utils::extract_placeholders($questiontext, 'feedback'));
sort($originalfeedbackplaceholders);
// Now format the questiontext.
$questiontext = $question->format_text(
......@@ -54,12 +56,17 @@ class qtype_stack_renderer extends qtype_renderer {
// Get the list of placeholders after format_text.
$formatedinputplaceholders = stack_utils::extract_placeholders($questiontext, 'input');
sort($formatedinputplaceholders);
$formatedfeedbackplaceholders = stack_utils::extract_placeholders($questiontext, 'feedback');
sort($formatedfeedbackplaceholders);
// We need to check that if the list has changed.
// Have we lost some of the placeholders entirely?
// Duplicates may have been removed by multi-lang,
// No duplicates should remain.
if ($formatedinputplaceholders !== $originalinputplaceholders ||
$formatedfeedbackplaceholders !== $originalfeedbackplaceholders) {
throw new coding_exception('Inconsistent placeholders.');
throw new coding_exception('Inconsistent placeholders. Possibly due to multi-lang filtter not being active.');
}
foreach ($question->inputs as $name => $input) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment