@extends('layouts.student')
@section('title', 'Hasil Kuis: ' . $quiz->title)
@section('content')
{{-- Header --}}
{{ $quiz->course->title }} ยท Kuis
{{ $quiz->title }}
{{-- Score Card --}}
@php
$score = $attempt->score ?? 0;
$passed = $score >= ($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 }}
dari 100 poin
{{ $passed ? 'Lulus!' : 'Belum Lulus' }}
{{ $correctCount }}
Benar
{{ $quiz->questions->count() }}
Total
@if($quiz->passing_score)
Nilai lulus: {{ $quiz->passing_score }}
@endif
{{-- Review Jawaban --}}
@if($attempt->answers && ($quiz->show_review ?? true))
Review Jawaban
@foreach($quiz->questions as $i => $question)
@php
$userAnswer = $attempt->answers[$question->id] ?? null;
$correctAnswer = $question->correct_answer ?? null;
$isCorrect = $userAnswer == $correctAnswer;
@endphp
{{ $i + 1 }}
{!! nl2br(e($question->question)) !!}
@if($question->type === 'multiple_choice' || $question->type === 'true_false')
@foreach($question->options ?? [] as $key => $option)
@if($key == $correctAnswer)
@elseif($key == $userAnswer)
@else
@endif
{{ $option }}
@endforeach
@elseif($question->type === 'essay')
Jawaban kamu:
{{ $userAnswer ?? '(tidak dijawab)' }}
@endif
@if($question->explanation)
{{ $question->explanation }}
@endif
@endforeach
@endif
{{-- Aksi --}}
@endsection