Welcome to muddle’s documentation!¶
Contents:
muddle.py¶
About¶
A rather incomplete python client for the Moodle 2.0 Web API. Feel free to give it some love.

API Coverage¶
- 19% core API coverage
- Complete: core_course_*
Usage¶
basic usage:
import muddle
API_KEY = '133bf54a4adf1e21aff0c29034c038e2'
API_URL = 'https://your.moodle.server'
moodle = muddle.authenticate(API_KEY, API_URL)
course_contents = moodle.course(10).contents()
Documentation¶
Documentation is available from: <http://muddlepy.readthedocs.org/en/latest/>
Installation¶
To install muddle.py
:
$ pip install muddle
Alternatively, if you’re a bad person:
$ easy_install muddle
License¶
Copyright (c) 2013 Kit Randel
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
class
muddle.api.
Muddle
[source]¶ The main Muddle class
Example Usage:
>>> import muddle >>> course = muddle.course(int)
<Response [200]>
-
class
muddle.api.
Course
(course_id=None)[source]¶ Represents API endpoints for a Moodle Course
-
contents
()[source]¶ Returns entire contents of course page
Returns: response object Example Usage:
>>> import muddle >>> muddle.course(10).content()
-
create
(fullname, shortname, category_id, **kwargs)[source]¶ Create a new course
Parameters: - fullname (string) – The course’s fullname
- shortname (string) – The course’s shortname
- category_id (int) – The course’s category
- idnumber (string) – (optional) Course ID number. Yes, it’s a string, blame Moodle.
- summaryformat (int) – (optional) Defaults to 1 (HTML). Summary format options: (1 = HTML, 0 = Moodle, 2 = Plain, or 4 = Markdown)
- format (string) – (optional) Defaults to “topics” Topic options: (weeks, topics, social, site)
- showgrades (bool) – (optional) Defaults to True. Determines if grades are shown
- newsitems (int) – (optional) Defaults to 5. Number of recent items appearing on the course page
- startdate (bool) – (optional) Timestamp when the course start
- maxbytes (int) – (optional) Defaults to 83886080. Largest size of file that can be uploaded into the course
- showreports (bool) – Default to True. Are activity report shown?
- visible (bool) – (optional) Determines if course is visible to students
- groupmode (int) – (optional) Defaults to 2. options: (0 = no group, 1 = separate, 2 = visible)
- groupmodeforce (bool) – (optional) Defaults to False. Force group mode
- defaultgroupingid (int) – (optional) Defaults to 0. Default grouping id
- enablecompletion (bool) – (optional) Enable control via completion in activity settings.
- completionstartonenrol (bool) – (optional) Begin tracking a student’s progress in course completion after
- completionnotify (bool) – (optional) Default? Dunno. Presumably notifies course completion
- lang (string) – (optional) Force course language.
- forcetheme (string) – (optional) Name of the force theme
Example Usage:
>>> import muddle >>> muddle.course().create('a new course', 'new-course', 20)
-
delete
()[source]¶ Deletes a specified courses
Example Usage:
>>> import muddle >>> muddle.course(10).delete()
-
duplicate
(fullname, shortname, categoryid, visible=True, **kwargs)[source]¶ Duplicates an existing course with options. Note: Can be very slow running.
Parameters: - fullname (string) – The new course’s full name
- shortname (string) – The new course’s short name
- categoryid (string) – Category new course should be created under
- visible (bool) – Defaults to True. The new course’s visiblity
- activities (bool) – (optional) Defaults to True. Include course activites
- blocks (bool) – (optional) Defaults to True. Include course blocks
- filters (bool) – (optional) Defaults to True. Include course filters
- users (bool) – (optional) Defaults to False. Include users
- role_assignments (bool) – (optional) Defaults to False. Include role assignments
- comments (bool) – (optional) Defaults to False. Include user comments
- usercompletion (bool) – (optional) Defaults to False. Include user course completion information
- logs (bool) – (optional) Defaults to False. Include course logs
- grade_histories (bool) – (optional) Defaults to False. Include histories
Returns: response object
Example Usage:
>>> import muddle >>> muddle.course(10).duplicate('new-fullname', 'new-shortname', 20)
-
-
class
muddle.api.
Category
(category_id=None)[source]¶ Represents API endpoints for Moodle Courses Categories
-
create
(category_name, **kwargs)[source]¶ Create a new category
Parameters: - name (string) – new category name
- parent (int) – (optional) Defaults to 0, root category. The parent category id inside which the new category will be created
- description (string) – (optional) The new category description
- descriptionformat (int) – (optional) Defaults to 1 description format (1 = HTML, 0 = MOODLE, 2 = PLAIN, 4 = MARKDOWN)
- theme (string) – (optional) The new category theme
Example Usage:
>>> import muddle >>> muddle.category().create('category name')
-
delete
(new_parent=None, recursive=False)[source]¶ Deletes a category. Optionally moves content to new category. Note: If category is in root, new_parent must be specified.
Parameters: - new_parent (int) – (optional) Category ID of new parent
- recursive (bool) – recursively delete contents inside this category
Example Usage:
>>> import muddle >>> muddle.category(10).delete()
-
details
()[source]¶ Returns details for given category
Returns: category response object Example Usage:
>>> import muddle >>> muddle.category(10).details()
-
update
(**kwargs)[source]¶ Update categories
Parameters: - name (string) – (optional) Name
- idnumber (string) – (optional) Id number
- parent (int) – (optional) Parent category id
- description (string) – (optional) Description
- description-format (int) – Defaults to 1 (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN)
- theme (string) – (optional) Theme
Example Usage:
>>> import muddle >>> muddle.category(10).update(name='new name')
-