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
1f7956e8
"code/eval/queries/cypher/ongdb/cypher_queries.py" did not exist on "b36847bd8ea36ab21cb768dfcca99ccbcf4cb41a"
Commit
1f7956e8
authored
7 years ago
by
Chris Sangwin
Browse files
Options
Downloads
Patches
Plain Diff
Add in functionality to the main codebase to export as YAML.
parent
07a32308
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
api/api.php
+1
-1
1 addition, 1 deletion
api/api.php
exportone.php
+23
-1
23 additions, 1 deletion
exportone.php
questiontestrun.php
+12
-1
12 additions, 1 deletion
questiontestrun.php
with
36 additions
and
3 deletions
api/api.php
+
1
−
1
View file @
1f7956e8
This diff is collapsed.
Click to expand it.
exportone.php
+
23
−
1
View file @
1f7956e8
...
...
@@ -23,6 +23,10 @@
require_once
(
__DIR__
.
'/../../../config.php'
);
require_once
(
__DIR__
.
'/api/libs/yaml.php'
);
require_once
(
__DIR__
.
'/api/libs/yaml_defaults.php'
);
require_once
(
__DIR__
.
'/api/libs/export.php'
);
require_once
(
$CFG
->
libdir
.
'/questionlib.php'
);
require_once
(
$CFG
->
dirroot
.
'/question/format/xml/format.php'
);
require_once
(
__DIR__
.
'/locallib.php'
);
...
...
@@ -30,6 +34,7 @@ require_once(__DIR__ . '/locallib.php');
// Get the parameters from the URL.
$questionid
=
required_param
(
'questionid'
,
PARAM_INT
);
$exportformat
=
required_param
(
'exportformat'
,
PARAM_TEXT
);
// Load the necessary data.
$questiondata
=
$DB
->
get_record
(
'question'
,
array
(
'id'
=>
$questionid
),
'*'
,
MUST_EXIST
);
...
...
@@ -67,4 +72,21 @@ if (!$qformat->exportpreprocess()) {
if
(
!
$content
=
$qformat
->
exportprocess
(
true
))
{
send_file_not_found
();
}
if
(
$exportformat
==
'xml'
)
{
// Send the xml.
send_file
(
$content
,
$filename
,
0
,
0
,
true
,
true
,
$qformat
->
mime_type
());
}
// Now add in the conversion to YAML.
$defaults
=
new
qtype_stack_api_yaml_defaults
(
null
);
$export
=
new
qtype_stack_api_export
(
$content
,
$defaults
);
$yaml_string
=
$export
->
YAML
();
$rows
=
substr_count
(
$yaml_string
,
"
\n
"
)
+
3
;
echo
"<form method = 'post' action = 'exportone.php'>"
;
echo
"<textarea name = 'yaml' cols = '200' rows = '
$rows
'>"
;
echo
$yaml_string
;
echo
"</textarea>
\n
"
;
echo
"</form>
\n\n
"
;
This diff is collapsed.
Click to expand it.
questiontestrun.php
+
12
−
1
View file @
1f7956e8
...
...
@@ -69,9 +69,18 @@ $qbankparams['lastchanged'] = $question->id;
if
(
$questiondata
->
hidden
)
{
$qbankparams
[
'showhidden'
]
=
1
;
}
// Create some other useful links.
$yamlparams
=
$urlparams
;
$yamlparams
[
'exportformat'
]
=
'yaml'
;
$urlparams
[
'exportformat'
]
=
'xml'
;
$questionbanklink
=
new
moodle_url
(
'/question/edit.php'
,
$qbankparams
);
$exportquestionlink
=
new
moodle_url
(
'/question/type/stack/exportone.php'
,
$urlparams
);
$exportquestionlink
->
param
(
'sesskey'
,
sesskey
());
$yamlquestionlink
=
new
moodle_url
(
'/question/type/stack/exportone.php'
,
$yamlparams
);
$yamlquestionlink
->
param
(
'sesskey'
,
sesskey
());
// Create the question usage we will use.
$quba
=
question_engine
::
make_questions_usage_by_activity
(
'qtype_stack'
,
$context
);
...
...
@@ -402,7 +411,9 @@ echo html_writer::tag('p', html_writer::link($questionbanklink,
if
(
$canedit
)
{
echo
html_writer
::
tag
(
'p'
,
html_writer
::
link
(
$exportquestionlink
,
stack_string
(
'exportthisquestion'
))
.
stack_string
(
'exportthisquestion'
)
.
' '
.
html_writer
::
link
(
$exportquestionlink
,
'XML'
)
.
' '
.
html_writer
::
link
(
$yamlquestionlink
,
'YAML'
)
.
$OUTPUT
->
help_icon
(
'exportthisquestion'
,
'qtype_stack'
));
}
...
...
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