Update learningCourseActivity
Article
09/27/2023
4 contributors
Feedback
In this article
Namespace: microsoft.graph
Update the properties of a learningCourseActivity object.
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.
This API is supported in the following national cloud deployments .
Global service
US Government L4
US Government L5 (DOD)
China operated by 21Vianet
✅
❌
❌
❌
Permissions
One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions .
Permission type
Permissions (from least to most privileged)
Delegated (work or school account)
Not supported.
Delegated (personal Microsoft account)
Not supported.
Application
LearningAssignedCourse.ReadWrite.All, LearningSelfInitiatedCourse.ReadWrite.All
HTTP request
PATCH /employeeExperience/learningProviders/{registrationId}/learningCourseActivities/{learningCourseActivityId}
Name
Description
Authorization
Bearer {token}. Required.
Content-Type
application/json. Required.
Request body
In the request body, use @odata.type to specify the type of learningCourseActivity resource (learningAssignment or learningSelfInitiated ), and include the properties of that type to update.
The following table lists the properties that you can change for an assigned learning course activity (learningAssignment ).
Property
Type
Description
assignedDateTime
DateTimeOffset
Assigned date for the course activity. Optional.
assignmentType
assignmentType
The assignment type for the course activity. Possible values are: required
, recommended
, unknownFutureValue
. Required.
completedDateTime
DateTimeOffset
Date and time when the assignment was completed. Optional.
completionPercentage
Int32
The percentage of the course completed by the user. If a value is provided, it must be between 0
and 100
(inclusive). Optional.
dueDateTime
DateTimeOffset
Due date for the course activity. Optional.
notes
String
Notes for the course activity. Optional.
status
courseStatus
The status of the course activity. Possible values are notStarted
, inProgress
, completed
. Required.
The following table lists the properties that you can change for a self-initiated learning course activity (learningSelfInitiated ).
Property
Type
Description
completedDateTime
DateTimeOffset
Date and time when the assignment was completed. Optional.
completionPercentage
Int32
The percentage of the course completed by the user. If a value is provided, it must be between 0
and 100
(inclusive). Optional.
status
courseStatus
The status of the course activity. Possible values are: notStarted
, inProgress
, completed
. Required.
startedDateTime
DateTimeOffset
The date and time when the self-initiated course was started by the learner.
Response
If successful, this method returns a 204 No Content
response code.
Examples
Example 1: Update an assigned learning course activity
Request
The following example shows the request.
PATCH https://graph.microsoft.com/v1.0/employeeExperience/learningProviders/01e8f81b-3060-4dec-acf0-0389665a0a38/learningCourseActivities/8ba2228a-e020-11ec-9d64-0242ac120003
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,
"learningProviderId": "01e8f81b-3060-4dec-acf0-0389665a0a38",
"dueDateTime": {
"dateTime": "2022-09-22T16:05:00.0000000",
"timeZone": "UTC"
},
"externalcourseActivityId": "12a2228a-e020-11ec-9d64-0242ac120002",
"learningContentId": "57baf9dc-e020-11ec-9d64-0242ac120002",
"learnerUserId": "7ba2228a-e020-11ec-9d64-0242ac120002",
"notes": {
"contentType": "text",
"content": "required assignment added for user"
},
"status": "inProgress"
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new LearningAssignment
{
OdataType = "#microsoft.graph.learningAssignment",
AssignedDateTime = DateTimeOffset.Parse("2021-05-11T22:57:17+00:00"),
AssignmentType = AssignmentType.Required,
AssignerUserId = "cea1684d-57dc-438d-a9d1-e666ec1a7f3d",
CompletedDateTime = null,
CompletionPercentage = 20,
LearningProviderId = "01e8f81b-3060-4dec-acf0-0389665a0a38",
DueDateTime = new DateTimeTimeZone
{
DateTime = "2022-09-22T16:05:00.0000000",
TimeZone = "UTC",
},
ExternalcourseActivityId = "12a2228a-e020-11ec-9d64-0242ac120002",
LearningContentId = "57baf9dc-e020-11ec-9d64-0242ac120002",
LearnerUserId = "7ba2228a-e020-11ec-9d64-0242ac120002",
Notes = new ItemBody
{
ContentType = BodyType.Text,
Content = "required assignment added for user",
},
Status = CourseStatus.InProgress,
};
var result = await graphClient.EmployeeExperience.LearningProviders["{learningProvider-id}"].LearningCourseActivities["{learningCourseActivity-id}"].PatchAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc employee-experience learning-providers learning-course-activities patch --learning-provider-id {learningProvider-id} --learning-course-activity-id {learningCourseActivity-id} --body '{\
"@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,\
"learningProviderId": "01e8f81b-3060-4dec-acf0-0389665a0a38",\
"dueDateTime": {\
"dateTime": "2022-09-22T16:05:00.0000000",\
"timeZone": "UTC"\
},\
"externalcourseActivityId": "12a2228a-e020-11ec-9d64-0242ac120002",\
"learningContentId": "57baf9dc-e020-11ec-9d64-0242ac120002",\
"learnerUserId": "7ba2228a-e020-11ec-9d64-0242ac120002",\
"notes": {\
"contentType": "text",\
"content": "required assignment added for user"\
},\
"status": "inProgress"\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
import (
"context"
"time"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestBody := graphmodels.NewLearningCourseActivity()
assignedDateTime , err := time.Parse(time.RFC3339, "2021-05-11T22:57:17+00:00")
requestBody.SetAssignedDateTime(&assignedDateTime)
assignmentType := graphmodels.REQUIRED_ASSIGNMENTTYPE
requestBody.SetAssignmentType(&assignmentType)
assignerUserId := "cea1684d-57dc-438d-a9d1-e666ec1a7f3d"
requestBody.SetAssignerUserId(&assignerUserId)
completedDateTime := null
requestBody.SetCompletedDateTime(&completedDateTime)
completionPercentage := int32(20)
requestBody.SetCompletionPercentage(&completionPercentage)
learningProviderId := "01e8f81b-3060-4dec-acf0-0389665a0a38"
requestBody.SetLearningProviderId(&learningProviderId)
dueDateTime := graphmodels.NewDateTimeTimeZone()
dateTime := "2022-09-22T16:05:00.0000000"
dueDateTime.SetDateTime(&dateTime)
timeZone := "UTC"
dueDateTime.SetTimeZone(&timeZone)
requestBody.SetDueDateTime(dueDateTime)
externalcourseActivityId := "12a2228a-e020-11ec-9d64-0242ac120002"
requestBody.SetExternalcourseActivityId(&externalcourseActivityId)
learningContentId := "57baf9dc-e020-11ec-9d64-0242ac120002"
requestBody.SetLearningContentId(&learningContentId)
learnerUserId := "7ba2228a-e020-11ec-9d64-0242ac120002"
requestBody.SetLearnerUserId(&learnerUserId)
notes := graphmodels.NewItemBody()
contentType := graphmodels.TEXT_BODYTYPE
notes.SetContentType(&contentType)
content := "required assignment added for user"
notes.SetContent(&content)
requestBody.SetNotes(notes)
status := graphmodels.INPROGRESS_COURSESTATUS
requestBody.SetStatus(&status)
learningCourseActivities, err := graphClient.EmployeeExperience().LearningProviders().ByLearningProviderId("learningProvider-id").LearningCourseActivities().ByLearningCourseActivityId("learningCourseActivity-id").Patch(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LearningAssignment learningCourseActivity = new LearningAssignment();
learningCourseActivity.assignedDateTime = OffsetDateTimeSerializer.deserialize("2021-05-11T22:57:17+00:00");
learningCourseActivity.assignmentType = AssignmentType.REQUIRED;
learningCourseActivity.assignerUserId = "cea1684d-57dc-438d-a9d1-e666ec1a7f3d";
learningCourseActivity.completedDateTime = OffsetDateTimeSerializer.deserialize("null");
learningCourseActivity.completionPercentage = 20;
learningCourseActivity.learningProviderId = "01e8f81b-3060-4dec-acf0-0389665a0a38";
DateTimeTimeZone dueDateTime = new DateTimeTimeZone();
dueDateTime.dateTime = "2022-09-22T16:05:00";
dueDateTime.timeZone = "UTC";
learningCourseActivity.dueDateTime = dueDateTime;
learningCourseActivity.externalcourseActivityId = "12a2228a-e020-11ec-9d64-0242ac120002";
learningCourseActivity.learningContentId = "57baf9dc-e020-11ec-9d64-0242ac120002";
learningCourseActivity.learnerUserId = "7ba2228a-e020-11ec-9d64-0242ac120002";
ItemBody notes = new ItemBody();
notes.contentType = BodyType.TEXT;
notes.content = "required assignment added for user";
learningCourseActivity.notes = notes;
learningCourseActivity.status = CourseStatus.IN_PROGRESS;
graphClient.employeeExperience().learningProviders("01e8f81b-3060-4dec-acf0-0389665a0a38").learningCourseActivities("8ba2228a-e020-11ec-9d64-0242ac120003")
.buildRequest()
.patch(learningCourseActivity);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
const options = {
authProvider,
};
const client = Client.init(options);
const learningCourseActivity = {
'@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,
learningProviderId: '01e8f81b-3060-4dec-acf0-0389665a0a38',
dueDateTime: {
dateTime: '2022-09-22T16:05:00.0000000',
timeZone: 'UTC'
},
externalcourseActivityId: '12a2228a-e020-11ec-9d64-0242ac120002',
learningContentId: '57baf9dc-e020-11ec-9d64-0242ac120002',
learnerUserId: '7ba2228a-e020-11ec-9d64-0242ac120002',
notes: {
contentType: 'text',
content: 'required assignment added for user'
},
status: 'inProgress'
};
await client.api('/employeeExperience/learningProviders/01e8f81b-3060-4dec-acf0-0389665a0a38/learningCourseActivities/8ba2228a-e020-11ec-9d64-0242ac120003')
.update(learningCourseActivity);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new LearningAssignment();
$requestBody->setOdataType('#microsoft.graph.learningAssignment');
$requestBody->setAssignedDateTime(new \DateTime('2021-05-11T22:57:17+00:00'));
$requestBody->setAssignmentType(new AssignmentType('required'));
$requestBody->setAssignerUserId('cea1684d-57dc-438d-a9d1-e666ec1a7f3d');
$requestBody->setCompletedDateTime(null);
$requestBody->setCompletionPercentage(20);
$requestBody->setLearningProviderId('01e8f81b-3060-4dec-acf0-0389665a0a38');
$dueDateTime = new DateTimeTimeZone();
$dueDateTime->setDateTime('2022-09-22T16:05:00.0000000');
$dueDateTime->setTimeZone('UTC');
$requestBody->setDueDateTime($dueDateTime);
$requestBody->setExternalcourseActivityId('12a2228a-e020-11ec-9d64-0242ac120002');
$requestBody->setLearningContentId('57baf9dc-e020-11ec-9d64-0242ac120002');
$requestBody->setLearnerUserId('7ba2228a-e020-11ec-9d64-0242ac120002');
$notes = new ItemBody();
$notes->setContentType(new BodyType('text'));
$notes->setContent('required assignment added for user');
$requestBody->setNotes($notes);
$requestBody->setStatus(new CourseStatus('inProgress'));
$result = $graphServiceClient->employeeExperience()->learningProviders()->byLearningProviderId('learningProvider-id')->learningCourseActivities()->byLearningCourseActivityId('learningCourseActivity-id')->patch($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(request_adapter)
request_body = LearningAssignment(
odata_type = "#microsoft.graph.learningAssignment",
assigned_date_time = "2021-05-11T22:57:17+00:00",
assignment_type = AssignmentType.Required,
assigner_user_id = "cea1684d-57dc-438d-a9d1-e666ec1a7f3d",
completed_date_time = None,
completion_percentage = 20,
learning_provider_id = "01e8f81b-3060-4dec-acf0-0389665a0a38",
due_date_time = DateTimeTimeZone(
date_time = "2022-09-22T16:05:00.0000000",
time_zone = "UTC",
),
externalcourse_activity_id = "12a2228a-e020-11ec-9d64-0242ac120002",
learning_content_id = "57baf9dc-e020-11ec-9d64-0242ac120002",
learner_user_id = "7ba2228a-e020-11ec-9d64-0242ac120002",
notes = ItemBody(
content_type = BodyType.Text,
content = "required assignment added for user",
),
status = CourseStatus.InProgress,
)
result = await graph_client.employee_experience.learning_providers.by_learning_provider_id('learningProvider-id').learning_course_activities.by_learning_course_activitie_id('learningCourseActivity-id').patch(body = request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
The following example shows the response.
HTTP/1.1 204 No Content
Example 2: Update a self-initiated learning course activity
Request
The following example shows the request.
PATCH https://graph.microsoft.com/v1.0/employeeExperience/learningProviders/01e8f81b-3060-4dec-acf0-0389665a0a38/learningCourseActivities/8ba2228a-e020-11ec-9d64-0242ac120003
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.learningSelfInitiatedCourse",
"completedDateTime": null,
"completionPercentage": 30,
"externalcourseActivityId": "12a2228a-e020-11ec-9d64-0242ac120002",
"learningContentId": "57baf9dc-e020-11ec-9d64-0242ac120002",
"learningProviderId": "01e8f81b-3060-4dec-acf0-0389665a0a38",
"startedDateTime": "2021-05-11T22:57:17+00:00",
"status": "inProgress"
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new LearningSelfInitiatedCourse
{
OdataType = "#microsoft.graph.learningSelfInitiatedCourse",
CompletedDateTime = null,
CompletionPercentage = 30,
ExternalcourseActivityId = "12a2228a-e020-11ec-9d64-0242ac120002",
LearningContentId = "57baf9dc-e020-11ec-9d64-0242ac120002",
LearningProviderId = "01e8f81b-3060-4dec-acf0-0389665a0a38",
StartedDateTime = DateTimeOffset.Parse("2021-05-11T22:57:17+00:00"),
Status = CourseStatus.InProgress,
};
var result = await graphClient.EmployeeExperience.LearningProviders["{learningProvider-id}"].LearningCourseActivities["{learningCourseActivity-id}"].PatchAsync(requestBody);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc employee-experience learning-providers learning-course-activities patch --learning-provider-id {learningProvider-id} --learning-course-activity-id {learningCourseActivity-id} --body '{\
"@odata.type": "#microsoft.graph.learningSelfInitiatedCourse",\
"completedDateTime": null,\
"completionPercentage": 30,\
"externalcourseActivityId": "12a2228a-e020-11ec-9d64-0242ac120002",\
"learningContentId": "57baf9dc-e020-11ec-9d64-0242ac120002",\
"learningProviderId": "01e8f81b-3060-4dec-acf0-0389665a0a38",\
"startedDateTime": "2021-05-11T22:57:17+00:00",\
"status": "inProgress"\
}\
'
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
import (
"context"
"time"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
graphClient := msgraphsdk.NewGraphServiceClientWithCredentials(cred, scopes)
requestBody := graphmodels.NewLearningCourseActivity()
completedDateTime := null
requestBody.SetCompletedDateTime(&completedDateTime)
completionPercentage := int32(30)
requestBody.SetCompletionPercentage(&completionPercentage)
externalcourseActivityId := "12a2228a-e020-11ec-9d64-0242ac120002"
requestBody.SetExternalcourseActivityId(&externalcourseActivityId)
learningContentId := "57baf9dc-e020-11ec-9d64-0242ac120002"
requestBody.SetLearningContentId(&learningContentId)
learningProviderId := "01e8f81b-3060-4dec-acf0-0389665a0a38"
requestBody.SetLearningProviderId(&learningProviderId)
startedDateTime , err := time.Parse(time.RFC3339, "2021-05-11T22:57:17+00:00")
requestBody.SetStartedDateTime(&startedDateTime)
status := graphmodels.INPROGRESS_COURSESTATUS
requestBody.SetStatus(&status)
learningCourseActivities, err := graphClient.EmployeeExperience().LearningProviders().ByLearningProviderId("learningProvider-id").LearningCourseActivities().ByLearningCourseActivityId("learningCourseActivity-id").Patch(context.Background(), requestBody, nil)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
LearningSelfInitiatedCourse learningCourseActivity = new LearningSelfInitiatedCourse();
learningCourseActivity.completedDateTime = OffsetDateTimeSerializer.deserialize("null");
learningCourseActivity.completionPercentage = 30;
learningCourseActivity.externalcourseActivityId = "12a2228a-e020-11ec-9d64-0242ac120002";
learningCourseActivity.learningContentId = "57baf9dc-e020-11ec-9d64-0242ac120002";
learningCourseActivity.learningProviderId = "01e8f81b-3060-4dec-acf0-0389665a0a38";
learningCourseActivity.startedDateTime = OffsetDateTimeSerializer.deserialize("2021-05-11T22:57:17+00:00");
learningCourseActivity.status = CourseStatus.IN_PROGRESS;
graphClient.employeeExperience().learningProviders("01e8f81b-3060-4dec-acf0-0389665a0a38").learningCourseActivities("8ba2228a-e020-11ec-9d64-0242ac120003")
.buildRequest()
.patch(learningCourseActivity);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
const options = {
authProvider,
};
const client = Client.init(options);
const learningCourseActivity = {
'@odata.type': '#microsoft.graph.learningSelfInitiatedCourse',
completedDateTime: null,
completionPercentage: 30,
externalcourseActivityId: '12a2228a-e020-11ec-9d64-0242ac120002',
learningContentId: '57baf9dc-e020-11ec-9d64-0242ac120002',
learningProviderId: '01e8f81b-3060-4dec-acf0-0389665a0a38',
startedDateTime: '2021-05-11T22:57:17+00:00',
status: 'inProgress'
};
await client.api('/employeeExperience/learningProviders/01e8f81b-3060-4dec-acf0-0389665a0a38/learningCourseActivities/8ba2228a-e020-11ec-9d64-0242ac120003')
.update(learningCourseActivity);
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new LearningSelfInitiatedCourse();
$requestBody->setOdataType('#microsoft.graph.learningSelfInitiatedCourse');
$requestBody->setCompletedDateTime(null);
$requestBody->setCompletionPercentage(30);
$requestBody->setExternalcourseActivityId('12a2228a-e020-11ec-9d64-0242ac120002');
$requestBody->setLearningContentId('57baf9dc-e020-11ec-9d64-0242ac120002');
$requestBody->setLearningProviderId('01e8f81b-3060-4dec-acf0-0389665a0a38');
$requestBody->setStartedDateTime(new \DateTime('2021-05-11T22:57:17+00:00'));
$requestBody->setStatus(new CourseStatus('inProgress'));
$result = $graphServiceClient->employeeExperience()->learningProviders()->byLearningProviderId('learningProvider-id')->learningCourseActivities()->byLearningCourseActivityId('learningCourseActivity-id')->patch($requestBody)->wait();
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(request_adapter)
request_body = LearningSelfInitiatedCourse(
odata_type = "#microsoft.graph.learningSelfInitiatedCourse",
completed_date_time = None,
completion_percentage = 30,
externalcourse_activity_id = "12a2228a-e020-11ec-9d64-0242ac120002",
learning_content_id = "57baf9dc-e020-11ec-9d64-0242ac120002",
learning_provider_id = "01e8f81b-3060-4dec-acf0-0389665a0a38",
started_date_time = "2021-05-11T22:57:17+00:00",
status = CourseStatus.InProgress,
)
result = await graph_client.employee_experience.learning_providers.by_learning_provider_id('learningProvider-id').learning_course_activities.by_learning_course_activitie_id('learningCourseActivity-id').patch(body = request_body)
For details about how to add the SDK to your project and create an authProvider instance, see the SDK documentation .
Response
The following example shows the response.
HTTP/1.1 204 No Content