@foreach($allTestsData as $memberName => $memberTests)
@foreach($memberTests as $test)
{{ $test['test_name'] }} Generated: {{ date('Y-m-d H:i:s') }}
@foreach($test['questionnaires'] as $questionnaire) @foreach($questionnaire['questions_by_category'] as $categoryName => $questions)
@if ($categoryName != 'General Information' && $categoryName != 'معلومات عامة')
{{ $categoryName }}
@endif
{{ $questionnaire['questionnaire_name'] }}
@php $count = 0; @endphp @foreach($questions as $key => $question) @php // Check if this is a SELECT or MULTIPLE_SELECT with more than 2 options $isWideQuestion = false; if ($question->TYPE == 'SELECT' || $question->TYPE == 'MULTIPLE_SELECT') { $optionsCount = $question->options->count(); $isWideQuestion = ($optionsCount > 2); } // Start a new row if needed if ($count % 2 == 0 || $isWideQuestion) { echo ''; } @endphp @php // Increment count $count++; // If it's a wide question, start a new row after it if ($isWideQuestion) { $count = $count % 2 == 0 ? $count : $count + 1; echo ''; } elseif ($count % 2 == 0) { // Otherwise close the row when we have two elements echo ''; } @endphp @endforeach @if($count % 2 != 0) @endif
{{$key + 1}} {{ isset($lang) && $lang === 'ar' ? ($question->NAME_AR ?: $question->NAME_EN) : $question->NAME_EN }}
@if($question->TYPE == 'SELECT' || $question->TYPE == 'MULTIPLE_SELECT') @php $selectedOptionIds = []; if (isset($test['answers'][$question->ID])) { if (!empty($test['answers'][$question->ID]->OPTION_ID)) { $selectedOptionIds = is_array($test['answers'][$question->ID]->OPTION_ID) ? $test['answers'][$question->ID]->OPTION_ID : json_decode($test['answers'][$question->ID]->OPTION_ID, true) ?? []; } elseif (!empty($test['answers'][$question->ID]->ANSWER)) { $selectedOptionIds = explode(',', $test['answers'][$question->ID]->ANSWER); } } @endphp
@foreach($question->options->chunk(3) as $optionChunk)
@foreach($optionChunk as $option) @php $isSelected = in_array($option->ID, $selectedOptionIds) || in_array($option->NAME_EN, $selectedOptionIds); @endphp
{{ isset($lang) && $lang === 'ar' ? ($option->NAME_AR ?: $option->NAME_EN) : $option->NAME_EN }}
@endforeach
@endforeach
@elseif($question->TYPE == 'FILE')
@elseif($question->TYPE == 'DOWNLOAD_FILE') @if(!empty($question->FILE_PATH)) @php $fileUrl = 'https://s3.eu-west-1.amazonaws.com/blazma.com' . $question->FILE_PATH; $fileExt = strtolower(pathinfo($question->FILE_PATH, PATHINFO_EXTENSION)); @endphp @if(in_array($fileExt, ['jpg', 'jpeg', 'png', 'gif'])) File @else Download @endif @else
No file available
@endif @else @if(isset($test['answers'][$question->ID]) && !empty($test['answers'][$question->ID]->ANSWER))
{{ $test['answers'][$question->ID]->ANSWER }}
@else
@endif @endif
@endforeach @endforeach
@endforeach
@endforeach