Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle-qtype_stack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle-qtype_stack
Commits
ea178a7d
Commit
ea178a7d
authored
2 years ago
by
Chris Sangwin
Browse files
Options
Downloads
Patches
Plain Diff
Do not set moodle context inside functions (WIP).
parent
10043290
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
adminui/dependencies.php
+5
-5
5 additions, 5 deletions
adminui/dependencies.php
deploy.php
+1
-0
1 addition, 0 deletions
deploy.php
locallib.php
+1
-8
1 addition, 8 deletions
locallib.php
with
7 additions
and
13 deletions
adminui/dependencies.php
+
5
−
5
View file @
ea178a7d
...
@@ -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
,
false
);
list
(
$context
,
$seed
,
$urlparams
)
=
qtype_stack_setup_question_test_page
(
$q
);
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
,
false
);
list
(
$context
,
$seed
,
$urlparams
)
=
qtype_stack_setup_question_test_page
(
$q
);
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
,
false
);
list
(
$context
,
$seed
,
$urlparams
)
=
qtype_stack_setup_question_test_page
(
$q
);
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
,
false
);
list
(
$context
,
$seed
,
$urlparams
)
=
qtype_stack_setup_question_test_page
(
$q
);
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
,
false
);
list
(
$context
,
$seed
,
$urlparams
)
=
qtype_stack_setup_question_test_page
(
$q
);
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
{
...
...
This diff is collapsed.
Click to expand it.
deploy.php
+
1
−
0
View file @
ea178a7d
...
@@ -36,6 +36,7 @@ $question = question_bank::load_question($questionid);
...
@@ -36,6 +36,7 @@ $question = question_bank::load_question($questionid);
// Process any other URL parameters, and do require_login.
// Process any other URL parameters, and do require_login.
list
(
$context
,
$seed
,
$urlparams
)
=
qtype_stack_setup_question_test_page
(
$question
);
list
(
$context
,
$seed
,
$urlparams
)
=
qtype_stack_setup_question_test_page
(
$question
);
$PAGE
->
set_context
(
$context
);
// Check permissions.
// Check permissions.
question_require_capability_on
(
$questiondata
,
'edit'
);
question_require_capability_on
(
$questiondata
,
'edit'
);
...
...
This diff is collapsed.
Click to expand it.
locallib.php
+
1
−
8
View file @
ea178a7d
...
@@ -207,9 +207,7 @@ function stack_string_sanitise($str) {
...
@@ -207,9 +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
,
$setcontext
=
true
)
{
function
qtype_stack_setup_question_test_page
(
$question
)
{
global
$PAGE
;
$seed
=
optional_param
(
'seed'
,
null
,
PARAM_INT
);
$seed
=
optional_param
(
'seed'
,
null
,
PARAM_INT
);
$urlparams
=
array
(
'questionid'
=>
$question
->
id
);
$urlparams
=
array
(
'questionid'
=>
$question
->
id
);
if
(
!
is_null
(
$seed
)
&&
$question
->
has_random_variants
())
{
if
(
!
is_null
(
$seed
)
&&
$question
->
has_random_variants
())
{
...
@@ -238,11 +236,6 @@ function qtype_stack_setup_question_test_page($question, $setcontext = true) {
...
@@ -238,11 +236,6 @@ function qtype_stack_setup_question_test_page($question, $setcontext = true) {
}
else
{
}
else
{
$urlparams
[
'courseid'
]
=
SITEID
;
$urlparams
[
'courseid'
]
=
SITEID
;
}
}
if
(
$setcontext
)
{
require_login
();
$PAGE
->
set_context
(
$context
);
}
// Note that in the other cases, require_login will set the correct page context.
}
}
return
array
(
$context
,
$seed
,
$urlparams
);
return
array
(
$context
,
$seed
,
$urlparams
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment