@php if (!function_exists('cleanLatex')) { function cleanLatex($text) { if (empty($text)) return ''; $replacements = [ // Arrows '$\rightarrow$' => '→', '$\leftarrow$' => '←', '$\Rightarrow$' => '⇒', '$\Leftarrow$' => '⇐', '$\leftrightarrow$' => '↔', '$\Leftrightarrow$' => '⇔', '\rightarrow' => '→', '\leftarrow' => '←', '\Rightarrow' => '⇒', '\Leftarrow' => '⇐', // Greek Letters '$\alpha$' => 'α', '$\beta$' => 'β', '$\gamma$' => 'γ', '$\delta$' => 'δ', '$\epsilon$' => 'ε', '$\zeta$' => 'ζ', '$\eta$' => 'η', '$\theta$' => 'θ', '$\iota$' => 'ι', '$\kappa$' => 'κ', '$\lambda$' => 'λ', '$\mu$' => 'μ', '$\nu$' => 'ν', '$\xi$' => 'ξ', '$\pi$' => 'π', '$\rho$' => 'ρ', '$\sigma$' => 'σ', '$\tau$' => 'τ', '$\upsilon$' => 'υ', '$\phi$' => 'φ', '$\chi$' => 'χ', '$\psi$' => 'ψ', '$\omega$' => 'ω', '$\Gamma$' => 'Γ', '$\Delta$' => 'Δ', '$\Theta$' => 'Θ', '$\Lambda$' => 'Λ', '$\Xi$' => 'Ξ', '$\Pi$' => 'Π', '$\Sigma$' => 'Σ', '$\Upsilon$' => 'Υ', '$\Phi$' => 'Φ', '$\Psi$' => 'Ψ', '$\Omega$' => 'Ω', // Math Operators & Symbols '$\pm$' => '±', '$\times$' => '×', '$\div$' => '÷', '$\approx$' => '≈', '$\neq$' => '≠', '$\leq$' => '≤', '$\geq$' => '≥', '$\infty$' => '∞', '$\circ$' => '°', '^\circ' => '°', '$\sqrt$' => '√', '$\propto$' => '∝', '$\equiv$' => '≡', // Stripped Math environments if they just typed $x$ '$' => '' // Fallback to remove remaining $ signs used for math mode ]; // First process specific tags foreach ($replacements as $latex => $unicode) { if ($latex !== '$') { $text = str_replace($latex, $unicode, $text); } } // Finally strip any remaining math mode dollars if you want, but might break currency. // It's safer to only replace specific latex tags and not raw $. // So we'll skip stripping raw '$' to avoid breaking actual currency. return $text; } } @endphp
@if($quiz->subLesson && $quiz->subLesson->lesson)

{{ $quiz->subLesson->lesson->title }}

@endif @if($quiz->subLesson)

{{ $quiz->subLesson->title }}

@endif

{{ $quiz->title }}

@foreach($quiz->questions as $index => $question)
{{ $index + 1 }}. {{ cleanLatex($question->text_content) }}
@if($question->image_path && Storage::disk('public')->exists($question->image_path))
Question Image @if($question->type === 'drag_drop') @foreach($question->answers as $aIndex => $answer)
{{ $aIndex + 1 }}
@endforeach @endif
@endif @if($question->type === 'statement_evaluation' && $question->statements)
@foreach($question->statements as $sIndex => $statement)
{{ chr(65 + $sIndex) }}. {{ cleanLatex($statement) }}
@endforeach
@endif @if($question->type !== 'drag_drop')
@foreach($question->answers as $aIndex => $answer)
({{ $aIndex + 1 }}). {{ cleanLatex($answer->content) }}
@endforeach
@elseif($question->type === 'drag_drop')
Labels to place:
@foreach($question->answers->shuffle() as $answer) {{ cleanLatex($answer->content) }} @endforeach
@endif
@endforeach

Answers

@foreach($quiz->questions as $index => $question)
{{ $index + 1 }}. {{ cleanLatex($question->text_content) }}
@if($question->type !== 'drag_drop')
Correct Answer(s):
@foreach($question->answers as $aIndex => $answer) @if($answer->is_correct)
({{ $aIndex + 1 }}). {{ cleanLatex($answer->content) }}
@endif @endforeach @if($question->definition)
Explanation: {{ cleanLatex($question->definition) }}
@endif
@else
Drag & Drop Labels:
@foreach($question->answers as $aIndex => $answer)
Marker {{ $aIndex + 1 }}: {{ cleanLatex($answer->content) }}
@endforeach
@endif
@endforeach