Laporan Hasil Survey: {{ $survey->title }}

@if($dateFrom && $dateTo) Periode: {{ $dateFrom }} s/d {{ $dateTo }}
@endif Total Responden: {{ $responses->count() }}

Rekapitulasi Jawaban Pertanyaan Radio

@foreach($questions as $question) @if($question->question_type === 'radio')

{{ $question->question_text }}

@php $optionCounts = array_fill_keys($question->options_array, 0); foreach($responses as $response) { $answers = is_array($response->answers) ? $response->answers : json_decode($response->answers, true); $ans = $answers[$question->id] ?? null; if($ans !== null && isset($optionCounts[$ans])) { $optionCounts[$ans]++; } } $totalResponses = $responses->count(); @endphp @foreach($question->options_array as $option) @endforeach
Pilihan Jumlah Persentase
{{ $option }} {{ $optionCounts[$option] }} @if($totalResponses > 0) {{ number_format(($optionCounts[$option] / $totalResponses) * 100, 1) }}% @else 0% @endif
@endif @endforeach @if($questions->where('question_type', 'radio')->count() === 0)
Tidak ada pertanyaan radio pada survey ini.
@endif

Jawaban Lainnya

@foreach($questions as $question) @if(in_array($question->question_type, ['checkbox', 'text']))

{{ $question->question_text }}

@endif @endforeach @if($questions->whereIn('question_type', ['checkbox','text'])->count() === 0)
Tidak ada pertanyaan checkbox atau text pada survey ini.
@endif