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

Create a web service function that enrols a user in a course, without knowing the id of the user, or the contextid of the course

XMLWordPrintable

    • MOODLE_20_STABLE

      As an external service, I want to enrol users in courses. But I don't know the id of the user, or the contextid of the course.

      Solution: expose something like the following:

      enrol_user(array $user, array $course, array $role)

      For example, any of the following should work:

      enrol_user(array('username'  => 'chrisf') , 
                 array('shortname' => 'PHP 101'),
                 array('shortname' => 'student')
      );
       
      enrol_user(array('idnumber'  => '0123456'), 
                 array('idnumber'  => '2010-2012-PHP101'), 
                 array('id'        => '3')
      );
       
      enrol_user(array('email'     => 'chrisf@example.com'),
                 array('fullname'  => 'Introduction to PHP programming'),
                 array('name'      => 'Student')
      );

      Looks a bit like MDL-26250 and MDL-26251

            Unassigned Unassigned
            chrisf Chris Fryer
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.