@extends('layouts.app') @section('content')
{{-- Progress Bar --}}
ทำต่อการประเมินผลิตภัณฑ์
ฉบับร่าง
กรุณาตอบคำถามการประเมินให้ครบถ้วน
{{-- Product Info --}}

ข้อมูลผลิตภัณฑ์

ชื่อผลิตภัณฑ์:{{ $assessment->product->name ?? 'ไม่ระบุ' }}
โมเดล/รุ่น:{{ $assessment->product->model ?? 'ไม่ระบุ' }}
วิธีรับข้อมูล:{{ $assessment->product->log_receive_method ?? 'ไม่ระบุ' }}
ประเภทผลิตภัณฑ์:{{ $assessment->product->product_type ?? 'ไม่ระบุ' }}
@if($assessment->product->image)
รูปภาพผลิตภัณฑ์
@else

ไม่มีรูปภาพ

@endif
{{-- Tips --}}
ทำต่อจากฉบับร่าง

กรอกต่อแล้วกด “บันทึกฉบับร่าง” หรือ “ส่งแบบประเมิน” เมื่อพร้อม

{{-- FORM --}}
@csrf {{-- Questions --}}
@php $globalQuestionNumber = 1; @endphp @foreach($questionGroups as $group)
@foreach($group->questions as $question) @if($question->use_in_evaluation && !$question->parent_id && $question->question_type !== null)
{{ $globalQuestionNumber }}
{{ $question->question_text }}
@php $existingAnswer = $assessment->answers->where('question_id', $question->id)->first(); $existingChoice = $existingAnswer?->answer_text; // "ใช่"/"ไม่ใช่" หรือ choice $existingDetails = $existingAnswer?->comment; @endphp @if($question->question_type == 'yes_no')
{{-- ช่องรายละเอียดเมื่อ "ใช่" --}}
@elseif($question->question_type == 'multiple_choice') @php $choices = is_string($question->choices) ? json_decode($question->choices, true) : $question->choices; $existingChoice = $existingAnswer?->answer_text; @endphp
@if($choices && is_array($choices) && count($choices)) @foreach($choices as $i => $choice)
@endforeach @else
ไม่มีตัวเลือก กรุณาติดต่อผู้ดูแลระบบ
@endif
@elseif($question->question_type == 'text') @php $existingText = $existingAnswer?->answer_text ?? ''; @endphp
@endif
@php $globalQuestionNumber++; @endphp @endif {{-- Parent + Children --}} @if(!$question->use_in_evaluation && $question->question_type === null && !$question->parent_id)

@foreach($group->questions->where('parent_id', $question->id) as $child) @if($child->use_in_evaluation && $child->question_type !== null)
{{ $child->question_text }}
@php $existingAnswer = $assessment->answers->where('question_id', $child->id)->first(); $existingChoice = $existingAnswer?->answer_text; $existingDetails = $existingAnswer?->comment; @endphp @if($child->question_type == 'yes_no')
@elseif($child->question_type == 'multiple_choice') @php $choices = is_string($child->choices) ? json_decode($child->choices, true) : $child->choices; $existingChoice = $existingAnswer?->answer_text; @endphp
@if($choices && is_array($choices) && count($choices)) @foreach($choices as $i => $choice)
@endforeach @else
ไม่มีตัวเลือก
@endif
@elseif($child->question_type == 'text') @php $existingText = $existingAnswer?->answer_text ?? ''; @endphp
@endif
@php $globalQuestionNumber++; @endphp @endif @endforeach
@endif @endforeach
@endforeach
{{-- Action buttons --}}
ย้อนกลับ {{-- บันทึกฉบับร่าง --}} {{-- ส่งแบบประเมิน --}}
@endsection