Skip to main content
The learning context tells the widget what the student is currently doing. Provide it as config.lmsContext and update it at runtime with widget.updateContext(...).
type PageType =
  | 'dashboard'
  | 'assignment'
  | 'quiz'
  | 'lesson'
  | 'submission'
  | 'grades';

interface LearningContext {
  pageType: PageType;            // required
  courseId?: string;
  moduleName?: string;
  moduleId?: string;
  assignmentId?: string;
  quizId?: string;
  lessonId?: string;
  userProgress?: UserProgress;
  metadata?: Record<string, unknown>;
}

interface UserProgress {
  completed: number;
  total: number;
  lastActivity: Date;
  averageGrade?: number;
  currentStreak?: number;
}

Update on navigation

Update the context as the student moves through the LMS. This snippet is from the playground:
function handleContextSubmit(event: FormEvent<HTMLFormElement>) {
  event.preventDefault();
  widget.updateContext({pageType});
}

Behavior

If no context exists yet and you call updateContext without pageType, a ConfigurationError is thrown.
When the context changes to a contextual page (assignment, quiz, or submission) while the widget is idle, it automatically transitions to nudge.
The context engine can infer whether a student is struggling from userProgress and suggest nudge types accordingly. This is used internally to drive nudges.