Mnet: enrol/mnet: Return enrol plugin type with list of enrolled users

This commit is contained in:
donal72 2007-01-17 23:03:18 +00:00
parent 92e46c0305
commit 68ea70b45f
2 changed files with 14 additions and 9 deletions

View File

@ -70,7 +70,7 @@ class enrolment_plugin_mnet {
$enrol = array();
$enrol['name'] = 'mnet_enrol'; // Name & Description go in lang file
$enrol['apiversion'] = 1;
$enrol['methods'] = array('available_courses','user_enrolments', 'enrol_user', 'unenrol_user' );
$enrol['methods'] = array('available_courses','user_enrolments', 'enrol_user', 'unenrol_user', 'course_enrolments' );
return array($enrol);
}
@ -234,6 +234,13 @@ class enrolment_plugin_mnet {
return array();
}
/**
*
*/
function user_enrolments($userid) {
return array();
}
/**
* Get a list of users from the client server who are enrolled in a course
*
@ -242,7 +249,7 @@ class enrolment_plugin_mnet {
* @return array Array of usernames who are homed on the
* client machine
*/
function user_enrolments($courseid, $roles = '') {
function course_enrolments($courseid, $roles = '') {
global $MNET_REMOTE_CLIENT, $CFG;
if (! $course = get_record('course', 'id', $courseid) ) {
@ -255,7 +262,8 @@ class enrolment_plugin_mnet {
$sql = "
SELECT
u.id,
u.username
u.username,
a.enrol
FROM
{$CFG->prefix}role_assignments a,
{$CFG->prefix}user u
@ -271,14 +279,11 @@ class enrolment_plugin_mnet {
a.roleid in ('".str_replace(',', "', '", $roles)."')";
}
$f = fopen('/tmp/sql.sql', 'w');
fwrite($f, $sql);
$enrolments = get_records_sql($sql);
$returnarray = array();
foreach($enrolments as $user) {
$returnarray[] = $user->username;
$returnarray[] = array('username' => $user->username, 'enrol' => $user->enrol);
}
return $returnarray;
}

View File

@ -79,7 +79,7 @@
$mnet_request = new mnet_xmlrpc_client();
/// Pass it the path to the method that we want to execute
$mnet_request->set_method('enrol/mnet/enrol.php/user_enrolments');
$mnet_request->set_method('enrol/mnet/enrol.php/course_enrolments');
$mnet_request->add_param($course->remoteid, 'int');
$mnet_request->send($mnet_peer);
$all_enrolled_users = $mnet_request->response;
@ -93,7 +93,7 @@
/// themselves, etc.
if (is_array($all_enrolled_users) && count($all_enrolled_users)) {
foreach($all_enrolled_users as $user) {
$all_enrolled_usernames .= "'{$user}', ";
$all_enrolled_usernames .= "'{$user['username']}', ";
}
$select = ' u.username IN (' .substr($all_enrolled_usernames, 0, -2) .') AND';
}