MDL-31861 add web service function save_definitions

This commit is contained in:
Paul Charsley 2014-06-13 15:36:25 +12:00
parent 337075d17b
commit 0ff4ebb4a3
5 changed files with 505 additions and 21 deletions

View file

@ -205,7 +205,7 @@ class gradingform_guide_controller extends gradingform_controller {
} else {
$newcomment = $newdefinition->guide['comments']; // New ones to be saved.
}
$currentcomments = $currentdefinition->guide_comment;
$currentcomments = $currentdefinition->guide_comments;
$commentfields = array('sortorder', 'description');
foreach ($newcomment as $id => $comment) {
if (preg_match('/^NEWID\d+$/', $id)) {
@ -309,7 +309,7 @@ class gradingform_guide_controller extends gradingform_controller {
$this->definition = $definition;
// Now get criteria.
$this->definition->guide_criteria = array();
$this->definition->guide_comment = array();
$this->definition->guide_comments = array();
$criteria = $DB->get_recordset('gradingform_guide_criteria', array('definitionid' => $this->definition->id), 'sortorder');
foreach ($criteria as $criterion) {
foreach (array('id', 'sortorder', 'description', 'descriptionformat',
@ -327,7 +327,7 @@ class gradingform_guide_controller extends gradingform_controller {
$comments = $DB->get_recordset('gradingform_guide_comments', array('definitionid' => $this->definition->id), 'sortorder');
foreach ($comments as $comment) {
foreach (array('id', 'sortorder', 'description', 'descriptionformat') as $fieldname) {
$this->definition->guide_comment[$comment->id][$fieldname] = $comment->{$fieldname};
$this->definition->guide_comments[$comment->id][$fieldname] = $comment->{$fieldname};
}
}
$comments->close();
@ -404,8 +404,8 @@ class gradingform_guide_controller extends gradingform_controller {
} else if (!$definition && $addemptycriterion) {
$properties->guide['criteria'] = array('addcriterion' => 1);
}
if (!empty($definition->guide_comment)) {
$properties->guide['comments'] = $definition->guide_comment;
if (!empty($definition->guide_comments)) {
$properties->guide['comments'] = $definition->guide_comments;
} else if (!$definition && $addemptycriterion) {
$properties->guide['comments'] = array('addcomment' => 1);
}
@ -508,7 +508,7 @@ class gradingform_guide_controller extends gradingform_controller {
}
$criteria = $this->definition->guide_criteria;
$comments = $this->definition->guide_comment;
$comments = $this->definition->guide_comments;
$output = $this->get_renderer($page);
$guide = '';
@ -652,7 +652,7 @@ class gradingform_guide_controller extends gradingform_controller {
/**
* @return array An array containing 2 key/value pairs which hold the external_multiple_structure
* for the 'guide_criteria' and the 'guide_comment'.
* for the 'guide_criteria' and the 'guide_comments'.
* @see gradingform_controller::get_external_definition_details()
* @since Moodle 2.5
*/
@ -660,8 +660,8 @@ class gradingform_guide_controller extends gradingform_controller {
$guide_criteria = new external_multiple_structure(
new external_single_structure(
array(
'id' => new external_value(PARAM_INT, 'criterion id'),
'sortorder' => new external_value(PARAM_INT, 'sortorder'),
'id' => new external_value(PARAM_INT, 'criterion id', VALUE_OPTIONAL),
'sortorder' => new external_value(PARAM_INT, 'sortorder', VALUE_OPTIONAL),
'description' => new external_value(PARAM_RAW, 'description', VALUE_OPTIONAL),
'descriptionformat' => new external_format_value('description', VALUE_OPTIONAL),
'shortname' => new external_value(PARAM_TEXT, 'description'),
@ -671,17 +671,17 @@ class gradingform_guide_controller extends gradingform_controller {
)
)
);
$guide_comment = new external_multiple_structure(
$guide_comments = new external_multiple_structure(
new external_single_structure(
array(
'id' => new external_value(PARAM_INT, 'criterion id'),
'sortorder' => new external_value(PARAM_INT, 'sortorder'),
'id' => new external_value(PARAM_INT, 'criterion id', VALUE_OPTIONAL),
'sortorder' => new external_value(PARAM_INT, 'sortorder', VALUE_OPTIONAL),
'description' => new external_value(PARAM_RAW, 'description', VALUE_OPTIONAL),
'descriptionformat' => new external_format_value('description', VALUE_OPTIONAL)
)
), 'comments', VALUE_OPTIONAL
);
return array('guide_criteria' => $guide_criteria, 'guide_comment' => $guide_comment);
return array('guide_criteria' => $guide_criteria, 'guide_comments' => $guide_comments);
}
/**
@ -895,7 +895,7 @@ class gradingform_guide_instance extends gradingform_instance {
}
}
$criteria = $this->get_controller()->get_definition()->guide_criteria;
$comments = $this->get_controller()->get_definition()->guide_comment;
$comments = $this->get_controller()->get_definition()->guide_comments;
$options = $this->get_controller()->get_options();
$value = $gradingformelement->getValue();
$html = '';

View file

@ -668,15 +668,15 @@ class gradingform_rubric_controller extends gradingform_controller {
$rubric_criteria = new external_multiple_structure(
new external_single_structure(
array(
'id' => new external_value(PARAM_INT, 'criterion id'),
'sortorder' => new external_value(PARAM_INT, 'sortorder'),
'id' => new external_value(PARAM_INT, 'criterion id', VALUE_OPTIONAL),
'sortorder' => new external_value(PARAM_INT, 'sortorder', VALUE_OPTIONAL),
'description' => new external_value(PARAM_RAW, 'description', VALUE_OPTIONAL),
'descriptionformat' => new external_format_value('description', VALUE_OPTIONAL),
'levels' => new external_multiple_structure(
new external_single_structure(
array(
'id' => new external_value(PARAM_INT, 'level id'),
'score' => new external_value(PARAM_FLOAT, 'score'),
'id' => new external_value(PARAM_INT, 'level id', VALUE_OPTIONAL),
'score' => new external_value(PARAM_FLOAT, 'score', VALUE_OPTIONAL),
'definition' => new external_value(PARAM_RAW, 'definition', VALUE_OPTIONAL),
'definitionformat' => new external_format_value('definition', VALUE_OPTIONAL)
)