Lambda Learn API Documentation

This article lists Lambda Learn API requests and responses.

 

important-3  NOTE

This article assumes that you have some knowledge in using APIs. If you would like a brief explanation on using APIs, click here for an introductory article.


TOPICS


core_completion_get_activities_completion_status

This request returns the activities' completion status for a user in a course.

Arguments

  • courseid (Required)

General Structure

int   //Course ID

REST (POST Parameters)

courseid= int

Arguments

  • userid (Required)

General Structure

int   //User ID

REST (POST Parameters)

userid= int

Response: General Structure

object {
statuses //List of activities status
list of ( //Activity
object {
cmid int //comment ID
modname string //activity module name
instance int //instance ID
state int //completion state value:
0 means incomplete, 1 complete,
2 complete pass, 3 complete fail

timecompleted int //timestamp for completed activity
tracking int //type of tracking:
0 means none, 1 manual, 2 automatic

}
)
warnings Optional //list of warnings
list of ( //warning
object {
item string Optional //item
itemid int Optional //item id
warningcode string //the warning code can be used by the client app to implement specific behaviour
message string //untranslated english message to explain the warning
}
)}

Response: REST

<?xml version="1.0" encoding="UTF-8" ?>
<RESPONSE>
<SINGLE>
<KEY name="statuses">
<MULTIPLE>
<SINGLE>
<KEY name="cmid">
<VALUE>int</VALUE>
</KEY>
<KEY name="modname">
<VALUE>string</VALUE>
</KEY>
<KEY name="instance">
<VALUE>int</VALUE>
</KEY>
<KEY name="state">
<VALUE>int</VALUE>
</KEY>
<KEY name="timecompleted">
<VALUE>int</VALUE>
</KEY>
<KEY name="tracking">
<VALUE>int</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
<KEY name="warnings">
<MULTIPLE>
<SINGLE>
<KEY name="item">
<VALUE>string</VALUE>
</KEY>
<KEY name="itemid">
<VALUE>int</VALUE>
</KEY>
<KEY name="warningcode">
<VALUE>string</VALUE>
</KEY>
<KEY name="message">
<VALUE>string</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
</SINGLE>
</RESPONSE>

Error Message: REST

<?xml version="1.0" encoding="UTF-8"?>
<EXCEPTION class="invalid_parameter_exception">
<MESSAGE>Invalid parameter value detected</MESSAGE>
<DEBUGINFO></DEBUGINFO>
</EXCEPTION>

Back to TOPICS


core_completion_get_course_completion_status

This request returns course completion status.

Arguments

  • courseid (Required)

General Structure

int   //Course ID

REST (POST Parameters)

courseid= int

Arguments

  • userid (Required)

General Structure

int   //User ID

REST (POST Parameters)

userid= int

Response: General Structure

//Course completion status
object {
completionstatus //Course status
object {
completed int //true if the course is complete, false otherwise
aggregation int //aggregation method 1 means all, 2 means any
completions list of ( //Completions
object {
type int //Completion criteria type
title string //Completion criteria Title
status string //Completion status (Yes/No) a % or number
complete int //Completion status (true/false)
timecompleted int //Timestamp for criteria completion
details //details
object {
type string //Type description
criteria string //Criteria description
requirement string //Requirement description
status string //Status description, can be anything
}
}
)
}
warnings Optional //list of warnings
list of ( //warning
object {
item string Optional //item
itemid int Optional //item id
warningcode string //the warning code can be used by the client app to implement specific behaviour
message string //untranslated english message to explain the warning
}
)
}

Response: REST

<?xml version="1.0" encoding="UTF-8" ?>
<RESPONSE>
<SINGLE>
<KEY name="completionstatus">
<SINGLE>
<KEY name="completed">
<VALUE>int</VALUE>
</KEY>
<KEY name="aggregation">
<VALUE>int</VALUE>
</KEY>
<KEY name="completions">
<MULTIPLE>
<SINGLE>
<KEY name="type">
<VALUE>int</VALUE>
</KEY>
<KEY name="title">
<VALUE>string</VALUE>
</KEY>
<KEY name="status">
<VALUE>string</VALUE>
</KEY>
<KEY name="complete">
<VALUE>int</VALUE>
</KEY>
<KEY name="timecompleted">
<VALUE>int</VALUE>
</KEY>
<KEY name="details">
<SINGLE>
<KEY name="type">
<VALUE>string</VALUE>
</KEY>
<KEY name="criteria">
<VALUE>string</VALUE>
</KEY>
<KEY name="requirement">
<VALUE>string</VALUE>
</KEY>
<KEY name="status">
<VALUE>string</VALUE>
</KEY>
</SINGLE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
</SINGLE>
</KEY>
<KEY name="warnings">
<MULTIPLE>
<SINGLE>
<KEY name="item">
<VALUE>string</VALUE>
</KEY>
<KEY name="itemid">
<VALUE>int</VALUE>
</KEY>
<KEY name="warningcode">
<VALUE>string</VALUE>
</KEY>
<KEY name="message">
<VALUE>string</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
</SINGLE>
</RESPONSE>

Error Message: REST

<?xml version="1.0" encoding="UTF-8"?>
<EXCEPTION class="invalid_parameter_exception">
<MESSAGE>Invalid parameter value detected</MESSAGE>
<DEBUGINFO></DEBUGINFO>
</EXCEPTION>

Back to TOPICS


core_course_create_categories

This request creates course categories.

Arguments

  • categories (Required)

General Structure

list of ( 
object {
name string //new category name
parent int Default to "0" //the parent category id inside which the new category will be created
- set to 0 for a root category

idnumber string Optional //the new category idnumber
description string Optional //the new category description
descriptionformat int Default to "1" //description format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN)
theme string Optional //the new category theme. This option must be enabled on moodle
}
)

