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
7fb7ca1d
Commit
7fb7ca1d
authored
4 years ago
by
Chris Sangwin
Browse files
Options
Downloads
Patches
Plain Diff
Refactor context session filtering out of the cassession2 method.
parent
c12c7bf6
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
question.php
+16
-3
16 additions, 3 deletions
question.php
stack/cas/cassession2.class.php
+1
-15
1 addition, 15 deletions
stack/cas/cassession2.class.php
stack/input/inputbase.class.php
+1
-1
1 addition, 1 deletion
stack/input/inputbase.class.php
with
18 additions
and
19 deletions
question.php
+
16
−
3
View file @
7fb7ca1d
...
...
@@ -117,6 +117,12 @@ class qtype_stack_question extends question_graded_automatically_with_countback
*/
protected
$session
;
/**
* Special variables in the question which should be exposed to the inputs and answer tests.
* @var cas_evaluatable[]
*/
protected
$contextsession
;
/**
* @var stack_ast_container[] STACK specific: the teacher's answers for each input.
*/
...
...
@@ -415,7 +421,15 @@ class qtype_stack_question extends question_graded_automatically_with_countback
$this
->
runtimeerrors
[
$s
]
=
true
;
}
$contextsession
=
$this
->
session
->
get_contextsession
();
// Set up the context session for this question.
$contextsession
=
array
();
foreach
(
$this
->
session
->
get_session
()
as
$statement
)
{
if
(
method_exists
(
$statement
,
'is_toplevel_property'
)
&&
$statement
->
is_toplevel_property
(
'contextvariable'
))
{
$contextsession
[]
=
$statement
;
}
}
$this
->
contextsession
=
$contextsession
;
foreach
(
$this
->
prts
as
$name
=>
$prt
)
{
$prt
->
add_contextsession
(
$contextsession
);
}
...
...
@@ -463,7 +477,6 @@ class qtype_stack_question extends question_graded_automatically_with_countback
* teacher's model answers.
*/
protected
function
adapt_inputs
()
{
$contextsession
=
$this
->
session
->
get_contextsession
();
foreach
(
$this
->
inputs
as
$name
=>
$input
)
{
// TODO: again should we give the whole thing to the input.
$teacheranswer
=
''
;
...
...
@@ -471,7 +484,7 @@ class qtype_stack_question extends question_graded_automatically_with_countback
$teacheranswer
=
$this
->
tas
[
$name
]
->
get_value
();
}
$input
->
adapt_to_model_answer
(
$teacheranswer
);
$input
->
add_contextsession
(
$contextsession
);
$input
->
add_contextsession
(
$
this
->
contextsession
);
}
}
...
...
This diff is collapsed.
Click to expand it.
stack/cas/cassession2.class.php
+
1
−
15
View file @
7fb7ca1d
...
...
@@ -328,7 +328,7 @@ class stack_cas_session2 {
$line
.
=
stack_utils
::
php_string_to_maxima_string
(
$statement
->
get_source_context
());
$line
.
=
')'
;
if
(
$statement
->
is_toplevel_property
(
'blockexternal'
))
{
if
(
method_exists
(
$statement
,
'is_toplevel_property'
)
&&
$statement
->
is_toplevel_property
(
'blockexternal'
))
{
$preblock
.
=
$line
.
"$\n"
;
}
else
{
$command
.
=
self
::
SEP
.
$line
;
...
...
@@ -534,20 +534,6 @@ class stack_cas_session2 {
return
trim
(
$keyvals
);
}
/*
* This is used to extract all the expressions for which "blockexternal" is true.
* This enables some context variables to communicate between the castext parts and the inputs.
*/
public
function
get_contextsession
()
{
$contextsession
=
array
();
foreach
(
$this
->
statements
as
$statement
)
{
if
(
$statement
->
is_toplevel_property
(
'contextvariable'
))
{
$contextsession
[]
=
$statement
;
}
}
return
$contextsession
;
}
public
function
get_debuginfo
()
{
if
(
trim
(
$this
->
timeouterrmessage
)
!==
''
)
{
return
$this
->
timeouterrmessage
;
...
...
This diff is collapsed.
Click to expand it.
stack/input/inputbase.class.php
+
1
−
1
View file @
7fb7ca1d
...
...
@@ -52,7 +52,7 @@ abstract class stack_input {
protected
$name
;
/**
* Special variables in the question which should be exposed to the inputs.
* Special variables in the question which should be exposed to the inputs
and answer tests
.
* @var cas_evaluatable[]
*/
protected
$contextsession
=
array
();
...
...
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