Singleton providing various functionality usable by plugin(s) implementing this MNet service.
More...
|
| format_error_message ($errormsg) |
| Prepares error messages returned by our XML-RPC requests to be send as debug info to {.
|
|
| get_remote_courses ($mnethostid, $usecache=true) |
| Fetches the information about the courses available on remote host for our students.
|
|
| get_remote_publishers () |
| Returns a list of remote servers that offer their courses for our users.
|
|
| get_remote_subscribers () |
| Returns a list of remote servers that can enrol their users into our courses.
|
|
| is_available () |
| Is this service enabled?
|
|
| req_course_enrolments ($mnethostid, $remotecourseid) |
| Updates local cache about enrolments of our users in remote courses.
|
|
| req_enrol_user (stdclass $user, stdclass $remotecourse) |
| Send request to enrol our user to the remote course.
|
|
| req_unenrol_user (stdclass $user, stdclass $remotecourse) |
| Send request to unenrol our user from the remote course.
|
|
Singleton providing various functionality usable by plugin(s) implementing this MNet service.
◆ format_error_message()
mnetservice_enrol::format_error_message |
( |
| $errormsg | ) |
|
Prepares error messages returned by our XML-RPC requests to be send as debug info to {.
- See also
- moodle_exception()}
MNet client-side methods in this class return request error as serialized array.
- Parameters
-
string | $error | serialized array |
- Return values
-
◆ get_instance()
static mnetservice_enrol::get_instance |
( |
| ) |
|
|
static |
◆ get_remote_courses()
mnetservice_enrol::get_remote_courses |
( |
| $mnethostid, |
|
|
| $usecache = true ) |
Fetches the information about the courses available on remote host for our students.
The information about remote courses available for us is cached in {mnetservice_enrol_courses}. This method either returns the cached information (typically when displaying the list to students) or fetch fresh data via new XML-RPC request (which updates the local cache, too). The lifetime of the cache is 1 day, so even if $usecache is set to true, the cache will be re-populated if we did not fetch from any server (not only the currently requested one) for some time.
- Parameters
-
id | $mnethostid | MNet remote host id |
bool | $usecache | use cached data or invoke new XML-RPC? @uses mnet_xmlrpc_client Invokes XML-RPC request if the cache is not used |
- Return values
-
array|string | returned list or serialized array of mnet error messages |
◆ get_remote_publishers()
mnetservice_enrol::get_remote_publishers |
( |
| ) |
|
Returns a list of remote servers that offer their courses for our users.
We must subscribe MNet service 'mnet_enrol' for the peers to allow our users to enrol into their courses.
- Todo
once the MNet core is refactored this may be part of a parent class
the name of the service should be changed to the name of this plugin
- Return values
-
◆ get_remote_subscribers()
mnetservice_enrol::get_remote_subscribers |
( |
| ) |
|
Returns a list of remote servers that can enrol their users into our courses.
We must publish MNet service 'mnet_enrol' for the peers to allow them to enrol their users into our courses.
- Todo
once the MNet core is refactored this may be part of a parent class
the name of the service should be changed to the name of this plugin
- Return values
-
◆ is_available()
mnetservice_enrol::is_available |
( |
| ) |
|
Is this service enabled?
Currently, this checks if whole MNet is available. In the future, additional checks can be done. Probably the field 'offer' should be checked but it does not seem to be used so far.
- Todo
- move this to some parent class once we have such
- Return values
-
◆ req_course_enrolments()
mnetservice_enrol::req_course_enrolments |
( |
| $mnethostid, |
|
|
| $remotecourseid ) |
Updates local cache about enrolments of our users in remote courses.
The remote course must allow enrolments via our Remote enrolment service client. Because of legacy design of data structure returned by XML-RPC code, only one user enrolment per course is returned by 1.9 MNet servers. This may be an issue if the user is enrolled multiple times by various enrolment plugins. MNet 2.0 servers do not use user name as array keys - they do not need to due to side effect of MDL-19219.
- Parameters
-
id | $mnethostid | MNet remote host id |
int | $remotecourseid | ID of the course at the remote host |
bool | $usecache | use cached data or invoke new XML-RPC? @uses mnet_xmlrpc_client Invokes XML-RPC request |
- Return values
-
bool|string | true if success or serialized array of mnet error messages |
◆ req_enrol_user()
mnetservice_enrol::req_enrol_user |
( |
stdclass | $user, |
|
|
stdclass | $remotecourse ) |
Send request to enrol our user to the remote course.
Updates our remote enrolments cache if the enrolment was successful.
@uses mnet_xmlrpc_client Invokes XML-RPC request
- Parameters
-
object | $user | our user |
object | $remotecourse | record from mnetservice_enrol_courses table |
- Return values
-
true|string | true if success, error message from the remote host otherwise |
◆ req_unenrol_user()
mnetservice_enrol::req_unenrol_user |
( |
stdclass | $user, |
|
|
stdclass | $remotecourse ) |
Send request to unenrol our user from the remote course.
Updates our remote enrolments cache if the unenrolment was successful.
@uses mnet_xmlrpc_client Invokes XML-RPC request
- Parameters
-
object | $user | our user |
object | $remotecourse | record from mnetservice_enrol_courses table |
- Return values
-
true|string | true if success, error message from the remote host otherwise |
The documentation for this class was generated from the following file:
- mnet/service/enrol/locallib.php