@php
$st = $track->lesson_status ?: 'not attempted';
$fresh = $st === 'not attempted';
$init12 = [
'cmi.core.student_id' => (string) $user->id, 'cmi.core.student_name' => $user->name, 'cmi.core.lesson_location' => $track->location ?? '',
'cmi.core.credit' => 'credit', 'cmi.core.lesson_status' => $st, 'cmi.core.entry' => $fresh ? 'ab-initio' : 'resume',
'cmi.core.total_time' => $track->total_time ?? '0000:00:00', 'cmi.core.lesson_mode' => 'normal', 'cmi.suspend_data' => $track->suspend_data ?? '', 'cmi.launch_data' => '',
'cmi.core.score.raw' => $track->score_raw !== null ? (string) $track->score_raw : '', 'cmi.core.score.max' => '100', 'cmi.core.score.min' => '0',
'cmi.core._children' => 'student_id,student_name,lesson_location,credit,lesson_status,entry,score,total_time,lesson_mode,exit,session_time', 'cmi.core.score._children' => 'raw,min,max',
];
$init2004 = [
'cmi.learner_id' => (string) $user->id, 'cmi.learner_name' => $user->name, 'cmi.location' => $track->location ?? '',
'cmi.completion_status' => in_array($st, ['completed', 'passed', 'failed'], true) ? 'completed' : ($fresh ? 'not attempted' : 'incomplete'),
'cmi.success_status' => in_array($st, ['passed', 'failed'], true) ? $st : 'unknown', 'cmi.entry' => $fresh ? 'ab-initio' : 'resume', 'cmi.suspend_data' => $track->suspend_data ?? '',
'cmi.total_time' => $track->total_time ?? 'PT0H0M0S', 'cmi.mode' => 'normal', 'cmi.credit' => 'credit', 'cmi.score.raw' => $track->score_raw !== null ? (string) $track->score_raw : '', 'cmi.score.scaled' => '', 'cmi.score.max' => '100', 'cmi.score.min' => '0', 'cmi._version' => '1.0',
];
$saved = (object) ($track->cmi ?? []);
@endphp