REST (POST Parameters)

categories[0][name]= string
categories[0][parent]= int
categories[0][idnumber]= string
categories[0][description]= string
categories[0][descriptionformat]= int
categories[0][theme]= string

Response: General Structure

list of ( 
object {
id int //new category id
name string //new category name
}
)

Response: REST

<?xml version="1.0" encoding="UTF-8" ?>
<RESPONSE>
<MULTIPLE>
<SINGLE>
<KEY name="id">
<VALUE>int</VALUE>
</KEY>
<KEY name="name">
<VALUE>string</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</RESPONSE>

Error Message: REST

<?xml version="1.0" encoding="UTF-8"?>
<EXCEPTION class="invalid_parameter_exception">
<MESSAGE>Invalid parameter value detected</MESSAGE>
<DEBUGINFO></DEBUGINFO>
</EXCEPTION>

Back to TOPICS


core_course_create_courses

This request creates new courses.

Arguments

  • courses (Required)

General Structure

//courses to create
list of (
object {
fullname string //full name
shortname string //course short name
categoryid int //category id
idnumber string Optional //id number
summary string Optional //summary
summaryformat int Default to "1" //summary format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN)
format string Default to "topics" //course format: weeks, topics, social, site,..
showgrades int Default to "1" //1 if grades are shown, otherwise 0
newsitems int Default to "5" //number of recent items appearing on the course page
startdate int Optional //timestamp when the course start
enddate int Optional //timestamp when the course end
numsections int Optional //(deprecated, use courseformatoptions) number of weeks/topics
maxbytes int Default to "0" //largest size of file that can be uploaded into the course
showreports int Default to "0" //are activity report shown (yes = 1, no =0)
visible int Optional //1: available to student, 0:not available
hiddensections int Optional //(deprecated, use courseformatoptions) How the hidden sections in the course are displayed to students
groupmode int Default to "0" //no group, separate, visible
groupmodeforce int Default to "0" //1: yes, 0: no
defaultgroupingid int Default to "0" //default grouping id
enablecompletion int Optional //Enabled, control via completion and activity settings. Disabled,
not shown in activity settings.

completionstartonenrol int Optional //1: begin tracking a student's progress in course completion
after course enrolment. 0: does not

completionnotify int Optional //1: yes 0: no
lang string Optional //forced course language
forcetheme string Optional //name of the force theme
courseformatoptions Optional //additional options for particular course format
list of (
object {
name string //course format option name
value string //course format option value
}
)
audiencevisible int Optional //0: enrolled users only,
1: enrolled users and members of the selected audiences,
2: all users,
3: no users

coursetype int Optional //0: elearning,
1: blended,
2: facetoface

completionprogressonview int Optional //1: mark as in progress on first view,
0: does not

}
)

REST (POST Parameters)

courses[0][fullname]= string
courses[0][shortname]= string
courses[0][categoryid]= int
courses[0][idnumber]= string
courses[0][summary]= string
courses[0][summaryformat]= int
courses[0][format]= string
courses[0][showgrades]= int
courses[0][newsitems]= int
courses[0][startdate]= int
courses[0][enddate]= int
courses[0][numsections]= int
courses[0][maxbytes]= int
courses[0][showreports]= int
courses[0][visible]= int
courses[0][hiddensections]= int
courses[0][groupmode]= int
courses[0][groupmodeforce]= int
courses[0][defaultgroupingid]= int
courses[0][enablecompletion]= int
courses[0][completionstartonenrol]= int
courses[0][completionnotify]= int
courses[0][lang]= string
courses[0][forcetheme]= string
courses[0][courseformatoptions][0][name]= string
courses[0][courseformatoptions][0][value]= string
courses[0][audiencevisible]= int
courses[0][coursetype]= int
courses[0][completionprogressonview]= int

Response: General Structure

list of ( 
object {
id int //course id
shortname string //short name
}
)

Response: REST

<?xml version="1.0" encoding="UTF-8" ?>
<RESPONSE>
<MULTIPLE>
<SINGLE>
<KEY name="id">
<VALUE>int</VALUE>
</KEY>
<KEY name="shortname">
<VALUE>string</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</RESPONSE>

Error Message: REST

<?xml version="1.0" encoding="UTF-8"?>
<EXCEPTION class="invalid_parameter_exception">
<MESSAGE>Invalid parameter value detected</MESSAGE>
<DEBUGINFO></DEBUGINFO>
</EXCEPTION>

Back to TOPICS


core_course_delete_courses

This request deletes all specified courses.

Arguments

  • courseids (Required)

General Structure

list of ( 
int //course ID
)

REST (POST Parameters)

courseids[0]= int

Respose: General Structure

object {
warnings Optional //list of warnings
list of ( //warning
object {
item string Optional //item
itemid int Optional //item id
warningcode string //the warning code can be used by the client app to implement specific behaviour
message string //untranslated english message to explain the warning
}
)}

Response: REST

<?xml version="1.0" encoding="UTF-8" ?>
<RESPONSE>
<SINGLE>
<KEY name="warnings">
<MULTIPLE>
<SINGLE>
<KEY name="item">
<VALUE>string</VALUE>
</KEY>
<KEY name="itemid">
<VALUE>int</VALUE>
</KEY>
<KEY name="warningcode">
<VALUE>string</VALUE>
</KEY>
<KEY name="message">
<VALUE>string</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
</SINGLE>
</RESPONSE>

Error Message: REST

<?xml version="1.0" encoding="UTF-8"?>
<EXCEPTION class="invalid_parameter_exception">
<MESSAGE>Invalid parameter value detected</MESSAGE>
<DEBUGINFO></DEBUGINFO>
</EXCEPTION>

