{{ $survey->title }}
Survey Response Analysis
{{ session('success') }}
@endif
{{ $totalResponses }}
Total Responses
@if($totalResponses > 0)
Active
@else
No data
@endif
{{ $guestResponses }}
Guest Responses
@if($totalResponses > 0)
{{ round(($guestResponses / max($totalResponses, 1)) * 100) }}% of total
@endif
{{ $staffResponses }}
Staff Responses
@if($totalResponses > 0)
{{ round(($staffResponses / max($totalResponses, 1)) * 100) }}% of total
@endif
{{ $responseRate }}%
Response Rate
@if($responseRate >= 70)
Excellent
@elseif($responseRate >= 40)
Average
@else
Low
@endif
Response Timeline
Daily Responses
Response Distribution
Guests
Staff
Response Trends
Hourly Pattern
Question-by-Question Analysis
@foreach($survey->questions as $question)
@php
$answers = $responses->flatMap->answers->where('question_id', $question->id);
$totalAnswers = $answers->count();
// Calculate statistics based on question type
if($question->type === 'rating') {
$ratingStats = [];
for($i = 1; $i <= 5; $i++) {
$count = $answers->where('answer', $i)->count();
$ratingStats[$i] = [
'count' => $count,
'percentage' => $totalAnswers > 0 ? round(($count / $totalAnswers) * 100) : 0
];
}
$averageRating = $totalAnswers > 0 ? round($answers->avg('answer'), 1) : 0;
}
if($question->type === 'multiple_choice' && $question->options) {
$options = is_string($question->options) ? json_decode($question->options, true) : $question->options;
$optionStats = [];
foreach($options as $option) {
$count = $answers->where('answer', $option)->count();
$optionStats[$option] = [
'count' => $count,
'percentage' => $totalAnswers > 0 ? round(($count / $totalAnswers) * 100) : 0
];
}
}
if($question->type === 'yes_no') {
$yesCount = $answers->where('answer', 'Yes')->count();
$noCount = $answers->where('answer', 'No')->count();
$yesPercentage = $totalAnswers > 0 ? round(($yesCount / $totalAnswers) * 100) : 0;
$noPercentage = $totalAnswers > 0 ? round(($noCount / $totalAnswers) * 100) : 0;
}
@endphp
@elseif($question->type === 'text')
@endforeach
{{ $question->question }}
{{ ucfirst(str_replace('_', ' ', $question->type)) }}
{{ $totalAnswers }} responses
@if($question->type === 'rating')
Average Rating:
{{ $averageRating }}
/5
@elseif($question->type === 'multiple_choice' && isset($optionStats))
@foreach($optionStats as $option => $stats)
@elseif($question->type === 'yes_no')
{{ Str::limit($option, 30) }}
{{ $stats['count'] }} ({{ $stats['percentage'] }}%)
@endforeach
{{ $yesCount }}
Yes ({{ $yesPercentage }}%)
{{ $noCount }}
No ({{ $noPercentage }}%)
@foreach($answers->take(3) as $answer)
@if($answer->answer)
@endif
@endforeach
@if($answers->count() > 3)
@endif
{{ $answer->response->guest->first_name ?? 'Anonymous' }}
{{ $answer->created_at->diffForHumans() }}
"{{ Str::limit($answer->answer, 150) }}"
+ {{ $answers->count() - 3 }} more responses
@endif
Individual Responses ({{ $totalResponses }})
@if($responses->count() > 0)
@foreach($responses as $response)
@endforeach
@else
@endif
@if($response->guest)
{{ substr($response->guest->first_name ?? 'G', 0, 1) }}{{ substr($response->guest->last_name ?? 'U', 0, 1) }}
@else
@endif
@if($response->guest)
{{ $response->guest->first_name }} {{ $response->guest->last_name }}
@else
Anonymous Guest
@endif
@if($response->guest && $response->guest->email)
{{ $response->guest->email }}
@endif
@if($response->guest && $response->guest->room_number)
Room {{ $response->guest->room_number }}
@endif
{{ $response->submitted_at->format('M j, Y g:i A') }}
@foreach($response->answers as $answer)
@endforeach
{{ $answer->question->question ?? 'Question' }}
@if(is_array(json_decode($answer->answer, true)))
{{ implode(', ', json_decode($answer->answer, true)) }}
@elseif($answer->question->type === 'rating')
{{ $answer->answer }} / 5
@else
{{ $answer->answer }}
@endif
No Responses Yet
Share this survey with guests or staff to start collecting responses.
Back to Survey