| title | Create learningCourseActivity |
|---|---|
| description | Create a new learningCourseActivity object. |
| author | malabikaroy |
| ms.localizationpriority | medium |
| ms.subservice | viva-learning |
| doc_type | apiPageType |
| ms.date | 04/05/2024 |
Namespace: microsoft.graph
[!INCLUDE beta-disclaimer]
Create a new learningCourseActivity object.
A learning course activity can be one of two types:
Use this method to create either type of activity.
Note: Learning course activities can be managed by a provider only when isCourseAcitvitySyncEnabled is set to
true. To update the value, use the Update learningProvider method.
[!INCLUDE national-cloud-support]
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
[!INCLUDE permissions-table]
POST /employeeExperience/learningProviders/{registrationId}/learningCourseActivities| Name | Description |
|---|---|
| Authorization | Bearer {token}. Required. Learn more about authentication and authorization. |
| Content-Type | application/json. Required. |
In the request body, use @odata.type to specify the type of learningCourseActivity resource that you're creating (learningAssignment or learningSelfInitiated), and include the properties of that type, as listed in the following table.
| Property | Type | Description |
|---|---|---|
| assignedDateTime | DateTimeOffset | Assigned date for the course activity. Optional. |
| assignmentType | assignmentType | The assignment type for the course activity. The possible values are: required, recommended, unknownFutureValue. Required. |
| assignerUserId | String | The user ID of the assigner. Optional. |
| completedDateTime | DateTimeOffset | The date and time when the assignment was completed. Optional. |
| completionPercentage | Int32 | The percentage of the course completed by the user. Optional. If a value is provided, it must be between 0 and 100 (inclusive). |
| dueDateTime | DateTimeOffset | Due date for the course activity. Optional. |
| externalCourseActivityId | String | A course activity ID generated by the provider. Optional. |
| id | String | The generated ID for a request that can be used to make further interactions to the course activity APIs. |
| learningContentId | String | The ID of the learning content created in Viva Learning. Required. |
| learningProviderId | String | The registration ID of the provider. Required. |
| learnerUserId | String | The user ID of the learner to whom the activity is assigned. Required. |
| notes | String | Notes for the course activity. Optional. |
| registrationId | String | ID of the provider. The ID is generated when the provider registers on Viva Learning. Required. |
| startedDateTime | DateTimeOffset | The date and time when the self-initiated course was started by the learner. Optional. |
| status | courseStatus | The status of the course activity. The possible values are: notStarted, inProgress, completed. Required. |
If successful, this method returns a 201 Created response code and a learningCourseActivity object of type learningAssignment or learningSelfInitiated in the response body.
The following example shows how to create a learningAssignment activity.
The following example shows the request.
POST https://graph.microsoft.com/beta/employeeExperience/learningProviders/01e8f81b-3060-4dec-acf0-0389665a0a38/learningCourseActivities
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.learningAssignment",
"assignedDateTime": "2021-05-11T22:57:17+00:00",
"assignmentType": "required",
"assignerUserId": "cea1684d-57dc-438d-a9d1-e666ec1a7f3d",
"completedDateTime": null,
"completionPercentage": 20,
"dueDateTime": {
"dateTime": "2022-09-22T16:05:00.0000000",
"timeZone": "UTC"
},
"externalCourseActivityId": "12a2228a-e020-11ec-9d64-0242ac120002",
"learningContentId": "57baf9dc-e020-11ec-9d64-0242ac120002",
"learningProviderId": "01e8f81b-3060-4dec-acf0-0389665a0a38",
"learnerUserId": "7ba2228a-e020-11ec-9d64-0242ac120002",
"notes": {
"contentType": "text",
"content": "required assignment added for user"
},
"status": "notStarted"
}[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
The following example shows the response.
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.learningAssignment",
"@odata.context": "https://graph.microsoft.com/beta/$metadata#learningProviders('13727311-e7bb-470d-8b20-6a23d9030d70')/learningCourseActivities('7ba2228a-e020-11ec-9d64-0242ac120002')$entity",
"assignedDateTime": "2021-05-11T22:57:17+00:00",
"assignmentType": "required",
"assignerUserId": "cea1684d-57dc-438d-a9d1-e666ec1a7f3d",
"completedDateTime": null,
"completionPercentage": 20,
"externalCourseActivityId": "12a2228a-e020-11ec-9d64-0242ac120002",
"id": "7ba2228a-e020-11ec-9d64-0242ac120002:749c8786-99bb-4b3b-8d5d-586428f6aaa3",
"dueDateTime": {
"dateTime": "2022-09-22T16:05:00.0000000",
"timeZone": "UTC"
},
"learningContentId": "57baf9dc-e020-11ec-9d64-0242ac120002",
"learningProviderId": "01e8f81b-3060-4dec-acf0-0389665a0a38",
"learnerUserId": "7ba2228a-e020-11ec-9d64-0242ac120002",
"notes": {
"contentType": "text",
"content": "required assignment added for user"
},
"status": "notStarted"
}The following example creates a learningSelfInitiated activity.
The following example shows the request.
POST https://graph.microsoft.com/beta/employeeExperience/learningProviders/01e8f81b-3060-4dec-acf0-0389665a0a38/learningCourseActivities
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.learningSelfInitiatedCourse",
"completedDateTime": null,
"completionPercentage": 20,
"externalCourseActivityId": "12a2228a-e020-11ec-9d64-0242ac120002",
"learningContentId": "57baf9dc-e020-11ec-9d64-0242ac120002",
"learnerUserId": "7ba2228a-e020-11ec-9d64-0242ac120002",
"startedDateTime": "2021-05-21T22:57:17+00:00",
"status": "inProgress"
}[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
[!INCLUDE sample-code] [!INCLUDE sdk-documentation]
The following example shows the response.
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.learningSelfInitiatedCourse",
"@odata.context": "https://graph.microsoft.com/beta/$metadata#learningProviders('13727311-e7bb-470d-8b20-6a23d9030d70')/learningCourseActivities('be2f4d76-e020-11ec-9d64-0242ac120002')$entity",
"completedDateTime": null,
"completionPercentage": 20,
"externalCourseActivityId": "12a2228a-e020-11ec-9d64-0242ac120002",
"id": "7ba2228a-e020-11ec-9d64-0242ac120002:749c8786-99bb-4b3b-8d5d-586428f6aaa3",
"learningContentId": "57baf9dc-e020-11ec-9d64-0242ac120002",
"learningProviderId": "01e8f81b-3060-4dec-acf0-0389665a0a38",
"learnerUserId": "7ba2228a-e020-11ec-9d64-0242ac120002",
"startedDateTime": "2021-05-21T22:57:17+00:00",
"status": "inProgress"
}