microsoft-graph-apimicrosoft-graph-edu

How to retrieve referenced entities returned by List Assignments


I'm calling the List Assignments endpoint in Microsoft Graph. It returns an array of classes with one of the classes shown below.

How do I unpack the referenced entity microsoft.graph.educationAssignmentClassRecipient to get the recipient list?

{
    "classId": "bef6024d-c51d-4c2d-9c4c-4e290581e7b4",
    "displayName": "Teleschool Week 5 Formative Grade",
    "closeDateTime": null,
    "dueDateTime": "2020-04-28T03:59:59Z",
    "assignDateTime": null,
    "assignedDateTime": "2020-04-24T15:51:00.8911402Z",
    "allowLateSubmissions": true,
    "createdDateTime": "2020-04-24T15:50:39.9443371Z",
    "lastModifiedDateTime": "2020-04-24T15:51:03.7407937Z",
    "allowStudentsToAddResourcesToSubmission": true,
    "status": "assigned",
    "id": "66e4a8f8-42ee-49e0-9503-e24a49be6908",
    "instructions": {
        "content": "",
        "contentType": "text"
    },
    "grading": {
        "@odata.type": "#microsoft.graph.educationAssignmentPointsGradeType",
        "maxPoints": 100
    },
    "assignTo": {
        "@odata.type": "#microsoft.graph.educationAssignmentClassRecipient"
    }

Solution

  • educationAssignmentClassRecipient {pasted from documentation}:

    Used inside the assignment.assignTo property. When set to class recipient, every student in the class will receive a submission object when the assignment is published.

    This resource is a subclass of educationAssignmentRecipient.

    For an assignment that is handed out to the whole class, it'll contain the classRecipient data type.

    For classRecipient, we do not include the full list of userIds. But you can query the ~/groups/{classId}/members API to get the member list OR to see exactly which user's were given out that assignment, you can query the ~/assignments/{id}/submissions list where each submission will contain the recipient/userId property.

    For an assignment that was selectively handed out to a subset of students, it'll contains the @odata.type: IndividualRecipient and a recipient's array with the student's userIds.