Back to TOPICS


core_enrol_get_enrolled_users

This request gets enrolled users by Course ID.

Arguments

  • courseid (Required)

General Structure

int   //course id

REST (POST Parameters)

courseid= int

Options (Default to "Array ( ) ")

     Option names: * withcapability (string) return only users with this capability. This option requires 'moodle/role:review' on the course context. * groupid (integer) return only users in this group id. If the course has groups enabled and this param isn't defined, returns all the viewable users. This option requires 'moodle/site:accessallgroups' on the course context if the user doesn't belong to the group. * onlyactive (integer) return only users with active enrolments and matching time restrictions. This option requires 'moodle/course:enrolreview' on the course context. * userfields ('string, string, ...') return only the values of these user fields. * limitfrom (integer) sql limit from. * limitnumber (integer) maximum number of returned users. * sortby (string) sort by id, firstname or lastname. For ordering like the site does, use siteorder. * sortdirection (string) ASC or DESC

General Structure

 Default to "Array
(
)
"
//Option names:
* withcapability (string) return only users with this capability. This option requires 'moodle/role:review' on the course context.
* groupid (integer) return only users in this group id. If the course has groups enabled and this parameter isn't defined, returns all the viewable users.
This option requires 'moodle/site:accessallgroups' on the course context if the user doesn't belong to the group.
* onlyactive (integer) return only users with active enrolments and matching time restrictions. This option requires 'moodle/course:enrolreview' on the course context.
* userfields ('string, string, ...') return only the values of these user fields.
* limitfrom (integer) sql limit from.
* limitnumber (integer) maximum number of returned users.
* sortby (string) sort by id, firstname or lastname. For ordering like the site does, use siteorder.
* sortdirection (string) ASC or DESC

list of (
object {
name string //option name
value string //option value
}
)

REST (POST Parameters)

options[0][name]= string
options[0][value]= string

Response: General Structure

list of ( 
object {
id int //ID of the user
username string Optional //Username policy is defined in Moodle security config
firstname string Optional //The first name(s) of the user
lastname string Optional //The family name of the user
fullname string //The fullname of the user
email string Optional //An email address - allow email as root@localhost
address string Optional //Postal address
phone1 string Optional //Phone 1
phone2 string Optional //Phone 2
icq string Optional //icq number
skype string Optional //skype id
yahoo string Optional //yahoo id
aim string Optional //aim id
msn string Optional //msn number
department string Optional //department
institution string Optional //institution
idnumber string Optional //An arbitrary ID code number perhaps from the institution
interests string Optional //user interests (separated by commas)
firstaccess int Optional //first access to the site (0 if never)
lastaccess int Optional //last access to the site (0 if never)
description string Optional //User profile description
descriptionformat int Optional //description format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN)
city string Optional //Home city of the user
url string Optional //URL of the user
country string Optional //Home country code of the user, such as AU or CZ
profileimageurlsmall string Optional //User image profile URL - small version
profileimageurl string Optional //User image profile URL - big version
customfields Optional //User custom fields (also known as user profile fields)
list of (
object {
type string //The type of the custom field - text field, checkbox...
value string //The value of the custom field
name string //The name of the custom field
shortname string //The shortname of the custom field - to be able to build the field class in the code
}
)
groups Optional //user groups
list of (
object {
id int //group id
name string //group name
description string //group description
descriptionformat int //description format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN)
}
)
roles Optional //user roles
list of (
object {
roleid int //role id
name string //role name
shortname string //role shortname
sortorder int //role sortorder
}
)
preferences Optional //User preferences
list of (
object {
name string //The name of the preferences
value string //The value of the custom field
}
)
enrolledcourses Optional //Courses where the user is enrolled - limited by which courses the user is able to see
list of (
object {
id int //Id of the course
fullname string //Fullname of the course
shortname string //Shortname of the course
}
)}
)

Response: REST

