educationAssignment erstellen
Artikel
07/18/2022
4 Minuten Lesedauer
3 Mitwirkende
In diesem Artikel
Namespace: microsoft.graph
Erstellen Sie eine neue Aufgabe.
Nur Lehrer in einem Kurs können eine Aufgabe erstellen. Aufgaben beginnen im Entwurfszustand, was bedeutet, dass die Aufgabe den Kursteilnehmern erst nach der Veröffentlichung angezeigt wird.
Berechtigungen
Eine der nachfolgenden Berechtigungen ist erforderlich, um diese API aufrufen zu können. Weitere Informationen, unter anderem zur Auswahl von Berechtigungen, finden Sie im Artikel zum Thema Berechtigungen .
Berechtigungstyp
Berechtigungen (von der Berechtigung mit den wenigsten Rechten zu der mit den meisten Rechten)
Delegiert (Geschäfts-, Schul- oder Unikonto)
EduAssignments.ReadWriteBasic, EduAssignments.ReadWrite
Delegiert (persönliches Microsoft-Konto)
Nicht unterstützt
Anwendung
Nicht unterstützt
HTTP-Anforderung
POST /education/classes/{class-id}/assignments
Kopfzeile
Wert
Authorization
Bearer {token}. Erforderlich.
Content-Type
application/json
Anforderungstext
Geben Sie im Anforderungstext eine JSON-Darstellung eines educationAssignment-Objekts an.
Antwort
Bei erfolgreicher Ausführung gibt die Methode den 201 Created Antwortcode und ein educationAssignment-Objekt im Antworttext zurück.
Beispiel
Anforderung
Nachfolgend sehen Sie ein Beispiel der Anforderung.
POST https://graph.microsoft.com/v1.0/education/classes/72a7baec-c3e9-4213-a850-f62de0adad5f/assignments
Content-type: application/json
{
"dueDateTime": "2021-09-07T00:00:00Z",
"displayName": "Reading test 09.03 #4",
"instructions": {
"contentType": "text",
"content": "Read chapter 4"
},
"grading": {
"@odata.type": "#microsoft.graph.educationAssignmentGradeType",
"maxPoints": 50
},
"assignTo": {
"@odata.type": "#microsoft.graph.educationAssignmentGradeType"
},
"status": "draft",
"allowStudentsToAddResourcesToSubmission": true
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var educationAssignment = new EducationAssignment
{
DueDateTime = DateTimeOffset.Parse("2021-09-07T00:00:00Z"),
DisplayName = "Reading test 09.03 #4",
Instructions = new EducationItemBody
{
ContentType = BodyType.Text,
Content = "Read chapter 4"
},
Grading = new EducationAssignmentPointsGradeType
{
MaxPoints = 50f
},
AssignTo = new EducationAssignmentClassRecipient
{
},
Status = EducationAssignmentStatus.Draft,
AllowStudentsToAddResourcesToSubmission = true
};
await graphClient.Education.Classes["{educationClass-id}"].Assignments
.Request()
.AddAsync(educationAssignment);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
const options = {
authProvider,
};
const client = Client.init(options);
const educationAssignment = {
dueDateTime: '2021-09-07T00:00:00Z',
displayName: 'Reading test 09.03 #4',
instructions: {
contentType: 'text',
content: 'Read chapter 4'
},
grading: {
'@odata.type': '#microsoft.graph.educationAssignmentPointsGradeType',
maxPoints: 50
},
assignTo: {
'@odata.type': '#microsoft.graph.educationAssignmentClassRecipient'
},
status: 'draft',
allowStudentsToAddResourcesToSubmission: true
};
await client.api('/education/classes/72a7baec-c3e9-4213-a850-f62de0adad5f/assignments')
.post(educationAssignment);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/education/classes/72a7baec-c3e9-4213-a850-f62de0adad5f/assignments"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphEducationAssignment *educationAssignment = [[MSGraphEducationAssignment alloc] init];
[educationAssignment setDueDateTime: "2021-09-07T00:00:00Z"];
[educationAssignment setDisplayName:@"Reading test 09.03 #4"];
MSGraphEducationItemBody *instructions = [[MSGraphEducationItemBody alloc] init];
[instructions setContentType: [MSGraphBodyType text]];
[instructions setContent:@"Read chapter 4"];
[educationAssignment setInstructions:instructions];
MSGraphEducationAssignmentGradeType *grading = [[MSGraphEducationAssignmentGradeType alloc] init];
[grading setMaxPoints: 50];
[educationAssignment setGrading:grading];
MSGraphEducationAssignmentRecipient *assignTo = [[MSGraphEducationAssignmentRecipient alloc] init];
[educationAssignment setAssignTo:assignTo];
[educationAssignment setStatus: [MSGraphEducationAssignmentStatus draft]];
[educationAssignment setAllowStudentsToAddResourcesToSubmission: true];
NSError *error;
NSData *educationAssignmentData = [educationAssignment getSerializedDataWithError:&error];
[urlRequest setHTTPBody:educationAssignmentData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
EducationAssignment educationAssignment = new EducationAssignment();
educationAssignment.dueDateTime = OffsetDateTimeSerializer.deserialize("2021-09-07T00:00:00Z");
educationAssignment.displayName = "Reading test 09.03 #4";
EducationItemBody instructions = new EducationItemBody();
instructions.contentType = BodyType.TEXT;
instructions.content = "Read chapter 4";
educationAssignment.instructions = instructions;
EducationAssignmentPointsGradeType grading = new EducationAssignmentPointsGradeType();
grading.maxPoints = 50;
educationAssignment.grading = grading;
EducationAssignmentClassRecipient assignTo = new EducationAssignmentClassRecipient();
educationAssignment.assignTo = assignTo;
educationAssignment.status = EducationAssignmentStatus.DRAFT;
educationAssignment.allowStudentsToAddResourcesToSubmission = true;
graphClient.education().classes("72a7baec-c3e9-4213-a850-f62de0adad5f").assignments()
.buildRequest()
.post(educationAssignment);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewEducationAssignment()
dueDateTime, err := time.Parse(time.RFC3339, "2021-09-07T00:00:00Z")
requestBody.SetDueDateTime(&dueDateTime)
displayName := "Reading test 09.03 #4"
requestBody.SetDisplayName(&displayName)
instructions := msgraphsdk.NewEducationItemBody()
requestBody.SetInstructions(instructions)
contentType := "text"
instructions.SetContentType(&contentType)
content := "Read chapter 4"
instructions.SetContent(&content)
grading := msgraphsdk.NewEducationAssignmentGradeType()
requestBody.SetGrading(grading)
grading.SetAdditionalData(map[string]interface{}{
"@odata.type": "#microsoft.graph.educationAssignmentPointsGradeType",
"maxPoints": ,
}
assignTo := msgraphsdk.NewEducationAssignmentRecipient()
requestBody.SetAssignTo(assignTo)
assignTo.SetAdditionalData(map[string]interface{}{
"@odata.type": "#microsoft.graph.educationAssignmentClassRecipient",
}
status := "draft"
requestBody.SetStatus(&status)
allowStudentsToAddResourcesToSubmission := true
requestBody.SetAllowStudentsToAddResourcesToSubmission(&allowStudentsToAddResourcesToSubmission)
educationClassId := "educationClass-id"
result, err := graphClient.Education().ClassesById(&educationClassId).Assignments().Post(requestBody)
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
Import-Module Microsoft.Graph.Education
$params = @{
DueDateTime = [System.DateTime]::Parse("2021-09-07T00:00:00Z")
DisplayName = "Reading test 09.03 #4"
Instructions = @{
ContentType = "text"
Content = "Read chapter 4"
}
Grading = @{
"@odata.type" = "#microsoft.graph.educationAssignmentPointsGradeType"
MaxPoints =
}
AssignTo = @{
"@odata.type" = "#microsoft.graph.educationAssignmentClassRecipient"
}
Status = "draft"
AllowStudentsToAddResourcesToSubmission = $true
}
New-MgEducationClassAssignment -EducationClassId $educationClassId -BodyParameter $params
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
Geben Sie im Anforderungstext eine JSON-Darstellung eines educationAssignment-Objekts an.
Antwort
Nachfolgend sehen Sie ein Beispiel der Antwort.
Hinweis: Das hier gezeigte Antwortobjekt kann zur besseren Lesbarkeit gekürzt werden.
HTTP/1.1 201 Created
Content-type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#education/classes('72a7baec-c3e9-4213-a850-f62de0adad5f')/assignments/$entity",
"classId": "72a7baec-c3e9-4213-a850-f62de0adad5f",
"displayName": "Reading test 09.03 #5",
"closeDateTime": null,
"dueDateTime": "2021-09-07T00:00:00Z",
"assignDateTime": null,
"assignedDateTime": null,
"allowLateSubmissions": true,
"resourcesFolderUrl": null,
"createdDateTime": "2021-09-03T23:57:14.6088791Z",
"lastModifiedDateTime": "2021-09-03T23:57:14.6398613Z",
"allowStudentsToAddResourcesToSubmission": true,
"status": "draft",
"notificationChannelUrl": null,
"webUrl": "https://teams.microsoft.com/l/entity/66aeee93-507d-479a-a3ef-8f494af43945/classroom?context=%7B%22subEntityId%22%3A%22%7B%5C%22version%5C%22%3A%5C%221.0%5C%22,%5C%22config%5C%22%3A%7B%5C%22classes%5C%22%3A%5B%7B%5C%22id%5C%22%3A%5C%2272a7baec-c3e9-4213-a850-f62de0adad5f%5C%22,%5C%22displayName%5C%22%3Anull,%5C%22assignmentIds%5C%22%3A%5B%5C%224679bc1b-90c5-45af-ae1a-d5357672ed39%5C%22%5D%7D%5D%7D,%5C%22action%5C%22%3A%5C%22navigate%5C%22,%5C%22view%5C%22%3A%5C%22assignment-viewer%5C%22%7D%22,%22channelId%22%3Anull%7D",
"addedStudentAction": "none",
"id": "4679bc1b-90c5-45af-ae1a-d5357672ed39",
"instructions": {
"content": "Read chapter 5",
"contentType": "text"
},
"grading": {
"@odata.type": "#microsoft.graph.educationAssignmentPointsGradeType",
"maxPoints": 50
},
"assignTo": {
"@odata.type": "#microsoft.graph.educationAssignmentClassRecipient"
},
"createdBy": {
"application": null,
"device": null,
"user": {
"id": "f3a5344e-dbde-48b0-be24-b5b62a243836",
"displayName": null
}
},
"lastModifiedBy": {
"application": null,
"device": null,
"user": {
"id": "f3a5344e-dbde-48b0-be24-b5b62a243836",
"displayName": null
}
}
}
Siehe auch