@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
@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