@if(count($codingQuestions) > 0)
@foreach($codingQuestions as $index => $question)
@php
$difficultyColors = [
'easy' => ['bg' => '#065f46', 'text' => '#34d399'],
'medium' => ['bg' => '#92400e', 'text' => '#f59e0b'],
'hard' => ['bg' => '#991b1b', 'text' => '#f87171']
];
$level = strtolower($question->level);
$colors = $difficultyColors[$level] ?? $difficultyColors['easy'];
$evaluatedInfo = $evaluatedData[$question->id] ?? ['evaluated' => false, 'image' => null, 'submitted_time' => null];
$isEvaluated = $evaluatedInfo['evaluated'];
// Check if this question is in allocatecodings
$isAllocated = in_array($question->id, explode(',', $allocatedQuestions->questionid ?? ''));
// Check if already evaluated in codingreports (from pre-fetched array)
$alreadyEvaluated = in_array($question->id, $alreadyEvaluatedQuestions ?? []);
// Determine evaluation status
$canEvaluate = ($isEvaluated && $isAllocated && !$alreadyEvaluated);
@endphp
Q{{ $index + 1 }}. {{ $question->title ?? 'Untitled Question' }}
ID: {{ $question->id }}
@if($isEvaluated && $evaluatedInfo['image'])
@endif
@if($canEvaluate)
@elseif($alreadyEvaluated)
Evaluated
@elseif(!$isEvaluated)
Not Submitted
@elseif(!$isAllocated)
Not Allocated
@endif
{{ ucfirst($level) }}
@if($isEvaluated && $evaluatedInfo['submitted_time'])
Submitted: {{ date('d M Y, H:i', strtotime($evaluatedInfo['submitted_time'])) }}
@endif
@if($alreadyEvaluated)
@elseif($isEvaluated && $isAllocated)
Ready for Evaluation
@elseif($isEvaluated && !$isAllocated)
Submitted but not allocated to this batch
@elseif(!$isEvaluated && $isAllocated)
Waiting for student submission
@else
Not available for evaluation
@endif
@endforeach
@else
No Questions Allocated
No coding questions have been allocated for this batch and topic.
@endif