-
Judul Soal
{{ $soal->judul_soal ?? '-' }}
-
Keterangan
{!! $soal->keterangan_soal !!}
@@ -123,82 +168,226 @@
$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();
$oldAnswer = old('jawaban.' . $detail->id);
$oldOtherAnswer = old('jawaban_lainnya.' . $detail->id);
- $showLainnya = $oldAnswer === 'Lainnya' || (!empty($oldOtherAnswer));
+ $hasOldAnswer = $oldAnswer !== null && $oldAnswer !== '';
+ $isCustomOldAnswer = $hasOldAnswer && !in_array($oldAnswer, $optionValues, true);
+ if (!$oldOtherAnswer && $isCustomOldAnswer) {
+ $oldOtherAnswer = $oldAnswer;
+ }
+ $showLainnya = $isCustomOldAnswer
+ || (is_string($oldAnswer) && stripos($oldAnswer, '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 && $oldAnswer) {
+ if (preg_match('/([0-9]+)\\s*\\(Tahun\\)/i', $oldAnswer, $matchYear)) {
+ $dualYearOld = $matchYear[1];
+ }
+ if (preg_match('/([0-9]+)\\s*\\(Bulan\\)/i', $oldAnswer, $matchMonth)) {
+ $dualMonthOld = $matchMonth[1];
+ }
+ }
@endphp
-
-
-
{{ $loop->iteration }}
+
+
+
+ {{ $loop->iteration }}
+
{{ $pertanyaan }}
+
+ @if ($isConsentQuestion)
+
Pertanyaan persetujuan
+ @endif
-
-
{{ $pertanyaan }}
-
- @if ($type === 'textarea')
-
- @elseif ($type === 'text')
-
- @else
- @if (!empty($options))
-
@empty
@@ -243,6 +432,7 @@
@endsection
@section('custom_js')
+
@endsection