ENGLISH·COURSE API
    Preparing search index...
    • Marks a lesson complete once the learner has watched it to the end.

      Parameters

      • lessonId: {
            lessonId: string & $brand<"LessonId">;
            durationSeconds: number;
            player: WatchedPlayer;
        }

        The lesson to mark

      Returns WatchedCompletion

      The two handlers a player binds to its lifecycle events

      The finish rule itself lives in hasFinishedWatching; this hook is the part that has to know when it is fair to act on it. Two refs carry that:

      • A gate, closed until playback begins. Opening a lesson whose stored position is already past the threshold fires time-update at that position, and writing then would record a completion the learner did not earn on this visit. The lesson already reads as complete from its position, so nothing is lost by waiting.
      • A "written" flag. time-update fires several times a second, and the last fifteen seconds of a lesson would otherwise write the same mark fifty times.

      The write goes through markLessonComplete — the same path the manual button uses — so there is one stored notion of "done" rather than two. The same "written" flag makes the celebration fire once: the burst belongs to the moment the lesson is finished, not to every progress event after it. Completion is never withdrawn here: rewinding a finished lesson leaves the mark standing.

      The lesson's own durationSeconds is preferred, and the provider's reported duration is the fallback, so a lesson whose metadata is missing a runtime can still be finished.