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

Don't modify the page context in the dependencies checker.

parent 6a85bfdd
No related branches found
No related tags found
No related merge requests found
...@@ -124,7 +124,7 @@ if (data_submitted() && optional_param('includes', false, PARAM_BOOL)) { ...@@ -124,7 +124,7 @@ if (data_submitted() && optional_param('includes', false, PARAM_BOOL)) {
if (isset($q->compiledcache['includes']) && ( if (isset($q->compiledcache['includes']) && (
(isset($q->compiledcache['includes']['keyval']) && count($q->compiledcache['includes']['keyval']) > 0) || (isset($q->compiledcache['includes']['keyval']) && count($q->compiledcache['includes']['keyval']) > 0) ||
(isset($q->compiledcache['includes']['castext']) && count($q->compiledcache['includes']['castext']) > 0))) { (isset($q->compiledcache['includes']['castext']) && count($q->compiledcache['includes']['castext']) > 0))) {
list($context, $seed, $urlparams) = qtype_stack_setup_question_test_page($q); list($context, $seed, $urlparams) = qtype_stack_setup_question_test_page($q, false);
if (stack_determine_moodle_version() < 400) { if (stack_determine_moodle_version() < 400) {
$qurl = question_preview_url($item->questionid, null, null, null, null, $context); $qurl = question_preview_url($item->questionid, null, null, null, null, $context);
} else { } else {
...@@ -190,7 +190,7 @@ if (data_submitted() && optional_param('jsxgraphs', false, PARAM_BOOL)) { ...@@ -190,7 +190,7 @@ if (data_submitted() && optional_param('jsxgraphs', false, PARAM_BOOL)) {
} }
// Confirm that it does have these. // Confirm that it does have these.
if ($block || $filter || $other) { if ($block || $filter || $other) {
list($context, $seed, $urlparams) = qtype_stack_setup_question_test_page($q); list($context, $seed, $urlparams) = qtype_stack_setup_question_test_page($q, false);
if (stack_determine_moodle_version() < 400) { if (stack_determine_moodle_version() < 400) {
$qurl = question_preview_url($item->questionid, null, null, null, null, $context); $qurl = question_preview_url($item->questionid, null, null, null, null, $context);
} else { } else {
...@@ -217,7 +217,7 @@ if (data_submitted() && optional_param('script', false, PARAM_BOOL)) { ...@@ -217,7 +217,7 @@ if (data_submitted() && optional_param('script', false, PARAM_BOOL)) {
// Load the whole question, simpler to get the contexts correct that way. // Load the whole question, simpler to get the contexts correct that way.
foreach ($qs as $item) { foreach ($qs as $item) {
$q = question_bank::load_question($item->questionid); $q = question_bank::load_question($item->questionid);
list($context, $seed, $urlparams) = qtype_stack_setup_question_test_page($q); list($context, $seed, $urlparams) = qtype_stack_setup_question_test_page($q, false);
if (stack_determine_moodle_version() < 400) { if (stack_determine_moodle_version() < 400) {
$qurl = question_preview_url($item->questionid, null, null, null, null, $context); $qurl = question_preview_url($item->questionid, null, null, null, null, $context);
} else { } else {
...@@ -242,7 +242,7 @@ if (data_submitted() && optional_param('PLUGINFILE', false, PARAM_BOOL)) { ...@@ -242,7 +242,7 @@ if (data_submitted() && optional_param('PLUGINFILE', false, PARAM_BOOL)) {
// Load the whole question, simpler to get the contexts correct that way. // Load the whole question, simpler to get the contexts correct that way.
foreach ($qs as $item) { foreach ($qs as $item) {
$q = question_bank::load_question($item->questionid); $q = question_bank::load_question($item->questionid);
list($context, $seed, $urlparams) = qtype_stack_setup_question_test_page($q); list($context, $seed, $urlparams) = qtype_stack_setup_question_test_page($q, false);
if (stack_determine_moodle_version() < 400) { if (stack_determine_moodle_version() < 400) {
$qurl = question_preview_url($item->questionid, null, null, null, null, $context); $qurl = question_preview_url($item->questionid, null, null, null, null, $context);
} else { } else {
...@@ -267,7 +267,7 @@ if (data_submitted() && optional_param('langs', false, PARAM_BOOL)) { ...@@ -267,7 +267,7 @@ if (data_submitted() && optional_param('langs', false, PARAM_BOOL)) {
// Load the whole question, simpler to get the contexts correct that way. // Load the whole question, simpler to get the contexts correct that way.
foreach ($qs as $item) { foreach ($qs as $item) {
$q = question_bank::load_question($item->questionid); $q = question_bank::load_question($item->questionid);
list($context, $seed, $urlparams) = qtype_stack_setup_question_test_page($q); list($context, $seed, $urlparams) = qtype_stack_setup_question_test_page($q, false);
if (stack_determine_moodle_version() < 400) { if (stack_determine_moodle_version() < 400) {
$qurl = question_preview_url($item->questionid, null, null, null, null, $context); $qurl = question_preview_url($item->questionid, null, null, null, null, $context);
} else { } else {
......
...@@ -207,7 +207,7 @@ function stack_string_sanitise($str) { ...@@ -207,7 +207,7 @@ function stack_string_sanitise($str) {
* that is needed on all of them. * that is needed on all of them.
* @return array page context, selected seed (or null), and URL parameters. * @return array page context, selected seed (or null), and URL parameters.
*/ */
function qtype_stack_setup_question_test_page($question) { function qtype_stack_setup_question_test_page($question, $setcontext = true) {
global $PAGE; global $PAGE;
$seed = optional_param('seed', null, PARAM_INT); $seed = optional_param('seed', null, PARAM_INT);
...@@ -230,7 +230,6 @@ function qtype_stack_setup_question_test_page($question) { ...@@ -230,7 +230,6 @@ function qtype_stack_setup_question_test_page($question) {
$urlparams['courseid'] = $courseid; $urlparams['courseid'] = $courseid;
} else { } else {
require_login();
$context = $question->get_context(); $context = $question->get_context();
if ($context->contextlevel == CONTEXT_MODULE) { if ($context->contextlevel == CONTEXT_MODULE) {
$urlparams['cmid'] = $context->instanceid; $urlparams['cmid'] = $context->instanceid;
...@@ -239,7 +238,10 @@ function qtype_stack_setup_question_test_page($question) { ...@@ -239,7 +238,10 @@ function qtype_stack_setup_question_test_page($question) {
} else { } else {
$urlparams['courseid'] = SITEID; $urlparams['courseid'] = SITEID;
} }
if ($setcontext) {
require_login();
$PAGE->set_context($context); $PAGE->set_context($context);
}
// Note that in the other cases, require_login will set the correct page context. // Note that in the other cases, require_login will set the correct page context.
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment