mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-51564 webservice: Review the use of external format_string
This commit is contained in:
parent
35d3e8b00b
commit
9748791ba8
12 changed files with 48 additions and 17 deletions
|
@ -238,17 +238,17 @@ class core_course_external extends external_api {
|
||||||
|
|
||||||
$module = array();
|
$module = array();
|
||||||
|
|
||||||
|
$modcontext = context_module::instance($cm->id);
|
||||||
|
|
||||||
//common info (for people being able to see the module or availability dates)
|
//common info (for people being able to see the module or availability dates)
|
||||||
$module['id'] = $cm->id;
|
$module['id'] = $cm->id;
|
||||||
$module['name'] = format_string($cm->name, true);
|
$module['name'] = external_format_string($cm->name, $modcontext->id);
|
||||||
$module['instance'] = $cm->instance;
|
$module['instance'] = $cm->instance;
|
||||||
$module['modname'] = $cm->modname;
|
$module['modname'] = $cm->modname;
|
||||||
$module['modplural'] = $cm->modplural;
|
$module['modplural'] = $cm->modplural;
|
||||||
$module['modicon'] = $cm->get_icon_url()->out(false);
|
$module['modicon'] = $cm->get_icon_url()->out(false);
|
||||||
$module['indent'] = $cm->indent;
|
$module['indent'] = $cm->indent;
|
||||||
|
|
||||||
$modcontext = context_module::instance($cm->id);
|
|
||||||
|
|
||||||
if (!empty($cm->showdescription) or $cm->modname == 'label') {
|
if (!empty($cm->showdescription) or $cm->modname == 'label') {
|
||||||
// We want to use the external format. However from reading get_formatted_content(), $cm->content format is always FORMAT_HTML.
|
// We want to use the external format. However from reading get_formatted_content(), $cm->content format is always FORMAT_HTML.
|
||||||
list($module['description'], $descriptionformat) = external_format_text($cm->content,
|
list($module['description'], $descriptionformat) = external_format_text($cm->content,
|
||||||
|
@ -2370,7 +2370,7 @@ class core_course_external extends external_api {
|
||||||
$info->completion = $cm->completion;
|
$info->completion = $cm->completion;
|
||||||
}
|
}
|
||||||
// Format name.
|
// Format name.
|
||||||
$info->name = format_string($cm->name, true, array('context' => $context));
|
$info->name = external_format_string($cm->name, $context->id);
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
$result['cm'] = $info;
|
$result['cm'] = $info;
|
||||||
|
@ -2392,7 +2392,7 @@ class core_course_external extends external_api {
|
||||||
'id' => new external_value(PARAM_INT, 'The course module id'),
|
'id' => new external_value(PARAM_INT, 'The course module id'),
|
||||||
'course' => new external_value(PARAM_INT, 'The course id'),
|
'course' => new external_value(PARAM_INT, 'The course id'),
|
||||||
'module' => new external_value(PARAM_INT, 'The module type id'),
|
'module' => new external_value(PARAM_INT, 'The module type id'),
|
||||||
'name' => new external_value(PARAM_TEXT, 'The activity name'),
|
'name' => new external_value(PARAM_RAW, 'The activity name'),
|
||||||
'modname' => new external_value(PARAM_COMPONENT, 'The module component name (forum, assign, etc..)'),
|
'modname' => new external_value(PARAM_COMPONENT, 'The module component name (forum, assign, etc..)'),
|
||||||
'instance' => new external_value(PARAM_INT, 'The activity instance id'),
|
'instance' => new external_value(PARAM_INT, 'The activity instance id'),
|
||||||
'section' => new external_value(PARAM_INT, 'The module section id'),
|
'section' => new external_value(PARAM_INT, 'The module section id'),
|
||||||
|
|
|
@ -143,6 +143,8 @@ information provided here is intended especially for developers.
|
||||||
<frankenstyle>_extend_navigation_category_settings(navigation_node, context_coursecat)
|
<frankenstyle>_extend_navigation_category_settings(navigation_node, context_coursecat)
|
||||||
* The clilib.php provides two new functions cli_write() and cli_writeln() that should be used for outputting texts from the command
|
* The clilib.php provides two new functions cli_write() and cli_writeln() that should be used for outputting texts from the command
|
||||||
line interface scripts.
|
line interface scripts.
|
||||||
|
* External function core_course_external::get_course_contents returned parameter "name" has been changed to PARAM_RAW,
|
||||||
|
this is because the new external_format_string function may return raw data if the global moodlewssettingraw parameter is used.
|
||||||
|
|
||||||
=== 2.9.1 ===
|
=== 2.9.1 ===
|
||||||
|
|
||||||
|
|
|
@ -201,7 +201,7 @@ class mod_book_external extends external_api {
|
||||||
$bookdetails['id'] = $book->id;
|
$bookdetails['id'] = $book->id;
|
||||||
$bookdetails['coursemodule'] = $book->coursemodule;
|
$bookdetails['coursemodule'] = $book->coursemodule;
|
||||||
$bookdetails['course'] = $book->course;
|
$bookdetails['course'] = $book->course;
|
||||||
$bookdetails['name'] = format_string($book->name, true, array('context' => $context));
|
$bookdetails['name'] = external_format_string($book->name, $context->id);
|
||||||
// Format intro.
|
// Format intro.
|
||||||
list($bookdetails['intro'], $bookdetails['introformat']) =
|
list($bookdetails['intro'], $bookdetails['introformat']) =
|
||||||
external_format_text($book->intro, $book->introformat, $context->id, 'mod_book', 'intro', null);
|
external_format_text($book->intro, $book->introformat, $context->id, 'mod_book', 'intro', null);
|
||||||
|
@ -242,7 +242,7 @@ class mod_book_external extends external_api {
|
||||||
'id' => new external_value(PARAM_INT, 'Book id'),
|
'id' => new external_value(PARAM_INT, 'Book id'),
|
||||||
'coursemodule' => new external_value(PARAM_INT, 'Course module id'),
|
'coursemodule' => new external_value(PARAM_INT, 'Course module id'),
|
||||||
'course' => new external_value(PARAM_INT, 'Course id'),
|
'course' => new external_value(PARAM_INT, 'Course id'),
|
||||||
'name' => new external_value(PARAM_TEXT, 'Book name'),
|
'name' => new external_value(PARAM_RAW, 'Book name'),
|
||||||
'intro' => new external_value(PARAM_RAW, 'The Book intro'),
|
'intro' => new external_value(PARAM_RAW, 'The Book intro'),
|
||||||
'introformat' => new external_format_value('intro'),
|
'introformat' => new external_format_value('intro'),
|
||||||
'numbering' => new external_value(PARAM_INT, 'Book numbering configuration'),
|
'numbering' => new external_value(PARAM_INT, 'Book numbering configuration'),
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
This files describes API changes in the book code.
|
This files describes API changes in the book code.
|
||||||
|
|
||||||
|
=== 3.0 ===
|
||||||
|
|
||||||
|
* External function mod_book_external::get_books_by_courses returned parameter "name" has been changed to PARAM_RAW,
|
||||||
|
this is because the new external_format_string function may return raw data if the global moodlewssettingraw parameter is used.
|
||||||
|
|
||||||
=== 2.7 ===
|
=== 2.7 ===
|
||||||
|
|
||||||
* bogus legacy log calls were removed
|
* bogus legacy log calls were removed
|
||||||
|
|
|
@ -116,7 +116,7 @@ class mod_choice_external extends external_api {
|
||||||
}
|
}
|
||||||
|
|
||||||
$options[] = array('id' => $optionid,
|
$options[] = array('id' => $optionid,
|
||||||
'text' => format_string($option->text, true, array('context' => $context)),
|
'text' => external_format_string($option->text, $context->id),
|
||||||
'maxanswer' => $option->maxanswer,
|
'maxanswer' => $option->maxanswer,
|
||||||
'userresponses' => $userresponses,
|
'userresponses' => $userresponses,
|
||||||
'numberofuser' => $numberofuser,
|
'numberofuser' => $numberofuser,
|
||||||
|
@ -230,7 +230,7 @@ class mod_choice_external extends external_api {
|
||||||
foreach ($options['options'] as $option) {
|
foreach ($options['options'] as $option) {
|
||||||
$optionarr = array();
|
$optionarr = array();
|
||||||
$optionarr['id'] = $option->attributes->value;
|
$optionarr['id'] = $option->attributes->value;
|
||||||
$optionarr['text'] = format_string($option->text, true, array('context' => $context));
|
$optionarr['text'] = external_format_string($option->text, $context->id);
|
||||||
$optionarr['maxanswers'] = $option->maxanswers;
|
$optionarr['maxanswers'] = $option->maxanswers;
|
||||||
$optionarr['displaylayout'] = $option->displaylayout;
|
$optionarr['displaylayout'] = $option->displaylayout;
|
||||||
$optionarr['countanswers'] = $option->countanswers;
|
$optionarr['countanswers'] = $option->countanswers;
|
||||||
|
@ -503,7 +503,7 @@ class mod_choice_external extends external_api {
|
||||||
$choicedetails['id'] = $choice->id;
|
$choicedetails['id'] = $choice->id;
|
||||||
$choicedetails['coursemodule'] = $choice->coursemodule;
|
$choicedetails['coursemodule'] = $choice->coursemodule;
|
||||||
$choicedetails['course'] = $choice->course;
|
$choicedetails['course'] = $choice->course;
|
||||||
$choicedetails['name'] = format_string($choice->name, true, array('context' => $context));;
|
$choicedetails['name'] = external_format_string($choice->name, $context->id);
|
||||||
// Format intro.
|
// Format intro.
|
||||||
list($choicedetails['intro'], $choicedetails['introformat']) =
|
list($choicedetails['intro'], $choicedetails['introformat']) =
|
||||||
external_format_text($choice->intro, $choice->introformat,
|
external_format_text($choice->intro, $choice->introformat,
|
||||||
|
@ -555,7 +555,7 @@ class mod_choice_external extends external_api {
|
||||||
'id' => new external_value(PARAM_INT, 'Choice instance id'),
|
'id' => new external_value(PARAM_INT, 'Choice instance id'),
|
||||||
'coursemodule' => new external_value(PARAM_INT, 'Course module id'),
|
'coursemodule' => new external_value(PARAM_INT, 'Course module id'),
|
||||||
'course' => new external_value(PARAM_INT, 'Course id'),
|
'course' => new external_value(PARAM_INT, 'Course id'),
|
||||||
'name' => new external_value(PARAM_TEXT, 'Choice name'),
|
'name' => new external_value(PARAM_RAW, 'Choice name'),
|
||||||
'intro' => new external_value(PARAM_RAW, 'The choice intro'),
|
'intro' => new external_value(PARAM_RAW, 'The choice intro'),
|
||||||
'introformat' => new external_format_value('intro'),
|
'introformat' => new external_format_value('intro'),
|
||||||
'publish' => new external_value(PARAM_BOOL, 'If choice is published', VALUE_OPTIONAL),
|
'publish' => new external_value(PARAM_BOOL, 'If choice is published', VALUE_OPTIONAL),
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
This files describes API changes in /mod/choice/*,
|
This files describes API changes in /mod/choice/*,
|
||||||
information provided here is intended especially for developers.
|
information provided here is intended especially for developers.
|
||||||
|
|
||||||
|
=== 3.0 ===
|
||||||
|
|
||||||
|
* External function mod_choice_external::get_choices_by_courses returned parameter "name" and
|
||||||
|
mod_choice_external::get_choice_results "text" have been changed to PARAM_RAW.
|
||||||
|
This is because the new external_format_string function may return raw data if the global moodlewssettingraw parameter is used.
|
||||||
|
|
||||||
=== 2.9 ===
|
=== 2.9 ===
|
||||||
|
|
||||||
* custom renderers must be updated to include action=makechoice field in display_options()
|
* custom renderers must be updated to include action=makechoice field in display_options()
|
||||||
|
|
|
@ -157,7 +157,7 @@ class mod_imscp_external extends external_api {
|
||||||
$imscpdetails['id'] = $imscp->id;
|
$imscpdetails['id'] = $imscp->id;
|
||||||
$imscpdetails['coursemodule'] = $imscp->coursemodule;
|
$imscpdetails['coursemodule'] = $imscp->coursemodule;
|
||||||
$imscpdetails['course'] = $imscp->course;
|
$imscpdetails['course'] = $imscp->course;
|
||||||
$imscpdetails['name'] = format_string($imscp->name, true, array('context' => $context));
|
$imscpdetails['name'] = external_format_string($imscp->name, $context->id);
|
||||||
|
|
||||||
if (has_capability('mod/imscp:view', $context)) {
|
if (has_capability('mod/imscp:view', $context)) {
|
||||||
// Format intro.
|
// Format intro.
|
||||||
|
@ -199,7 +199,7 @@ class mod_imscp_external extends external_api {
|
||||||
'id' => new external_value(PARAM_INT, 'IMSCP id'),
|
'id' => new external_value(PARAM_INT, 'IMSCP id'),
|
||||||
'coursemodule' => new external_value(PARAM_INT, 'Course module id'),
|
'coursemodule' => new external_value(PARAM_INT, 'Course module id'),
|
||||||
'course' => new external_value(PARAM_INT, 'Course id'),
|
'course' => new external_value(PARAM_INT, 'Course id'),
|
||||||
'name' => new external_value(PARAM_TEXT, 'Activity name'),
|
'name' => new external_value(PARAM_RAW, 'Activity name'),
|
||||||
'intro' => new external_value(PARAM_RAW, 'The IMSCP intro', VALUE_OPTIONAL),
|
'intro' => new external_value(PARAM_RAW, 'The IMSCP intro', VALUE_OPTIONAL),
|
||||||
'introformat' => new external_format_value('intro', VALUE_OPTIONAL),
|
'introformat' => new external_format_value('intro', VALUE_OPTIONAL),
|
||||||
'revision' => new external_value(PARAM_INT, 'Revision', VALUE_OPTIONAL),
|
'revision' => new external_value(PARAM_INT, 'Revision', VALUE_OPTIONAL),
|
||||||
|
|
6
mod/imscp/upgrade.txt
Normal file
6
mod/imscp/upgrade.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
This files describes API changes in the imscp code.
|
||||||
|
|
||||||
|
=== 3.0 ===
|
||||||
|
|
||||||
|
* External function mod_imscp_external::get_imscps_by_courses returned parameter "name" has been changed to PARAM_RAW,
|
||||||
|
this is because the new external_format_string function may return raw data if the global moodlewssettingraw parameter is used.
|
|
@ -651,7 +651,7 @@ class mod_scorm_external extends external_api {
|
||||||
$module['id'] = $scorm->id;
|
$module['id'] = $scorm->id;
|
||||||
$module['coursemodule'] = $scorm->coursemodule;
|
$module['coursemodule'] = $scorm->coursemodule;
|
||||||
$module['course'] = $scorm->course;
|
$module['course'] = $scorm->course;
|
||||||
$module['name'] = format_string($scorm->name, true, array('context' => $context));
|
$module['name'] = external_format_string($scorm->name, $context->id);
|
||||||
list($module['intro'], $module['introformat']) =
|
list($module['intro'], $module['introformat']) =
|
||||||
external_format_text($scorm->intro, $scorm->introformat, $context->id, 'mod_scorm', 'intro', $scorm->id);
|
external_format_text($scorm->intro, $scorm->introformat, $context->id, 'mod_scorm', 'intro', $scorm->id);
|
||||||
|
|
||||||
|
@ -725,7 +725,7 @@ class mod_scorm_external extends external_api {
|
||||||
'id' => new external_value(PARAM_INT, 'SCORM id'),
|
'id' => new external_value(PARAM_INT, 'SCORM id'),
|
||||||
'coursemodule' => new external_value(PARAM_INT, 'Course module id'),
|
'coursemodule' => new external_value(PARAM_INT, 'Course module id'),
|
||||||
'course' => new external_value(PARAM_INT, 'Course id'),
|
'course' => new external_value(PARAM_INT, 'Course id'),
|
||||||
'name' => new external_value(PARAM_TEXT, 'SCORM name'),
|
'name' => new external_value(PARAM_RAW, 'SCORM name'),
|
||||||
'intro' => new external_value(PARAM_RAW, 'The SCORM intro'),
|
'intro' => new external_value(PARAM_RAW, 'The SCORM intro'),
|
||||||
'introformat' => new external_format_value('intro'),
|
'introformat' => new external_format_value('intro'),
|
||||||
'packagesize' => new external_value(PARAM_INT, 'SCORM zip package size', VALUE_OPTIONAL),
|
'packagesize' => new external_value(PARAM_INT, 'SCORM zip package size', VALUE_OPTIONAL),
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
This files describes API changes in the mod_scorm code.
|
This files describes API changes in the mod_scorm code.
|
||||||
|
|
||||||
|
=== 3.0 ===
|
||||||
|
|
||||||
|
* External function mod_scorm_external::get_scorms_by_courses returned parameter "name" has been changed to PARAM_RAW,
|
||||||
|
this is because the new external_format_string function may return raw data if the global moodlewssettingraw parameter is used.
|
||||||
|
* Function scorm_view_display was renamed to scorm_print_launch to avoid
|
||||||
|
confussion with new function scorm_view.
|
||||||
|
|
||||||
=== 2.8 ===
|
=== 2.8 ===
|
||||||
|
|
||||||
* Coding style fixes. A large number of coding style issues were fixed in MDL-45887. This means any local modifications
|
* Coding style fixes. A large number of coding style issues were fixed in MDL-45887. This means any local modifications
|
||||||
|
|
|
@ -6,8 +6,6 @@ information provided here is intended especially for developers.
|
||||||
* Dropped support for the $module in mod/xxx/version.php files (deprecated
|
* Dropped support for the $module in mod/xxx/version.php files (deprecated
|
||||||
since 2.7). All activity modules must use the $plugin syntax now. See
|
since 2.7). All activity modules must use the $plugin syntax now. See
|
||||||
https://docs.moodle.org/dev/version.php for details (MDL-43896).
|
https://docs.moodle.org/dev/version.php for details (MDL-43896).
|
||||||
* Function scorm_view_display was renamed to scorm_print_launch to avoid
|
|
||||||
confussion with new function scorm_view.
|
|
||||||
* Modules using rating component must implement a callback mod_x_rating_can_see_item_ratings(). Refer
|
* Modules using rating component must implement a callback mod_x_rating_can_see_item_ratings(). Refer
|
||||||
to mod_forum_rating_can_see_item_ratings() for example.
|
to mod_forum_rating_can_see_item_ratings() for example.
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,13 @@ information provided here is intended especially for developers.
|
||||||
|
|
||||||
This information is intended for authors of webservices, not people writing webservice clients.
|
This information is intended for authors of webservices, not people writing webservice clients.
|
||||||
|
|
||||||
|
=== 3.0 ===
|
||||||
|
|
||||||
|
* New function for formatting external strings: external_format_strings, it should be used as a replacement of format_string in
|
||||||
|
external functions.
|
||||||
|
All the occurrences of format_strings have been replaced with this new function.
|
||||||
|
|
||||||
|
|
||||||
=== 2.9 ===
|
=== 2.9 ===
|
||||||
|
|
||||||
* The deprecated functions can not be added to services anymore and
|
* The deprecated functions can not be added to services anymore and
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue