Gitlab CSE Unil

Commit 1ffa90b3 authored by M. Chardon's avatar M. Chardon
Browse files

noettoyage et optimisation code avec sonarqube

parent a0f7790a
...@@ -33,6 +33,10 @@ require_once($CFG->dirroot . '/mod/assign/locallib.php'); ...@@ -33,6 +33,10 @@ require_once($CFG->dirroot . '/mod/assign/locallib.php');
require_sesskey(); require_sesskey();
const PLUGIN_NAME = "assignfeedback_editpdfplus";
const PERMISSION_ASSIGN_GRADE = "mod/assign:grade";
const PERMISSION_ASSIGN_SUBMIT = "mod/assign:submit";
$action = optional_param('action', '', PARAM_ALPHANUM); $action = optional_param('action', '', PARAM_ALPHANUM);
$assignmentid = required_param('assignmentid', PARAM_INT); $assignmentid = required_param('assignmentid', PARAM_INT);
$userid = required_param('userid', PARAM_INT); $userid = required_param('userid', PARAM_INT);
...@@ -52,11 +56,11 @@ if (!$assignment->can_view_submission($userid)) { ...@@ -52,11 +56,11 @@ if (!$assignment->can_view_submission($userid)) {
if ($action === 'pollconversions') { if ($action === 'pollconversions') {
$draft = true; $draft = true;
if (!has_capability('mod/assign:grade', $context)) { if (!has_capability(PERMISSION_ASSIGN_GRADE, $context)) {
// A student always sees the readonly version. // A student always sees the readonly version.
$readonly = true; $readonly = true;
$draft = false; $draft = false;
require_capability('mod/assign:submit', $context); require_capability(PERMISSION_ASSIGN_SUBMIT, $context);
} }
if ($readonly) { if ($readonly) {
...@@ -96,7 +100,7 @@ if ($action === 'pollconversions') { ...@@ -96,7 +100,7 @@ if ($action === 'pollconversions') {
$index = count($response->pages); $index = count($response->pages);
$page = new stdClass(); $page = new stdClass();
//$comments = page_editor::get_comments($grade->id, $index, $draft); //$comments = page_editor::get_comments($grade->id, $index, $draft);
$page->url = moodle_url::make_pluginfile_url($context->id, 'assignfeedback_editpdfplus', $filearea, $grade->id, '/', $pagefile->get_filename())->out(); $page->url = moodle_url::make_pluginfile_url($context->id, PLUGIN_NAME, $filearea, $grade->id, '/', $pagefile->get_filename())->out();
//$page->comments = $comments; //$page->comments = $comments;
if ($imageinfo = $pagefile->get_imageinfo()) { if ($imageinfo = $pagefile->get_imageinfo()) {
$page->width = $imageinfo['width']; $page->width = $imageinfo['width'];
...@@ -109,7 +113,7 @@ if ($action === 'pollconversions') { ...@@ -109,7 +113,7 @@ if ($action === 'pollconversions') {
$page->annotations = $annotations; $page->annotations = $annotations;
$response->pages[] = $page; $response->pages[] = $page;
$component = 'assignfeedback_editpdfplus'; $component = PLUGIN_NAME;
$filearea = document_services::PAGE_IMAGE_FILEAREA; $filearea = document_services::PAGE_IMAGE_FILEAREA;
$filepath = '/'; $filepath = '/';
$fs = get_file_storage(); $fs = get_file_storage();
...@@ -128,7 +132,7 @@ if ($action === 'pollconversions') { ...@@ -128,7 +132,7 @@ if ($action === 'pollconversions') {
echo json_encode($response); echo json_encode($response);
die(); die();
} else if ($action == 'savepage') { } else if ($action == 'savepage') {
require_capability('mod/assign:grade', $context); require_capability(PERMISSION_ASSIGN_GRADE, $context);
$response = new stdClass(); $response = new stdClass();
$response->errors = array(); $response->errors = array();
...@@ -141,19 +145,18 @@ if ($action === 'pollconversions') { ...@@ -141,19 +145,18 @@ if ($action === 'pollconversions') {
$added = page_editor::set_annotations($grade->id, $index, $page->annotations); $added = page_editor::set_annotations($grade->id, $index, $page->annotations);
if ($added != count($page->annotations)) { if ($added != count($page->annotations)) {
array_push($response->errors, get_string('couldnotsavepage', 'assignfeedback_editpdfplus', $index + 1)); array_push($response->errors, get_string('couldnotsavepage', PLUGIN_NAME, $index + 1));
} }
echo json_encode($response); echo json_encode($response);
die(); die();
} else if ($action == 'generatepdf') { } else if ($action == 'generatepdf') {
$refresh = optional_param('refresh', false, PARAM_BOOL); $refresh = optional_param('refresh', false, PARAM_BOOL);
if (!$refresh) { if (!$refresh) {
require_capability('mod/assign:grade', $context); require_capability(PERMISSION_ASSIGN_GRADE, $context);
} else { } else {
require_capability('mod/assign:submit', $context); require_capability(PERMISSION_ASSIGN_SUBMIT, $context);
} }
$response = new stdClass(); $response = new stdClass();
$grade = $assignment->get_user_grade($userid, true, $attemptnumber); $grade = $assignment->get_user_grade($userid, true, $attemptnumber);
...@@ -161,7 +164,7 @@ if ($action === 'pollconversions') { ...@@ -161,7 +164,7 @@ if ($action === 'pollconversions') {
$response->url = ''; $response->url = '';
if ($file) { if ($file) {
$url = moodle_url::make_pluginfile_url($assignment->get_context()->id, 'assignfeedback_editpdfplus', document_services::FINAL_PDF_FILEAREA, $grade->id, '/', $file->get_filename(), false); $url = moodle_url::make_pluginfile_url($assignment->get_context()->id, PLUGIN_NAME, document_services::FINAL_PDF_FILEAREA, $grade->id, '/', $file->get_filename(), false);
$response->url = $url->out(true); $response->url = $url->out(true);
$response->filename = $file->get_filename(); $response->filename = $file->get_filename();
} }
...@@ -198,7 +201,7 @@ if ($action === 'pollconversions') { ...@@ -198,7 +201,7 @@ if ($action === 'pollconversions') {
. "<p>La correction du devoir a été mise à jour. Vous pouvez accéder au document en suivant ce <a href='" . "<p>La correction du devoir a été mise à jour. Vous pouvez accéder au document en suivant ce <a href='"
. $response->url . $response->url
. "'>lien</a></p>" . "'>lien</a></p>"
. "<i>Ceci est un mail automatique.</i>"; . "<i>Ceci est un mail automatique, merci de ne pas y répondre.</i>";
foreach ($teachers as $teacher) { foreach ($teachers as $teacher) {
$res = email_to_user($teacher, $USER, "[Moodle] Mise à jour devoir", $body, $bodyhtml); $res = email_to_user($teacher, $USER, "[Moodle] Mise à jour devoir", $body, $bodyhtml);
} }
...@@ -207,7 +210,7 @@ if ($action === 'pollconversions') { ...@@ -207,7 +210,7 @@ if ($action === 'pollconversions') {
echo json_encode($response); echo json_encode($response);
die(); die();
} else if ($action == 'revertchanges') { } else if ($action == 'revertchanges') {
require_capability('mod/assign:grade', $context); require_capability(PERMISSION_ASSIGN_GRADE, $context);
$grade = $assignment->get_user_grade($userid, true, $attemptnumber); $grade = $assignment->get_user_grade($userid, true, $attemptnumber);
...@@ -216,7 +219,7 @@ if ($action === 'pollconversions') { ...@@ -216,7 +219,7 @@ if ($action === 'pollconversions') {
echo json_encode($result); echo json_encode($result);
die(); die();
} else if ($action == 'deletefeedbackdocument') { } else if ($action == 'deletefeedbackdocument') {
require_capability('mod/assign:grade', $context); require_capability(PERMISSION_ASSIGN_GRADE, $context);
$grade = $assignment->get_user_grade($userid, true, $attemptnumber); $grade = $assignment->get_user_grade($userid, true, $attemptnumber);
$result = document_services::delete_feedback_document($assignment, $userid, $attemptnumber); $result = document_services::delete_feedback_document($assignment, $userid, $attemptnumber);
...@@ -225,7 +228,7 @@ if ($action === 'pollconversions') { ...@@ -225,7 +228,7 @@ if ($action === 'pollconversions') {
echo json_encode($result); echo json_encode($result);
die(); die();
} else if ($action == 'updatestudentview') { } else if ($action == 'updatestudentview') {
require_capability('mod/assign:submit', $context); require_capability(PERMISSION_ASSIGN_SUBMIT, $context);
$response = new stdClass(); $response = new stdClass();
$response->errors = array(); $response->errors = array();
...@@ -238,7 +241,7 @@ if ($action === 'pollconversions') { ...@@ -238,7 +241,7 @@ if ($action === 'pollconversions') {
$added = page_editor::update_annotations_status($page->annotations); $added = page_editor::update_annotations_status($page->annotations);
if ($added != count($page->annotations)) { if ($added != count($page->annotations)) {
array_push($response->errors, get_string('couldnotsavepage', 'assignfeedback_editpdfplus', $index + 1)); array_push($response->errors, get_string('couldnotsavepage', PLUGIN_NAME, $index + 1));
} }
echo json_encode($response); echo json_encode($response);
die(); die();
......
...@@ -35,6 +35,8 @@ defined('MOODLE_INTERNAL') || die(); ...@@ -35,6 +35,8 @@ defined('MOODLE_INTERNAL') || die();
*/ */
class backup_assignfeedback_editpdfplus_subplugin extends backup_subplugin { class backup_assignfeedback_editpdfplus_subplugin extends backup_subplugin {
const GRADEID = 'gradeid';
/** /**
* Returns the subplugin information to attach to feedback element * Returns the subplugin information to attach to feedback element
* @return backup_subplugin_element * @return backup_subplugin_element
...@@ -44,10 +46,10 @@ class backup_assignfeedback_editpdfplus_subplugin extends backup_subplugin { ...@@ -44,10 +46,10 @@ class backup_assignfeedback_editpdfplus_subplugin extends backup_subplugin {
// Create XML elements. // Create XML elements.
$subplugin = $this->get_subplugin_element(); $subplugin = $this->get_subplugin_element();
$subpluginwrapper = new backup_nested_element($this->get_recommended_name()); $subpluginwrapper = new backup_nested_element($this->get_recommended_name());
$subpluginelementfiles = new backup_nested_element('feedback_editpdfplus_files', null, array('gradeid')); $subpluginelementfiles = new backup_nested_element('feedback_editpdfplus_files', null, array(self::GRADEID));
$subpluginelementannotations = new backup_nested_element('feedback_editpdfplus_annotations'); $subpluginelementannotations = new backup_nested_element('feedback_editpdfplus_annotations');
$subpluginelementannotation = new backup_nested_element( $subpluginelementannotation = new backup_nested_element(
'feedback_editpdfplus_annotation', null, array('gradeid', 'pageno', 'x', 'y', 'endx', 'endy', 'cartridgex', 'cartridgey', 'path', 'toolid', 'textannot', 'colour', 'draft', 'answerrequested', 'studentanswer', 'studentstatus', 'displaylock', 'displayrotation', 'borderstyle', 'parent_annot') 'feedback_editpdfplus_annotation', null, array(self::GRADEID, 'pageno', 'x', 'y', 'endx', 'endy', 'cartridgex', 'cartridgey', 'path', 'toolid', 'textannot', 'colour', 'draft', 'answerrequested', 'studentanswer', 'studentstatus', 'displaylock', 'displayrotation', 'borderstyle', 'parent_annot')
); );
// Connect XML elements into the tree. // Connect XML elements into the tree.
...@@ -57,12 +59,12 @@ class backup_assignfeedback_editpdfplus_subplugin extends backup_subplugin { ...@@ -57,12 +59,12 @@ class backup_assignfeedback_editpdfplus_subplugin extends backup_subplugin {
$subpluginwrapper->add_child($subpluginelementannotations); $subpluginwrapper->add_child($subpluginelementannotations);
// Set source to populate the data. // Set source to populate the data.
$subpluginelementfiles->set_source_sql('SELECT id AS gradeid from {assign_grades} where id = :gradeid', array('gradeid' => backup::VAR_PARENTID)); $subpluginelementfiles->set_source_sql('SELECT id AS gradeid from {assign_grades} where id = :' . self::GRADEID, array(self::GRADEID => backup::VAR_PARENTID));
$subpluginelementannotation->set_source_table('assignfeedback_editpp_annot', array('gradeid' => backup::VAR_PARENTID)); $subpluginelementannotation->set_source_table('assignfeedback_editpp_annot', array(self::GRADEID => backup::VAR_PARENTID));
// We only need to backup the files in the final pdf area, and the readonly page images - the others can be regenerated. // We only need to backup the files in the final pdf area, and the readonly page images - the others can be regenerated.
$subpluginelementfiles->annotate_files('assignfeedback_editpdfplus', \assignfeedback_editpdfplus\document_services::FINAL_PDF_FILEAREA, 'gradeid'); $subpluginelementfiles->annotate_files('assignfeedback_editpdfplus', \assignfeedback_editpdfplus\document_services::FINAL_PDF_FILEAREA, self::GRADEID);
$subpluginelementfiles->annotate_files('assignfeedback_editpdfplus', \assignfeedback_editpdfplus\document_services::PAGE_IMAGE_READONLY_FILEAREA, 'gradeid'); $subpluginelementfiles->annotate_files('assignfeedback_editpdfplus', \assignfeedback_editpdfplus\document_services::PAGE_IMAGE_READONLY_FILEAREA, self::GRADEID);
return $subplugin; return $subplugin;
} }
} }
...@@ -36,6 +36,8 @@ defined('MOODLE_INTERNAL') || die(); ...@@ -36,6 +36,8 @@ defined('MOODLE_INTERNAL') || die();
*/ */
class restore_assignfeedback_editpdfplus_subplugin extends restore_subplugin { class restore_assignfeedback_editpdfplus_subplugin extends restore_subplugin {
const GRADE = 'grade';
/** /**
* Returns the paths to be handled by the subplugin at assignment level * Returns the paths to be handled by the subplugin at assignment level
* @return array * @return array
...@@ -66,8 +68,8 @@ class restore_assignfeedback_editpdfplus_subplugin extends restore_subplugin { ...@@ -66,8 +68,8 @@ class restore_assignfeedback_editpdfplus_subplugin extends restore_subplugin {
$data = (object) $data; $data = (object) $data;
// In this case the id is the old gradeid which will be mapped. // In this case the id is the old gradeid which will be mapped.
$this->add_related_files('assignfeedback_editpdfplus', \assignfeedback_editpdfplus\document_services::FINAL_PDF_FILEAREA, 'grade', null, $data->gradeid); $this->add_related_files('assignfeedback_editpdfplus', \assignfeedback_editpdfplus\document_services::FINAL_PDF_FILEAREA, self::GRADE, null, $data->gradeid);
$this->add_related_files('assignfeedback_editpdfplus', \assignfeedback_editpdfplus\document_services::PAGE_IMAGE_READONLY_FILEAREA, 'grade', null, $data->gradeid); $this->add_related_files('assignfeedback_editpdfplus', \assignfeedback_editpdfplus\document_services::PAGE_IMAGE_READONLY_FILEAREA, self::GRADE, null, $data->gradeid);
} }
/** /**
...@@ -81,7 +83,7 @@ class restore_assignfeedback_editpdfplus_subplugin extends restore_subplugin { ...@@ -81,7 +83,7 @@ class restore_assignfeedback_editpdfplus_subplugin extends restore_subplugin {
$oldgradeid = $data->gradeid; $oldgradeid = $data->gradeid;
// The mapping is set in the restore for the core assign activity // The mapping is set in the restore for the core assign activity
// when a grade node is processed. // when a grade node is processed.
$data->gradeid = $this->get_mappingid('grade', $data->gradeid); $data->gradeid = $this->get_mappingid(self::GRADE, $data->gradeid);
$DB->insert_record('assignfeedback_editpp_annot', $data); $DB->insert_record('assignfeedback_editpp_annot', $data);
} }
......
...@@ -188,7 +188,6 @@ class combined_document { ...@@ -188,7 +188,6 @@ class combined_document {
switch ($status) { switch ($status) {
case \core_files\conversion::STATUS_COMPLETE: case \core_files\conversion::STATUS_COMPLETE:
continue; continue;
break;
default: default:
$converter->poll_conversion($conversion); $converter->poll_conversion($conversion);
} }
......
...@@ -37,48 +37,123 @@ use \assignfeedback_editpdfplus\admin_editor; ...@@ -37,48 +37,123 @@ use \assignfeedback_editpdfplus\admin_editor;
class assignfeedback_editpdfplus_external extends external_api { class assignfeedback_editpdfplus_external extends external_api {
const PLUGINNAME = "assignfeedback_editpdfplus";
const DATAJSON = 'jsonformdata';
const MESSAGELIB = 'message';
const COURSELIB = "course";
const COURSEID = "courseid";
const AXEID = "axeid";
const AXEIDDESC = "Axe ID";
const AXELIB = "axelabel";
const AXELIBDESC = "Axe label";
const TOOLID = "toolid";
const TOOLIDDESC = "Tool ID";
const TOOLLIBDESC = "Tool label";
const TOOLTYPE = "typetool";
const TOOLTYPEDESC = "Type of tool";
const TOOLSELECTED = "selecttool";
const BOUTONLIBTOOL = "button";
const ENABLETOOL = "enable";
const ENABLETOOLDESC = "Tool is enabled";
/** /**
* Returns description of method parameters * Returns description of method parameters for general calling
* @return external_function_parameters * @return \external_function_parameters
*/ */
public static function submit_axis_form_parameters() { public static function submit_generic_form_parameters() {
$message = 'The data from the grading form, encoded as a json array';
return new external_function_parameters( return new external_function_parameters(
array( array(
'jsonformdata' => new external_value(PARAM_RAW, 'The data from the grading form, encoded as a json array') self::DATAJSON => new external_value(PARAM_RAW, $message)
) )
); );
} }
/** /**
* Submit axis form for adding or edditing *
* @global $USER * Form return generic structure
* @global $PAGE * @return \external_single_structure
* @global $DB
* @param String $jsonformdata
* @return array
*/ */
public static function submit_axis_form($jsonformdata) { public static function submit_generic_form_returns() {
global $USER, $PAGE, $DB; return new external_single_structure(
array(
self::MESSAGELIB => new external_value(PARAM_TEXT, self::MESSAGELIB, VALUE_OPTIONAL)
)
);
}
$params = self::validate_parameters(self::submit_axis_form_parameters(), array( /**
'jsonformdata' => $jsonformdata * Form return tool structure
)); * @return \external_multiple_structure
*/
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)
)
)
);
}
$serialiseddata = json_decode($params['jsonformdata']); /**
* Returns description of method parameters
* @return external_function_parameters
*/
public static function submit_axis_form_parameters() {
return self::submit_generic_form_parameters();
}
/**
* Extract and parse json data string into an array
* @param external_function_parameters $externalFunctionParameter
* @param String $jsonformdata
* @return array decoded data
*/
public static function getParseData($externalFunctionParameter, $jsonformdata) {
$params = self::validate_parameters($externalFunctionParameter, array(
self::DATAJSON => $jsonformdata
));
$serialiseddata = json_decode($params[self::DATAJSON]);
$data = array(); $data = array();
parse_str($serialiseddata, $data); parse_str($serialiseddata, $data);
return $data;
}
$warnings = array(); /**
* Set Page context from the course id given. It returns the context found.
if (WS_SERVER) { * @global $DB
// Assume form submission if coming from WS. * @global $PAGE
$USER->ignoresesskey = true; * @param int $courseid Current course id
} * @return context course's context
*/
$course = $DB->get_record('course', array('id' => $data['courseid']), '*', MUST_EXIST); public static function setPageContext($courseid) {
global $DB, $PAGE;
$course = $DB->get_record(self::COURSELIB, array('id' => $courseid), '*', MUST_EXIST);
$context = context_course::instance($course->id, MUST_EXIST); $context = context_course::instance($course->id, MUST_EXIST);
$PAGE->set_context($context); $PAGE->set_context($context);
return $context;
}
public static function getMessageError() {
return array(self::MESSAGELIB => get_string("admin_messageko", self::PLUGINNAME));
}
/**
* Submit axis form for adding or edditing
* @param String $jsonformdata
* @return array
*/
public static function submit_axis_form($jsonformdata) {
$data = self::getParseData(self::submit_axis_form_parameters(), $jsonformdata);
$context = self::setPageContext($data[self::COURSEID]);
$customdata = (object) $data; $customdata = (object) $data;
$formparams = array($customdata); $formparams = array($customdata);
...@@ -91,16 +166,12 @@ class assignfeedback_editpdfplus_external extends external_api { ...@@ -91,16 +166,12 @@ class assignfeedback_editpdfplus_external extends external_api {
if ($validateddata->axeid) { if ($validateddata->axeid) {
admin_editor::edit_axis($validateddata->axeid, $validateddata->label); admin_editor::edit_axis($validateddata->axeid, $validateddata->label);
$axeid = $validateddata->axeid; $axeid = $validateddata->axeid;
return array(array('axeid' => $axeid, 'axelabel' => $validateddata->label));
} else { } else {
$axeid = admin_editor::add_axis($validateddata->label, $context->id); $axeid = admin_editor::add_axis($validateddata->label, $context->id);
return array(array('axeid' => $axeid, 'axelabel' => $validateddata->label));
} }
} else { return array(array(self::AXEID => $axeid, self::AXELIB => $validateddata->label));
$warnings[] = array('message' => get_string('admin_messageko', 'assignfeedback_editpdfplus'));
} }
return array(self::getMessageError());
return $warnings;
} }
/** /**
...@@ -111,9 +182,9 @@ class assignfeedback_editpdfplus_external extends external_api { ...@@ -111,9 +182,9 @@ class assignfeedback_editpdfplus_external extends external_api {
return new external_multiple_structure( return new external_multiple_structure(
new external_single_structure( new external_single_structure(
array( array(
'axeid' => new external_value(PARAM_INT, 'axis id'), self::AXEID => new external_value(PARAM_INT, self::AXEIDDESC),
'axelabel' => new external_value(PARAM_TEXT, 'axis label'), self::AXELIB => new external_value(PARAM_TEXT, self::AXELIBDESC),
'message' => new external_value(PARAM_TEXT, 'message', VALUE_OPTIONAL) self::MESSAGELIB => new external_value(PARAM_TEXT, self::MESSAGELIB, VALUE_OPTIONAL)
) )
) )
); );
...@@ -124,41 +195,18 @@ class assignfeedback_editpdfplus_external extends external_api { ...@@ -124,41 +195,18 @@ class assignfeedback_editpdfplus_external extends external_api {
* @return external_function_parameters * @return external_function_parameters
*/ */
public static function submit_axis_del_form_parameters() { public static function submit_axis_del_form_parameters() {
return new external_function_parameters( return self::submit_generic_form_parameters();
array(
'jsonformdata' => new external_value(PARAM_RAW, 'The data from the grading form, encoded as a json array')
)
);
} }
/** /**
* Submit axis form for deleting * Submit axis form for deleting
* @global $USER
* @global $PAGE
* @global $DB
* @param String $jsonformdata * @param String $jsonformdata
* @return array * @return array
*/ */
public static function submit_axis_del_form($jsonformdata) { public static function submit_axis_del_form($jsonformdata) {
global $USER, $PAGE, $DB; $data = self::getParseData(self::submit_axis_form_parameters(), $jsonformdata);
$params = self::validate_parameters(self::submit_axis_form_parameters(), array(
'jsonformdata' => $jsonformdata
));
$serialiseddata = json_decode($params['jsonformdata']);
$data = array();
parse_str($serialiseddata, $data);
$warnings = array();
if (WS_SERVER) { self::setPageContext($data[self::COURSEID]);
// Assume form submission if coming from WS.
$USER->ignoresesskey = true;
}
$course = $DB->get_record('course', array('id' => $data['courseid']), '*', MUST_EXIST);
$context = context_course::instance($course->id, MUST_EXIST);
$PAGE->set_context($context);
$customdata = (object) $data; $customdata = (object) $data;
$formparams = array($customdata); $formparams = array($customdata);
...@@ -167,17 +215,13 @@ class assignfeedback_editpdfplus_external extends external_api { ...@@ -167,17 +215,13 @@ class assignfeedback_editpdfplus_external extends external_api {
$mform = new axis_del_form(null, $formparams, 'post', '', null, true, $data); $mform = new axis_del_form(null, $formparams, 'post', '', null, true, $data);
$validateddata = $mform->get_data(); $validateddata = $mform->get_data();
if ($validateddata) { if ($validateddata && $validateddata->axeid && admin_editor::del_axis($validateddata->axeid)) {
if ($validateddata->axeid && admin_editor::del_axis($validateddata->axeid)) { $message = "1";
$message = "1"; return array(array(self::MESSAGELIB => $message));
return array(array('message' => $message));
}
} else {
$message = get_string('admindeltool_messageko', 'assignfeedback_editpdfplus');
$warnings[] = array('message' => $message);
} }
$warnings = array();
$message = get_string('admindeltool_messageko', self::PLUGINNAME);
$warnings[] = array(self::MESSAGELIB => $message);
return $warnings; return $warnings;
} }
...@@ -187,78 +231,58 @@ class assignfeedback_editpdfplus_external extends external_api { ...@@ -187,78 +231,58 @@ class assignfeedback_editpdfplus_external extends external_api {
*/ */
public static function submit_axis_del_form_returns() { public static function submit_axis_del_form_returns() {
return new external_multiple_structure( return new external_multiple_structure(
new external_single_structure( self::submit_generic_form_returns()
array(
'message' => new external_value(PARAM_TEXT, 'message', VALUE_OPTIONAL)
)
)
); );
} }
/**