Skip to main content

Moodle web services connection library

Project description

Moodle - Webservice Moodle in Python
=========================================================================================
Webservice functions to Moodle

Installation
------------------------------------------------------------------------------------------
Installing Moodle Webservice is fairly easy. You can...

sudo python setup.py install

Setting up Moodle 2.0.x web services
------------------------------------------------------------------------------------------
1. Enable web services
- Site administration => Plugins => Web services => Overview => Enable web services

2. Enable REST or XML-RPC protocol
- Site administration => Plugins => Web services => Overview => Enable protocols

3. Create web services user with Admin rights (for web services authentication)
- Site administration => Plugins => Web services => Overview => Create a specific user

4. Set permissions
- Site administration => Plugins => Web services => Overview => Check user capability

5. Add a service
- Site administration => Plugins => Web services => Overview => Select a service
- => add (eg. moodle/user:wiewalldetails: View user full information)

6. Add functions you want access to
- Site administration => Plugins => Web services => Overview => Select a service
- => Functions => Add functions (eg. moodle_user_create_users, moodle_user_create_users)

7. Allow web services user access to web service
- Site administration => Plugins => Web services => Overview => Select a service
- => Authorised users

8. Create security token
- Site administration => Plugins => Web services => Overview => Create a token for a user

Example Use
-----------------------------------------------------------------------------------------------------
Create a new course:

from moodle import MDL
mdl = MDL()

# Connect to moodle data
server = {
'protocol': 'xmlrpc', # xmlrpc, rest
'uri': 'http://www.mymoodle.org',
'token': 'yourtokenkeymoodle',
}

# Create new courses
courses = [{
'shortname': 'New Course', # shortname must be unique
'fullname': 'New Course Zikzakmedia',
'categoryid': 1,
#'visible': 1,
'id': 2,
#'maxbytes': 2097152,
#'showreports': 0,
#'startdate': 1314396000,
#'defaultgroupingid': 0,
#'summaryformat': 1,
#'completionstartonenrol': 0,
#'groupmode': 0,
#'numsections': 10,
#'showgrades': 1,
#'enablecompletion': 0,
#'hiddensections': 0,
#'format': 'topics',
#'completionnotify': 0,
#'lang': '',
#'categorysortorder': 10001,
#'timecreated': 1314367091,
#'groupmodeforce': 0,
#'forcetheme': '',
#'summary': u'<p>\ufeff</p>',
#'idnumber': '',
#'newsitems': 5,
#'timemodified': 1314367091
}]
mdl.create_courses(server, courses)

The implemented methods and APIs are:

* create_courses(server, courses)
* get_courses(server)
* create_users(server, users)
* update_users(server, users)
* get_users(server, user_ids)
* enrol_users(server, enrols)

For more examples, see examples dir


Changes
=======

Version 0.0.1
-------------

* Rest protocol connection
* XML-RPC protocol connection
* TODO: SOAP and AMF Protocols
* Webserices available
* create_courses(server, courses)
* get_courses(server)
* create_users(server, users)
* update_users(server, users)
* get_users(server, user_ids)
* enrol_users(server, enrols)
* update courses webservice available Moodle version 2.2. TODO

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moodle-0.0.1.tar.gz (4.6 kB view details)

Uploaded Source

File details

Details for the file moodle-0.0.1.tar.gz.

File metadata

  • Download URL: moodle-0.0.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for moodle-0.0.1.tar.gz
Algorithm Hash digest
SHA256 791531a4c48232d629920b9cb79caa804e065b5afe41b4704266c5bfb672b88f
MD5 bd867f7acbadaf92e4c2d8db20e98010
BLAKE2b-256 683af73cf0eea0685880101d030817a52eb5692f1a44cd90c25a639b44872b58

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page