Skip to main content
Once you have a LessonSession from lessons.start(), the question loop is how your app drives the lesson forward. Call session.next() to get a question, render it, then call session.submit() with the student’s answer.

The basic loop

let question = await session.next()

while (question) {
	// Render the question, collect an answer from the student
	const answer = await renderQuestion(question)

	const result = await session.submit({
		question: question.id,
		response: answer,
	})

	// result.score, result.correct, result.complete are available

	question = await session.next()
}

// No more questions -- complete the lesson
const completion = await session.complete()

Fetch a question

session.next() returns the next LessonQuestion, or null when there are no more questions:
const question = await session.next()

if (!question) {
	// Lesson is complete, call session.complete()
}
Each question includes an id and content.rawXml with QTI XML. Your app is responsible for parsing and rendering this XML.
See the reference for the full type.
QTI XML parsing utilities are coming soon to the SDK. In the meantime, you’ll need to parse the XML yourself to extract prompts, choices, and correct responses.

Submit an answer

After the student answers, submit their response:
const result = await session.submit({
	question: question.id,
	response: selectedAnswer,
})
The result tells you whether the answer was correct, the updated score, and whether the lesson is now complete. After each submission, the session’s score and finalized properties update automatically.
See the reference for full parameter and return type documentation.
const result = await session.submit({ question: question.id, response: 'A' })
console.log(result.correct) // Whether the answer was correct
console.log(session.score) // Updated cumulative score
console.log(session.finalized) // true if the lesson auto-completed

Adaptive vs linear delivery

The SDK handles two delivery modes transparently. Your code uses the same next() / submit() loop regardless of mode.
You do not need to detect which mode is active. The LessonSession handles it based on the lessonType set during lessons.start().

Adaptive (powerpath-100)

Each next() call hits the server, which asks PowerPath for the next question based on the student’s performance so far. Questions are served one at a time, and difficulty adapts.

Linear (quiz, test-out, etc.)

On the first next() call, the SDK fetches all questions at once and buffers them locally. Subsequent next() calls return from the local buffer without a network round trip. Already-answered questions are skipped automatically.

Track progress during the loop

The session properties update in real time as the student progresses. Use session.score, session.finalized, and session.lessonType to render progress indicators, score displays, or early-completion UI.

Next steps

Completion

Finalize scoring and interpret results

Reference

Parameters, properties, methods, and return types