- Your answer
- @if($r['given']){{ collect($r['given'])->map(fn ($t) => $t)->join(' · ') }}@else No answer given@endif @if($state !== 'ok')
- Correct answer
- {{ collect($r['correct'])->join(' · ') }} @endif
Why: {{ $r['explanation'] }}
@endif@extends('layouts.portal')
@php
use App\Support\ExamText;
use App\Support\Share;
$voided = $a->status === 'voided';
$passed = ! $voided && $a->passed;
$verdict = $voided ? 'void' : ($passed ? 'pass' : 'fail');
$pct = (float) $a->percent;
$mins = intdiv((int) $a->time_spent_seconds, 60);
$secs = (int) $a->time_spent_seconds % 60;
$timeTaken = $a->time_spent_seconds ? ($mins >= 60 ? intdiv($mins, 60).'h '.($mins % 60).'m' : $mins.'m '.str_pad((string) $secs, 2, '0', STR_PAD_LEFT).'s') : '—';
$domains = collect($a->domain_scores ?? [])->map(fn ($d, $k) => $d + ['name' => $k])->sortBy('percent')->values();
$weak = $domains->filter(fn ($d) => $d['percent'] < $exam->pass_percent)->take(2);
$used = (int) ($elig['attempts_used'] ?? $a->attempt_no);
$left = $exam->max_attempts ? max(0, $exam->max_attempts - $used) : null;
$events = $a->violations > 0 || $a->auto_submitted ? $a->events()->get() : collect();
$evLabels = ['tab_hidden' => 'Switched to another tab or window', 'window_blur' => 'Exam window lost focus', 'fullscreen_exit' => 'Left full screen', 'copy' => 'Copy attempts', 'paste' => 'Paste attempts', 'context_menu' => 'Right-click attempts'];
$evCounts = $events->whereIn('type', array_keys($evLabels))->groupBy('type')->map->count();
$autoNote = $events->firstWhere('type', 'auto_submit')?->meta['note'] ?? null;
if ($autoNote === 'Time expired') { $autoNote = null; }
$cred = $passed ? $a->credential : null;
$issuance = $cred?->badge;
$badge = $issuance?->badge;
$enrolled = $exam->course && $a->user && $a->user->isEnrolledInCourse($exam->course_id);
$shC = $cred ? Share::credential($cred) : null;
$shB = $issuance ? Share::badge($issuance) : null;
@endphp
@section('title', 'Exam result')
@section('subtitle', $exam->title.' · attempt '.$a->attempt_no.' · '.($a->submitted_at?->format('d M Y, g:i A') ?? '—'))
@section('actions')
@if($voided){{ $a->void_reason ?: 'An administrator voided this attempt.' }} Contact your trainer or the academy office if you believe this is a mistake.
@elseif($passed)You scored {{ rtrim(rtrim(number_format($pct, 2), '0'), '.') }}% against a pass mark of {{ $exam->pass_percent }}%.{{ $cred ? ' Your certificate and digital badge have been issued below.' : '' }}
@else You scored {{ rtrim(rtrim(number_format($pct, 2), '0'), '.') }}%; the pass mark is {{ $exam->pass_percent }}%.@if($weak->isNotEmpty()) Focus your revision on {{ $weak->pluck('name')->join(', ', ' and ') }}.@endif @endif
@if($voided)This attempt was voided
@elseif($passed)You passed {{ $exam->title }}
@else You did not reach the pass mark @endif
{{ $badge ? $badge->name.' badge · ' : '' }}Credential ID {{ $cred->credential_id }} · Issued {{ $cred->issued_at?->format('d M Y') }}
Share your achievement
You can sit this exam again{{ $left === null ? '.' : ' — '.$left.' '.\Illuminate\Support\Str::plural('attempt', $left).' left.' }} A new attempt draws a fresh set of questions with shuffled answer options.
Cooldown in effect. You can retake this exam ({{ $elig['next_at']->format('d M Y, g:i A') }}). Use the time to revise the domains below.
@elseNo retake available. {{ $elig['reason'] ?? 'You have used all attempts for this exam.' }} Speak to your trainer if you need an extra attempt.
@endifThese events are recorded for every proctored exam and may be reviewed by the academy before a certificate is confirmed.
@endif @if($autoNote)Why: {{ $r['explanation'] }}
@endif