Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 401 and 402]

(no description)

File Size: 137 lines (7 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

helper_for_get_mods_by_courses:: (3 methods):
  standard_coursemodule_element_values()
  format_name_and_intro()
  standard_coursemodule_elements_returns()


Class: helper_for_get_mods_by_courses  - X-Ref

This class helps implement the get_..._by_courses web service that every activity should have.

It has helper methods to add the standard course-module fields to the results, and the declaration of the return value.

standard_coursemodule_element_values(\stdClass $modinstance, string $component,string $capabilityforgroups = 'moodle/course:manageactivities', string $capabilityforintro = null)   X-Ref
Add the value of all the standard fields to the results to be returned by the service.
This is designed to be used in the implementation of the get_..._by_courses web service methods.

Note that $modinstance is also updated in-place.

param: \stdClass $modinstance one of the objects returned from a call to {@see get_all_instances_in_courses()}.
param: string $component the plugin name, e.g. 'mod_book'.
param: string $capabilityforgroups capability to check before including group/visible/section info in the results.
param: string|null $capabilityforintro capability to check before including intro info in the results.
return: array with the containing all the values declared in {@see standard_coursemodule_elements_returns()}.

format_name_and_intro(\stdClass $modinstance, string $component)   X-Ref
Format the module name an introduction ready to be exported to a web service.

Note that $modinstance is updated in-place.

param: \stdClass $modinstance one of the objects returned from a call to {@see get_all_instances_in_courses()}.
param: string $component the plugin name, e.g. 'mod_book'.

standard_coursemodule_elements_returns(bool $introoptional = false)   X-Ref
Get the list of standard fields, to add to the declaration of the return values.

Example usage combine the fields returned here with any extra ones your activity uses:

public static function execute_returns() {
return new external_single_structure([
'bigbluebuttonbns' => new external_multiple_structure(
new external_single_structure(array_merge(
helper_for_get_mods_by_courses::standard_coursemodule_elements_returns(),
[
'meetingid' => new external_value(PARAM_RAW, 'Meeting id'),
'timemodified' => new external_value(PARAM_INT, 'Last time the instance was modified'),
]
))
),
'warnings' => new external_warnings(),
]
);
}

param: bool $introoptional if true, the intro fields are marked as optional. Default false.
return: external_description[] array of standard fields, to which you can add your activity-specific ones.