ข้อมูลคำถามทั้งหมดในตาราง questions

สรุปสถิติ

{{ $questions->count() }}

คำถามทั้งหมด

{{ $questions->where('parent_id', null)->count() }}

Parent Questions

{{ $questions->where('parent_id', '!=', null)->count() }}

Child Questions

{{ $questions->where('use_in_evaluation', false)->where('question_type', null)->count() }}

Accordion Questions

{{ $questions->where('use_in_evaluation', true)->where('question_type', '!=', null)->count() }}

Evaluation Questions

{{ $questions->where('use_in_evaluation', false)->where('question_type', '!=', null)->count() }}

Non-Evaluation Questions
รายละเอียดคำถามทั้งหมด
@foreach($questions as $question) @php $level = getQuestionLevel($question, $questions); $levelClass = getLevelClass($level); $displayType = getDisplayType($question->use_in_evaluation, $question->question_type); $displayClass = getDisplayClass($displayType); @endphp @endforeach
ID Group Level Parent ID Question Text Question Type Use in Evaluation Choices Display Type
{{ $question->id }} {{ $question->questionGroup->name ?? 'ไม่มี' }} {{ $level }} {{ $question->parent_id ?? 'ไม่มี' }} {{ $question->question_text }} @if($question->question_type) {{ $question->question_type }} @else null @endif @if($question->use_in_evaluation) ใช่ @else ไม่ใช่ @endif @if($question->choices) มี @else ไม่มี @endif {{ $displayType }}
ข้อมูลตาม Group
@php $groupStats = $questions->groupBy('question_group_id'); @endphp @foreach($groupStats as $groupId => $groupQuestions)
{{ $groupQuestions->first()->questionGroup->name ?? 'ไม่มีชื่อ' }} (ID: {{ $groupId }}) - {{ $groupQuestions->count() }} คำถาม
@foreach($groupQuestions as $question)
ID: {{ $question->id }} {{ getQuestionLevel($question, $questions) }} {{ $question->question_text }}
@endforeach
@endforeach
@php function getQuestionLevel($question, $allQuestions) { if (!$question->parent_id) { return "Parent (ระดับที่ 1)"; } $level = 1; $currentParentId = $question->parent_id; while ($currentParentId) { $parent = $allQuestions->where('id', $currentParentId)->first(); if ($parent) { $level++; $currentParentId = $parent->parent_id; } else { break; } } switch ($level) { case 1: return "Parent (ระดับที่ 1)"; case 2: return "Child (ระดับที่ 2)"; case 3: return "Grand Child (ระดับที่ 3)"; case 4: return "Great Grand Child (ระดับที่ 4)"; case 5: return "Great Great Grand Child (ระดับที่ 5)"; case 6: return "Great Great Great Grand Child (ระดับที่ 6)"; default: return "ระดับที่ {$level}"; } } function getLevelClass($level) { if (strpos($level, 'Parent') !== false) return 'parent'; if (strpos($level, 'Child') !== false && strpos($level, 'Grand') === false) return 'child'; if (strpos($level, 'Grand Child') !== false && strpos($level, 'Great') === false) return 'grandchild'; if (strpos($level, 'Great Grand Child') !== false && strpos($level, 'Great Great') === false) return 'great-grandchild'; if (strpos($level, 'Great Great Grand Child') !== false && strpos($level, 'Great Great Great') === false) return 'great-great-grandchild'; if (strpos($level, 'Great Great Great Grand Child') !== false) return 'great-great-great-grandchild'; return ''; } function getDisplayType($useInEvaluation, $questionType) { if (!$useInEvaluation && $questionType === null) { return "Accordion Button"; } elseif ($useInEvaluation && $questionType !== null) { return "Card ปกติ (ใช้ในการประเมิน)"; } elseif (!$useInEvaluation && $questionType !== null) { return "Card สีเทา (ไม่ใช้ในการประเมิน)"; } else { return "ไม่ระบุ"; } } function getDisplayClass($displayType) { if (strpos($displayType, 'Accordion') !== false) return 'accordion'; if (strpos($displayType, 'ใช้ในการประเมิน') !== false) return 'evaluation'; if (strpos($displayType, 'ไม่ใช้ในการประเมิน') !== false) return 'non-evaluation'; return ''; } @endphp