diff --git a/local/o365/classes/feature/sds/task/sync.php b/local/o365/classes/feature/sds/task/sync.php index a602465a8..1ad9569f9 100644 --- a/local/o365/classes/feature/sds/task/sync.php +++ b/local/o365/classes/feature/sds/task/sync.php @@ -128,15 +128,30 @@ public static function runsync(unified $apiclient) : bool { $studentstudentnumber = ''; $teacherexternalid = ''; $teacherteachernumber = ''; - if (array_key_exists('student', $processedschooluser)) { - $studentexternalid = $processedschooluser['student']['externalId']; - $studentbirthdate = $processedschooluser['student']['birthDate']; - $studentgrade = $processedschooluser['student']['grade']; - $studentgraduationyear = $processedschooluser['student']['graduationYear']; - $studentstudentnumber = $processedschooluser['student']['studentNumber']; - } else if (array_key_exists('teacher', $processedschooluser)) { - $teacherexternalid = $processedschooluser['teacher']['externalId']; - $teacherteachernumber = $processedschooluser['teacher']['teacherNumber']; + if ($primaryrole == 'student' && isset($processedschooluser['student'])) { + if (isset($processedschooluser['student']['externalId'])) { + $studentexternalid = $processedschooluser['student']['externalId']; + } + if (isset($processedschooluser['student']['birthDate'])) { + $studentbirthdate = $processedschooluser['student']['birthDate']; + } + if (isset($processedschooluser['student']['grade'])) { + $studentgrade = $processedschooluser['student']['grade']; + } + if (isset($processedschooluser['student']['graduationYear'])) { + $studentgraduationyear = $processedschooluser['student']['graduationYear']; + } + if (isset($processedschooluser['student']['studentNumber'])) { + $studentstudentnumber = $processedschooluser['student']['studentNumber']; + } + } + if ($primaryrole == 'teacher' && isset($processedschooluser['teacher'])) { + if (isset($processedschooluser['teacher']['externalId'])) { + $teacherexternalid = $processedschooluser['teacher']['externalId']; + } + if (isset($processedschooluser['teacher']['teacherNumber'])) { + $teacherteachernumber = $processedschooluser['teacher']['teacherNumber']; + } } foreach ($additionalprofilemappings as $remotefield => $localfield) { diff --git a/local/o365/lang/en/local_o365.php b/local/o365/lang/en/local_o365.php index 556334d41..6f645ef15 100644 --- a/local/o365/lang/en/local_o365.php +++ b/local/o365/lang/en/local_o365.php @@ -553,7 +553,8 @@ $string['settings_sds_profilesync_disabled'] = 'Disabled'; $string['settings_sds_profilesync'] = 'Sync profile data from school'; $string['settings_sds_profilesync_desc'] = 'Select the SDS school from which Moodle synchronises SDS specific profile data.
-Note synchronisation of SDS fields will only happen when running the "Sync with SDS" scheduled task, and will not happen when running the "Sync users with Azure AD" scheduled task, nor when user logs in.'; +Note synchronisation of SDS fields will only happen when running the "Sync with SDS" scheduled task, and will not happen when running the "Sync users with Azure AD" scheduled task, nor when user logs in.
+Note there is a known issue in Microsoft Graph API used by this feature that certain student and teacher school profile fields are not returned, therefore are unavilable to sync even when configured.'; $string['settings_sds_noschools'] = '
You do not have any schools available in School data sync.
'; $string['settings_sds_get_schools_error'] = '
Failed to get SDS schools. Check the Azure app has required permission.
'; $string['settings_sds_school_disabled_action'] = 'School sync disabled action';