DXLessonClient

This class is responsible for requests to the lesson API.

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

Properties

public static let shared: DXLessonClient

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

Methods

getLesson

public func getLesson(
    lessonId: String,
    _ completion: @escaping (_ error: Error?, _ lesson: DXLesson?) -> Void)
    -> Void

Retrieves a single lesson by ID.

Parameter

Type

Description

lessonId

String

The ID of the requested lesson.

completion

(_ error: Error?, _ lesson: DXLesson?) -> Void

The closure invoked when the request finishes. Called with an Error argument if the request fails; otherwise, called with the requested lesson.

getLessonsInCourse

public func getLessonsInCourse(
    courseId: String,
    limit: Int? = nil,
    page: Int? = nil,
    _ completion: @escaping (_ error: Error?, _ lessons: [DXLesson]?) -> Void)
    -> Void

Request all lessons belonging to a course.

Parameter

Type

Description

courseId

String

ID of the course.

limit

Int?

Page size.

page

Int?

Results page to return.

completion

(_ error: Error?, _ lessons: [DXLesson]?) -> Void

The closure invoked when the request finishes. Called with an Error argument if the request fails; otherwise, called with the requested lessons.

getAppLessons

public func getAppLessons(
    classId: String,
    _ completion: @escaping (_ error: Error?, _ lessons: [DXLesson]?) -> Void)
    -> Void

Returns all lessons that belong to the app the user is currently authenticated into, filtered by a provided class.

Parameter

Type

Description

classId

String

Class to which the requested lessons are assigned.

completion

(_ error: Error?, _ lessons: [DXLesson]?) -> Void

The closure invoked when the request finishes. Called with an Error argument if the request fails; otherwise, called with the requested lessons.

startLesson

public func startLesson(
    classId: String,
    lessonId: String,
    studentId: String? = nil,
    _ completion: @escaping (_ error: Error?, _ progress: DXLessonProgress?) -> Void)
    -> Void

Indicates a student has started taking a lesson, updating the start date in the lesson's progress. If the user has previously started the lesson but not completed it, this request will fail.

Parameter

Type

Description

classId

String

Lesson progress is tracked on a class-by-class basis. This parameter is the ID of the student's class for which you would like to retrieve progress in this lesson for.

lessonId

String

ID of the lesson.

studentId

String?

Specify which student to return progress for. If not provided, will return the progress of the currently authenticated user.

completion

(_ error: Error?, _ progress: DXLessonProgress?) -> Void

The closure invoked when the request finishes. Called with an Error argument if the request fails; otherwise, called with an instance of DXLessonProgress.

getStudentsProgress

public func getStudentsProgress(
    classId: String,
    lessonId: String,
    studentId: String? = nil,
    _ completion: @escaping (_ error: Error?, _ progress: DXLessonProgress?) -> Void)
    -> Void

Returns the current (or latest) progress for the specified lesson either for the currently authenticated user or a specified user.

Parameter

Type

Description

classId

String

Lesson is tracked on a class-by-class basis. This parameter is the ID of the student's class for which you would like to retrieve progress in this lesson for.

lessonId

String

ID of the lesson.

studentId

String?

Specify which student to return progress for. If not provided, will return the progress of the currently authenticated user.

completion

(_ error: Error?, _ progress: DXLessonProgress?) -> Void

The closure invoked when the request finishes. Called with an Error argument if the request fails; otherwise, called with an instance of DXLessonProgress.

getStudentsProgressHistory

public func getStudentsProgressHistory(
    classId: String,
    lessonId: String,
    studentId: String? = nil,
    _ completion: @escaping (_ error: Error?, _ history: [DXLessonProgress]?) -> Void
    ) -> Void

Returns all the attempts for the specified lesson either for the currently authenticated user or a specified user.

Parameter

Type

Description

classId

String

Lesson progress is tracked on a class-by-class basis. This parameter is the ID of the student's class for which you would like to retrieve progress in this lesson for.

lessonId

String

ID of the lesson.

studentId

String?

Specify which student to return progress for. If not provided, will return the progress of the currently authenticated user.

completion

(_ error: Error?, _ history: [DXLessonProgress]?) -> Void

The closure invoked when the request finishes. Called with an Error argument if the request fails; otherwise, called with the requested progress history.

updateStudentsProgress

public func updateStudentsProgress(
    classId: String,
    lessonId: String,
    pass: Bool,
    studentId: String? = nil,
    complete: Bool? = nil,
    score: Int? = nil,
    startTime: String? = nil,
    endTime: String? = nil,
    _ completion: @escaping (_ error: Error?, _ progress: DXLessonProgress?) -> Void
    ) -> Void

Updates a student's progress for a lesson in a class with a score, answers, and a pass/fail result.

Parameter

Type

Description

classId

String

Lesson progress is tracked on a class-by-class basis. This parameter is the ID of the student's class for which you would like to retrieve progress in this lesson for.

