-
-
Notifications
You must be signed in to change notification settings - Fork 62
Moodle API Forums
To download databases the following functions are of interest:
Area | Name | Introduced in | Description |
---|---|---|---|
mod_forum | mod_forum_get_forums_by_courses | 2.5 (2013051400) | Returns a list of forum instances in a provided set of courses, if no courses are provided then all the forum instances the user has access to will be returned. |
mod_forum | mod_forum_get_forum_discussions_paginated | 2.8 (2014111000) | Returns a list of forum discussions optionally sorted and paginated. |
mod_forum | mod_forum_get_forum_discussions | 3.7 (2019052000) | Returns a list of forum discussions optionally sorted and paginated. |
mod_forum | mod_forum_get_forum_discussion_posts | 2.7 (2014051200) | Returns a list of forum posts for a discussion. |
mod_forum | mod_forum_get_discussion_posts | 3.7 (2019052000) | Returns a list of forum posts for a discussion. |
An example module which returns core_course_get_contents
:
{
"id":944164,
"url":"https:\/\/moodle.uni.de\/m\/mod\/forum\/view.php?id=944164",
"name":"Ank\u00fcndigungen",
"instance":44539,
"visible":1,
"uservisible":true,
"visibleoncoursepage":1,
"modicon":"https:\/\/moodle.uni.de\/m\/theme\/image.php\/boost_campus\/forum\/1589567880\/icon",
"modname":"forum",
"modplural":"Foren\/Blogs",
"indent":0,
"onclick":"",
"afterlink":null,
"customdata":"\"\"",
"completion":0
}
The module indicates where the forum is located in the course, nothing more can be derived from it.
With the help of mod_forum_get_forums_by_courses
all forum-id's of all courses can be loaded. It exists since Version 2.5. The function takes the following arguments:
-
courseids
is an array of the course-ids from which the forums are to be loaded.
mod_forum_get_forums_by_courses
returns a list of forums:
{
"id":52079,
"course":27288,
"type":"news",
"name":"Ank\u00fcndigungen",
"intro":"Nachrichten und Ank\u00fcndigungen",
"introformat":1,
"introfiles":[
],
"duedate":0,
"cutoffdate":0,
"assessed":0,
"assesstimestart":0,
"assesstimefinish":0,
"scale":0,
"maxbytes":0,
"maxattachments":1,
"forcesubscribe":1,
"trackingtype":1,
"rsstype":0,
"rssarticles":0,
"timemodified":1586339792,
"warnafter":0,
"blockafter":0,
"blockperiod":0,
"completiondiscussions":0,
"completionreplies":0,
"completionposts":0,
"cmid":1086705,
"numdiscussions":2,
"cancreatediscussions":false,
"lockdiscussionafter":0,
"istracked":true,
"unreadpostscount":0
}
Important attributes:
-
course
is the id of the course the forum belongs to. -
id
is the id of the forum -
cmid
is the module id that was returned bycore_course_get_contents
-
name
is the name of the forum
To get a list of discussions in the forum there are two functions. mod_forum_get_forum_discussions_paginated
is used from version 2.8 to 3.7 and is the deprecated version of mod_forum_get_forum_discussions
. Both functions work identically. The function takes the following arguments:
-
forumid
is the id of the forum from which the discussions should be loaded. -
perpage
specifies how many entries should be returned at once, this is optional. -
page
is the page number of the paged result.
For the new function only:
-
sortorder
Is the way the list should be sorted, as integer.SORTORDER_LASTPOST_DESC = 1
gives the best result, because you can filter the already downloaded discussions.
For the old function only:
-
sortby
is an entry fromid, timemodified, timestart or timeend
-
sortdirection
is an entry fromASC or DESC
To finally download all entries of a discussion, the function mod_forum_get_forum_discussion_posts
is required. This function exists since version 2.7 but will be deprecated in 4.1. The function takes the following arguments:
-
discussionid
is the id of the discussion to be loaded. -
sortby
is an element ofid, created or modified
-
sortdirection
is an element ofASC or DESC
I think sorting by created ASC should return the best result.
- Example Config.json and Options
- Change Download Folder
- Download (external) linked files
- Copy a token from the Moodle app
- Telegram Notification
- Additional Youtube-dl Settings
- Use cookies when downloading
- Download public courses
- Set user id and Moodle version number manually
- Exclude file extensions
- Download password protected external links
- Use of external programs to download external links
- Start Moodle dl periodically or via Telegram