@php $responses = \App\Models\Response::where('exam_id', $exam->id) ->where('user_id', auth()->id()) ->get() ->keyBy('question_id'); $totalQuestions = $exam->questions->count(); $attempted = $responses->whereNotNull('option_id')->count(); $correct = $responses->where('is_correct', 1)->count(); $wrong = $responses->where('is_correct', 0)->whereNotNull('option_id')->count(); $notAttempted = $totalQuestions - $attempted; $passPercentage = (float) ($exam->pass_percentage ?? 40); $passed = $percentage >= $passPercentage; $totalMarks = $exam->questions->sum(fn ($q) => (int) ($q->marks ?? 1)); @endphp
{{-- HERO --}}

Exam Result

{{ $exam->title }}

A simple summary of your exam performance.

{{ $passed ? 'Passed' : 'Failed' }}
{{-- STATS --}}

Total Questions

0

Correct

0

Not Attempted

0

Wrong

0

{{-- SCORE SUMMARY --}}
{{-- Marks --}}

Marks Obtained

{{ number_format($obtainedMarks, 2) }}

/ {{ number_format($totalMarks, 2) }}

{{ number_format($percentage, 1) }}%
{{-- Percentage --}}

Percentage

0%

{{ $passed ? 'Pass' : 'Fail' }}

Pass threshold: {{ number_format($passPercentage, 1) }}%

{{-- QUESTION REVIEW --}}

Question Review

Question-wise Performance

@foreach($exam->questions as $index => $question) @php $resp = $responses[$question->id] ?? null; $isAttempted = $resp && $resp->option_id !== null; $isCorrect = $resp && $resp->is_correct == 1; $marksDisplay = 0; $selectedOption = $isAttempted ? $question->options->firstWhere('id', $resp->option_id) : null; $correctOption = $question->options->firstWhere('is_correct', 1); if ($isCorrect) { $marksDisplay = $resp->marks_obtained; } elseif ($isAttempted && $exam->negative_enabled) { $marksDisplay = -$exam->negative_marking; } $state = !$isAttempted ? 'skipped' : ($isCorrect ? 'correct' : 'wrong'); @endphp
Q{{ $index + 1 }} {{ $state === 'correct' ? 'Correct' : ($state === 'wrong' ? 'Wrong' : 'Skipped') }}
Marks: {{ $isCorrect ? '+' . number_format($marksDisplay, 2) : ($isAttempted && $exam->negative_enabled ? number_format($marksDisplay, 2) : '0.00') }}
Ask AI about this question

{{ $question->question_text }}

@if($question->question_text_en)

{{ $question->question_text_en }}

@endif
{{-- Your Answer --}}

Your Answer

@if($isAttempted && $selectedOption)

{{ $selectedOption->option_text }}

@if($selectedOption->option_text_en)

{{ $selectedOption->option_text_en }}

@endif @else

Not attempted

@endif
{{-- Correct Answer --}}

Correct Answer

@if($correctOption)

{{ $correctOption->option_text }}

@if($correctOption->option_text_en)

{{ $correctOption->option_text_en }}

@endif @endif
@endforeach