Moodle API Pages - C0D3D3V/Moodle-DL GitHub Wiki
To download pages the following function is of interest:
Area | Name | Introduced in | Description |
---|---|---|---|
mod_page | mod_page_get_pages_by_courses | 3.3 (2017051500) | Returns a list of pages in a provided list of courses, if no list is provided all pages that the user can view will be returned. |
An example module which returns core_course_get_contents
:
{
"id": 62,
"url": "http://archlinux-vm/moodle/mod/page/view.php?id=62",
"name": "Nicer Dicer 10000",
"instance": 2,
"contextid": 127,
"visible": 1,
"uservisible": true,
"visibleoncoursepage": 1,
"modicon": "http://archlinux-vm/moodle/theme/image.php/boost/page/1633802793/icon",
"modname": "page",
"modplural": "Textseiten",
"indent": 0,
"onclick": "",
"afterlink": null,
"customdata": "\"\"",
"noviewlink": false,
"completion": 1,
"completiondata": {
"state": 0,
"timecompleted": 0,
"overrideby": null,
"valueused": false
},
"contents": [
{
"type": "file",
"filename": "1.png",
"filepath": "/",
"filesize": 65071,
"fileurl": "http://archlinux-vm/moodle/webservice/pluginfile.php/127/mod_page/content/2/1.png?forcedownload=1",
"timecreated": 1634560752,
"timemodified": 1634560807,
"sortorder": 0,
"mimetype": "image/png",
"isexternalfile": false,
"userid": 3,
"author": "Administrator/in Nutzer",
"license": "unknown"
},
{
"type": "file",
"filename": "index.html",
"filepath": "/",
"filesize": 0,
"fileurl": "http://archlinux-vm/moodle/webservice/pluginfile.php/127/mod_page/content/index.html?forcedownload=1",
"timecreated": null,
"timemodified": 1634560807,
"sortorder": 1,
"userid": null,
"author": null,
"license": null
}
],
"contentsinfo": {
"filescount": 2,
"filessize": 65071,
"lastmodified": 1634560807,
"mimetypes": [
"image/png"
],
"repositorytype": ""
}
}
As you can see in contents
is also the index.html
linked, this corresponds to the same HTML as mod_page_get_pages_by_courses
returns. But core_course_get_contents
exists since version 2.2 and therefore much earlier. We should best fall back on this index html if the version is < than 3.3.
With the help of mod_page_get_pages_by_courses
all pages of all courses can be loaded. It exists since Version 3.3.
-
courseids
is an array of the course-ids from which the pages are to be loaded.
mod_page_get_pages_by_courses
returns a list of pages:
{
"pages": [
{
"id": 2,
"coursemodule": 62,
"course": 3,
"name": "Nicer Dicer 10000",
"intro": "<p dir=\"ltr\" style=\"text-align: left;\">Kaufen sie noch heute den Nicer Dicer 6000 und gewinnen Sie ein Schuh!<br></p>",
"introformat": 1,
"introfiles": [],
"content": "<p dir=\"ltr\" style=\"text-align: left;\">Den anderen Schuh gibt es gratis dazu, wenn Sie eine Waschmaschiene Kaufen!!!</p><p dir=\"ltr\" style=\"text-align: left;\"><img src=\"http://archlinux-vm/moodle/webservice/pluginfile.php/127/mod_page/content/2/1.png\" alt=\"Nice Nudes\" class=\"img-fluid atto_image_button_text-bottom\" title=\"\" style=\"\" width=\"501\" height=\"495\"></p><p dir=\"ltr\" style=\"text-align: left;\"><br></p><p dir=\"ltr\" style=\"text-align: left;\"><br></p>",
"contentformat": 1,
"contentfiles": [
{
"filename": "1.png",
"filepath": "/",
"filesize": 65071,
"fileurl": "http://archlinux-vm/moodle/webservice/pluginfile.php/127/mod_page/content/0/1.png",
"timemodified": 1634560807,
"mimetype": "image/png",
"isexternalfile": false
}
],
"legacyfiles": 0,
"legacyfileslast": null,
"display": 5,
"displayoptions": "a:3:{s:12:\"printheading\";s:1:\"1\";s:10:\"printintro\";s:1:\"0\";s:17:\"printlastmodified\";s:1:\"1\";}",
"revision": 2,
"timemodified": 1634560807,
"section": 3,
"visible": 1,
"groupmode": 0,
"groupingid": 0
}
],
"warnings": []
}
Important attributes:
-
course
is the id of the course the page belongs to. -
id
is the id of the page -
coursemodule
is the module id that was returned bycore_course_get_contents
-
name
is the name of the page -
content
is the page