Skip to content
Snippets Groups Projects
Commit 856ac571 authored by Chris Sangwin's avatar Chris Sangwin
Browse files

WIP/proposal to make sure the bulk tester does not stop because of exceptions.

parent 5a1372bd
No related branches found
No related tags found
No related merge requests found
...@@ -238,3 +238,25 @@ function qtype_stack_setup_question_test_page($question) { ...@@ -238,3 +238,25 @@ function qtype_stack_setup_question_test_page($question) {
return array($context, $seed, $urlparams); return array($context, $seed, $urlparams);
} }
/* This class is needed to ignore requests for pluginfile rewrites in the bulk tester
* and possibly elsewhere, e.g. API.
*/
class stack_outofcontext_process {
public function __construct() {
}
/**
* Calls {@link question_rewrite_question_urls()} with appropriate parameters
* for content belonging to this question.
* @param string $text the content to output.
* @param string $component the component name (normally 'question' or 'qtype_...')
* @param string $filearea the name of the file area.
* @param int $itemid the item id.
* @return string the content with the URLs rewritten.
*/
public function rewrite_pluginfile_urls($text, $component, $filearea, $itemid) {
return $text;
}
}
\ No newline at end of file
...@@ -161,6 +161,8 @@ class stack_bulk_tester { ...@@ -161,6 +161,8 @@ class stack_bulk_tester {
$qdotoutput = 0; $qdotoutput = 0;
} }
// At this point we have no question context and so we can't possibly correctly evaluate URLs.
$question->castextprocessor = new castext2_qa_processor(new stack_outofcontext_process());
$upgradeerrors = $question->validate_against_stackversion(); $upgradeerrors = $question->validate_against_stackversion();
if ($upgradeerrors != '') { if ($upgradeerrors != '') {
if ($outputmode == 'web') { if ($outputmode == 'web') {
......
<?php <?php
// This file is part of Stateful // This file is part of Stateful.
// //
// Stateful is free software: you can redistribute it and/or modify // Stateful is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
...@@ -71,6 +71,9 @@ class castext2_qa_processor extends castext2_default_processor { ...@@ -71,6 +71,9 @@ class castext2_qa_processor extends castext2_default_processor {
// can call things like `rewrite_pluginfile_urls`. // can call things like `rewrite_pluginfile_urls`.
public $qa; public $qa;
public function __construct($qa) { public function __construct($qa) {
if (!method_exists($qa, 'rewrite_pluginfile_urls')) {
stack_exception('Error in constructing castext2_qa_processor: argument must provide rewrite_pluginfile_urls.');
}
$this->qa = $qa; $this->qa = $qa;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment