Select Git revision
backup_and_restore_workflow_test.php
-
Justus Dieckmann authoredJustus Dieckmann authored
renderer.php 23.79 KiB
<?php
// This file is part of Stack - http://stack.maths.ed.ac.uk/
//
// Stack is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Stack is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Stack. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
/**
* Stack question renderer class.
*
* @package qtype_stack
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(__DIR__ . '/vle_specific.php');
/**
* Generates the output for Stack questions.
*
* @copyright 2012 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// @codingStandardsIgnoreStart
// There's a matching class name in the API.
class qtype_stack_renderer extends qtype_renderer {
// @codingStandardsIgnoreEnd
public function formulation_and_controls(question_attempt $qa, question_display_options $options) {
/* Return type should be @var qtype_stack_question $question. */
$question = $qa->get_question();
$response = $qa->get_last_qt_data();
// We need to provide a processor for the CASText2 post-processing,
// basically for targetting pluginfiles.
$question->castextprocessor = new castext2_qa_processor($qa);
if (is_string($question->questiontextinstantiated)) {
// The question has not been instantiated successfully, at this level it is likely
// a failure at compilation and that means invalid teacher code.
return $question->questiontextinstantiated;
}
$questiontext = $question->questiontextinstantiated->get_rendered($question->castextprocessor);
// Replace inputs.
$inputstovaldiate = [];
// Get the list of placeholders before format_text.
$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(
stack_maths::process_display_castext($questiontext, $this),
FORMAT_HTML, // All CASText2 processed content has already been formatted to HTML.