我们在教育环境中使用Microsoft Graph API来存储有关由老师创建的学生的数据。我们正在尝试找出一种方法来确定:
如果用户是学生或老师。根据文档看来,should be possible似乎是这样,但是基于有关Stack Overflow的评论以及我们所看到的,这仅在学校使用SDS且我们使用应用程序而不是委派权限的情况下才有效。
我们想以某种方式确定学生是否由老师教给学生。我们看不到任何明确的方法可以做到这一点。我们能弄清楚的唯一方法是扫描学生的所有班级,然后找到用户为所有者的班级/教那些班级。
答案 0 :(得分:3)
从技术上讲,您不需要使用School Data Sync(SDS),但确实可以使数据使用起来更容易且更一致。这是因为SDS每次同步都会自动填充primaryRole
,teacher
和student
数据。如果没有SDS,则需要由您的应用程序确定和更新。这通常是不平凡的练习。
也就是说,有几种方法可以确定用户是学生还是教师,而无需依靠primaryRole
。更直接的方法是/taughtClasses
端点。这将返回用户拥有/授课的类的集合:
GET beta/education/users/{id|userPrincipalName}/taughtClasses
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.educationClass)",
"value": [
{
"id": "c4c1b1e9-bd8e-4ffc-acb4-e7745342bf6d",
"description": "PrimaryTestClass",
"displayName": "PrimaryTestClass",
"mailNickname": "PrimaryTestClass",
"classCode": "21001",
"externalName": "PrimaryTestClass",
"externalId": "21001",
"externalSource": "sis",
"term": {
"externalId": "12000",
"startDate": "2017-07-01",
"endDate": "2018-06-30",
"displayName": "SY1516"
},
"course": {
"subject": "PrimaryTestClass",
"courseNumber": "101",
"description": "PrimaryTestClass",
"displayName": "PrimaryTestClass",
"externalId": "21001"
}
},
{
"id": "8a15c9c0-13ed-464a-81ec-a6fb2d571599",
"description": "Health Level 1",
"displayName": "Health 1",
"mailNickname": "fineartschool.net",
"externalSource": "sis",
"externalName": "Health Level 1",
"externalId": "11019",
"classCode": "Health 501",
"createdBy": {
"application": {
"id": "a0c464d5-af1f-4bb9-bbdd-196bd577c796"
},
"user": {
"id": "7cea8be3-ceec-4200-b224-4845c8e38363"
}
}
}
]
}
确定由哪个老师教哪些学生比较棘手。您可以使用beta/education/users/{id}/classes
获取其所属的班级列表,但随后需要遍历 列表以通过查询beta/education/classes/c4c1b1e9-bd8e-4ffc-acb4-e7745342bf6d/teachers?$select=id,userPrincipalName
来获取每个班级的教师列表。编制完整的教师名单。
对于应用程序还是委托,对于委托范围,Education API有意地非常严格。这是由于学生信息的高度敏感性质以及该数据接收到的可理解的安全审查级别。