Detailed Results
@foreach ($examQuestions as $key => $examQuestion)
@php
$answer = $examQuestion->answer;
$answerValue = $answer->answer_value ?? 'undefined';
$selectedOption = null;
$correctOption = null;
$isCorrect = false;
if ($examQuestion->question->answer_type == 8) {
$selectedOption = $examQuestion->question->mcqOptions->where('id', (int) $answerValue)->first();
$correctOption = $examQuestion->question->mcqOptions->where('is_correct', 1)->first();
if ($selectedOption && $correctOption && $selectedOption->id == $correctOption->id) {
$isCorrect = true;
}
}
@endphp
Q.{{ $key + 1 }} - {!! $examQuestion->question->question_title !!}
@if ($examQuestion->question->question_mark)
({{ $examQuestion->question->question_mark }} marks)
@endif
{{ ($answerValue === 'undefined' || !$isCorrect) ? 'close' : 'done' }}
Your Answer:
{{ $selectedOption->title ?? ($answerValue === 'undefined' ? 'Not Attempted' : $answerValue) }}
@if (!$isCorrect && $examQuestion->question->answer_type == 8 && $correctOption)
Correct Answer:
{{ $correctOption->title }}
@endif
@endforeach