DXCourseClient

This class is responsible for making requests to the course API.

You will need to enable the "Training" scope for your app in the developer dashboard before using the course API.

Properties

public static let shared: DXCourseClient

Singleton instance of DXCourseClient . You will access all the available DXCourseClient methods through this instance.

Methods

getCourse

public func getCourse(
    courseId: String,
    _ completion: @escaping (_ error: Error?, _ course: DXCourse?) -> Void)
    -> Void

Retrieves a single course by ID.

Parameter

Type

Description

courseId

String

The ID of the requested course.

completion

(_ error: Error?, _ course: DXCourse?) -> Void

Closure invoked when the request finishes. Called with an Error argument if the request fails; otherwise, called with the newly created DXCourse.

getAllCourses

public func getAllCourses(
    limit: Int? = nil,
    page: Int? = nil,
    completion: @escaping (_ error: Error?, _ courses: [DXCourse]?) -> Void
  )

Retrieves all courses.

Parameter

Type

Description

limit

Int?

Page size.

page

Int?

Results page to return.

completion

(_ error: Error?, _ courses: [DXCourse]?) -> Void

Closure invoked when the request finishes. Called with an Error argument if the request fails; otherwise, called with the requested courses.

getCourseObjectives

public func getCourseObjectives(
        courseId: String,
        completion: @escaping (_ error: Error?, _ objectives: [DXCourseObjective]?) -> Void
    )

Retrieves a course's objectives.

Parameter

Type

Description

courseId

String

The ID of the requested course.

completion

( error: Error?, objectives: [DXCourseObjective]?) -> Void

Closure invoked when the request finishes. Called with an Error argument if the request fails; otherwise, called with the requested course objectives.

getCourseObjectivesPerformance

public func getCourseObjectivesPerformances(
        courseId: String,
        completion: @escaping (_ error: Error?, _ objectives: [DXCourseObjective]?) -> Void
    )

Retrieves a courses objectives along with a student's performance on the objectives.

A list of course objectives with the requested student's skill level and the scores that were used to calculate it. Skill level ranks can be 0 ("Basic"), 1 ("Advanced"), or 2 ("Expert").

In the "lessonScores" array, the score is either the score of the student's latest completed attempt at the lesson, or an objective score sent in via the API (see Update Student's Objective Score), indicated by the "scoreType" attribute.

If a student has no recorded progress on the Objective's linked lessons, "skill" will be 0, and "skillDescription" and "score" will both be null.

Parameter

Type

Description

courseId

String

The ID of the requested course.

completion

( error: Error?, objectives: [DXCourseObjective]?) -> Void

Closure invoked when the request finishes. Called with an Error argument if the request fails; otherwise, called with the requested course objectives.

Last updated