diff --git a/resources/views/soal/index.blade.php b/resources/views/soal/index.blade.php index 18ff21b..0d9d760 100644 --- a/resources/views/soal/index.blade.php +++ b/resources/views/soal/index.blade.php @@ -171,6 +171,10 @@ font-weight: 600; font-size: 12px; } + + .badge-placeholder { + visibility: hidden; + } @endsection @@ -257,10 +261,59 @@ @php $questionCounter = 0; + $groupedQuestionDetails = []; + $groupIndexMap = []; + foreach ($soal->soalDetail as $detailItem) { + $detailConfigItem = json_decode($detailItem->soal, true) ?? []; + $detailHalValue = $detailItem->hal ?? $listHal->first(); + $questionNumberValue = $detailConfigItem['no'] ?? null; + $hasNumberValue = $questionNumberValue !== null && $questionNumberValue !== ''; + $groupKey = $hasNumberValue + ? $detailHalValue . '|' . $questionNumberValue + : 'detail_' . $detailItem->id; + + if (!array_key_exists($groupKey, $groupIndexMap)) { + $groupIndexMap[$groupKey] = count($groupedQuestionDetails); + $groupedQuestionDetails[] = [ + 'hal' => $detailHalValue, + 'number' => $hasNumberValue ? $questionNumberValue : null, + 'items' => [], + ]; + } + + $groupPosition = $groupIndexMap[$groupKey]; + $groupedQuestionDetails[$groupPosition]['items'][] = [ + 'detail' => $detailItem, + 'config' => $detailConfigItem, + ]; + } @endphp - @forelse ($soal->soalDetail as $detail) + @forelse ($groupedQuestionDetails as $groupData) @php - $detailConfig = json_decode($detail->soal, true) ?? []; + $groupHal = $groupData['hal']; + $groupNumber = $groupData['number']; + $groupItems = $groupData['items']; + $groupFirstDetail = $groupItems[0]['detail'] ?? null; + $groupFirstConfig = $groupItems[0]['config'] ?? []; + $groupType = $groupFirstConfig['type'] ?? 'option'; + $groupHasConsent = false; + foreach ($groupItems as $groupItemCheck) { + if (!empty($groupItemCheck['config']['persetujuan_form'])) { + $groupHasConsent = true; + break; + } + } + @endphp +