Gitlab CSE Unil
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
M. Chardon
moodle-assignfeedback_editpdfplus
Commits
dcff1e14
Commit
dcff1e14
authored
Jun 17, 2019
by
M. Chardon
Browse files
- modèle/favoris d'axes
- suppression facilité des axes
parent
0d967ff5
Changes
21
Expand all
Hide whitespace changes
Inline
Side-by-side
amd/build/admin_panel.min.js
View file @
dcff1e14
This diff is collapsed.
Click to expand it.
amd/src/admin_panel.js
View file @
dcff1e14
This diff is collapsed.
Click to expand it.
classes/admin_editor.php
View file @
dcff1e14
...
...
@@ -38,6 +38,8 @@ class admin_editor {
const
BDDTABLETOOL
=
"assignfeedback_editpp_tool"
;
const
BDDTABLEAXE
=
"assignfeedback_editpp_axis"
;
const
BDDTABLETOOLTYPE
=
"assignfeedback_editpp_typet"
;
const
BDDTABLEMODELAXIS
=
"assignfeedback_editpp_modax"
;
const
BDDTABLEANNOT
=
"assignfeedback_editpp_annot"
;
const
CONTEXTIDLIB
=
"contextid"
;
/**
...
...
@@ -190,7 +192,6 @@ class admin_editor {
$DB
->
update_record
(
self
::
BDDTABLETOOL
,
$tool
);
$lastTool
=
$tool
;
}
//$decalage++;
}
else
{
$lastTool
=
$tool
;
}
...
...
@@ -223,6 +224,15 @@ class admin_editor {
*/
public
static
function
del_axis
(
$axeid
)
{
global
$DB
;
$res
=
true
;
//delete all related tools if possible
$tools
=
self
::
get_tools_by_axis
(
$axeid
);
foreach
(
$tools
as
$tool
)
{
$res
&=
self
::
del_tool
(
$tool
);
}
if
(
!
$res
)
{
return
false
;
}
return
$DB
->
delete_records
(
self
::
BDDTABLEAXE
,
array
(
'id'
=>
$axeid
));
}
...
...
@@ -234,6 +244,11 @@ class admin_editor {
*/
public
static
function
del_tool
(
$tool
)
{
global
$DB
;
//check if this tool is used
$nbAnnotations
=
self
::
getNbAnnotationsForTool
(
$tool
->
toolid
);
if
(
$nbAnnotations
>
0
)
{
return
false
;
}
return
$DB
->
delete_records
(
self
::
BDDTABLETOOL
,
array
(
'id'
=>
$tool
->
toolid
));
}
...
...
@@ -309,6 +324,17 @@ class admin_editor {
return
null
;
}
/**
* Get number of annotations related to this tool
* @global $DB
* @param int $toolid
* @return int number of annotations
*/
public
static
function
getNbAnnotationsForTool
(
$toolid
)
{
global
$DB
;
return
$DB
->
count_records
(
self
::
BDDTABLEANNOT
,
array
(
'toolid'
=>
$toolid
));
}
/**
* Get all the type tools which are configurabled.
* @return array<\assignfeedback_editpdfplus\bdd\type_tool> array of type tools
...
...
@@ -393,4 +419,65 @@ class admin_editor {
return
$DB
->
insert_record
(
self
::
BDDTABLETOOL
,
$tool
);
}
/**
* get model axis for a given user
* @global $DB
* @param $user moodle user
* @return array set of model axis
*/
public
static
function
getCategoryModel
(
$user
)
{
global
$DB
;
return
$DB
->
get_records
(
self
::
BDDTABLEMODELAXIS
,
array
(
'user'
=>
$user
));
}
/**
* Add a new model on database
* @global $DB
* @param int $axeid axe's id
* @param string $label label for the new model
* @param USER $user moodle user
* @return int id of the new model
*/
public
static
function
addModel
(
$axeid
,
$label
,
$user
)
{
global
$DB
;
$model
=
new
\
stdClass
();
$model
->
axis
=
$axeid
;
$model
->
label
=
$label
;
$model
->
user
=
$user
->
id
;
return
$DB
->
insert_record
(
self
::
BDDTABLEMODELAXIS
,
$model
);
}
/**
* get a model with from its id
* @global $DB
* @param int $modelid model's id
* @return record model record
*/
public
static
function
gelModel
(
$modelid
)
{
global
$DB
;
return
$DB
->
get_record
(
self
::
BDDTABLEMODELAXIS
,
array
(
'id'
=>
$modelid
),
'*'
,
MUST_EXIST
);
}
/**
* delete a given model
* @global $DB
* @param int $modelid id of the model to delete
* @return boolean true if the delete is success
*/
public
static
function
delModel
(
$modelid
)
{
global
$DB
;
$model
=
self
::
gelModel
(
$modelid
);
if
(
!
$model
)
{
return
false
;
}
$axe
=
self
::
getAxisById
(
$model
->
axis
);
if
(
!
$axe
)
{
return
false
;
}
if
(
!
self
::
del_axis
(
$axe
->
id
))
{
return
false
;
}
return
$DB
->
delete_records
(
self
::
BDDTABLEMODELAXIS
,
array
(
'id'
=>
$modelid
));
}
}
classes/form/axis_del_form.php
View file @
dcff1e14
...
...
@@ -37,15 +37,8 @@ class axis_del_form extends moodleform {
protected
function
definition
()
{
$mform
=
$this
->
_form
;
$mform
->
addElement
(
self
::
HIDDENSTATE
,
'label'
,
''
);
// Add elements to your form
$mform
->
setType
(
self
::
HIDDENSTATE
,
PARAM_TEXT
);
//Set type of element
$mform
->
addElement
(
self
::
HIDDENSTATE
,
'axeid'
,
''
);
// Add elements to your form
$mform
->
setType
(
self
::
HIDDENSTATE
,
PARAM_INT
);
//Set type of element
}
//Custom validation should be added here
function
validation
(
$data
,
$files
)
{
return
array
();
$mform
->
addElement
(
self
::
HIDDENSTATE
,
'axeid'
);
// Add elements to your form
$mform
->
setType
(
'axeid'
,
PARAM_INT
);
//Set type of element
}
}
classes/form/axis_export_form.php
0 → 100644
View file @
dcff1e14
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains the axis_export_form class for the assignfeedback_editpdfplus plugin
*
* Form to export an axis
*
* @package assignfeedback_editpdfplus
* @copyright 2019 Université de Lausanne
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
assignfeedback_editpdfplus\form
;
require_once
(
"
$CFG->libdir
/formslib.php"
);
use
moodleform
;
/**
* Form to export an axis
*
* @package mod_audioannotation
* @copyright 2019 Université de Lausanne
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
axis_export_form
extends
moodleform
{
const
HIDDENTYPE
=
"hidden"
;
protected
function
definition
()
{
$mform
=
$this
->
_form
;
$mform
->
_formName
=
"axis_export_form"
;
$mform
->
addElement
(
'text'
,
'label'
,
get_string
(
'adminaxisimport_name'
,
'assignfeedback_editpdfplus'
));
// Add elements to your form
$mform
->
setType
(
'label'
,
PARAM_TEXT
);
//Set type of element
$mform
->
addRule
(
'label'
,
null
,
'required'
,
null
,
'client'
);
// Hidden params.
$mform
->
addElement
(
'hidden'
,
'contextid'
);
$mform
->
setType
(
'contextid'
,
PARAM_INT
);
$mform
->
addElement
(
'hidden'
,
'axeid'
);
$mform
->
setType
(
'axeid'
,
PARAM_INT
);
$mform
->
addElement
(
'hidden'
,
'action'
,
'savetagexport'
);
$mform
->
setType
(
'action'
,
PARAM_ALPHA
);
}
}
classes/form/model_del_form.php
0 → 100644
View file @
dcff1e14
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains the model_del_form class for the assignfeedback_editpdfplus plugin
*
* Form to delete a model
*
* @package assignfeedback_editpdfplus
* @copyright 2019 Université de Lausanne
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
assignfeedback_editpdfplus\form
;
require_once
(
"
$CFG->libdir
/formslib.php"
);
use
moodleform
;
/**
* Form to delete a model
*
* @package assignfeedback_editpdfplus
* @copyright 2019 Université de Lausanne
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
model_del_form
extends
moodleform
{
protected
function
definition
()
{
$mform
=
$this
->
_form
;
$mform
->
_formName
=
"model_del_form"
;
// Hidden params.
$mform
->
addElement
(
'hidden'
,
'contextid'
);
$mform
->
setType
(
'contextid'
,
PARAM_INT
);
$mform
->
addElement
(
'hidden'
,
'modelid'
);
$mform
->
setType
(
'modelid'
,
PARAM_INT
);
$mform
->
addElement
(
'hidden'
,
'action'
,
'delmodel'
);
$mform
->
setType
(
'action'
,
PARAM_ALPHA
);
}
}
classes/page_editor.php
View file @
dcff1e14
...
...
@@ -41,6 +41,7 @@ class page_editor {
const
BDDTABLEOOL
=
"assignfeedback_editpp_tool"
;
const
BDDTABLETOOLTYPE
=
"assignfeedback_editpp_typet"
;
const
BDDTABLEANNOTATION
=
"assignfeedback_editpp_annot"
;
const
BDDTABLEAXIS
=
"assignfeedback_editpp_axis"
;
const
CONTEXTID
=
"contextid"
;
const
GRADEID
=
"gradeid"
;
const
DRAFLIB
=
"draft"
;
...
...
@@ -88,6 +89,43 @@ class page_editor {
return
$tools
;
}
/**
* Get all tools for a given axis.
* @param int $axisid
* @return tool[]
*/
public
static
function
get_tools_by_axis
(
$axisid
)
{
global
$DB
;
$typeToolsRaw
=
self
::
get_typetools
(
null
);
$typeTools
=
array
();
foreach
(
$typeToolsRaw
as
$typeTool
)
{
$typeTools
[
$typeTool
->
id
]
=
$typeTool
;
}
$tools
=
array
();
$records
=
$DB
->
get_records
(
self
::
BDDTABLEOOL
,
array
(
'axis'
=>
$axisid
));
foreach
(
$records
as
$record
)
{
$tooltmp
=
null
;
if
(
$record
->
axis
==
self
::
AXISGENERIC
)
{
$tooltmp
=
new
tool_generic
(
$record
);
}
else
{
$tooltmp
=
new
tool
(
$record
);
}
$tooltmp
->
typeObject
=
$typeTools
[
$tooltmp
->
type
];
array_push
(
$tools
,
$tooltmp
);
}
usort
(
$tools
,
function
(
$a
,
$b
)
{
$al
=
$a
->
order_tool
;
$bl
=
$b
->
order_tool
;
if
(
$al
==
$bl
)
{
return
0
;
}
return
(
$al
>
$bl
)
?
+
1
:
-
1
;
});
return
$tools
;
}
/**
* Get a single tool by id.
* @param int $toolid
...
...
@@ -167,6 +205,20 @@ class page_editor {
return
$axis
;
}
/**
* Get an axis given by its id.
* @param int $axisid
* @return axis
*/
public
static
function
get_axis_by_id
(
$axisid
)
{
global
$DB
;
$record
=
$DB
->
get_record
(
self
::
BDDTABLEAXIS
,
array
(
'id'
=>
$axisid
),
'*'
,
IGNORE_MISSING
);
if
(
$record
)
{
return
new
axis
(
$record
);
}
return
null
;
}
/**
* Get all annotations for a page.
* @param int $gradeid
...
...
classes/renderer.php
View file @
dcff1e14
...
...
@@ -335,12 +335,12 @@ class assignfeedback_editpdfplus_renderer extends plugin_renderer_base {
}
/**
* Display axis form (
delete
)
* @param
moodleform $form
* Display axis form (
export
)
* @param
stdClass $widget
* @return String
*/
public
function
render_assignfeedback_editpdfplus_widget_admin_axis
delform
(
moodleform
$form
)
{
return
$this
->
render_from_template
(
'assignfeedback_editpdfplus/axis_
del
_form'
,
$
form
);
public
function
render_assignfeedback_editpdfplus_widget_admin_axis
exportform
(
$widget
)
{
return
$this
->
render_from_template
(
'assignfeedback_editpdfplus/axis_
export
_form'
,
$
widget
);
}
/**
...
...
db/install.xml
View file @
dcff1e14
...
...
@@ -109,6 +109,21 @@
<KEY
NAME=
"contextid"
TYPE=
"foreign"
FIELDS=
"contextid"
REFTABLE=
"context"
REFFIELDS=
"id"
/>
</KEYS>
</TABLE>
<TABLE
NAME=
"assignfeedback_editpp_modax"
COMMENT=
"Model of axis"
>
<FIELDS>
<FIELD
NAME=
"id"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
UNSIGNED=
"true"
SEQUENCE=
"true"
/>
<FIELD
NAME=
"user"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
UNSIGNED=
"true"
SEQUENCE=
"false"
COMMENT=
"Model s user"
/>
<FIELD
NAME=
"axis"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
SEQUENCE=
"false"
/>
<FIELD
NAME=
"label"
TYPE=
"text"
LENGTH=
"100"
NOTNULL=
"false"
COMMENT=
""
/>
</FIELDS>
<KEYS>
<KEY
NAME=
"primary"
TYPE=
"primary"
FIELDS=
"id"
/>
<KEY
NAME=
"axis"
TYPE=
"foreign"
FIELDS=
"axis"
REFTABLE=
"editpdfpp_axis"
REFFIELDS=
"id"
/>
</KEYS>
<INDEXES>
<INDEX
NAME=
"useraxis"
UNIQUE=
"false"
FIELDS=
"user, axis"
/>
</INDEXES>
</TABLE>
<TABLE
NAME=
"assignfeedback_editpp_rot"
COMMENT=
"Stores rotation information of a page."
>
<FIELDS>
<FIELD
NAME=
"id"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
SEQUENCE=
"true"
/>
...
...
db/services.php
View file @
dcff1e14
...
...
@@ -89,6 +89,28 @@ $functions = array(
'enabled'
=>
1
,
'services'
=>
array
(
MOODLE_OFFICIAL_MOBILE_SERVICE
)
),
'assignfeedback_editpdfplus_submit_axis_export_form'
=>
array
(
'classname'
=>
'assignfeedback_editpdfplus_external'
,
'methodname'
=>
'submit_axis_export_form'
,
'classpath'
=>
'mod/assign/feedback/editpdfplus/externallib.php'
,
'description'
=>
'Export an axis with its tools'
,
'type'
=>
'write'
,
'ajax'
=>
true
,
'requiredcapability'
=>
'assignfeedback/editpdfplus:managetools'
,
'enabled'
=>
1
,
'services'
=>
array
(
MOODLE_OFFICIAL_MOBILE_SERVICE
)
),
'assignfeedback_editpdfplus_submit_model_del_form'
=>
array
(
'classname'
=>
'assignfeedback_editpdfplus_external'
,
'methodname'
=>
'submit_model_del_form'
,
'classpath'
=>
'mod/assign/feedback/editpdfplus/externallib.php'
,
'description'
=>
'Remove a model'
,
'type'
=>
'write'
,
'ajax'
=>
true
,
'requiredcapability'
=>
'assignfeedback/editpdfplus:managetools'
,
'enabled'
=>
1
,
'services'
=>
array
(
MOODLE_OFFICIAL_MOBILE_SERVICE
)
),
'assignfeedback_editpdfplus_submit_axis_import_form'
=>
array
(
'classname'
=>
'assignfeedback_editpdfplus_external'
,
'methodname'
=>
'submit_axis_import_form'
,
...
...
db/upgrade.php
View file @
dcff1e14
...
...
@@ -341,10 +341,34 @@ function xmldb_assignfeedback_editpdfplus_upgrade($oldversion) {
if
(
!
$dbman
->
field_exists
(
$table
,
$field
))
{
$dbman
->
add_field
(
$table
,
$field
);
}
// Editpdfplus savepoint reached.
upgrade_plugin_savepoint
(
true
,
2019053100
,
'assignfeedback'
,
'editpdfplus'
);
}
if
(
$oldversion
<
2019061201
)
{
/* model annotation table */
$table
=
new
xmldb_table
(
'assignfeedback_editpp_modax'
);
$table
->
add_field
(
'id'
,
XMLDB_TYPE_INTEGER
,
'10'
,
null
,
XMLDB_NOTNULL
,
XMLDB_SEQUENCE
,
null
);
$table
->
add_field
(
'user'
,
XMLDB_TYPE_INTEGER
,
'10'
,
null
,
XMLDB_NOTNULL
,
null
,
'0'
);
$table
->
add_field
(
'axis'
,
XMLDB_TYPE_INTEGER
,
'10'
,
null
,
XMLDB_NOTNULL
,
null
,
'0'
);
$table
->
add_field
(
'label'
,
XMLDB_TYPE_TEXT
,
null
,
null
,
null
,
null
,
null
);
// Adding keys to table assignfeedback_editpp_modax.
$table
->
add_key
(
'primary'
,
XMLDB_KEY_PRIMARY
,
[
'id'
]);
$table
->
add_key
(
'axis'
,
XMLDB_KEY_FOREIGN
,
[
'axis'
],
'editpdfpp_axis'
,
[
'id'
]);
// Adding indexes to table assignfeedback_editpp_modax.
$table
->
add_index
(
'useraxis'
,
XMLDB_INDEX_UNIQUE
,
[
'user'
,
'axis'
]);
// Conditionally launch create table for assignfeedback_editpp_modax.
if
(
!
$dbman
->
table_exists
(
$table
))
{
$dbman
->
create_table
(
$table
);
}
// Editpdfplus savepoint reached.
upgrade_plugin_savepoint
(
true
,
2019061201
,
'assignfeedback'
,
'editpdfplus'
);
}
return
true
;
}
externallib.php
View file @
dcff1e14
...
...
@@ -33,6 +33,8 @@ require_once("locallib_admin.php");
use
\
assignfeedback_editpdfplus\form\axis_form
;
use
\
assignfeedback_editpdfplus\form\axis_del_form
;
use
\
assignfeedback_editpdfplus\form\axis_import_form
;
use
\
assignfeedback_editpdfplus\form\axis_export_form
;
use
\
assignfeedback_editpdfplus\form\model_del_form
;
use
\
assignfeedback_editpdfplus\admin_editor
;
class
assignfeedback_editpdfplus_external
extends
external_api
{
...
...
@@ -89,15 +91,15 @@ class assignfeedback_editpdfplus_external extends external_api {
public
static
function
submit_tool_form_returns
()
{
return
new
external_multiple_structure
(
new
external_single_structure
(
array
(
self
::
AXEID
=>
new
external_value
(
PARAM_INT
,
self
::
AXEIDDESC
),
self
::
TOOLSELECTED
=>
new
external_value
(
PARAM_INT
,
self
::
TOOLIDDESC
),
self
::
ENABLETOOL
=>
new
external_value
(
PARAM_INT
,
self
::
ENABLETOOLDESC
,
VALUE_OPTIONAL
),
self
::
TOOLID
=>
new
external_value
(
PARAM_INT
,
self
::
TOOLIDDESC
),
self
::
TOOLTYPE
=>
new
external_value
(
PARAM_INT
,
self
::
TOOLTYPEDESC
,
VALUE_OPTIONAL
),
self
::
BOUTONLIBTOOL
=>
new
external_value
(
PARAM_TEXT
,
self
::
TOOLLIBDESC
,
VALUE_OPTIONAL
),
self
::
MESSAGELIB
=>
new
external_value
(
PARAM_TEXT
,
self
::
MESSAGELIB
,
VALUE_OPTIONAL
)
)
array
(
self
::
AXEID
=>
new
external_value
(
PARAM_INT
,
self
::
AXEIDDESC
),
self
::
TOOLSELECTED
=>
new
external_value
(
PARAM_INT
,
self
::
TOOLIDDESC
),
self
::
ENABLETOOL
=>
new
external_value
(
PARAM_INT
,
self
::
ENABLETOOLDESC
,
VALUE_OPTIONAL
),
self
::
TOOLID
=>
new
external_value
(
PARAM_INT
,
self
::
TOOLIDDESC
),
self
::
TOOLTYPE
=>
new
external_value
(
PARAM_INT
,
self
::
TOOLTYPEDESC
,
VALUE_OPTIONAL
),
self
::
BOUTONLIBTOOL
=>
new
external_value
(
PARAM_TEXT
,
self
::
TOOLLIBDESC
,
VALUE_OPTIONAL
),
self
::
MESSAGELIB
=>
new
external_value
(
PARAM_TEXT
,
self
::
MESSAGELIB
,
VALUE_OPTIONAL
)
)
)
);
}
...
...
@@ -180,11 +182,11 @@ class assignfeedback_editpdfplus_external extends external_api {
public
static
function
submit_axis_form_returns
()
{
return
new
external_multiple_structure
(
new
external_single_structure
(
array
(
self
::
AXEID
=>
new
external_value
(
PARAM_INT
,
self
::
AXEIDDESC
),
self
::
AXELIB
=>
new
external_value
(
PARAM_TEXT
,
self
::
AXELIBDESC
),
self
::
MESSAGELIB
=>
new
external_value
(
PARAM_TEXT
,
self
::
MESSAGELIB
,
VALUE_OPTIONAL
)
)
array
(
self
::
AXEID
=>
new
external_value
(
PARAM_INT
,
self
::
AXEIDDESC
),
self
::
AXELIB
=>
new
external_value
(
PARAM_TEXT
,
self
::
AXELIBDESC
),
self
::
MESSAGELIB
=>
new
external_value
(
PARAM_TEXT
,
self
::
MESSAGELIB
,
VALUE_OPTIONAL
)
)
)
);
}
...
...
@@ -421,19 +423,142 @@ class assignfeedback_editpdfplus_external extends external_api {
public
static
function
submit_axis_import_form_returns
()
{
return
new
external_multiple_structure
(
new
external_single_structure
(
array
(
self
::
AXEID
=>
new
external_value
(
PARAM_INT
,
self
::
AXEIDDESC
,
VALUE_OPTIONAL
),
self
::
AXELIB
=>
new
external_value
(
PARAM_TEXT
,
self
::
AXELIBDESC
,
VALUE_OPTIONAL
),
self
::
MESSAGELIB
=>
new
external_value
(
PARAM_TEXT
,
self
::
MESSAGELIB
),
self
::
ENABLETOOL
=>
new
external_value
(
PARAM_INT
,
self
::
ENABLETOOLDESC
,
VALUE_OPTIONAL
),
self
::
TOOLID
=>
new
external_value
(
PARAM_INT
,
self
::
TOOLIDDESC
,
VALUE_OPTIONAL
),
self
::
TOOLTYPE
=>
new
external_value
(
PARAM_INT
,
self
::
TOOLTYPEDESC
,
VALUE_OPTIONAL
),
self
::
BOUTONLIBTOOL
=>
new
external_value
(
PARAM_TEXT
,
self
::
TOOLLIBDESC
,
VALUE_OPTIONAL
)
array
(
self
::
AXEID
=>
new
external_value
(
PARAM_INT
,
self
::
AXEIDDESC
,
VALUE_OPTIONAL
),
self
::
AXELIB
=>
new
external_value
(
PARAM_TEXT
,
self
::
AXELIBDESC
,
VALUE_OPTIONAL
),
self
::
MESSAGELIB
=>
new
external_value
(
PARAM_TEXT
,
self
::
MESSAGELIB
),
self
::
ENABLETOOL
=>
new
external_value
(
PARAM_INT
,
self
::
ENABLETOOLDESC
,
VALUE_OPTIONAL
),
self
::
TOOLID
=>
new
external_value
(
PARAM_INT
,
self
::
TOOLIDDESC
,
VALUE_OPTIONAL
),
self
::
TOOLTYPE
=>
new
external_value
(
PARAM_INT
,
self
::
TOOLTYPEDESC
,
VALUE_OPTIONAL
),
self
::
BOUTONLIBTOOL
=>
new
external_value
(
PARAM_TEXT
,
self
::
TOOLLIBDESC
,
VALUE_OPTIONAL
)
)
)
);
}
/**
* Returns description of method parameters
* @return external_function_parameters
*/
public
static
function
submit_axis_export_form_parameters
()
{
return
self
::
submit_generic_form_parameters
();
}
/**
* Submit axis form for exporting
* @param String $jsonformdata
* @return array
*/
public
static
function
submit_axis_export_form
(
$jsonformdata
)
{
global
$USER
;
$data
=
self
::
getParseData
(
self
::
submit_axis_export_form_parameters
(),
$jsonformdata
);
$context
=
self
::
setPageContext
(
$data
[
self
::
CONTEXTID
]);
$customdata
=
(
object
)
$data
;
$formparams
=
array
(
$customdata
);
// Data is injected into the form by the last param for the constructor.
$mform
=
new
axis_export_form
(
null
,
$formparams
,
'post'
,
''
,
null
,
true
,
$data
);
$validateddata
=
$mform
->
get_data
();
if
(
$validateddata
&&
$validateddata
->
axeid
)
{
$axeToExport
=
admin_editor
::
getAxisById
(
$validateddata
->
axeid
);
$axeToExport
->
label
=
$validateddata
->
label
;
$axeNew
=
admin_editor
::
import_axis
(
$axeToExport
,
-
1
);
if
(
$axeNew
)
{
$tools
=
admin_editor
::
get_tools_by_axis
(
$axeToExport
->
id
);
foreach
(
$tools
as
$toolToImport
)
{
admin_editor
::
import_tool
(
$toolToImport
,
$axeNew
,
$context
->
id
);
}
$model
=
admin_editor
::
addModel
(
$axeNew
,
$validateddata
->
label
,
$USER
);
if
(
$model
>
-
1
)
{
$res
=
array
();
$toolsNew
=
admin_editor
::
get_tools_by_axis
(
$axeNew
);
if
(
sizeof
(
$toolsNew
)
>
0
)
{
foreach
(
$toolsNew
as
$tool
)
{
$tool
->
setDesign
();
$res
[]
=
array
(
'modelid'
=>
$model
,
self
::
AXEID
=>
$axeNew
,
self
::
AXELIB
=>
$validateddata
->
label
,
self
::
MESSAGELIB
=>
""
,
self
::
ENABLETOOL
=>
$tool
->
enabled
,
self
::
TOOLID
=>
$tool
->
id
,
self
::
TOOLTYPE
=>
$tool
->
type
,
self
::
BOUTONLIBTOOL
=>
$tool
->
label
,
'style'
=>
$tool
->
style
);
}
}
else
{
$res
=
array
(
array
(
'modelid'
=>
$model
,
self
::
AXEID
=>
$axeNew
,
self
::
AXELIB
=>
$validateddata
->
label
,
self
::
MESSAGELIB
=>
""
));
}
return
$res
;
}
}
}
return
array
(
self
::
getMessageError
());
}
/**
* Form return structure
* @return \external_multiple_structure
*/
public
static
function
submit_axis_export_form_returns
()
{
return
new
external_multiple_structure
(
new
external_single_structure
(
array
(
'modelid'
=>
new
external_value
(
PARAM_INT
,
self
::
AXEIDDESC
,
VALUE_OPTIONAL
),
self
::
AXEID
=>
new
external_value
(
PARAM_INT
,
self
::
AXEIDDESC
,
VALUE_OPTIONAL
),
self
::
AXELIB
=>
new
external_value
(
PARAM_TEXT
,
self
::
AXELIBDESC
,
VALUE_OPTIONAL
),
self
::
MESSAGELIB
=>
new
external_value
(
PARAM_TEXT
,
self
::
MESSAGELIB
),
self
::
ENABLETOOL
=>
new
external_value
(
PARAM_INT
,
self
::
ENABLETOOLDESC
,
VALUE_OPTIONAL
),
self
::
TOOLID
=>
new
external_value
(
PARAM_INT
,
self
::
TOOLIDDESC
,
VALUE_OPTIONAL
),
self
::
TOOLTYPE
=>
new
external_value
(
PARAM_INT
,
self
::
TOOLTYPEDESC
,
VALUE_OPTIONAL
),
self
::
BOUTONLIBTOOL
=>
new
external_value
(
PARAM_TEXT
,
self
::
TOOLLIBDESC
,
VALUE_OPTIONAL
),
'style'
=>
new
external_value
(
PARAM_TEXT
,
self
::
TOOLLIBDESC
,
VALUE_OPTIONAL
)
)
)
);
}
/**
* Returns description of method parameters
* @return external_function_parameters
*/