@php use Illuminate\Support\Facades\DB; $surveyId = $survey->id; $submitUrl = route('surveys.submit', $surveyId); // ✅ الشرط الحقيقي: هل المستخدم قدّم Submission لهذا الاستطلاع؟ $alreadySubmitted = false; try { if (auth()->check()) { $alreadySubmitted = DB::table('socratic_survey_submissions') ->where('survey_id', $surveyId) ->where('user_id', auth()->id()) // حتى لو anonymous = false ->exists(); // ✅ لو الاستطلاع Anonymous: ما في user_id، فنعتمد submission_key // (حسب submissionKey اللي عندك في الكنترول: user:{id} أو anon:{hash}) if (!$alreadySubmitted) { $alreadySubmitted = DB::table('socratic_survey_submissions') ->where('survey_id', $surveyId) ->where('submission_key', 'user:'.auth()->id()) ->exists(); } } } catch (\Throwable $e) { $alreadySubmitted = false; } @endphp @if(!$alreadySubmitted) {{-- BACKDROP --}}
{{-- MODAL WRAPPER --}}
{{-- MODAL BOX (مربع بالنص + سكرول داخلي) --}}
{{-- HEADER (ثابت) --}}
استطلاع إلزامي

{{ $survey->title }}

@if(!empty($survey->description))

{{ $survey->description }}

@endif
{{-- BODY (سكرول داخلي) --}}
@csrf @foreach($survey->questions as $i => $q)
{{-- QUESTION HEADER --}}
{{ $i+1 }}. {{ $q->question_text }} @if($q->is_required) • مطلوب @endif
{{ strtoupper($q->question_type) }}
{{-- ANSWER --}}
@php $name = "answers[{$q->id}]"; @endphp {{-- SCALE --}} @if($q->question_type === 'scale') @if(isset($q->options) && $q->options->count() > 0)
@foreach($q->options as $opt) @endforeach
@else @endif {{-- SINGLE --}} @elseif($q->question_type === 'single')
@foreach($q->options as $opt) @endforeach
{{-- MULTIPLE --}} @elseif($q->question_type === 'multiple' || $q->question_type === 'multi')
@foreach($q->options as $opt) @endforeach
{{-- TEXT --}} @else @endif
@endforeach {{-- SUBMIT --}}
{{-- JS --}} @endif