lessonId

String

ID of the lesson.

pass

Bool

A boolean pass/fail flag.

studentId

String?

Specify which student to return progress for. If not provided, will return the progress of the currently authenticated user.

complete

Bool?

If true, the lesson's completed attribute will be set to the current date/time, indicating the student has finished the lesson.

score

Int?

A numeric score for the lesson.

startTime

String?

A parseable date to mark the start of the student's session. Suggested format is ISO date, eg. 2020-01-07T21:45:35.649Z.

endTime

String?

A parseable date to mark the end of the student's session. Suggested format is ISO date, eg. 2020-01-07T21:45:35.649Z.

completion

(_ error: Error?, _ progress: DXLessonProgress?) -> Void

The closure invoked when the request finishes. Called with an Error argument if the request fails; otherwise, called with an instance of DXLessonProgress.

getLessonsLockStatus

public func getLessonsLockStatus(
        classId: String,
        _ completion: @escaping (_ error: Error?, _ lessons: [DXLesson]?) -> Void
    )

Checks whether or not the specified lesson is currently locked or unlocked.

Parameter

Type

Description

classId

String

Lesson progress is tracked on a class-by-class basis. This parameter is the ID of the student's class for which you would like to retrieve progress in this lesson for.

completion

( error: Error?, lessons: [DXLesson]?) -> Void

Closure invoked when the request finishes. Called with an Error argument if the request fails; otherwise, called with the lessons for that student.

pauseLesson

public func pauseLesson(
        lessonId: String,
        classId: String,
        _ completion: @escaping (_ error: Error?, _ lessonProgress: DXLessonProgress?) -> Void
    )

Indicates that a student has paused progress on a lesson.

The "progressIntervals" attribute will be updated with the previous start time and an end time of the current time.

Parameter

Type

Description

lessonId

String

ID of the lesson.

classId

String

Lesson progress is tracked on a class-by-class basis. This parameter is the ID of the student's class for which you would like to update the student's progress.

completion

( error: Error?, lessonProgress: DXLessonProgress?) -> Void

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

resumeLesson

public func resumeLesson(
        lessonId: String,
        classId: String,
        _ completion: @escaping (_ error: Error?, _ lessonProgress: DXLessonProgress?) -> Void
    )

Indicates that a student has resumed progress on a paused lesson.

Parameter

Type

Description

lessonId

String

ID of the lesson.

classId

String

Lesson progress is tracked on a class-by-class basis. This parameter is the ID of the student's class for which you would like to update the student's progress.

completion

( error: Error?, lessonProgress: DXLessonProgress?) -> Void

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

startIdleTimeForLesson

public func startIdleTimeForLesson(
        lessonId: String,
        classId: String,
        _ completion: @escaping (_ error: Error?, _ lessonProgress: DXLessonProgress?) -> Void
    )

Indicates that the student's progress is temporarily paused. The "idleIntervals" attribute will be updated with the previous start time and an end time of the current time.

Parameter

Type

Description

lessonId

String

ID of the lesson.

classId

String

Lesson progress is tracked on a class-by-class basis. This parameter is the ID of the student's class for which you would like to update the student's progress.

completion

( error: Error?, lessonProgress: DXLessonProgress?) -> Void

Closure invoked when the request finishes. Called with an Error argument if the request fails; otherwise, called with the lesson progress marked as idle.

endIdleTimeForLesson

public func endIdleTimeForLesson(
        lessonId: String,
        classId: String,
        _ completion: @escaping (_ error: Error?, _ lessonProgress: DXLessonProgress?) -> Void
    )

Indicates that a student has ended idle time.

Parameter

Type

Description

lessonId

String

ID of the lesson.

classId

String

Lesson progress is tracked on a class-by-class basis. This parameter is the ID of the student's class for which you would like to update the student's progress.

completion

( error: Error?, lessonProgress: DXLessonProgress?) -> Void

Closure invoked when the request finishes. Called with an Error argument if the request fails; otherwise, called with the lesson progress marked as active.

updateStudentsObjectiveScore

public func updateStudentsObjectiveScore(
        lessonId: String,
        classId: String,
        objectiveId: String,
        score: Int,
        _ completion: @escaping (_ error: Error?) -> Void
    )

Updates a student's objective score for a lesson, if the objective score is different than the student's overall lesson score.

Note that a student must have a lesson attempt started (or completed) before objective scores can be recorded for any objectives linked to that lesson.

Parameter

Type

Description

lessonId

String

ID of the lesson.

classId

String

Lesson progress is tracked on a class-by-class basis. This parameter is the ID of the student's class for which you would like to update the student's progress.

objectiveId

String

The objective's ID.

score

Int

A numeric score from 0-100.

completion

(_ error: Error?) -> Void

Closure invoked when the request finishes. Called with an Error argument if the request fails.

Last updated