创建 learningCourseActivity

命名空间:microsoft.graph

创建新的 learningCourseActivity 对象。

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

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

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

此 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 指定要创建的 learningCourseActivity 资源类型, (learningAssignmentlearningSelfInitiated) ,并包括该类型的属性,如下表所示。

属性 类型 说明
assignedDateTime DateTimeOffset 课程活动的分配日期。 可选。
assignmentType assignmentType 课程活动的作业类型。 可取值为:requiredrecommendedunknownFutureValue。 必填。
assignerUserId String 分配者的Microsoft Entra ID。 可选。
completedDateTime DateTimeOffset 作业完成的日期和时间。 可选。
completionPercentage Int32 用户完成的课程的百分比。 可选。 如果提供了值,则该值必须介于 0100 ((含) )。
dueDateTime DateTimeOffset 课程活动的截止日期。 可选。
externalCourseActivityId String 提供商生成的课程活动 ID。 可选。
id String 可用于与课程活动 API 进一步交互的请求生成的 ID。
learningContentId String 在 Viva Learning 中创建的学习内容的 ID。 必填。
learningProviderId String 提供程序的注册 ID。 必填。
learnerUserId String 活动分配到的学习者的Microsoft Entra ID。 必填。
notes String 课程活动说明。 可选。
registrationId String 提供程序的 ID。 提供程序在 Viva Learning 上注册时生成 ID。 必填。
startedDateTime DateTimeOffset 学习者开始自启动课程的日期和时间。 可选。
status courseStatus 课程活动的状态。 可取值为:notStartedinProgresscompleted。 必填。

响应

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

如果失败,此方法将返回以下响应之一:

应用场景 HTTP 代码 代码 消息 详细信息
禁止访问 (Forbidden) 403 禁止访问 (Forbidden) 对于此请求,你没有足够的服务计划。
错误请求 400 badRequest 未为给定租户启用此提供程序。
错误请求 400 badRequest 你的请求存在问题。 确保输入的 registrationId 对租户有效或已注册。
内部服务器错误 500 internalServerError 内部服务器错误。
请求受限制 429 tooManyRequests {“code”: “tooManyRequests”,“message”: “在 {noOfMinutes} 分钟后重试”}。
服务不可用 503 serviceUnavailable {“code”: “serviceUnavailable”,“message”: “在 {noOfMinutes} 分钟后重试”}。
多个字段验证失败 400 badRequest badRequest {“code”: “badRequest”,“message”: “输入字段 {fieldName}不应为空”}, {“code”: “badRequest”,“message”: “Input field {fieldName} is required”}, {“code”: “badRequest”,“message”: “输入字段 {fieldName} 长度超出 {expectedLength}”}。
禁止访问 (Forbidden) 403 提供商无法为给定的学习内容创建课程活动 当 registrationId/learningProviderId 与创建 learningContent 的提供程序不匹配时。
禁止访问 (Forbidden) 403 用户许可证无效,无法执行操作 要为其创建分配的用户没有高级许可证时。

示例

示例 1:创建分配的学习课程活动

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

请求

以下示例显示了一个请求。

POST https://graph.microsoft.com/v1.0/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/v1.0/$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/v1.0/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/v1.0/$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"
}