@extends('layouts.admin') @section('title', 'Review Question #'.$question->id) @php use Illuminate\Support\Carbon; $human = function ($d, $fallback = null) { if (empty($d)) return $fallback; if ($d instanceof \DateTimeInterface) return $d->diffForHumans(); try { return Carbon::parse($d)->diffForHumans(); } catch (\Throwable $e) { return $fallback; } }; $u = auth()->user(); $canQA = $u && ( (method_exists($u,'canAccessQA') && $u->canAccessQA()) || (method_exists($u,'canAccessAdmin') && $u->canAccessAdmin()) ); // Force read-only on this page $editMode = false; $qaStatus = $question->qa_status ?? 'unreviewed'; $statusConfig = [ 'unreviewed' => ['color'=>'warning','icon'=>'clock','text'=>'Unreviewed'], 'approved' => ['color'=>'success','icon'=>'check-circle','text'=>'Approved'], 'flagged' => ['color'=>'danger','icon'=>'flag','text'=>'Flagged'], 'needs_revision' => ['color'=>'info','icon'=>'edit','text'=>'Needs Revision'], 'ai_generated' => ['color'=>'secondary','icon'=>'robot','text'=>'AI-Generated'], ]; $config = $statusConfig[$qaStatus] ?? $statusConfig['unreviewed']; $isPublic = (int)($question->status_id ?? 4) === 3; $difficultyNames = ['', 'Easy', 'Medium', 'Hard']; $difficulty = $difficultyNames[$question->difficulty_id ?? 0] ?? 'Unknown'; $difficultyColors = ['', 'success', 'warning', 'danger']; $difficultyColor = $difficultyColors[$question->difficulty_id ?? 0] ?? 'secondary'; @endphp @push('head') @endpush @push('styles') @endpush @section('content')
{{-- Header --}}

Review Question #{{ $question->id }} {{$question->is_diagnostic ? ' ⚡' : ''}}

Created: {{ $question->created_at ? $question->created_at->format('M d, Y') : 'Unknown' }} @if(!empty($question->published_at))  •  Published {{ $human($question->published_at, 'recently') }} @endif
{{-- QA Manual Modal --}}
{{-- Left: Content and metadata --}}
{{-- Status card --}}
{{ $config['text'] }} {{ $isPublic ? 'Public' : 'Draft' }} @if($question->is_diagnostic) Sentinel @endif
@if($question->skill) Skill: {{ $question->skill->skill }}    @endif Difficulty: {{ $difficulty }}
{{-- Question content --}}
Question Content {{ $question->type->type }}
{{-- Only path to editing is via Questions.show --}} Edit Content
{{-- Read-only view --}} {{-- Question image block (no upload/remove controls) --}}
QUESTION IMAGE
@php $qImg = $question->question_image; @endphp
Question image
No image uploaded
{{-- Question text --}}
QUESTION TEXT
{!! $question->question ?: '[No question text provided]' !!}
{{-- Answers read only --}} @if($question->type_id == 1) @php $answers = [ ['text' => $question->answer0 ?? '', 'image' => $question->answer0_image ?? '', 'i' => 0], ['text' => $question->answer1 ?? '', 'image' => $question->answer1_image ?? '', 'i' => 1], ['text' => $question->answer2 ?? '', 'image' => $question->answer2_image ?? '', 'i' => 2], ['text' => $question->answer3 ?? '', 'image' => $question->answer3_image ?? '', 'i' => 3], ]; $correctIndex = (int)($question->correct_answer ?? 0); @endphp
ANSWER OPTIONS
@foreach($answers as $ans) @php $i = $ans['i']; $img = $ans['image']; $isCorrect = $i === $correctIndex; $letter = chr(65 + $i); @endphp
{{ $letter }} @if($isCorrect) @endif
@if($ans['text'])
{!! $ans['text'] !!}
@endif
Answer {{ $letter }} image
No image
@if($isCorrect) Correct Answer @endif
@endforeach @else @php // Gather any FIB answers (answer0–answer3) that exist $fibAnswers = []; foreach ([0,1,2,3] as $i) { $val = $question->{'answer'.$i} ?? null; if (!is_null($val) && trim($val) !== '') { $fibAnswers[] = ['idx' => $i, 'text' => $val]; } } @endphp
FILL-IN ANSWERS
@if(count($fibAnswers))
@foreach($fibAnswers as $a)
Blank {{ $a['idx'] + 1 }}
{!! $a['text'] !!}
@endforeach
@else
No FIB answers found. Add values in answer0…answer3 on the edit page.
@endif
@endif {{-- Meta row --}}
DIFFICULTY
{{ $question->difficulty->short_description }}
SKILL
@if($question->skill) {{ $question->skill->skill }} @else No skill assigned @endif
{{ $question->calculator ? ucfirst($question->calculator) : 'None' }}
{{-- Hints (read-only) --}}
@if($question->hints && $question->hints->count() > 0)
@foreach($question->hints->sortBy('hint_level') as $hint)
Level {{ $hint->hint_level }} {{ $hint->hint_text }}
@if($hint->user) Added by {{ $hint->user->name }} @endif
@endforeach
@else

No hints available

@endif
{{-- Solutions (read-only) --}}
@if($question->solutions && $question->solutions->count() > 0)
@foreach($question->solutions as $solution)
{!! nl2br(e($solution->solution)) !!}
By {{ $solution->user->name ?? 'Unknown' }} on {{ optional($solution->created_at)->format('M d, Y') }}
@endforeach
@else

No solutions available

@endif
{{-- Right: QA actions (status only) --}}
QA Actions
@if($question->qa_reviewer_id) Assigned to: {{ optional(\App\Models\User::find($question->qa_reviewer_id))->name ?? 'Unknown' }} @endif
@if($canQA)
@else
You do not have QA privileges on this item.
@endif @include('admin.components.math-help') @if($question->qa_reviewed_at)
Reviewed {{ $human($question->qa_reviewed_at) }}
@endif
Issues {{ $qaIssues->count() }}
@if($qaIssues->count())
@foreach($qaIssues as $issue) @php $typeColors = [ 'grammar' => 'primary', 'math_error' => 'danger', 'unclear' => 'warning', 'image_issue'=> 'info', 'other' => 'secondary', ]; $statusColors = [ 'open' => 'warning', 'resolved' => 'success', 'dismissed' => 'secondary', ]; $tColor = $typeColors[$issue->issue_type] ?? 'secondary'; $sColor = $statusColors[$issue->status] ?? 'secondary'; @endphp
{{ $issue->issue_type }} {{ $issue->status }}
{!! nl2br(e($issue->description)) !!}
{{ optional($issue->reviewer)->name ?? 'Unknown' }} · {{ \Illuminate\Support\Carbon::parse($issue->created_at)->diffForHumans() }} @if($issue->updated_at && $issue->updated_at != $issue->created_at) (updated {{ \Illuminate\Support\Carbon::parse($issue->updated_at)->diffForHumans() }}) @endif
@if($canQA)
@if($issue->status !== 'open') @endif @if($issue->status !== 'resolved') @endif @if($issue->status !== 'dismissed') @endif
@endif
@endforeach
@else
No issues have been filed for this question yet. Use Report Issue… to add one.
@endif
@endsection @push('scripts') @endpush