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
4685a355
Commit
4685a355
authored
12 years ago
by
Tim Hunt
Browse files
Options
Downloads
Patches
Plain Diff
Proposed solution 2. Just rely on the CAS cache.
parent
e69abb7d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
question.php
+21
-11
21 additions, 11 deletions
question.php
renderer.php
+3
-3
3 additions, 3 deletions
renderer.php
replacedollars.php
+0
-18
0 additions, 18 deletions
replacedollars.php
with
24 additions
and
32 deletions
question.php
+
21
−
11
View file @
4685a355
...
@@ -117,6 +117,16 @@ class qtype_stack_question extends question_graded_automatically_with_countback
...
@@ -117,6 +117,16 @@ class qtype_stack_question extends question_graded_automatically_with_countback
*/
*/
protected
$questionnoteinstantiated
;
protected
$questionnoteinstantiated
;
/**
* @var array stack_cas_session STACK specific: session of variables.
*/
public
$questiontextinstantiated
;
/**
* @var array stack_cas_session STACK specific: session of variables.
*/
public
$specificfeedbackinstantiated
;
/**
/**
* The next three fields cache the results of some expensive computations.
* The next three fields cache the results of some expensive computations.
* The chache is only vaid for a particular response, so we store the current
* The chache is only vaid for a particular response, so we store the current
...
@@ -225,6 +235,13 @@ class qtype_stack_question extends question_graded_automatically_with_countback
...
@@ -225,6 +235,13 @@ class qtype_stack_question extends question_graded_automatically_with_countback
}
}
$step
->
set_qt_var
(
'_seed'
,
$this
->
seed
);
$step
->
set_qt_var
(
'_seed'
,
$this
->
seed
);
$this
->
initialise_question_from_seed
();
}
/**
* Once we know the random seed, we can initialise all the other parts of the question.
*/
public
function
initialise_question_from_seed
()
{
// Build up the question session out of all the bits that need to go into it.
// Build up the question session out of all the bits that need to go into it.
// 1. question variables.
// 1. question variables.
$questionvars
=
new
stack_cas_keyval
(
$this
->
questionvariables
,
$this
->
options
,
$this
->
seed
,
't'
);
$questionvars
=
new
stack_cas_keyval
(
$this
->
questionvariables
,
$this
->
options
,
$this
->
seed
,
't'
);
...
@@ -272,14 +289,10 @@ class qtype_stack_question extends question_graded_automatically_with_countback
...
@@ -272,14 +289,10 @@ class qtype_stack_question extends question_graded_automatically_with_countback
$session
->
get_errors
(
$this
->
user_can_edit
()));
$session
->
get_errors
(
$this
->
user_can_edit
()));
}
}
// Now store the values that depend on the instantiated session.
$step
->
set_qt_var
(
'_questionvars'
,
$session
->
get_keyval_representation
());
$step
->
set_qt_var
(
'_questiontext'
,
$questiontext
->
get_display_castext
());
$step
->
set_qt_var
(
'_feedback'
,
$feedbacktext
->
get_display_castext
());
$this
->
questionnoteinstantiated
=
$notetext
->
get_display_castext
();
$step
->
set_qt_var
(
'_questionnote'
,
$this
->
questionnoteinstantiated
);
// Finally, store only those values really needed for later.
// Finally, store only those values really needed for later.
$this
->
questiontextinstantiated
=
$questiontext
->
get_display_castext
();
$this
->
specificfeedbackinstantiated
=
$feedbacktext
->
get_display_castext
();
$this
->
questionnoteinstantiated
=
$notetext
->
get_display_castext
();
$session
->
prune_session
(
$session_length
);
$session
->
prune_session
(
$session_length
);
$this
->
session
=
$session
;
$this
->
session
=
$session
;
...
@@ -289,10 +302,7 @@ class qtype_stack_question extends question_graded_automatically_with_countback
...
@@ -289,10 +302,7 @@ class qtype_stack_question extends question_graded_automatically_with_countback
public
function
apply_attempt_state
(
question_attempt_step
$step
)
{
public
function
apply_attempt_state
(
question_attempt_step
$step
)
{
$this
->
seed
=
(
int
)
$step
->
get_qt_var
(
'_seed'
);
$this
->
seed
=
(
int
)
$step
->
get_qt_var
(
'_seed'
);
$questionvars
=
new
stack_cas_keyval
(
$step
->
get_qt_var
(
'_questionvars'
),
$this
->
options
,
$this
->
seed
,
't'
);
$this
->
initialise_question_from_seed
();
$this
->
session
=
$questionvars
->
get_session
();
$this
->
questionnoteinstantiated
=
$step
->
get_qt_var
(
'_questionnote'
);
$this
->
adapt_inputs
();
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
renderer.php
+
3
−
3
View file @
4685a355
...
@@ -37,7 +37,7 @@ class qtype_stack_renderer extends qtype_renderer {
...
@@ -37,7 +37,7 @@ class qtype_stack_renderer extends qtype_renderer {
$response
=
$qa
->
get_last_qt_data
();
$response
=
$qa
->
get_last_qt_data
();
$questiontext
=
$q
a
->
get_last_qt_var
(
'_questiontext'
)
;
$questiontext
=
$q
uestion
->
questiontextinstantiated
;
$questiontext
=
$question
->
format_text
(
$questiontext
=
$question
->
format_text
(
stack_maths
::
process_display_castext
(
$questiontext
),
stack_maths
::
process_display_castext
(
$questiontext
),
$question
->
questiontextformat
,
$question
->
questiontextformat
,
...
@@ -164,7 +164,7 @@ class qtype_stack_renderer extends qtype_renderer {
...
@@ -164,7 +164,7 @@ class qtype_stack_renderer extends qtype_renderer {
protected
function
stack_specific_feedback_errors_only
(
question_attempt
$qa
)
{
protected
function
stack_specific_feedback_errors_only
(
question_attempt
$qa
)
{
$question
=
$qa
->
get_question
();
$question
=
$qa
->
get_question
();
$response
=
$qa
->
get_last_qt_data
();
$response
=
$qa
->
get_last_qt_data
();
$feedbacktext
=
$q
a
->
get_last_qt_var
(
'_feedback'
)
;
$feedbacktext
=
$q
uestion
->
specificfeedbackinstantiated
;
if
(
!
$feedbacktext
)
{
if
(
!
$feedbacktext
)
{
return
''
;
return
''
;
}
}
...
@@ -204,7 +204,7 @@ class qtype_stack_renderer extends qtype_renderer {
...
@@ -204,7 +204,7 @@ class qtype_stack_renderer extends qtype_renderer {
$question
=
$qa
->
get_question
();
$question
=
$qa
->
get_question
();
$response
=
$qa
->
get_last_qt_data
();
$response
=
$qa
->
get_last_qt_data
();
$feedbacktext
=
$q
a
->
get_last_qt_var
(
'_feedback'
)
;
$feedbacktext
=
$q
uestion
->
specificfeedbackinstantiated
;
if
(
!
$feedbacktext
)
{
if
(
!
$feedbacktext
)
{
return
''
;
return
''
;
}
}
...
...
This diff is collapsed.
Click to expand it.
replacedollars.php
+
0
−
18
View file @
4685a355
...
@@ -50,7 +50,6 @@ $questionfields = array('questiontext', 'generalfeedback');
...
@@ -50,7 +50,6 @@ $questionfields = array('questiontext', 'generalfeedback');
$qtypestackfields
=
array
(
'specificfeedback'
,
'prtcorrect'
,
'prtpartiallycorrect'
,
'prtincorrect'
,
'questionnote'
);
$qtypestackfields
=
array
(
'specificfeedback'
,
'prtcorrect'
,
'prtpartiallycorrect'
,
'prtincorrect'
,
'questionnote'
);
$prtnodefields
=
array
(
'truefeedback'
,
'falsefeedback'
);
$prtnodefields
=
array
(
'truefeedback'
,
'falsefeedback'
);
$qafields
=
array
(
'questionsummary'
,
'rightanswer'
,
'responsesummary'
);
$qafields
=
array
(
'questionsummary'
,
'rightanswer'
,
'responsesummary'
);
$stepdatanames
=
"'_questiontext', '_feedback', '_questionnote'"
;
$anychanges
=
false
;
$anychanges
=
false
;
// Display.
// Display.
...
@@ -128,23 +127,6 @@ foreach ($categories as $key => $category) {
...
@@ -128,23 +127,6 @@ foreach ($categories as $key => $category) {
}
}
$anychanges
=
$anychanges
||
$changes
;
$anychanges
=
$anychanges
||
$changes
;
}
}
// Fields in the question_attempt_step_data table.
$attemptdata
=
$DB
->
get_records_sql
(
"
SELECT qasd.*
FROM
{
question_attempt_step_data
}
qasd
JOIN
{
question_attempt_steps
}
qas ON qasd.attemptstepid = qas.id
JOIN
{
question_attempts
}
qa ON qa.id = qas.questionattemptid
WHERE qa.questionid = :questionid
AND qasd.name IN (
{
$stepdatanames
}
)
"
,
array
(
'questionid'
=>
$question
->
id
));
foreach
(
$attemptdata
as
$data
)
{
$changes
=
$fixer
->
fix_question_field
(
$data
,
'value'
);
if
(
$changes
&&
$confirm
)
{
$DB
->
update_record
(
'question_attempt_step_data'
,
$data
);
}
$anychanges
=
$anychanges
||
$changes
;
}
}
}
}
}
...
...
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