Update Saqel Platform: 2026-09-02 09:06:45
This commit is contained in:
@@ -69,6 +69,7 @@ class VideoPlaybackError extends VideoPlaybackState {
|
||||
|
||||
class VideoPlaybackCubit extends Cubit<VideoPlaybackState> {
|
||||
final CurriculumRepository _repo;
|
||||
int _lastObservedPosition = -1;
|
||||
|
||||
VideoPlaybackCubit({CurriculumRepository? repo})
|
||||
: _repo = repo ?? CurriculumRepository(),
|
||||
@@ -76,6 +77,7 @@ class VideoPlaybackCubit extends Cubit<VideoPlaybackState> {
|
||||
|
||||
Future<void> loadLesson(CurriculumLessonItemModel lesson, {SubjectModel? subject}) async {
|
||||
AppLogger.log('Loading Socratic playback for lesson: ${lesson.title}', tag: 'VIDEO_CUBIT');
|
||||
_lastObservedPosition = -1;
|
||||
emit(VideoPlaybackLoading());
|
||||
try {
|
||||
final playback = await _repo.getLessonPlayback(lesson.markdownFilePath ?? lesson.id, subjectId: subject?.id);
|
||||
@@ -97,9 +99,9 @@ class VideoPlaybackCubit extends Cubit<VideoPlaybackState> {
|
||||
if (currentState is VideoPlaybackReady && currentState.activeCheckpoint == null) {
|
||||
// Check if this second triggers a Socratic checkpoint
|
||||
for (var cp in currentState.playbackData.checkpoints) {
|
||||
if (!currentState.passedCheckpointIds.contains(cp.id) &&
|
||||
seconds >= cp.timestampSeconds &&
|
||||
seconds <= cp.timestampSeconds + 2) {
|
||||
final crossedCheckpoint = seconds >= cp.timestampSeconds &&
|
||||
(_lastObservedPosition < cp.timestampSeconds || _lastObservedPosition > seconds);
|
||||
if (!currentState.passedCheckpointIds.contains(cp.id) && crossedCheckpoint) {
|
||||
AppLogger.log('🚨 Socratic Checkpoint Triggered! (${cp.questionText})', tag: 'SOCRATIC_ENGINE');
|
||||
emit(currentState.copyWith(
|
||||
currentPositionSeconds: seconds,
|
||||
@@ -110,6 +112,7 @@ class VideoPlaybackCubit extends Cubit<VideoPlaybackState> {
|
||||
}
|
||||
}
|
||||
|
||||
_lastObservedPosition = seconds;
|
||||
emit(currentState.copyWith(currentPositionSeconds: seconds));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user