<?xml version="1.0" encoding="UTF-8" ?>
<RESPONSE>
<MULTIPLE>
<SINGLE>
<KEY name="id">
<VALUE>int</VALUE>
</KEY>
<KEY name="username">
<VALUE>string</VALUE>
</KEY>
<KEY name="firstname">
<VALUE>string</VALUE>
</KEY>
<KEY name="lastname">
<VALUE>string</VALUE>
</KEY>
<KEY name="fullname">
<VALUE>string</VALUE>
</KEY>
<KEY name="email">
<VALUE>string</VALUE>
</KEY>
<KEY name="address">
<VALUE>string</VALUE>
</KEY>
<KEY name="phone1">
<VALUE>string</VALUE>
</KEY>
<KEY name="phone2">
<VALUE>string</VALUE>
</KEY>
<KEY name="icq">
<VALUE>string</VALUE>
</KEY>
<KEY name="skype">
<VALUE>string</VALUE>
</KEY>
<KEY name="yahoo">
<VALUE>string</VALUE>
</KEY>
<KEY name="aim">
<VALUE>string</VALUE>
</KEY>
<KEY name="msn">
<VALUE>string</VALUE>
</KEY>
<KEY name="department">
<VALUE>string</VALUE>
</KEY>
<KEY name="institution">
<VALUE>string</VALUE>
</KEY>
<KEY name="idnumber">
<VALUE>string</VALUE>
</KEY>
<KEY name="interests">
<VALUE>string</VALUE>
</KEY>
<KEY name="firstaccess">
<VALUE>int</VALUE>
</KEY>
<KEY name="lastaccess">
<VALUE>int</VALUE>
</KEY>
<KEY name="description">
<VALUE>string</VALUE>
</KEY>
<KEY name="descriptionformat">
<VALUE>int</VALUE>
</KEY>
<KEY name="city">
<VALUE>string</VALUE>
</KEY>
<KEY name="url">
<VALUE>string</VALUE>
</KEY>
<KEY name="country">
<VALUE>string</VALUE>
</KEY>
<KEY name="profileimageurlsmall">
<VALUE>string</VALUE>
</KEY>
<KEY name="profileimageurl">
<VALUE>string</VALUE>
</KEY>
<KEY name="customfields">
<MULTIPLE>
<SINGLE>
<KEY name="type">
<VALUE>string</VALUE>
</KEY>
<KEY name="value">
<VALUE>string</VALUE>
</KEY>
<KEY name="name">
<VALUE>string</VALUE>
</KEY>
<KEY name="shortname">
<VALUE>string</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
<KEY name="groups">
<MULTIPLE>
<SINGLE>
<KEY name="id">
<VALUE>int</VALUE>
</KEY>
<KEY name="name">
<VALUE>string</VALUE>
</KEY>
<KEY name="description">
<VALUE>string</VALUE>
</KEY>
<KEY name="descriptionformat">
<VALUE>int</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
<KEY name="roles">
<MULTIPLE>
<SINGLE>
<KEY name="roleid">
<VALUE>int</VALUE>
</KEY>
<KEY name="name">
<VALUE>string</VALUE>
</KEY>
<KEY name="shortname">
<VALUE>string</VALUE>
</KEY>
<KEY name="sortorder">
<VALUE>int</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
<KEY name="preferences">
<MULTIPLE>
<SINGLE>
<KEY name="name">
<VALUE>string</VALUE>
</KEY>
<KEY name="value">
<VALUE>string</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
<KEY name="enrolledcourses">
<MULTIPLE>
<SINGLE>
<KEY name="id">
<VALUE>int</VALUE>
</KEY>
<KEY name="fullname">
<VALUE>string</VALUE>
</KEY>
<KEY name="shortname">
<VALUE>string</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
</SINGLE>
</MULTIPLE>
</RESPONSE>

Error Message: REST

<?xml version="1.0" encoding="UTF-8"?>
<EXCEPTION class="invalid_parameter_exception">
<MESSAGE>Invalid parameter value detected</MESSAGE>
<DEBUGINFO></DEBUGINFO>
</EXCEPTION>

Back to TOPICS


core_enrol_get_users_courses

This request gets the list of courses where a specified user is enrolled in.

Arguments

  • userid (Required)

General Structure

int   //user id

REST (POST Parameters)

userid= int

Response: General Structure

list of ( 
object {
id int //id of course
shortname string //short name of course
fullname string //long name of course
enrolledusercount int //Number of enrolled users in this course
idnumber string //id number of course
visible int //1 means visible, 0 means hidden course
summary string Optional //summary
summaryformat int Optional //summary format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN)
format string Optional //course format: weeks, topics, social, site
showgrades int Optional //true if grades are shown, otherwise false
lang string Optional //forced course language
enablecompletion int Optional //true if completion is enabled, otherwise false
category int Optional //course category id
startdate int Optional //Timestamp when the course start
enddate int Optional //Timestamp when the course end
}
)

Response: REST

<?xml version="1.0" encoding="UTF-8" ?>
<RESPONSE>
<MULTIPLE>
<SINGLE>
<KEY name="id">
<VALUE>int</VALUE>
</KEY>
<KEY name="shortname">
<VALUE>string</VALUE>
</KEY>
<KEY name="fullname">
<VALUE>string</VALUE>
</KEY>
<KEY name="enrolledusercount">
<VALUE>int</VALUE>
</KEY>
<KEY name="idnumber">
<VALUE>string</VALUE>
</KEY>
<KEY name="visible">
<VALUE>int</VALUE>
</KEY>
<KEY name="summary">
<VALUE>string</VALUE>
</KEY>
<KEY name="summaryformat">
<VALUE>int</VALUE>
</KEY>
<KEY name="format">
<VALUE>string</VALUE>
</KEY>
<KEY name="showgrades">
<VALUE>int</VALUE>
</KEY>
<KEY name="lang">
<VALUE>string</VALUE>
</KEY>
<KEY name="enablecompletion">
<VALUE>int</VALUE>
</KEY>
<KEY name="category">
<VALUE>int</VALUE>
</KEY>
<KEY name="startdate">
<VALUE>int</VALUE>
</KEY>
<KEY name="enddate">
<VALUE>int</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</RESPONSE>

Error Message: REST

<?xml version="1.0" encoding="UTF-8"?>
<EXCEPTION class="invalid_parameter_exception">
<MESSAGE>Invalid parameter value detected</MESSAGE>
<DEBUGINFO></DEBUGINFO>
</EXCEPTION>

Back to TOPICS


core_user_create_users

This request creates users.

Arguments

  • users (Required)

General Structure

list of ( 
object {
username string //Username policy is defined in Moodle security config.
password string Optional //Plain text password consisting of any characters
createpassword int Optional //True if password should be created and mailed to user.
firstname string //The first name(s) of the user
lastname string //The family name of the user
email string //A valid and unique email address
auth string Default to "manual" //Auth plugins include manual, ldap, imap, etc
idnumber string Default to "" //An arbitrary ID code number perhaps from the institution
lang string Default to "en" //Language code such as "en", must exist on server
calendartype string Default to "gregorian" //Calendar type such as "gregorian", must exist on server
theme string Optional //Theme name such as "standard", must exist on server
timezone string Optional //Timezone code such as Australia/Perth, or 99 for default
mailformat int Optional //Mail format code is 0 for plain text, 1 for HTML etc
description string Optional //User profile description, no HTML
city string Optional //Home city of the user
country string Optional //Home country code of the user, such as AU or CZ
firstnamephonetic string Optional //The first name(s) phonetically of the user
lastnamephonetic string Optional //The family name phonetically of the user
middlename string Optional //The middle name of the user
alternatename string Optional //The alternate name of the user
preferences Optional //User preferences
list of (
object {
type string //The name of the preference
value string //The value of the preference
}
)
customfields Optional //User custom fields (also known as user profile fields)
list of (
object {
type string //The name of the custom field
value string //The value of the custom field
}
)}
)

