创建 learningCourseActivity

命名空间:microsoft.graph

重要

Microsoft Graph /beta 版本下的 API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。

创建新的 learningCourseActivity 对象。

学习课程活动可以是以下两种类型之一:

使用此方法创建任一类型的活动。

注意:只有当 isCourseAcitvitySyncEnabled 设置为 true时,提供商才能管理学习课程活动。 若要更新该值,请使用 Update learningProvider 方法。

API 可用性

此 API 可用于以下国家级云部署。

全局服务 美国政府 L4 美国政府 L5 (DOD) 由世纪互联运营的中国
✅ ❌ ❌ ❌

权限

为此 API 选择标记为最低特权的权限。 只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。

权限类型 最低特权权限 更高特权权限
委派(工作或学校帐户) 不支持。 不支持。
委派(个人 Microsoft 帐户) 不支持。 不支持。
应用程序 LearningAssignedCourse.ReadWrite.All LearningSelfInitiatedCourse.ReadWrite.All

HTTP 请求

POST /employeeExperience/learningProviders/{registrationId}/learningCourseActivities

请求标头

名称 说明
Authorization 持有者 {token}。 必填。 详细了解 身份验证和授权。
Content-Type application/json. 必需。

请求正文

在请求正文中,用于@odata.type指定要 (learningAssignment 或 learningSelfInitiated) 创建的 learningCourseActivity 资源的类型,并包含该类型的属性,如下表所示。

属性 类型 说明
assignedDateTime DateTimeOffset 为课程活动分配的日期。 可选。
assignmentType assignmentType 课程活动的作业类型。 可能的值包括 required、recommended、unknownFutureValue。 必填。
assignerUserId String 分配者的用户 ID。 可选。
completedDateTime DateTimeOffset 作业完成的日期和时间。 可选。
completionPercentage Int32 用户完成的课程百分比。 可选。 如果提供值,则值必须介于 () 100 之间0。
dueDateTime DateTimeOffset 课程活动的截止日期。 可选。
externalCourseActivityId String 提供商生成的课程活动 ID。 可选。
id String 为可用于与课程活动 API 进行进一步交互的请求生成的 ID。
learningContentId String Viva Learning 中创建的学习内容的 ID。 必填。
learningProviderId String 提供程序的注册 ID。 必填。
learnerUserId String 活动分配到的学习者的用户 ID。 必填。
notes String 课程活动备注。 可选。
registrationId String 提供程序的 ID。 提供商在Viva Learning上注册时生成此 ID。 必填。
startedDateTime DateTimeOffset 学习者开始自发课程的日期和时间。 可选。
status courseStatus 课程活动的状态。 可能的值包括 notStarted、inProgress、completed。 必填。

响应

如果成功,此方法将在响应正文中返回响应201 Created代码和类型为 learningAssignment 或 learningSelfInitiated 的 learningCourseActivity 对象。

示例

示例 1:创建指定学习课程活动

下面的示例演示如何创建 learningAssignment 活动。

请求

下面为请求示例。

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"
}

响应

以下示例显示了相应的响应。

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"
}

示例 2:创建自发学习课程活动

以下示例创建一个 learningSelfInitiated 活动。

请求

下面为请求示例。

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"
}

响应

以下示例显示了相应的响应。

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"
}