@extends('layouts.layoutMaster') @section('title', 'OMM-Print') @section('content')
@foreach ($sections as $s) @php $answeredQuestions = $questions ->where('section_id', $s->id) ->filter(function ($question) use ($answers, $s) { return $answers ->where('question_id', $question->id) ->where('section_id', $s->id) // ->where('user_id', auth()->user()->id) ->isNotEmpty(); }); // dd($answeredQuestions); @endphp @if ($answeredQuestions->isNotEmpty())
{{ $s->pillar->name}}
{{ $s->section_name }}
{{-- --}} @foreach ($answeredQuestions as $q) @php $userAnswers = $answers ->where('question_id', $q->id) ->where('section_id', $s->id) // ->where('user_id', auth()->user()->id); // dd($answeredQuestions); @endphp @if ($userAnswers->isNotEmpty()) @foreach ($userAnswers as $userAnswer) @if ($q->type == 'radio') @foreach (json_decode($q->options) as $option) @endforeach @endif @endforeach @if ($q->type == 'checkbox') @foreach (json_decode($q->options) as $option) @endforeach @endif @foreach ($userAnswers as $userAnswer) @endforeach @endif @endforeach
QuestionLevel Nascent Stable Maturing Efficient World Class
{{ $q->question_text }} {{ $option }} {{ $option }}
@if ($q->type === 'text' || $q->type === 'textarea')

{{ $userAnswer->answer ?? 'No Answer' }}

@elseif ($q->type === 'date')

{{ $userAnswer->answer ?? 'No Answer' }}

@elseif ($q->type === 'checkbox') {{-- @php $totalOptions = 5; // Total number of checkbox options $selectedValues = json_decode($userAnswer->answer); // User's selected answers (e.g., [1, 4]) // Ensure selected values are numeric and convert to zero-based index $selectedIndexes = array_map(function($value) use ($totalOptions) { return is_numeric($value) ? intval($value) - 1 : null; // Convert to zero-based index }, $selectedValues); // Filter out any null values (non-numeric) $selectedIndexes = array_filter($selectedIndexes); @endphp
@for ($i = 0; $i < $totalOptions; $i++)
{{ in_array($i, $selectedIndexes) ? 'Selected ' . ($i + 1) : '' }}
@endfor
--}}

@php $options = json_decode($q->options); $selectedOptions = json_decode($userAnswer->answer); @endphp @foreach ($options as $index => $option)
@if (in_array($option, $selectedOptions)) {{ 'Current Level' }} @endif
@endforeach

{{--

--}} @elseif ($q->type === 'radio')
{{ 'Current Level' }}
{{ 'After Three Year' }}
{{-- Option: {{ $userAnswer->answer }} --}} @elseif ($q->type === 'rating')

@php $answer = $userAnswer->answer ?? 0; @endphp @if ($answer > 0) @for ($i = 1; $i <= 5; $i++) @endfor @else No Rating Given @endif

@elseif ($q->type === 'file')

@if ($userAnswer->answer) View File @else No File Uploaded @endif

@endif
@endif @endforeach

Assessment Comments:

{{ $comment ?? '' }}
@endsection