REST (POST parameters)

users[0][username]= string
users[0][password]= string
users[0][createpassword]= int
users[0][firstname]= string
users[0][lastname]= string
users[0][email]= string
users[0][auth]= string
users[0][idnumber]= string
users[0][lang]= string
users[0][calendartype]= string
users[0][theme]= string
users[0][timezone]= string
users[0][mailformat]= int
users[0][description]= string
users[0][city]= string
users[0][country]= string
users[0][firstnamephonetic]= string
users[0][lastnamephonetic]= string
users[0][middlename]= string
users[0][alternatename]= string
users[0][preferences][0][type]= string
users[0][preferences][0][value]= string
users[0][customfields][0][type]= string
users[0][customfields][0][value]= string

Response: General Structure

list of ( 
object {
id int //user id
username string //user name
}
)

Response: REST

<?xml version="1.0" encoding="UTF-8" ?>
<RESPONSE>
<MULTIPLE>
<SINGLE>
<KEY name="id">
<VALUE>int</VALUE>
</KEY>
<KEY name="username">
<VALUE>string</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</RESPONSE>

Error Message: REST

<?xml version="1.0" encoding="UTF-8"?>
<EXCEPTION class="invalid_parameter_exception">
<MESSAGE>Invalid parameter value detected</MESSAGE>
<DEBUGINFO></DEBUGINFO>
</EXCEPTION>

Back to TOPICS


core_user_delete_users

This request deletes users.

Arguments

  • userids (Required)

General Structure

list of ( 
int //user ID
)

REST (POST Parameters)

userids[0]= int

Error Message: REST

<?xml version="1.0" encoding="UTF-8"?>
<EXCEPTION class="invalid_parameter_exception">
<MESSAGE>Invalid parameter value detected</MESSAGE>
<DEBUGINFO></DEBUGINFO>
</EXCEPTION>

Back to TOPICS


core_user_get_users

This request researches for users matching specified parameters.

Arguments

  • criteria (Required)

     The key/value pairs to be considered in user search. Values can not be empty. Specify different keys only once (fullname => 'user1', auth => 'manual', ...) - key occurences are forbidden. The search is executed with AND operator on the criterias. Invalid criterias (keys) are ignored, the search is still executed on the valid criterias. You can search without criteria, but the function is not designed for it. It could very slow or timeout. The function is designed to search some specific users.

General Structure

  //the key/value pairs to be considered in user search. Values can not be empty.
Specify different keys only once (fullname => 'user1', auth => 'manual', ...) - key occurences are forbidden.
The search is executed with AND operator on the criterias. Invalid criterias (keys) are ignored,the search is still executed on the valid criterias.
You can search without criteria, but the function is not designed for it.
It could very slow or timeout. The function is designed to search some specific users.

list of (
object {
key string //the user column to search, expected keys (value format) are:
"id" (int) matching user id,
"lastname" (string) user last name (Note: you can use % for searching but it may be considerably slower!),
"firstname" (string) user first name (Note: you can use % for searching but it may be considerably slower!),
"idnumber" (string) matching user idnumber,
"username" (string) matching user username,
"email" (string) user email (Note: you can use % for searching but it may be considerably slower!),
"auth" (string) matching user auth plugin

value string //the value to search
}
)

REST (POST Parameters)

criteria[0][key]= string
criteria[0][value]= string

Response: General Structure

object {
users list of (
object {
id int //ID of the user
username string Optional //The username
firstname string Optional //The first name(s) of the user
lastname string Optional //The family name of the user
fullname string //The fullname of the user
email string Optional //An email address - allow email as root@localhost
address string Optional //Postal address
phone1 string Optional //Phone 1
phone2 string Optional //Phone 2
icq string Optional //icq number
skype string Optional //skype id
yahoo string Optional //yahoo id
aim string Optional //aim id
msn string Optional //msn number
department string Optional //department
institution string Optional //institution
idnumber string Optional //An arbitrary ID code number perhaps from the institution
interests string Optional //user interests (separated by commas)
firstaccess int Optional //first access to the site (0 if never)
lastaccess int Optional //last access to the site (0 if never)
auth string Optional //Auth plugins include manual, ldap, imap, etc
suspended int Optional //Suspend user account, either false to enable user login or true to disable it
confirmed int Optional //Active user: 1 if confirmed, 0 otherwise
lang string Optional //Language code such as "en", must exist on server
calendartype string Optional //Calendar type such as "gregorian", must exist on server
theme string Optional //Theme name such as "standard", must exist on server
timezone string Optional //Timezone code such as Australia/Perth, or 99 for default
mailformat int Optional //Mail format code is 0 for plain text, 1 for HTML etc
description string Optional //User profile description
descriptionformat int Optional //int format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN)
city string Optional //Home city of the user
url string Optional //URL of the user
country string Optional //Home country code of the user, such as AU or CZ
profileimageurlsmall string //User image profile URL - small version
profileimageurl string //User image profile URL - big version
customfields Optional //User custom fields (also known as user profile fields)
list of (
object {
type string //The type of the custom field - text field, checkbox...
value string //The value of the custom field
name string //The name of the custom field
shortname string //The shortname of the custom field - to be able to build the field class in the code
}
)
preferences Optional //Users preferences
list of (
object {
name string //The name of the preferences
value string //The value of the preference
}
)}
)
warnings Optional //list of warnings
list of ( //warning
object {
item string Optional //always set to 'key'
itemid int Optional //faulty key name
warningcode string //the warning code can be used by the client app to implement specific behaviour
message string //untranslated english message to explain the warning
}
)}

