@php use App\Models\Category; use App\Models\EnrollTestSeries; use App\Models\Group; $enrolltestSeries = EnrollTestSeries::where('testseries_id', $testSeries->id) ->first(); $group = Group::where('id', $enrolltestSeries->group_id ?? 0) ->first(); // Fetch Subject name from Category table using category_level = 'subject' $categoryIds = array_map('intval', explode(',', $testSeries->category_id)); $subjects = Category::whereIn('id', $categoryIds) ->where('category_level', 'subject') ->take(3) ->pluck('category_name') ->toArray(); $subjectName = !empty($subjects) ? implode(' / ', $subjects) : 'N/A'; $className = Category::whereIn('id', $categoryIds) ->where('category_level', 'class') ->first(); $className = $className->category_name ?? 'N/A'; // Ensure instructions are available $instructions = $testSeries->instructions ?? 'Read all questions carefully.'; // Current date for the exam $examDate = date('d-m-Y'); @endphp
Date: {{ $examDate }}
{{ $school_info->school_name ?? 'Achievam Institute' }}
{{ $testSeries->name }}
Class: {{ $className }}
Subject: {{ $subjectName }}
Roll No: ________________
@php $total_max_marks = $data['total_marks'] ?? 0; @endphp
Time: {{ $testSeries->total_time }} Minutes Max Marks: {{ $total_max_marks }}
@if(!empty($instructions))
INSTRUCTIONS:
{!! $instructions !!}
@endif @php $globalIndex = 1; // Show section headings when: test series explicitly has sections, OR data has multiple sections $showSections = ($data['has_sections'] ?? false) || count($data['sections']) > 1; @endphp @foreach ($data['sections'] as $section) @if($showSections)
{{ $section['section_title'] }}
@endif @foreach ($section['questions'] as $question) @php $qMark = $question['question_mark']; $marksLabel = $qMark == 1 ? '1 Mark' : $qMark . ' Marks'; @endphp
{{ $globalIndex }}. {!! $question['question_text'] !!}[{{ $marksLabel }}]
@if(!empty($question['options'])) @php $opts = $question['options']; $count = count($opts); // Determine if we should use 1 or 2 columns based on text length $useTwoColumns = true; foreach ($opts as $opt) { if (strlen(strip_tags($opt['option_text'])) > 50) { $useTwoColumns = false; break; } } @endphp @if($useTwoColumns && $count >= 2) @for ($i = 0; $i < $count; $i += 2) @if ($i + 1 < $count) @else @endif @endfor
{{ chr(65 + $i) }})
{!! $opts[$i]['option_text'] !!}
{{ chr(65 + $i + 1) }})
{!! $opts[$i + 1]['option_text'] !!}
@else
@foreach ($opts as $key => $option)
{{ chr(65 + $key) }})
{!! $option['option_text'] !!}
@endforeach
@endif @endif
@php $globalIndex++; @endphp @endforeach @endforeach