@extends('layouts.template') @section('title', 'Kuesioner Soal') @section('custom_css') @endsection @section('content') @php $listHal = $daftarHal ?? collect([$hal]); $posisiAktif = $listHal->search($hal); if ($posisiAktif === false) { $posisiAktif = 0; } $totalHalaman = $totalHal ?? $listHal->count(); $progressPercentage = $totalHalaman > 0 ? round((($posisiAktif + 1) / max($totalHalaman, 1)) * 100) : 100; $halSebelumnya = $posisiAktif > 0 ? $listHal[$posisiAktif - 1] : null; $halBerikut = ($posisiAktif < $listHal->count() - 1) ? $listHal[$posisiAktif + 1] : null; $isHalTerakhir = $halBerikut === null; $formLocked = $formLocked ?? false; $prefillJawaban = $prefillJawaban ?? []; $existingJawaban = $existingJawaban ?? []; @endphp

Kuesioner

{{ $soal->judul_soal ?? 'Daftar Soal' }}

← Daftar Judul Halaman {{ $hal }}
Progres Halaman {{ $progressPercentage }}%
@if ($hal === $halPertama)
{{ $soal->judul_soal ?? '-' }}
{!! $soal->keterangan_soal !!}
@endif @if ($errors->any()) @endif @if ($formLocked)
Anda sudah mengisi kuesioner ini. Jawaban di bawah ditampilkan dalam mode baca.
@endif
Daftar Pertanyaan
Halaman {{ $hal }} dari {{ $listHal->count() }}
@csrf @forelse ($soal->soalDetail as $detail) @php $detailConfig = json_decode($detail->soal, true) ?? []; $pertanyaan = $detailConfig['soal'] ?? 'Pertanyaan tidak tersedia'; $type = $detailConfig['type'] ?? 'option'; $options = $detailConfig['options'] ?? []; if (!is_array($options)) { $options = []; } $optionValues = collect($options)->map(function ($value) { return is_scalar($value) ? (string) $value : ''; })->all(); $existingAnswer = $existingJawaban[$detail->id] ?? null; $prefillAnswer = $prefillJawaban[$detail->id] ?? null; $currentAnswer = old('jawaban.' . $detail->id, $existingAnswer ?? $prefillAnswer); $existingOtherAnswer = $existingAnswer && !in_array($existingAnswer, $optionValues, true) ? $existingAnswer : null; $prefillOtherAnswer = $prefillAnswer && !in_array($prefillAnswer, $optionValues, true) ? $prefillAnswer : null; $oldOtherAnswer = old('jawaban_lainnya.' . $detail->id, $existingOtherAnswer ?? $prefillOtherAnswer); $hasCurrentAnswer = $currentAnswer !== null && $currentAnswer !== ''; $isCustomCurrentAnswer = $hasCurrentAnswer && !in_array($currentAnswer, $optionValues, true); if (!$oldOtherAnswer && $isCustomCurrentAnswer) { $oldOtherAnswer = $currentAnswer; } $showLainnya = $isCustomCurrentAnswer || (is_string($currentAnswer) && stripos($currentAnswer, 'lainnya') !== false) || (!empty($oldOtherAnswer)); $detailHal = $detail->hal ?? $listHal->first(); $isVisible = $detailHal == $hal; $optionsCount = is_array($options) ? count($options) : 0; $useSelectSearch = $optionsCount > 4; $hasLainnyaOption = collect($options)->contains(function ($optionItem) { return is_string($optionItem) && stripos($optionItem, 'lainnya') !== false; }); if (!$hasLainnyaOption && $type === 'option_with_other') { $hasLainnyaOption = true; } $isConsentQuestion = !empty($detailConfig['persetujuan_form']); $shouldForceLainnyaSelection = $hasLainnyaOption && $showLainnya; $dualFormConfig = $detailConfig['dual_form'] ?? null; $useDualForm = $type === 'dual_form' || (!empty($dualFormConfig) && $dualFormConfig !== false); $dualYearOld = null; $dualMonthOld = null; if ($useDualForm && $currentAnswer) { if (preg_match('/([0-9]+)\\s*\\(Tahun\\)/i', $currentAnswer, $matchYear)) { $dualYearOld = $matchYear[1]; } if (preg_match('/([0-9]+)\\s*\\(Bulan\\)/i', $currentAnswer, $matchMonth)) { $dualMonthOld = $matchMonth[1]; } } @endphp
{{ $loop->iteration }}
{{ $pertanyaan }}
@if ($isConsentQuestion)

Pertanyaan persetujuan

@endif
@if ($useDualForm)
@elseif ($type === 'textarea') @elseif ($type === 'text') @else @if (!empty($options)) @if ($useSelectSearch) @if ($hasLainnyaOption || $type === 'option_with_other')
@endif @else @php $lainnyaWrapperRendered = false; @endphp
@foreach ($options as $optionIndex => $option) @php $optionId = 'jawaban-' . $detail->id . '-' . $optionIndex; $optionLabel = is_scalar($option) ? (string) $option : ''; $isLainnya = stripos($optionLabel, 'lainnya') !== false; $optionValue = $isLainnya && $oldOtherAnswer ? $oldOtherAnswer : $optionLabel; $shouldCheck = $currentAnswer === $optionValue || ($isLainnya && $shouldForceLainnyaSelection); @endphp
@if ($isLainnya) @php $lainnyaWrapperRendered = true; @endphp
@endif @endforeach
@if (!$lainnyaWrapperRendered && $type === 'option_with_other')
@endif @endif @else @endif @endif @error('jawaban.' . $detail->id)
{{ $message }}
@enderror @error('jawaban_lainnya.' . $detail->id)
{{ $message }}
@enderror
@empty
Belum ada pertanyaan pada halaman ini.
@endforelse @error('lms_mutu_soal_id')

{{ $message }}

@enderror @error('jawaban')

{{ $message }}

@enderror
@endsection @section('custom_js') @endsection