Response: REST

<?xml version="1.0" encoding="UTF-8" ?>
<RESPONSE>
<SINGLE>
<KEY name="users">
<MULTIPLE>
<SINGLE>
<KEY name="id">
<VALUE>int</VALUE>
</KEY>
<KEY name="username">
<VALUE>string</VALUE>
</KEY>
<KEY name="firstname">
<VALUE>string</VALUE>
</KEY>
<KEY name="lastname">
<VALUE>string</VALUE>
</KEY>
<KEY name="fullname">
<VALUE>string</VALUE>
</KEY>
<KEY name="email">
<VALUE>string</VALUE>
</KEY>
<KEY name="address">
<VALUE>string</VALUE>
</KEY>
<KEY name="phone1">
<VALUE>string</VALUE>
</KEY>
<KEY name="phone2">
<VALUE>string</VALUE>
</KEY>
<KEY name="icq">
<VALUE>string</VALUE>
</KEY>
<KEY name="skype">
<VALUE>string</VALUE>
</KEY>
<KEY name="yahoo">
<VALUE>string</VALUE>
</KEY>
<KEY name="aim">
<VALUE>string</VALUE>
</KEY>
<KEY name="msn">
<VALUE>string</VALUE>
</KEY>
<KEY name="department">
<VALUE>string</VALUE>
</KEY>
<KEY name="institution">
<VALUE>string</VALUE>
</KEY>
<KEY name="idnumber">
<VALUE>string</VALUE>
</KEY>
<KEY name="interests">
<VALUE>string</VALUE>
</KEY>
<KEY name="firstaccess">
<VALUE>int</VALUE>
</KEY>
<KEY name="lastaccess">
<VALUE>int</VALUE>
</KEY>
<KEY name="auth">
<VALUE>string</VALUE>
</KEY>
<KEY name="suspended">
<VALUE>int</VALUE>
</KEY>
<KEY name="confirmed">
<VALUE>int</VALUE>
</KEY>
<KEY name="lang">
<VALUE>string</VALUE>
</KEY>
<KEY name="calendartype">
<VALUE>string</VALUE>
</KEY>
<KEY name="theme">
<VALUE>string</VALUE>
</KEY>
<KEY name="timezone">
<VALUE>string</VALUE>
</KEY>
<KEY name="mailformat">
<VALUE>int</VALUE>
</KEY>
<KEY name="description">
<VALUE>string</VALUE>
</KEY>
<KEY name="descriptionformat">
<VALUE>int</VALUE>
</KEY>
<KEY name="city">
<VALUE>string</VALUE>
</KEY>
<KEY name="url">
<VALUE>string</VALUE>
</KEY>
<KEY name="country">
<VALUE>string</VALUE>
</KEY>
<KEY name="profileimageurlsmall">
<VALUE>string</VALUE>
</KEY>
<KEY name="profileimageurl">
<VALUE>string</VALUE>
</KEY>
<KEY name="customfields">
<MULTIPLE>
<SINGLE>
<KEY name="type">
<VALUE>string</VALUE>
</KEY>
<KEY name="value">
<VALUE>string</VALUE>
</KEY>
<KEY name="name">
<VALUE>string</VALUE>
</KEY>
<KEY name="shortname">
<VALUE>string</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
<KEY name="preferences">
<MULTIPLE>
<SINGLE>
<KEY name="name">
<VALUE>string</VALUE>
</KEY>
<KEY name="value">
<VALUE>string</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
<KEY name="warnings">
<MULTIPLE>
<SINGLE>
<KEY name="item">
<VALUE>string</VALUE>
</KEY>
<KEY name="itemid">
<VALUE>int</VALUE>
</KEY>
<KEY name="warningcode">
<VALUE>string</VALUE>
</KEY>
<KEY name="message">
<VALUE>string</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
</SINGLE>
</RESPONSE>

Error Message: REST

<?xml version="1.0" encoding="UTF-8"?>
<EXCEPTION class="invalid_parameter_exception">
<MESSAGE>Invalid parameter value detected</MESSAGE>
<DEBUGINFO></DEBUGINFO>
</EXCEPTION>

Back to TOPICS


core_user_get_users_by_field

This request retrieves users' information for a specified unique field.

Arguments

  • field (Required)
    • Search field can be 'id' or 'idnumber' or 'username' or 'email'

General Structure

string   //the search field can be'id' or 'idnumber' or 'username' or 'email'

REST (POST Parameters)

field= string

Arguments

  • values (Required)

General Structure

list of ( 
string //the value to match
)

REST (POST Parameters)

values[0]= string

Response: General Structure

