Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Class: mod_data_external  - X-Ref

Database module external functions

get_databases_by_courses_parameters()   X-Ref
Describes the parameters for get_databases_by_courses.

return: external_function_parameters

get_databases_by_courses($courseids = array()   X-Ref
Returns a list of databases in a provided list of courses,
if no list is provided all databases that the user can view will be returned.

param: array $courseids the course ids
return: array the database details

get_databases_by_courses_returns()   X-Ref
Describes the get_databases_by_courses return value.

return: external_single_structure

validate_database($databaseid)   X-Ref
Utility function for validating a database.

param: int $databaseid database instance id
return: array array containing the database object, course, context and course module objects

view_database_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

view_database($databaseid)   X-Ref
Simulate the data/view.php web interface page: trigger events, completion, etc...

param: int $databaseid the data instance id
return: array of warnings and status result

view_database_returns()   X-Ref
Returns description of method result value

return: external_description

get_data_access_information_parameters()   X-Ref
Returns description of method parameters.

return: external_function_parameters

get_data_access_information($databaseid, $groupid = 0)   X-Ref
Return access information for a given database.

param: int $databaseid the database instance id
param: int $groupid (optional) group id, 0 means that the function will determine the user group
return: array of warnings and access information

get_data_access_information_returns()   X-Ref
Returns description of method result value.

return: external_description

get_entries_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

get_entries($databaseid, $groupid = 0, $returncontents = false, $sort = null, $order = null,$page = 0, $perpage = 0)   X-Ref
Return access information for a given feedback

param: int $databaseid       the data instance id
param: int $groupid          (optional) group id, 0 means that the function will determine the user group
param: bool $returncontents  Whether to return the entries contents or not
param: str $sort             sort by this field
param: int $order            the direction of the sorting
param: int $page             page of records to return
param: int $perpage          number of records to return per page
return: array of warnings and the entries

get_entries_returns()   X-Ref
Returns description of method result value

return: external_description

get_entry_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

get_entry($entryid, $returncontents = false)   X-Ref
Return one entry record from the database, including contents optionally.

param: int $entryid          the record entry id id
param: bool $returncontents  whether to return the entries contents or not
return: array of warnings and the entries

get_entry_returns()   X-Ref
Returns description of method result value

return: external_description

get_fields_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

get_fields($databaseid)   X-Ref
Return the list of configured fields for the given database.

param: int $databaseid the database id
return: array of warnings and the fields

get_fields_returns()   X-Ref
Returns description of method result value

return: external_description

search_entries_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

search_entries($databaseid, $groupid = 0, $returncontents = false, $search = '', $advsearch = [],$sort = null, $order = null, $page = 0, $perpage = 0)   X-Ref
Return access information for a given feedback

param: int $databaseid       the data instance id
param: int $groupid          (optional) group id, 0 means that the function will determine the user group
param: bool $returncontents  whether to return contents or not
param: str $search           search text
param: array $advsearch      advanced search data
param: str $sort             sort by this field
param: int $order            the direction of the sorting
param: int $page             page of records to return
param: int $perpage          number of records to return per page
return: array of warnings and the entries

search_entries_returns()   X-Ref
Returns description of method result value

return: external_description

approve_entry_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

approve_entry($entryid, $approve = true)   X-Ref
Approves or unapproves an entry.

param: int $entryid          the record entry id id
param: bool $approve         whether to approve (true) or unapprove the entry
return: array of warnings and the entries

approve_entry_returns()   X-Ref
Returns description of method result value

return: external_description

delete_entry_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

delete_entry($entryid)   X-Ref
Deletes an entry.

param: int $entryid the record entry id
return: array of warnings success status

delete_entry_returns()   X-Ref
Returns description of method result value

return: external_description

add_entry_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

add_entry($databaseid, $groupid, $data)   X-Ref
Adds a new entry to a database

param: int $databaseid the data instance id
param: int $groupid (optional) group id, 0 means that the function will determine the user group
param: array $data the fields data to be created
return: array of warnings and status result

add_entry_returns()   X-Ref
Returns description of method result value

return: external_description

update_entry_parameters()   X-Ref
Returns description of method parameters

return: external_function_parameters

update_entry($entryid, $data)   X-Ref
Updates an existing entry.

param: int $entryid the data instance id
param: array $data the fields data to be created
return: array of warnings and status result

update_entry_returns()   X-Ref
Returns description of method result value

return: external_description