Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Moodle Qtype Moopt
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 Moopt
Commits
c13218a8
Commit
c13218a8
authored
1 year ago
by
Isabel Uffinger
Browse files
Options
Downloads
Patches
Plain Diff
display exceptions from unzip_task_file
parent
dd6344a8
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
externallib.php
+2
-0
2 additions, 0 deletions
externallib.php
locallib.php
+7
-5
7 additions, 5 deletions
locallib.php
with
9 additions
and
5 deletions
externallib.php
+
2
−
0
View file @
c13218a8
...
...
@@ -85,6 +85,8 @@ class qtype_moopt_external extends external_api {
$unzipinfo
=
unzip_task_file_in_draft_area
(
$draftid
,
$usercontext
);
if
(
$unzipinfo
==
null
)
{
return
[
'error'
=>
'Error extracting zip file'
];
}
else
if
(
isset
(
$unzipinfo
[
'error'
]))
{
return
$unzipinfo
;
}
$taskxmlfilename
=
$unzipinfo
[
'xml'
];
$taskzipfilename
=
$unzipinfo
[
'zip'
]
??
null
;
...
...
This diff is collapsed.
Click to expand it.
locallib.php
+
7
−
5
View file @
c13218a8
...
...
@@ -122,6 +122,7 @@ use qtype_moopt\utility\proforma_xml\separate_feedback_handler;
/*
* Unzips the task zip file in the given draft area into the area
* moodle doesn't display thrown exceptions, so we handle them as array with key 'error' in calling function
*
* @param type $draftareaid
* @param type $usercontext
...
...
@@ -131,7 +132,6 @@ use qtype_moopt\utility\proforma_xml\separate_feedback_handler;
* 'xml' => (string) the name of the xml file (mandatory)
* ]
* Returns false, if there is no file in the given draft area.
* @throws invalid_parameter_exception
*/
function
unzip_task_file_in_draft_area
(
$draftareaid
,
$usercontext
)
{
global
$USER
;
...
...
@@ -143,8 +143,8 @@ function unzip_task_file_in_draft_area($draftareaid, $usercontext) {
if
(
$area
[
'filecount'
]
==
0
)
{
return
false
;
}
else
if
(
$area
[
'filecount'
]
>
1
||
$area
[
'foldercount'
]
!=
0
)
{
throw
new
invalid_parameter_exception
(
'Only one file is allowed to be in this draft area: A ProFormA-Task as either ZIP or XML file.'
);
$error
=
'Only one file is allowed to be in this draft area: A ProFormA-Task as either ZIP or XML file. Check for additional folders as well.'
;
return
array
(
'error'
=>
$error
);
}
// Get name of the file.
...
...
@@ -166,7 +166,8 @@ function unzip_task_file_in_draft_area($draftareaid, $usercontext) {
return
array
(
'xml'
=>
$filename
);
}
if
(
$filetype
!=
'zip'
)
{
throw
new
invalid_parameter_exception
(
'Supplied file must be a xml or zip file.'
);
$error
=
'Supplied file must be a xml or zip file.'
;
return
array
(
'error'
=>
$error
);
}
$zipfilename
=
$filename
;
$result
=
array
(
'zip'
=>
$zipfilename
);
...
...
@@ -217,7 +218,8 @@ function unzip_task_file_in_draft_area($draftareaid, $usercontext) {
}
if
(
!
array_key_exists
(
'xml'
,
$result
))
{
throw
new
invalid_parameter_exception
(
'Supplied zip file must contain the file task.xml.'
);
$error
=
'Supplied zip file must contain the file task.xml.'
;
return
array
(
'error'
=>
$error
);
}
return
$result
;
...
...
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