@foreach($record->quizAnswers->groupBy('quiz_question_id') as $questionId => $answers) @php $question = $answers->first()->question; $correctOptions = $question?->options?->where('is_correct', true); $selectedTexts = $answers->pluck('option.option_text') ->map(fn($v) => strtolower(trim($v))) ->sort() ->values(); $correctTexts = $correctOptions?->pluck('option_text') ->map(fn($v) => strtolower(trim($v))) ->sort() ->values(); $isCorrect = $correctTexts->diff($selectedTexts)->isEmpty(); @endphp
{{ $question->question_text ?? 'Question' }}
Participant Answer: {{ $answers->pluck('option.option_text')->join(', ') ?: '-' }}
Correct Answer: {{ $correctOptions?->pluck('option_text')->join(', ') ?: '-' }}
@if($isCorrect) Correct @else Wrong @endif
@endforeach