@extends('layout.unit.unit_app') @push('style') @vite(['resources/css/layout/banner_main.css', 'resources/css/landing.css', 'resources/css/animate.css', 'resources/css/students/student.css', 'resources/css/unit/unit_detail.css', 'resources/css/unit/unit_exercise.css']) @endpush @php use App\Enums\QuestionLabelEnum; use App\Enums\LevelExercise; use App\Enums\CourseType; if ($selectedExerciseParam['level'] != null) { switch ($selectedExerciseParam['level']) { case LevelExercise::NORMAL->value: $level = LevelExercise::NORMAL->name(); break; case LevelExercise::MEDIUM->value: $level = LevelExercise::MEDIUM->name(); break; default: $level = LevelExercise::ADVANCED->name(); } } else { $level = ''; } function getImageQuestion($answers, $question_id): array|null { $question = collect($answers) ->map(function ($item) use ($question_id) { return $item->question->where('id', $question_id)->first(); }) ->first(); if ($question) { return [ // 'image_path' => $question->image_path, 'text' => $question->text, 'choices' => $question->choices ?? '[]', ]; } else { return [ 'text' => null, 'choices' => '[]', ]; } } function getCorrectAnswer($answers, $question_id) { $result = collect($answers)->where('id', $question_id); $dd = [ 'correct' => $result->pluck('result')->first(), 'text_answer' => $result->pluck('text')->first(), //Text cua cau tra loi dung(giai thich) // 'image_answer' => $result->pluck('image_path')->first(), //image cua cau tra loi dung(giai thich) ]; return $dd; } function getLabelClass($label, $answer, $correct) { if ($label === $correct && $correct === $answer) { return 'answered-correct'; // cau tra loi dung voi dap an va dung voi label } if ($label === $correct && $answer !== $correct) { return 'answer-correct'; // cau tra loi dung khong dung voi dap an va nhung dung voi label } if ($label === $answer && $answer !== $correct) { return 'answer-wrong'; // cau tra loi sai voi dap an va sai voi label } return ''; } // get so checkbox de hien thi dua vao truong choices // $answerLabel=["A","B","C",...] function getAnswerLabels($answers, $question_id): array { $findChoices = collect($answers)->map(function ($item) use ($question_id) { return $item->question->where('id', $question_id)->first(); }); $choices = $findChoices->pluck('choices')->first(); // choices cua cau hoi $choicesArray = json_decode($choices, true); return QuestionLabelEnum::getAnswerLabels(count($choicesArray)); } $levelStar = getLevelExercise( countCorrectAnswer($answerExerciseData, $answerExercises->toArray()), $selectedExerciseParam['question_number'], ); @endphp @section('content')
flag
{{ $coursesPurchased['course_purchased']->course_type === CourseType::COURSE_SELF_STUDY->value ? 'Chúc mừng bạn đã hoàn thành' : 'Congratulations on your completion' }}
{{ countCorrectAnswer($answerExerciseData, $answerExercises->toArray()) }} / {{ $selectedExerciseParam['question_number'] }}
@if ($levelStar == 0) @else @endif
{{ $coursesPurchased['course_purchased']->course_type === CourseType::COURSE_SELF_STUDY->value ? 'Điểm tích lũy' : 'Accumulated points' }} + {{ $score }}
@endsection