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
5c4ae734
Commit
5c4ae734
authored
13 years ago
by
Tim Hunt
Browse files
Options
Downloads
Patches
Plain Diff
Handle deleting stack questions
... and moving them between contexts.
parent
2c14f1c5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
edit_stack_form.php
+10
-5
10 additions, 5 deletions
edit_stack_form.php
questiontype.php
+53
-0
53 additions, 0 deletions
questiontype.php
with
63 additions
and
5 deletions
edit_stack_form.php
+
10
−
5
View file @
5c4ae734
...
@@ -349,7 +349,7 @@ class qtype_stack_edit_form extends question_edit_form {
...
@@ -349,7 +349,7 @@ class qtype_stack_edit_form extends question_edit_form {
$question
->
{
$prtname
.
'testoptions'
}[
$nodename
]
=
$node
->
testoptions
;
$question
->
{
$prtname
.
'testoptions'
}[
$nodename
]
=
$node
->
testoptions
;
$question
->
{
$prtname
.
'quiet'
}[
$nodename
]
=
$node
->
quiet
;
$question
->
{
$prtname
.
'quiet'
}[
$nodename
]
=
$node
->
quiet
;
// 0 + bit is to
change strings like 1.0000000 from the DB to the nicer 1
.
// 0 + bit is to
eliminate excessive decimal places from the DB
.
$question
->
{
$prtname
.
'truescoremode'
}[
$nodename
]
=
$node
->
truescoremode
;
$question
->
{
$prtname
.
'truescoremode'
}[
$nodename
]
=
$node
->
truescoremode
;
$question
->
{
$prtname
.
'truescore'
}[
$nodename
]
=
0
+
$node
->
truescore
;
$question
->
{
$prtname
.
'truescore'
}[
$nodename
]
=
0
+
$node
->
truescore
;
$question
->
{
$prtname
.
'truepenalty'
}[
$nodename
]
=
0
+
$node
->
truepenalty
;
$question
->
{
$prtname
.
'truepenalty'
}[
$nodename
]
=
0
+
$node
->
truepenalty
;
...
@@ -357,7 +357,7 @@ class qtype_stack_edit_form extends question_edit_form {
...
@@ -357,7 +357,7 @@ class qtype_stack_edit_form extends question_edit_form {
$question
->
{
$prtname
.
'trueanswernote'
}[
$nodename
]
=
$node
->
trueanswernote
;
$question
->
{
$prtname
.
'trueanswernote'
}[
$nodename
]
=
$node
->
trueanswernote
;
$question
->
{
$prtname
.
'truefeedback'
}[
$nodename
]
=
$this
->
prepare_text_field
(
$question
->
{
$prtname
.
'truefeedback'
}[
$nodename
]
=
$this
->
prepare_text_field
(
$prtname
.
'truefeedback['
.
$nodename
.
']'
,
$node
->
truefeedback
,
$prtname
.
'truefeedback['
.
$nodename
.
']'
,
$node
->
truefeedback
,
$node
->
truefeedbackformat
,
$node
->
id
);
$node
->
truefeedbackformat
,
$node
->
id
,
'prtnodetruefeedback'
);
$question
->
{
$prtname
.
'falsescoremode'
}[
$nodename
]
=
$node
->
falsescoremode
;
$question
->
{
$prtname
.
'falsescoremode'
}[
$nodename
]
=
$node
->
falsescoremode
;
$question
->
{
$prtname
.
'falsescore'
}[
$nodename
]
=
0
+
$node
->
falsescore
;
$question
->
{
$prtname
.
'falsescore'
}[
$nodename
]
=
0
+
$node
->
falsescore
;
...
@@ -366,7 +366,7 @@ class qtype_stack_edit_form extends question_edit_form {
...
@@ -366,7 +366,7 @@ class qtype_stack_edit_form extends question_edit_form {
$question
->
{
$prtname
.
'falseanswernote'
}[
$nodename
]
=
$node
->
falseanswernote
;
$question
->
{
$prtname
.
'falseanswernote'
}[
$nodename
]
=
$node
->
falseanswernote
;
$question
->
{
$prtname
.
'falsefeedback'
}[
$nodename
]
=
$this
->
prepare_text_field
(
$question
->
{
$prtname
.
'falsefeedback'
}[
$nodename
]
=
$this
->
prepare_text_field
(
$prtname
.
'falsefeedback['
.
$nodename
.
']'
,
$node
->
falsefeedback
,
$prtname
.
'falsefeedback['
.
$nodename
.
']'
,
$node
->
falsefeedback
,
$node
->
falsefeedbackformat
,
$node
->
id
);
$node
->
falsefeedbackformat
,
$node
->
id
,
'prtnodefalsefeedback'
);
return
$question
;
return
$question
;
}
}
...
@@ -377,13 +377,18 @@ class qtype_stack_edit_form extends question_edit_form {
...
@@ -377,13 +377,18 @@ class qtype_stack_edit_form extends question_edit_form {
* @param string $text the raw text contents of this field.
* @param string $text the raw text contents of this field.
* @param int $format the text format (one of the FORMAT_... constants.)
* @param int $format the text format (one of the FORMAT_... constants.)
* @param int $itemid file area itemid.
* @param int $itemid file area itemid.
* @param string $filearea the file area name. Defaults to $field.
* @return array in the format needed by the form.
* @return array in the format needed by the form.
*/
*/
protected
function
prepare_text_field
(
$field
,
$text
,
$format
,
$itemid
)
{
protected
function
prepare_text_field
(
$field
,
$text
,
$format
,
$itemid
,
$filearea
=
''
)
{
if
(
$filearea
===
''
)
{
$filearea
=
$field
;
}
$data
=
array
();
$data
=
array
();
$data
[
'itemid'
]
=
file_get_submitted_draft_itemid
(
$field
);
$data
[
'itemid'
]
=
file_get_submitted_draft_itemid
(
$field
);
$data
[
'text'
]
=
file_prepare_draft_area
(
$data
[
'itemid'
],
$this
->
context
->
id
,
$data
[
'text'
]
=
file_prepare_draft_area
(
$data
[
'itemid'
],
$this
->
context
->
id
,
'qtype_stack'
,
$fi
eld
,
$itemid
,
$this
->
fileoptions
,
$text
);
'qtype_stack'
,
$fi
learea
,
$itemid
,
$this
->
fileoptions
,
$text
);
$data
[
'format'
]
=
$format
;
$data
[
'format'
]
=
$format
;
return
$data
;
return
$data
;
}
}
...
...
This diff is collapsed.
Click to expand it.
questiontype.php
+
53
−
0
View file @
5c4ae734
...
@@ -286,4 +286,57 @@ class qtype_stack extends question_type {
...
@@ -286,4 +286,57 @@ class qtype_stack extends question_type {
$feedbackvariables
->
get_session
(),
$nodes
);
$feedbackvariables
->
get_session
(),
$nodes
);
}
}
}
}
public
function
delete_question
(
$questionid
,
$contextid
)
{
global
$DB
;
$DB
->
delete_records
(
'qtype_stack_prt_nodes'
,
array
(
'questionid'
=>
$questionid
));
$DB
->
delete_records
(
'qtype_stack_prts'
,
array
(
'questionid'
=>
$questionid
));
$DB
->
delete_records
(
'qtype_stack_inputs'
,
array
(
'questionid'
=>
$questionid
));
$DB
->
delete_records
(
'qtype_stack'
,
array
(
'questionid'
=>
$questionid
));
parent
::
delete_question
(
$questionid
,
$contextid
);
}
public
function
move_files
(
$questionid
,
$oldcontextid
,
$newcontextid
)
{
global
$DB
;
$fs
=
get_file_storage
();
parent
::
move_files
(
$questionid
,
$oldcontextid
,
$newcontextid
);
$fs
->
move_area_files_to_new_context
(
$oldcontextid
,
$newcontextid
,
'qtype_stack'
,
'specificfeedback'
,
$questionid
);
$fs
->
move_area_files_to_new_context
(
$oldcontextid
,
$newcontextid
,
'qtype_stack'
,
'prtcorrect'
,
$questionid
);
$fs
->
move_area_files_to_new_context
(
$oldcontextid
,
$newcontextid
,
'qtype_stack'
,
'prtpartiallycorrect'
,
$questionid
);
$fs
->
move_area_files_to_new_context
(
$oldcontextid
,
$newcontextid
,
'qtype_stack'
,
'prtincorrect'
,
$questionid
);
$nodeids
=
$DB
->
get_records_menu
(
'qtype_stack_prt_nodes'
,
array
(
'questionid'
=>
$questionid
),
'id'
,
'id,1'
);
foreach
(
$nodeids
as
$nodeid
=>
$notused
)
{
$fs
->
move_area_files_to_new_context
(
$oldcontextid
,
$newcontextid
,
'qtype_stack'
,
'prtnodetruefeedback'
,
$nodeid
);
$fs
->
move_area_files_to_new_context
(
$oldcontextid
,
$newcontextid
,
'qtype_stack'
,
'prtnodefalsefeedback'
,
$nodeid
);
}
}
protected
function
delete_files
(
$questionid
,
$contextid
)
{
global
$DB
;
$fs
=
get_file_storage
();
parent
::
delete_files
(
$questionid
,
$contextid
);
$fs
->
delete_area_files
(
$contextid
,
'qtype_stack'
,
'specificfeedback'
,
$questionid
);
$fs
->
delete_area_files
(
$contextid
,
'qtype_stack'
,
'prtcorrect'
,
$questionid
);
$fs
->
delete_area_files
(
$contextid
,
'qtype_stack'
,
'prtpartiallycorrect'
,
$questionid
);
$fs
->
delete_area_files
(
$contextid
,
'qtype_stack'
,
'prtincorrect'
,
$questionid
);
$nodeids
=
$DB
->
get_records_menu
(
'qtype_stack_prt_nodes'
,
array
(
'questionid'
=>
$questionid
),
'id'
,
'id,1'
);
foreach
(
$nodeids
as
$nodeid
=>
$notused
)
{
$fs
->
delete_area_files
(
$oldcontextid
,
$newcontextid
,
'qtype_stack'
,
'prtnodetruefeedback'
,
$nodeid
);
$fs
->
delete_area_files
(
$oldcontextid
,
$newcontextid
,
'qtype_stack'
,
'prtnodefalsefeedback'
,
$nodeid
);
}
}
}
}
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