<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Udara Jayawardena</title>
    <description>The latest articles on DEV Community by Udara Jayawardena (@udarajayawardena).</description>
    <link>https://dev.to/udarajayawardena</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F303356%2F59dd2114-5c7f-4491-91c2-26f26cc95052.jpg</url>
      <title>DEV Community: Udara Jayawardena</title>
      <link>https://dev.to/udarajayawardena</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/udarajayawardena"/>
    <language>en</language>
    <item>
      <title>Moodle Web Service APIs</title>
      <dc:creator>Udara Jayawardena</dc:creator>
      <pubDate>Sat, 31 Oct 2020 13:22:00 +0000</pubDate>
      <link>https://dev.to/udarajayawardena/moodle-web-service-apis-51k4</link>
      <guid>https://dev.to/udarajayawardena/moodle-web-service-apis-51k4</guid>
      <description>&lt;p&gt;Moodle is a free open source learning management system written in PHP. Moodle is modular base Object Oriented dynamic learning platform that is designed to help educators, administrators, teachers and students to interact with each other through the platform share personalized resources.&lt;/p&gt;

&lt;p&gt;Moodle has web services API allows you to expose your plugin's functions such as internal core functionalities like user creation, update, delete, enroll, unenroll, create events and many more..&lt;/p&gt;

&lt;p&gt;To do that first of all system administrator has to enable the web services that can be used by rest API endpoints/ once you have done this, your system core functionalities will be accessible to other systems through Web services using one of a number of protocols, like XML-RPC, REST(Most used) or SOAP.&lt;/p&gt;

&lt;p&gt;Each of the web service can be accessible with a token that created by system administrator. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;These are some of the main core functions&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;core_user_create_users&lt;/li&gt;
&lt;li&gt;core_user_update_users&lt;/li&gt;
&lt;li&gt;local_gdpr_deleteuserdata_single&lt;/li&gt;
&lt;li&gt;core_course_create_courses&lt;/li&gt;
&lt;li&gt;core_course_create_categories&lt;/li&gt;
&lt;li&gt;enrol_manual_enrol_users&lt;/li&gt;
&lt;li&gt;enrol_manual_unenrol_users&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="http://DOMAIN_OR_IP/webservice/rest/server.php?wstoken=TOKEN&amp;amp;moodlewsrestformat=JSON&amp;amp;wsfunction=FUNCTION"&gt;http://DOMAIN_OR_IP/webservice/rest/server.php?wstoken=TOKEN&amp;amp;moodlewsrestformat=JSON&amp;amp;wsfunction=FUNCTION&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This Rest API enable you to create, update, delete internal resources form the database.&lt;/p&gt;

&lt;h1&gt;
  
  
  1. Create User
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Function Name : - core_user_create_users (Internal Plugin)&lt;br&gt;
Token : - Generated by Site administrator.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this function you can create a user in the moodle database.&lt;/p&gt;

&lt;h3&gt;
  
  
  Parameters
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;users[0][username]&lt;/li&gt;
&lt;li&gt;users[0][email]&lt;/li&gt;
&lt;li&gt;users[0][lastname]&lt;/li&gt;
&lt;li&gt;users[0][firstname]&lt;/li&gt;
&lt;li&gt;users[0][password]&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  2. Update User
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Function Name : - core_user_update_users (Internal Plugin)&lt;br&gt;
Token : - Generated by Site administrator.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this function you can change existing user model details in the database.&lt;/p&gt;

&lt;h3&gt;
  
  
  Parameters
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;users[0][username]&lt;/li&gt;
&lt;li&gt;users[0][email]&lt;/li&gt;
&lt;li&gt;users[0][lastname]&lt;/li&gt;
&lt;li&gt;users[0][firstname]&lt;/li&gt;
&lt;li&gt;users[0][password]&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  3. Delete User
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Function Name: - local_gdpr_deleteuserdata_single (External plugin) can learn more about the plugin in &lt;a href="https://github.com/dmanolescu/moodle-local_gdpr_deleteuserdata"&gt;here&lt;/a&gt;&lt;br&gt;
Token : - Generated by Site administrator.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this function you can delete an existing user from the database.&lt;/p&gt;

&lt;h3&gt;
  
  
  Parameters
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;parameters[userid]&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  4. Create Category
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Function Name: - core_course_create_categories (Internal plugin)&lt;br&gt;
Token : - Generated by Site administrator.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this function you can create a category in the database.&lt;/p&gt;

&lt;h3&gt;
  
  
  Parameters
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;categories[0][name]&lt;/li&gt;
&lt;li&gt;categories[0][parent]&lt;/li&gt;
&lt;li&gt;categories[0][description]&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  5. Create Courses
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Function Name: - core_course_create_courses (Internal plugin)&lt;br&gt;
Token : - Generated by Site administrator.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this function you can create a course and a relation with an existing category to the course(Mentioned above in example 4).&lt;/p&gt;

&lt;h3&gt;
  
  
  Parameters
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;courses[0][fullname]&lt;/li&gt;
&lt;li&gt;courses[0][categoryid]&lt;/li&gt;
&lt;li&gt;courses[0][shortname]&lt;/li&gt;
&lt;li&gt;courses[0][summary]&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  6. Enrol Users
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Function Name : - enrol_manual_enrol_users (Internal plugin)&lt;br&gt;
Token : - Generated by Site administrator.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this function you can assign a role to an existing user in the database such as Student role, Teacher role, Sys admin role.&lt;/p&gt;

&lt;h3&gt;
  
  
  Parameters
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;enrolments[0][roleid]&lt;/li&gt;
&lt;li&gt;enrolments[0][userid]&lt;/li&gt;
&lt;li&gt;enrolments[0][courseid]&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  7. UnEnrol Users
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Function Name: -enrol_manual_unenrol_users (Internal plugin)&lt;br&gt;
Token : - Generated by Site administrator.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this function you can un enroll a user from the database.&lt;/p&gt;

&lt;h3&gt;
  
  
  Parameters
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;enrolments[0][roleid]&lt;/li&gt;
&lt;li&gt;enrolments[0][userid]&lt;/li&gt;
&lt;li&gt;enrolments[0][courseid]&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Read more about Moodle web services&lt;br&gt;
👉 &lt;a href="https://docs.moodle.org/dev/Web_service_API_functions"&gt;https://docs.moodle.org/dev/Web_service_API_functions&lt;/a&gt;&lt;br&gt;
👉 &lt;a href="https://docs.moodle.org/dev/Core_APIs"&gt;https://docs.moodle.org/dev/Core_APIs&lt;/a&gt;&lt;br&gt;
👉 &lt;a href="https://docs.moodle.org/39/en/Using_web_services"&gt;https://docs.moodle.org/39/en/Using_web_services&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;if you guys have any issue, send me a mail &lt;a href="mailto:udarajayawardena5@gmail.com"&gt;udarajayawardena5@gmail.com&lt;/a&gt;&lt;br&gt;
Hope you guys like the blog and learn something new!&lt;br&gt;
A ❤️ would be Awesome... 😊 #UJ&lt;/p&gt;

</description>
      <category>moodle</category>
      <category>lms</category>
    </item>
  </channel>
</rss>
