@php $statsBySkill = collect($data['question_skill_stats'] ?? []) ->mapWithKeys(fn ($row) => [strtolower(trim((string) ($row['skill'] ?? ''))) => $row]); @endphp @foreach (($data['questions_by_skill'] ?? []) as $skillGroup) @php $skillName = (string) ($skillGroup['skill'] ?? ''); $stat = $statsBySkill[strtolower(trim($skillName))] ?? null; $statTotal = (int) ($stat['total'] ?? count($skillGroup['questions'] ?? [])); $statCorrect = (int) ($stat['correct'] ?? 0); $statPercentage = (int) ($stat['percentage'] ?? ($statTotal > 0 ? (int) ceil(($statCorrect / $statTotal) * 100) : 0)); $skillDescription = \App\Support\SkillDescriptions::for($skillName); $skillDescription = $skillDescription ? str_replace('--', '—', $skillDescription) : $skillDescription; @endphp
Readingful Logo
Question Answer Record
{{ $dateRange }}
{{ $studentName }} ( {{ $grade }} )
{{ $skillName }} {{ $statCorrect }}/{{ $statTotal }} ({{ $statPercentage }}%)
@if($skillDescription)
{{ $skillDescription }}
@endif @php $skillQuestions = $skillGroup['questions'] ?? []; $skillQuestionCount = count($skillQuestions); if ($skillQuestionCount <= 3) { $totalSlots = 3; } else { $subsequentPages = (int) ceil(($skillQuestionCount - 3) / 5); $totalSlots = 3 + ($subsequentPages * 5); } $emptySlotCount = max(0, $totalSlots - $skillQuestionCount); @endphp @foreach ($skillQuestions as $idx => $question) @php $correctLetter = $question['correct_letter'] ?? null; $studentLetter = $question['student_letter'] ?? null; $correctLetterDisplay = $correctLetter ? strtoupper($correctLetter) : '—'; $studentLetterDisplay = $studentLetter ? strtoupper($studentLetter) : '—'; $questionTextClean = trim(preg_replace('/\s+/', ' ', preg_replace('//i', ' ', (string) ($question['question_text'] ?? '')))); $questionTextClean = str_replace('--', '—', $questionTextClean); $storyTitleClean = str_replace('--', '—', (string) ($question['story_title'] ?? '')); $needsPageBreak = $idx >= 3 && (($idx - 3) % 5 === 0); @endphp @if($needsPageBreak)
@endif @php $blockClasses = 'question-block'; if ($idx === 0) { $blockClasses .= ' first-on-page-1'; } elseif ($needsPageBreak) { $blockClasses .= ' first-on-subsequent-page'; } @endphp
{{ $idx + 1 }}. {{ $questionTextClean }}
@foreach (($question['choices'] ?? []) as $choice) @php $choiceText = str_replace('--', '—', (string) ($choice['text'] ?? '')); $choiceText = mb_strlen($choiceText) > 70 ? mb_substr($choiceText, 0, 70) . '…' : $choiceText; @endphp
{{ $choice['letter'] }}. {{ $choiceText }}
@endforeach
From the quiz for “{{ $storyTitleClean }}.” Correct answer: {{ $correctLetterDisplay }}. Student answer: {{ $studentLetterDisplay }}.
@endforeach @for ($i = 0; $i < $emptySlotCount; $i++) @php $emptyIdx = $skillQuestionCount + $i; $emptyNeedsPageBreak = $emptyIdx >= 3 && (($emptyIdx - 3) % 5 === 0); $emptyBlockClasses = 'question-block'; if ($emptyIdx === 0) { $emptyBlockClasses .= ' first-on-page-1'; } elseif ($emptyNeedsPageBreak) { $emptyBlockClasses .= ' first-on-subsequent-page'; } @endphp @if($emptyNeedsPageBreak)
@endif
@endfor
@endforeach