Skip to content

Commit

Permalink
Merge branch 'wip-MSFTMPP-647-m32' into MOODLE_32_RC
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmcq committed Oct 31, 2017
2 parents d6d8dae + 6f1865c commit 8a5d88d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 4 additions & 3 deletions local/o365/classes/feature/usergroups/coursegroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,13 @@ public function resync_group_membership($courseid, $groupobjectid = null, $curre
$coursecontext = \context_course::instance($courseid);
list($esql, $params) = get_enrolled_sql($coursecontext);
$sql = "SELECT u.id,
tok.oidcuniqid as userobjectid
objs.objectid as userobjectid
FROM {user} u
JOIN ($esql) je ON je.id = u.id
JOIN {auth_oidc_token} tok ON tok.username = u.username AND tok.resource = :tokresource
WHERE u.deleted = 0";
JOIN {local_o365_objects} objs ON objs.moodleid = u.id
WHERE u.deleted = 0 AND objs.type = :user";
$params['tokresource'] = 'https://graph.windows.net';
$params['user'] = 'user';
$enrolled = $this->DB->get_recordset_sql($sql, $params);
foreach ($enrolled as $user) {
$intendedmembers[$user->userobjectid] = $user->id;
Expand Down
12 changes: 11 additions & 1 deletion local/o365/tests/coursegroups_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function test_resync_group_membership() {
$this->getDataGenerator()->create_user(),
];

// Create tokens for users.
// Create tokens and objects for users.
foreach ($users as $i => $user) {
$tokenrec = [
'oidcuniqid' => 'user'.$i,
Expand All @@ -172,6 +172,16 @@ public function test_resync_group_membership() {
'expiry' => time() + 9999,
];
$tokenrec['id'] = $DB->insert_record('auth_oidc_token', (object)$tokenrec);

$objectrec = [
'moodleid' => $user->id,
'type' => 'user',
'objectid' => 'user'.$i,
'o365name' => 'testuser'.$i.'@example.onmicrosoft.com',
'timecreated' => time(),
'timemodified' => time(),
];
$objectrec['id'] = $DB->insert_record('local_o365_objects', (object)$objectrec);
}

// Enrol users.
Expand Down

0 comments on commit 8a5d88d

Please sign in to comment.