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