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
ae7870bd
Commit
ae7870bd
authored
7 years ago
by
Chris Sangwin
Browse files
Options
Downloads
Patches
Plain Diff
Add in checks to whether the YAML functions exist on your PHP server.
parent
18b86faf
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
api/api.php
+4
-0
4 additions, 0 deletions
api/api.php
exportone.php
+9
-3
9 additions, 3 deletions
exportone.php
lang/en/qtype_stack.php
+3
-0
3 additions, 0 deletions
lang/en/qtype_stack.php
questiontestrun.php
+7
-3
7 additions, 3 deletions
questiontestrun.php
with
23 additions
and
6 deletions
api/api.php
+
4
−
0
View file @
ae7870bd
...
@@ -18,6 +18,10 @@
...
@@ -18,6 +18,10 @@
* Minimal functionality needed to display and grade a question in a stateless way.
* Minimal functionality needed to display and grade a question in a stateless way.
*/
*/
if
(
!
function_exists
(
yaml_parse_file
()))
{
throw
new
Exception
(
"To make use of the STACK API you must have support for YAML."
);
}
require_once
(
"apilib.php"
);
require_once
(
"apilib.php"
);
require_once
(
__DIR__
.
'/../question.php'
);
require_once
(
__DIR__
.
'/../question.php'
);
...
...
This diff is collapsed.
Click to expand it.
exportone.php
+
9
−
3
View file @
ae7870bd
...
@@ -23,9 +23,11 @@
...
@@ -23,9 +23,11 @@
require_once
(
__DIR__
.
'/../../../config.php'
);
require_once
(
__DIR__
.
'/../../../config.php'
);
if
(
function_exists
(
'yaml_parse_file'
))
{
require_once
(
__DIR__
.
'/api/libs/yaml.php'
);
require_once
(
__DIR__
.
'/api/libs/yaml.php'
);
require_once
(
__DIR__
.
'/api/libs/yaml_defaults.php'
);
require_once
(
__DIR__
.
'/api/libs/yaml_defaults.php'
);
require_once
(
__DIR__
.
'/api/libs/export.php'
);
require_once
(
__DIR__
.
'/api/libs/export.php'
);
}
require_once
(
$CFG
->
libdir
.
'/questionlib.php'
);
require_once
(
$CFG
->
libdir
.
'/questionlib.php'
);
require_once
(
$CFG
->
dirroot
.
'/question/format/xml/format.php'
);
require_once
(
$CFG
->
dirroot
.
'/question/format/xml/format.php'
);
...
@@ -77,6 +79,10 @@ if ($exportformat == 'xml') {
...
@@ -77,6 +79,10 @@ if ($exportformat == 'xml') {
// Send the xml.
// Send the xml.
send_file
(
$content
,
$filename
,
0
,
0
,
true
,
true
,
$qformat
->
mime_type
());
send_file
(
$content
,
$filename
,
0
,
0
,
true
,
true
,
$qformat
->
mime_type
());
}
}
if
(
!
function_exists
(
'yaml_parse_file'
))
{
throw
new
stack_exception
(
"You must enable YAML support to export in YAML format."
);
}
// Add in the conversion to YAML.
// Add in the conversion to YAML.
$defaults
=
new
qtype_stack_api_yaml_defaults
(
null
);
$defaults
=
new
qtype_stack_api_yaml_defaults
(
null
);
// We take the _site_ defaults here, not the YAML defaults.
// We take the _site_ defaults here, not the YAML defaults.
...
...
This diff is collapsed.
Click to expand it.
lang/en/qtype_stack.php
+
3
−
0
View file @
ae7870bd
...
@@ -853,6 +853,9 @@ $string['stackDoc_404message'] = 'File not found.';
...
@@ -853,6 +853,9 @@ $string['stackDoc_404message'] = 'File not found.';
$string
[
'stackDoc_directoryStructure'
]
=
'Directory structure'
;
$string
[
'stackDoc_directoryStructure'
]
=
'Directory structure'
;
$string
[
'stackDoc_version'
]
=
'Your site is running STACK version {$a}.'
;
$string
[
'stackDoc_version'
]
=
'Your site is running STACK version {$a}.'
;
// API specific and YAML format.
$string
[
'noyaml'
]
=
'(YAML not supported on this server)'
;
// Fact sheets.
// Fact sheets.
$string
[
'greek_alphabet_name'
]
=
'The Greek Alphabet'
;
$string
[
'greek_alphabet_name'
]
=
'The Greek Alphabet'
;
...
...
This diff is collapsed.
Click to expand it.
questiontestrun.php
+
7
−
3
View file @
ae7870bd
...
@@ -417,11 +417,15 @@ echo html_writer::tag('p', html_writer::link($questionbanklink,
...
@@ -417,11 +417,15 @@ echo html_writer::tag('p', html_writer::link($questionbanklink,
stack_string
(
'seethisquestioninthequestionbank'
)));
stack_string
(
'seethisquestioninthequestionbank'
)));
if
(
$canedit
)
{
if
(
$canedit
)
{
$links
=
array
(
html_writer
::
link
(
$exportquestionlink
,
'XML'
));
if
(
function_exists
(
'yaml_parse_file'
))
{
$links
[]
=
html_writer
::
link
(
$yamlquestionlink
,
'YAML'
);
}
else
{
$links
[]
=
stack_string
(
'noyaml'
,
null
);
}
echo
html_writer
::
tag
(
'p'
,
echo
html_writer
::
tag
(
'p'
,
stack_string
(
'exportthisquestion'
)
.
' '
.
stack_string
(
'exportthisquestion'
)
.
' '
.
html_writer
::
link
(
$exportquestionlink
,
'XML'
)
.
' '
.
implode
(
$links
,
' '
)
.
' '
.
$OUTPUT
->
help_icon
(
'exportthisquestion'
,
'qtype_stack'
));
html_writer
::
link
(
$yamlquestionlink
,
'YAML'
)
.
$OUTPUT
->
help_icon
(
'exportthisquestion'
,
'qtype_stack'
));
}
}
echo
$renderquestion
;
echo
$renderquestion
;
...
...
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