Skip to content
Daniel Vogt edited this page Jul 3, 2020 · 18 revisions

To download databases the following functions are of interest:

Area Name Introduced in Description
mod_data mod_data_get_databases_by_courses 2.9 (2015051100) Returns a list of database instances in a provided set of courses, if no courses are provided then all the database instances the user has access to will be returned.
mod_data mod_data_get_entries 3.3 (2017051500) Return the complete list of entries of the given database.
mod_data mod_data_get_fields 3.3 (2017051500) Return the list of configured fields for the given database.

mod_data_get_databases_by_courses

Parameter
Funktion
Returns
Result Structure

The function returns all databases that a user is allowed to see. If the parameter courseids is specified, then filtering is done using the course id's. The result is an array called databases, which looks like this:

"databases":[      
    {         
        "id":25,
        "course":66,
        "name":"Learner database",
        "intro":"<p>Give us a few details about yourself so we can build a bank of course participants and get to know each other!</p>",
        "introformat":1,
        "comments":false,
        "timeavailablefrom":0,
        "timeavailableto":0,
        "timeviewfrom":0,
        "timeviewto":0,
        "requiredentries":0,
        "requiredentriestoview":0,
        "maxentries":0,
        "rssarticles":0,
        "singletemplate":"<some HTML>",
        "listtemplate":"<some HTML>",
        "listtemplateheader":"<table align=\"center\"  class=\"recipelist\">",
        "listtemplatefooter":"</table>",
        "addtemplate":"<some HTML>",
        "rsstemplate":"<p>[[Your nickname]] - [[Main role]]</p>",
        "rsstitletemplate":"",
        "csstemplate":"<some CSS>",
        "jstemplate":"",
        "asearchtemplate":"<p>Type: [[Type]]</p>",
        "approval":false,
        "manageapproved":true,
        "defaultsort":0,
        "defaultsortdir":1,
        "coursemodule":802,
        "introfiles":[ ]
    },
 ....]

Important is the coursemodule which corresponds to the module_id of a module. The id corresponds to the instance id of a module. introfiles can contain some intro files. name is identical to the name of the module, only the intro text is new.

In reality we do not need this request at all to download individual databases.

mod_data_get_entries

Parameters
Function
Returns
Returns Structure and the Contents (the file structure as usual)

This function returns all entries of a database. As parameter the databaseid is needed, which is the instance id.

Clone this wiki locally