DXAssessmentClient

This class is responsible for making requests to the the assessment API. An assessment is a series of questions or tasks that a student must complete to finish a course.

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

Properties

public static let shared: DXAssessmentClient

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

Methods

getAssessment

public func getAssessment(
    assessmentId: String,
    _ completion: @escaping (_ error: Error?, _ assessment: [DXAssessmentQuestion]?) -> Void)
    -> Void

Retrieves a single assessment by ID to be displayed to a user.

Parameter

Type

Description

assessmentId

String

The ID of the requested assessment. This can be found when reading an assessment lesson. Corresponds to the media property of a DXLesson.

completion

(_ error: Error?, _ assessment: [DXAssessmentQuestion]?) -> Void

The closure invoked when the request finishes. Called with an Error argument if the request fails; otherwise, called with a list of assessment questions that represents an assessment.

updateStudentAssessmentAnswers

public func updateStudentAssessmentAnswers(
    correct: Bool,
    answer: String,
    questionIndex: Int,
    classId: String,
    lessonId: String,
    studentId: String? = nil,
    _ completion: @escaping (_ error: Error?, _ progress: DXLessonProgress?) -> Void
  ) -> Void

Updates a student's answer for an assessment question. Returns the student's progress including their answers. Note that all questions in the assessment will be returned. Questions that the student has answered will have an "answer" field, questions that the student hasn't answered will have null for the "answer" and "correct" fields.

Parameter

Type

Description

correct

Bool

Whether or not the student's answer is correct.

answer

String

Student's answer.

questionIndex

Int

Integer index of the question in the assessment. This should match the index of the question returned in the assessment's array above.

classId

String

Assessments are graded on a class-by-class basis. Indicate which class you are reporting student answers on with this ID.

lessonId

String

ID of the assessment lesson.

studentId

String?

Student who is being assessed. If omitted, defaults to 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, returns the student's lesson progress.

Last updated