You have finished the exam!
@if($answersArray)
@php
$correctAnswersCount = 0;
$totalSubmittedAnswers = 0;
$totalQuestionsCount = 0; // Initialize total questions count
$skippedQuestionsCount = 0; // Initialize skipped questions count
@endphp
@php
$percentage = $totalSubmittedAnswers > 0 ? floor(($correctAnswersCount / $totalSubmittedAnswers) * 100) : 0;
$incorrectAnswer = $totalSubmittedAnswers - $correctAnswersCount;
@endphp
@if($percentage > $passingMarks)
@else
@endif
Required Score:{{ $passingMarks }}%
Overall Score: {{ $percentage }}%
Total Question: {{ $totalQuestionsCount }}
Total Skipped Question: {{ $skippedQuestionsCount }}
Correct Answer
:
{{ $correctAnswersCount }}
Incorrect Answer
:
{{ $incorrectAnswer }}
your answer:
@foreach($answersArray as $questionM => $answerM)
@php
$totalQuestionsCount++; // Increment for each question
$question = $soalan->find($questionM);
$correctAnswers = $jawapan->where('question_id', $questionM)->where('is_correct', 1)->pluck('id')->toArray();
@endphp
Question: {{ $question->question }}
@if(empty($answerM))
@php $skippedQuestionsCount++; @endphp
Answer: SKIPPED
@elseif(is_array($answerM))
@php $totalSubmittedAnswers++; @endphp
@foreach($answerM as $subAnswer)
@php $answer = $jawapan->find($subAnswer); @endphp
Answer: {{ $answer->answer }}
@if($answer->is_correct)
@else
@endif
@endforeach
@if(count(array_intersect($answerM, $correctAnswers)) == count($correctAnswers))
@php $correctAnswersCount++; @endphp
@endif
@else
@php $totalSubmittedAnswers++; @endphp
@php $answer = $jawapan->find($answerM); @endphp
Answer: {{ $answer->answer }}
@if($answer->is_correct)
@php $correctAnswersCount++; @endphp
@else
@endif
@endif
@endforeach
@else
No answers submitted.
@endif