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

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

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

ไม่มีรูปภาพ

@endif
ทำต่อจากฉบับร่าง

คุณสามารถทำต่อการประเมินจากที่ค้างไว้ และส่งแบบประเมินเมื่อพร้อม

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

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