@inject('request', 'Illuminate\Http\Request') @extends('backend.layouts.app') @section('title', __('labels.backend.tests_result.title').' | '.app_name()) @section('content')

@lang('labels.backend.tests_result.title')

←
@foreach($questions as $question) @php // dd($answers, $questions); // Filter the $result array to find the result with the same question_id $matchingResults = array_filter($answers->toArray(), function ($res) use ($question) { return $res['question_id'] == $question->id; }); // If there is a matching result, compare the scores if (!empty($matchingResults)) { $matchingResult = reset($matchingResults); if ($matchingResult['correct'] == 1){ $isCorrect = true; } else { $isCorrect = false; } } else { $isCorrect = false; } //if question has an option then get it if($question->question_type == 'option' || $question->question_type == 'multiple_choice'){ $answer = $question->options->where('correct', 1)->first(); $option = $answer->option_text ?? ''; $plagiarism_degree = $answer->plagiarism_degree ?? 0; }else{ if (!empty($matchingResults)) { $plagiarism_degree = $matchingResult['plagiarism_degree']; $option = $matchingResult['answer']; }else{ $plagiarism_degree = "Removed"; $option = trans('labels.backend.questions.fields.answer_removed'); } } @endphp @endforeach
@lang('labels.backend.tests.qust') @lang('labels.backend.tests.fields.test_type') @lang('labels.backend.questions.fields.score') @lang('labels.backend.faqs.fields.answer') @lang('labels.backend.tests.fields.plagiarism_degree') @lang('labels.general.actions')
@if(empty($matchingResults)) {{ app()->getLocale() == "ar" ? $question->question_ar ?? $question->question : $question->question ?? $question->question_ar }} ( @lang('labels.backend.questions.fields.removed') ) @else {{ app()->getLocale() == "ar" ? $question->question_ar ?? $question->question : $question->question ?? $question->question_ar }} @endif @if(empty($question->question_type)) @lang('labels.backend.questions.fields.removed') @else {{ $question->question_type }} @endif {!! $option !!} @if($question->question_type != 'multiple_choice' && $question->question_type != 'option') {{ $isCorrect ? 'Correct' : 'Incorrect/Pending' }} @else {{ $isCorrect ? 'Correct' : 'Incorrect' }} @endif {{ $plagiarism_degree }} % @if($question->question_type != 'multiple_choice' && $question->question_type != 'option') @if(!empty($matchingResults)) @if($isCorrect)
@csrf @if (!empty($matchingResults)) @endif
@endif @else @lang('labels.backend.questions.fields.answer_removed') @endif @endif
{{-- @else--}} {{-- {{trans('labels.backend.dashboard.no_data')}}--}} {{-- @endif--}}
@stop @push('after-scripts') @endpush