list of ( 
object {
id int //ID of the user
username string Optional //The username
firstname string Optional //The first name(s) of the user
lastname string Optional //The family name of the user
fullname string //The fullname of the user
email string Optional //An email address - allow email as root@localhost
address string Optional //Postal address
phone1 string Optional //Phone 1
phone2 string Optional //Phone 2
icq string Optional //icq number
skype string Optional //skype id
yahoo string Optional //yahoo id
aim string Optional //aim id
msn string Optional //msn number
department string Optional //department
institution string Optional //institution
idnumber string Optional //An arbitrary ID code number perhaps from the institution
interests string Optional //user interests (separated by commas)
firstaccess int Optional //first access to the site (0 if never)
lastaccess int Optional //last access to the site (0 if never)
auth string Optional //Auth plugins include manual, ldap, imap, etc
suspended int Optional //Suspend user account, either false to enable user login or true to disable it
confirmed int Optional //Active user: 1 if confirmed, 0 otherwise
lang string Optional //Language code such as "en", must exist on server
calendartype string Optional //Calendar type such as "gregorian", must exist on server
theme string Optional //Theme name such as "standard", must exist on server
timezone string Optional //Timezone code such as Australia/Perth, or 99 for default
mailformat int Optional //Mail format code is 0 for plain text, 1 for HTML etc
description string Optional //User profile description
descriptionformat int Optional //int format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN)
city string Optional //Home city of the user
url string Optional //URL of the user
country string Optional //Home country code of the user, such as AU or CZ
profileimageurlsmall string //User image profile URL - small version
profileimageurl string //User image profile URL - big version
customfields Optional //User custom fields (also known as user profile fields)
list of (
object {
type string //The type of the custom field - text field, checkbox...
value string //The value of the custom field
name string //The name of the custom field
shortname string //The shortname of the custom field - to be able to build the field class in the code
}
)
preferences Optional //Users preferences
list of (
object {
name string //The name of the preferences
value string //The value of the preference
}
)}
)

Response: REST

<?xml version="1.0" encoding="UTF-8" ?>
<RESPONSE>
<MULTIPLE>
<SINGLE>
<KEY name="id">
<VALUE>int</VALUE>
</KEY>
<KEY name="username">
<VALUE>string</VALUE>
</KEY>
<KEY name="firstname">
<VALUE>string</VALUE>
</KEY>
<KEY name="lastname">
<VALUE>string</VALUE>
</KEY>
<KEY name="fullname">
<VALUE>string</VALUE>
</KEY>
<KEY name="email">
<VALUE>string</VALUE>
</KEY>
<KEY name="address">
<VALUE>string</VALUE>
</KEY>
<KEY name="phone1">
<VALUE>string</VALUE>
</KEY>
<KEY name="phone2">
<VALUE>string</VALUE>
</KEY>
<KEY name="icq">
<VALUE>string</VALUE>
</KEY>
<KEY name="skype">
<VALUE>string</VALUE>
</KEY>
<KEY name="yahoo">
<VALUE>string</VALUE>
</KEY>
<KEY name="aim">
<VALUE>string</VALUE>
</KEY>
<KEY name="msn">
<VALUE>string</VALUE>
</KEY>
<KEY name="department">
<VALUE>string</VALUE>
</KEY>
<KEY name="institution">
<VALUE>string</VALUE>
</KEY>
<KEY name="idnumber">
<VALUE>string</VALUE>
</KEY>
<KEY name="interests">
<VALUE>string</VALUE>
</KEY>
<KEY name="firstaccess">
<VALUE>int</VALUE>
</KEY>
<KEY name="lastaccess">
<VALUE>int</VALUE>
</KEY>
<KEY name="auth">
<VALUE>string</VALUE>
</KEY>
<KEY name="suspended">
<VALUE>int</VALUE>
</KEY>
<KEY name="confirmed">
<VALUE>int</VALUE>
</KEY>
<KEY name="lang">
<VALUE>string</VALUE>
</KEY>
<KEY name="calendartype">
<VALUE>string</VALUE>
</KEY>
<KEY name="theme">
<VALUE>string</VALUE>
</KEY>
<KEY name="timezone">
<VALUE>string</VALUE>
</KEY>
<KEY name="mailformat">
<VALUE>int</VALUE>
</KEY>
<KEY name="description">
<VALUE>string</VALUE>
</KEY>
<KEY name="descriptionformat">
<VALUE>int</VALUE>
</KEY>
<KEY name="city">
<VALUE>string</VALUE>
</KEY>
<KEY name="url">
<VALUE>string</VALUE>
</KEY>
<KEY name="country">
<VALUE>string</VALUE>
</KEY>
<KEY name="profileimageurlsmall">
<VALUE>string</VALUE>
</KEY>
<KEY name="profileimageurl">
<VALUE>string</VALUE>
</KEY>
<KEY name="customfields">
<MULTIPLE>
<SINGLE>
<KEY name="type">
<VALUE>string</VALUE>
</KEY>
<KEY name="value">
<VALUE>string</VALUE>
</KEY>
<KEY name="name">
<VALUE>string</VALUE>
</KEY>
<KEY name="shortname">
<VALUE>string</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
<KEY name="preferences">
<MULTIPLE>
<SINGLE>
<KEY name="name">
<VALUE>string</VALUE>
</KEY>
<KEY name="value">
<VALUE>string</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
</SINGLE>
</MULTIPLE>
</RESPONSE>

Error Message: REST

<?xml version="1.0" encoding="UTF-8"?>
<EXCEPTION class="invalid_parameter_exception">
<MESSAGE>Invalid parameter value detected</MESSAGE>
<DEBUGINFO></DEBUGINFO>
</EXCEPTION>

Back to TOPICS


core_user_update_users

This request updates users.

General Structure

