@php $submits = $result->submits ? json_decode($result->submits, true) : []; $correct_answers = $result->correct_answer ? json_decode($result->correct_answer, true) : []; $wrong_answers = $result->wrong_answer ? json_decode($result->wrong_answer, true) : []; $mark_per_question = $quiz->total_mark / $questions->count(); @endphp

{{ get_phrase('Duration : ') }} @php $duration = explode(':', $quiz->duration); @endphp {{ $duration[0] }} {{ get_phrase('Hour') }} {{ $duration[1] }} {{ get_phrase('Minute') }} {{ $duration[1] }} {{ get_phrase('Second') }}

{{ get_phrase('Total Mark : ') }}{{ $quiz->total_mark }}

{{ get_phrase('Pass Mark : ') }}{{ $quiz->pass_mark }}

{{ get_phrase('Correct Answer : ') }}{{ count($correct_answers) }}

{{ get_phrase('Wrong Answer : ') }}{{ count($wrong_answers) }}

{{ get_phrase('Obtained marks') }} : {{ count($correct_answers) * $mark_per_question }}

{{ get_phrase('Result : ') }} @if (count($correct_answers)*$mark_per_question >= $quiz->pass_mark) {{ get_phrase('Passed') }} @else {{ get_phrase('Failed') }} @endif

@foreach ($questions as $key => $question) @php $given_answer = $question->type == 'true_false' ? $question->answer : implode(', ', json_decode($question->answer, true)); $user_answers = array_key_exists($question->id, $submits) ? $submits[$question->id] : []; @endphp
{{ ++$key }}
{!! $question->title !!}
@if (in_array($question->id, $correct_answers)) @elseif(in_array($question->id, $wrong_answers)) @endif
@if ($question->type == 'mcq') @php $options = json_decode($question->options, true) ?? []; @endphp @foreach ($options as $index => $option) @php $val = $user_answers ? array_search($option, $user_answers) : ''; @endphp
@endforeach @elseif($question->type == 'fill_blanks') @elseif($question->type == 'true_false')
@endif

{{ get_phrase('Answer : ') }}{{ $given_answer }}

@endforeach