@extends('layouts.app') @section('title', $survey->title) @section('content')
{{ $survey->responses->count() }}
عدد الاستجابات
{{ $survey->questions->count() }}
عدد الأسئلة
@php $allRatings = $survey->questions->filter(fn($q) => in_array($q->question_type, ['rating','scale']))->flatMap(fn($q) => $q->answers->pluck('answer_rating'))->filter(); @endphp {{ number_format($allRatings->avg() ?? 0, 1) }}
متوسط التقييم العام
@foreach($survey->questions as $q)

{{ $q->sort_order }}. {{ $q->question_text }}

@php $ql = ['rating'=>'تقييم','scale'=>'مقياس','text'=>'نص','yes_no'=>'نعم/لا','multiple_choice'=>'اختيار متعدد']; @endphp {{ $ql[$q->question_type] ?? $q->question_type }}
@if(in_array($q->question_type, ['rating','scale'])) @php $qStats = $stats[$q->id] ?? ['avg'=>0,'count'=>0,'distribution'=>[]]; @endphp
{{ number_format($qStats['avg'], 1) }}
من {{ $q->question_type === 'rating' ? '5' : '10' }} — {{ $qStats['count'] }} إجابة
@php $max = max($qStats['distribution'] ?: [1]); @endphp @for($r = 1; $r <= ($q->question_type === 'rating' ? 5 : 10); $r++) @php $cnt = $qStats['distribution'][$r] ?? 0; $pct = $max > 0 ? ($cnt / $max * 100) : 0; @endphp
{{ $r }}
{{ $cnt }}
@endfor
@elseif($q->question_type === 'yes_no') @php $qs = $stats[$q->id] ?? ['yes'=>0,'no'=>0]; $total = $qs['yes'] + $qs['no']; @endphp
{{ $qs['yes'] }}
نعم ({{ $total > 0 ? round($qs['yes']/$total*100) : 0 }}%)
{{ $qs['no'] }}
لا ({{ $total > 0 ? round($qs['no']/$total*100) : 0 }}%)
@elseif($q->question_type === 'text') @foreach($q->answers->take(10) as $ans) @if($ans->answer_text)
{{ $ans->answer_text }}
@endif @endforeach @endif
@endforeach @endsection