list of ( 
object {
id int //ID of the user
username string Optional //Username policy is defined in Moodle security config.
password string Optional //Plain text password consisting of any characters
firstname string Optional //The first name(s) of the user
lastname string Optional //The family name of the user
email string Optional //A valid and unique email address
auth string Optional //Auth plugins include manual, ldap, imap, etc
suspended int Optional //Suspend user account, either false to enable user login or true to disable it
idnumber string Optional //An arbitrary ID code number perhaps from the institution
lang string Optional //Language code such as "en", must exist on server
calendartype string Optional //Calendar type such as "gregorian", must exist on server
theme string Optional //Theme name such as "standard", must exist on server
timezone string Optional //Timezone code such as Australia/Perth, or 99 for default
mailformat int Optional //Mail format code is 0 for plain text, 1 for HTML etc
description string Optional //User profile description, no HTML
city string Optional //Home city of the user
country string Optional //Home country code of the user, such as AU or CZ
firstnamephonetic string Optional //The first name(s) phonetically of the user
lastnamephonetic string Optional //The family name phonetically of the user
middlename string Optional //The middle name of the user
alternatename string Optional //The alternate name of the user
userpicture int Optional //The itemid where the new user picture has been uploaded to, 0 to delete
customfields Optional //User custom fields (also known as user profil fields)
list of (
object {
type string //The name of the custom field
value string //The value of the custom field
}
)
preferences Optional //User preferences
list of (
object {
type string //The name of the preference
value string //The value of the preference
}
)}
)

REST (POST Parameters)

users[0][id]= int
users[0][username]= string
users[0][password]= string
users[0][firstname]= string
users[0][lastname]= string
users[0][email]= string
users[0][auth]= string
users[0][suspended]= int
users[0][idnumber]= string
users[0][lang]= string
users[0][calendartype]= string
users[0][theme]= string
users[0][timezone]= string
users[0][mailformat]= int
users[0][description]= string
users[0][city]= string
users[0][country]= string
users[0][firstnamephonetic]= string
users[0][lastnamephonetic]= string
users[0][middlename]= string
users[0][alternatename]= string
users[0][userpicture]= int
users[0][customfields][0][type]= string
users[0][customfields][0][value]= string
users[0][preferences][0][type]= string
users[0][preferences][0][value]= string

Error Message: REST

<?xml version="1.0" encoding="UTF-8"?>
<EXCEPTION class="invalid_parameter_exception">
<MESSAGE>Invalid parameter value detected</MESSAGE>
<DEBUGINFO></DEBUGINFO>
</EXCEPTION>

Back to TOPICS


enrol_manual_enrol_users

This request manually enrols users.

Arguments

  • enrolments (Required)

General Structure

list of ( 
object {
roleid int //Role to assign to the user
userid int //The user that is going to be enrolled
courseid int //The course to enrol the user role in
timestart int Optional //Timestamp when the enrolment start
timeend int Optional //Timestamp when the enrolment end
suspend int Optional //set to 1 to suspend the enrolment
}
)

REST (POST Parameters)

enrolments[0][roleid]= int
enrolments[0][userid]= int
enrolments[0][courseid]= int
enrolments[0][timestart]= int
enrolments[0][timeend]= int
enrolments[0][suspend]= int

Error Message: REST

<?xml version="1.0" encoding="UTF-8"?>
<EXCEPTION class="invalid_parameter_exception">
<MESSAGE>Invalid parameter value detected</MESSAGE>
<DEBUGINFO></DEBUGINFO>
</EXCEPTION>

Back to TOPICS


enrol_manual_unenrol_users

This request manually unenrols users.

Arguments

  • enrolments (Required)

General Structure

list of ( 
object {
userid int //The user that is going to be unenrolled
courseid int //The course to unenrol the user from
roleid int Optional //The user role
}
)

REST (POST Parameters)

enrolments[0][userid]= int
enrolments[0][courseid]= int
enrolments[0][roleid]= int

Error Message: REST

<?xml version="1.0" encoding="UTF-8"?>
<EXCEPTION class="invalid_parameter_exception">
<MESSAGE>Invalid parameter value detected</MESSAGE>
<DEBUGINFO></DEBUGINFO>
</EXCEPTION>

Back to TOPICS


gradereport_overview_get_course_grades

This request gets the specified user courses' final grades.

Arguments

  • userid (Default to "0")
  • Get grades for this user (optional, default current)

General Structure

int  Default to "0" //Get grades for this user (optional, default current)

REST (POST Parameters)

userid= int

Response: General Structure

object {
grades list of (
object {
courseid int //Course id
grade string //Grade formatted
rawgrade string //Raw grade, not formatted
rank int Optional //Your rank in the course
}
)
warnings Optional //list of warnings
list of ( //warning
object {
item string Optional //item
itemid int Optional //item id
warningcode string //the warning code can be used by the client app to implement specific behaviour
message string //untranslated english message to explain the warning
}
)}

Response: REST

<?xml version="1.0" encoding="UTF-8" ?>
<RESPONSE>
<SINGLE>
<KEY name="grades">
<MULTIPLE>
<SINGLE>
<KEY name="courseid">
<VALUE>int</VALUE>
</KEY>
<KEY name="grade">
<VALUE>string</VALUE>
</KEY>
<KEY name="rawgrade">
<VALUE>string</VALUE>
</KEY>
<KEY name="rank">
<VALUE>int</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
<KEY name="warnings">
<MULTIPLE>
<SINGLE>
<KEY name="item">
<VALUE>string</VALUE>
</KEY>
<KEY name="itemid">
<VALUE>int</VALUE>
</KEY>
<KEY name="warningcode">
<VALUE>string</VALUE>
</KEY>
<KEY name="message">
<VALUE>string</VALUE>
</KEY>
</SINGLE>
</MULTIPLE>
</KEY>
</SINGLE>
</RESPONSE>

Error Message: REST

<?xml version="1.0" encoding="UTF-8"?>
<EXCEPTION class="invalid_parameter_exception">
<MESSAGE>Invalid parameter value detected</MESSAGE>
<DEBUGINFO></DEBUGINFO>
</EXCEPTION>

Back to TOPICS