Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-51568

New Web Service enrol_self_enrol_user

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.9.2
    • Fix Version/s: 3.0
    • Component/s: Enrolments
    • Labels:
    • Testing Instructions:
      Hide
      1. Create a new course, doest not enrol any user.
      2. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      3. Create a Token for any user in the site (not a global admin)
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      4. Next, you can do a CURL REST call simulating a WS client with the user.
        • You need to replace the wstoken, courseid and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=enrol_self_enrol_user&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&courseid=9'

      5. Confirm that you receive an error: canntenrol Enrolment is disabled or inactive
      6. Now, enable the self enrolment method in the course settings ▶︎ Users ▶︎ Enrolment methods
      7. Run the curl command again:
      8. You should see now {"status":true,"warnings":[]}

        , check that the user is enrolled in Settings ▶︎ Users ▶︎ Enrolled users

      9. Remove the enrolment
      10. Go to the self enrolment settings and add a Enrolment key: abc
      11. Run this command (replacing courseid, token, etc..)

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=enrol_self_enrol_user&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&courseid=9&password=abc'

      12. Confirm that the user is enrolled
      13. Now, change the different security settings of the plugin: For example Allow new enrolments to no or max enrolled users and check that you got errors
      14. Now, enable groups in the course and create a couple of groups. One group with a enrolment password "def" (or a different password but different that the self enrol plugin) and, in the self enrolment pluging settings set Use group enrolment keys to yes
      15. Run the CURL command again changing the password, and check that the user is enrolled in the course group
      Show
      Create a new course, doest not enrol any user. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for any user in the site (not a global admin) Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the user. You need to replace the wstoken, courseid and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=enrol_self_enrol_user&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&courseid=9' Confirm that you receive an error: canntenrol Enrolment is disabled or inactive Now, enable the self enrolment method in the course settings ▶︎ Users ▶︎ Enrolment methods Run the curl command again: You should see now {"status":true,"warnings":[]} , check that the user is enrolled in Settings ▶︎ Users ▶︎ Enrolled users Remove the enrolment Go to the self enrolment settings and add a Enrolment key: abc Run this command (replacing courseid, token, etc..) curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=enrol_self_enrol_user&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&courseid=9&password=abc' Confirm that the user is enrolled Now, change the different security settings of the plugin: For example Allow new enrolments to no or max enrolled users and check that you got errors Now, enable groups in the course and create a couple of groups. One group with a enrolment password "def" (or a different password but different that the self enrol plugin) and, in the self enrolment pluging settings set Use group enrolment keys to yes Run the CURL command again changing the password, and check that the user is enrolled in the course group
    • Affected Branches:
      MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_30_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-51568-master

      Description

      New Web Service for auto-enrolling users (passing as parameter the course id and optionally a password)

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                16/Nov/15