@extends('layouts.student')
@section('title', 'Kuis Dikumpulkan: ' . $quiz->title)
@section('content')
{{-- Success Header --}}
{{ $quiz->course->title }}
Kuis Berhasil Dikumpulkan!
{{ $quiz->title }}
@if(isset($attempt))
@php
$passed = ($attempt->score ?? 0) >= ($quiz->passing_score ?? 70);
$answers = json_decode($attempt->answers_json, true) ?? [];
$correctCount = 0; $wrongCount = 0;
foreach($quiz->questions as $question) {
$userAnswer = $answers[$question->id] ?? null;
if ($question->type === 'multiple_choice' || $question->type === 'true_false') {
$correctAnswer = $question->answers->firstWhere('is_correct', true);
if ($correctAnswer && $userAnswer == $correctAnswer->id) $correctCount++; else $wrongCount++;
} elseif ($question->type === 'essay') {
if (!empty($userAnswer)) $correctCount++; else $wrongCount++;
}
}
@endphp
{{-- Score --}}
Skor Akhir
{{ $attempt->score ?? 0 }}
dari 100 poin
{{ $passed ? 'Lulus' : 'Belum Lulus' }}
@if($quiz->passing_score)
Nilai minimum kelulusan: {{ $quiz->passing_score }}
@endif
{{-- Statistik --}}
{{ $correctCount }}
Benar
{{ $quiz->questions->count() }}
Total Soal
@endif
{{-- Aksi --}}
Kembali ke Kursus
@if(isset($attempt))
Lihat Detail Hasil
@endif
@php
$canRetry = !isset($attempt) || ($attempt->score ?? 100) < ($quiz->passing_score ?? 70);
$attemptsCount = isset($attempts) ? $attempts->count() : 0;
$maxAttempts = $quiz->max_attempts ?? null;
$canAttempt = !$maxAttempts || $attemptsCount < $maxAttempts;
@endphp
@if($canRetry && $canAttempt)
Coba Lagi
@endif
@endsection