Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,26 @@ public function formulation_and_controls(question_attempt $qa, question_display_
$originalfeedbackplaceholders = array_unique(stack_utils::extract_placeholders($questiontext, 'feedback'));
sort($originalfeedbackplaceholders);

// Salt input and prt names for moodle glossary auto-link filter protection.
foreach ($question->inputs as $name => $input) {
$questiontext = str_replace(
"[[input:{$name}]]",
"<span class=\"nolink\">[[InMNEYMWDx:{$name}]]</span>",
$questiontext
);
$questiontext = str_replace(
"[[validation:{$name}]]",
"<span class=\"nolink\">[[VnMNEYMWDx:{$name}]]</span>",
$questiontext
);
}
foreach ($question->prts as $index => $prt) {
$questiontext = str_replace(
"[[feedback:{$index}]]",
"<span class=\"nolink\">[[GDBBdLBJLg:{$index}]]</span>",
$questiontext
);
}
// Now format the questiontext.
$questiontext = $question->format_text(
stack_maths::process_display_castext($questiontext, $this),
Expand All @@ -75,6 +95,26 @@ public function formulation_and_controls(question_attempt $qa, question_display_
'questiontext',
$question->id
);
// Restore inputnames.
foreach ($question->inputs as $name => $input) {
$questiontext = str_replace(
"<span class=\"nolink\">[[InMNEYMWDx:{$name}]]</span>",
"[[input:{$name}]]",
$questiontext
);
$questiontext = str_replace(
"<span class=\"nolink\">[[VnMNEYMWDx:{$name}]]</span>",
"[[validation:{$name}]]",
$questiontext
);
}
foreach ($question->prts as $index => $prt) {
$questiontext = str_replace(
"<span class=\"nolink\">[[GDBBdLBJLg:{$index}]]</span>",
"[[feedback:{$index}]]",
$questiontext
);
}
// Replace the secured bits.
$questiontext = $question->questiontextinstantiated->apply_placeholder_holder($questiontext);

Expand All @@ -92,7 +132,7 @@ public function formulation_and_controls(question_attempt $qa, question_display_
$formatedinputplaceholders !== $originalinputplaceholders ||
$formatedfeedbackplaceholders !== $originalfeedbackplaceholders
) {
throw new coding_exception('Inconsistent placeholders. Possibly due to multi-lang filtter not being active.');
throw new coding_exception('Inconsistent placeholders. Possibly due to multi-lang filter not being active.');
}

foreach ($question->inputs as $name => $input) {
Expand Down
2 changes: 1 addition & 1 deletion stack/cas/ast.container.silent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public static function make_from_teacher_source(
// As we take no filter options for teachers sourced stuff lets build them from scratch.
$filteroptions = ['998_security' => ['security' => 't'], '995_ev_modification' => ['flags' => true]];

// Get the filter pipeline. Now we only want the core filtters and
// Get the filter pipeline. Now we only want the core filters and
// append the strict syntax check to the end.
$pipeline = stack_parsing_rule_factory::get_filter_pipeline([
'995_ev_modification', '996_call_modification', '998_security',
Expand Down
Loading