- done soal dan dashboard unit
This commit is contained in:
parent
d5bb9cc508
commit
6c37654b0a
@ -171,6 +171,10 @@
|
||||
font-weight: 600;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.badge-placeholder {
|
||||
visibility: hidden;
|
||||
}
|
||||
</style>
|
||||
@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
|
||||
<div class="question-card mb-4"
|
||||
data-hal-card="{{ $groupHal }}"
|
||||
data-detail-id="{{ $groupFirstDetail ? $groupFirstDetail->id : '' }}"
|
||||
data-consent-question="{{ $groupHasConsent ? '1' : '0' }}"
|
||||
data-question-type="{{ $groupType }}"
|
||||
style="{{ $groupHal == $hal ? '' : 'display: none;' }}">
|
||||
@foreach ($groupItems as $groupItem)
|
||||
@php
|
||||
$detail = $groupItem['detail'];
|
||||
$detailConfig = $groupItem['config'] ?? [];
|
||||
$pertanyaan = $detailConfig['soal'] ?? 'Pertanyaan tidak tersedia';
|
||||
$type = $detailConfig['type'] ?? 'option';
|
||||
$optionsRaw = $detailConfig['options'] ?? [];
|
||||
@ -298,7 +351,6 @@
|
||||
|| (is_string($currentAnswer) && stripos($currentAnswer, 'lainnya') !== false)
|
||||
|| (!empty($oldOtherAnswer));
|
||||
$detailHal = $detail->hal ?? $listHal->first();
|
||||
$isVisible = $detailHal == $hal;
|
||||
$optionsCount = is_array($options) ? count($options) : 0;
|
||||
$hasLainnyaOption = collect($options)->contains(function ($optionItem) {
|
||||
return is_string($optionItem) && stripos($optionItem, 'lainnya') !== false;
|
||||
@ -315,6 +367,9 @@
|
||||
$dualYearOld = null;
|
||||
$dualMonthOld = null;
|
||||
$questionNumber = $detailConfig['no'] ?? '';
|
||||
$hasGroupNumber = $groupNumber !== null && $groupNumber !== '';
|
||||
$badgeNumber = $hasGroupNumber ? $groupNumber : $questionNumber;
|
||||
$shouldShowNumber = $badgeNumber !== null && $badgeNumber !== '' && (!$hasGroupNumber || $loop->first);
|
||||
$rangeMin = null;
|
||||
$rangeMax = null;
|
||||
$rangeStep = 1;
|
||||
@ -428,17 +483,16 @@
|
||||
$rangeMaxDisplay = ($rangeMax !== null && floor($rangeMax) == $rangeMax) ? (int) $rangeMax : $rangeMax;
|
||||
$rangeDefaultDisplay = ($rangeDefault !== null && floor($rangeDefault) == $rangeDefault) ? (int) $rangeDefault : $rangeDefault;
|
||||
@endphp
|
||||
<div class="question-card mb-4"
|
||||
data-hal-card="{{ $detailHal }}"
|
||||
data-detail-id="{{ $detail->id }}"
|
||||
data-consent-question="{{ $isConsentQuestion ? '1' : '0' }}"
|
||||
data-question-type="{{ $type }}"
|
||||
style="{{ $isVisible ? '' : 'display: none;' }}">
|
||||
@if (!$loop->first)
|
||||
<hr class="my-4">
|
||||
@endif
|
||||
<div class="row g-3 align-items-start question-layout">
|
||||
<div class="col-md-6 question-text-col">
|
||||
<div class="d-flex align-items-center gap-3 mb-1">
|
||||
@if ($questionNumber !== null)
|
||||
<span class="badge rounded-pill bg-label-primary fs-6">{{ $questionNumber }}</span>
|
||||
@if ($shouldShowNumber)
|
||||
<span class="badge rounded-pill bg-label-primary fs-6">{{ $badgeNumber }}</span>
|
||||
@elseif($hasGroupNumber)
|
||||
<span class="badge rounded-pill bg-label-primary fs-6 badge-placeholder" aria-hidden="true">{{ $badgeNumber }}</span>
|
||||
@endif
|
||||
<h5 class="fw-semibold mb-0">{{ $pertanyaan }}</h5>
|
||||
</div>
|
||||
@ -653,6 +707,7 @@
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@empty
|
||||
<div class="alert alert-info">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user