diff --git a/Penilaian Literasi/iClOP-V2/resources/views/literacy/student/assessments/result.blade.php b/Penilaian Literasi/iClOP-V2/resources/views/literacy/student/assessments/result.blade.php
index 4f2be4a..a64acad 100644
--- a/Penilaian Literasi/iClOP-V2/resources/views/literacy/student/assessments/result.blade.php
+++ b/Penilaian Literasi/iClOP-V2/resources/views/literacy/student/assessments/result.blade.php
@@ -299,16 +299,34 @@
@php
$totalBenar = 0;
$totalSalah = 0;
+ $essayThreshold = 50; // Ambang batas kemiripan agar dianggap benar
- // Hitung total benar dan salah terlebih dahulu (loop pertama)
+ $normalize = function ($text) {
+ $text = strtolower($text);
+ $text = preg_replace('/[^\p{L}\p{N}\s]/u', '', $text);
+ $text = preg_replace('/\s+/', ' ', $text);
+ return trim($text);
+ };
+
+ // Hitung total benar dan salah
foreach ($questions as $question) {
$answer = $question->answers->first();
$isCorrect = false;
if ($question->type === 'multiple_choice' && $answer) {
- $isCorrect = $answer->option->is_correct;
- } elseif ($question->type === 'essay') {
- $isCorrect = strtolower(trim($answer->answer_text)) === strtolower(trim($question->essay_answer));
+ $isCorrect = optional($answer->option)->is_correct;
+ } elseif ($question->type === 'essay' && $answer) {
+ $userAnswer = $normalize($answer->answer_text ?? '');
+ $correctAnswers = explode("\n", $question->essay_answer ?? '');
+ $maxMatch = 0;
+
+ foreach ($correctAnswers as $correct) {
+ $correctNormalized = $normalize($correct);
+ similar_text($userAnswer, $correctNormalized, $percent);
+ $maxMatch = max($maxMatch, $percent);
+ }
+
+ $isCorrect = $maxMatch >= $essayThreshold;
}
if ($isCorrect) {
@@ -318,6 +336,7 @@
}
}
@endphp
+
Assessment Result
@@ -347,13 +366,26 @@
@php
$answer = $question->answers->first();
$isCorrect = false;
+ $similarityScore = null;
if ($question->type === 'multiple_choice' && $answer) {
- $isCorrect = $answer->option->is_correct;
- } elseif ($question->type === 'essay') {
- $isCorrect = strtolower(trim($answer->answer_text)) === strtolower(trim($question->essay_answer));
+ $isCorrect = optional($answer->option)->is_correct;
+ } elseif ($question->type === 'essay' && $answer) {
+ $userAnswer = $normalize($answer->answer_text ?? '');
+ $correctAnswers = explode("\n", $question->essay_answer ?? '');
+ $maxMatch = 0;
+
+ foreach ($correctAnswers as $correct) {
+ $correctNormalized = $normalize($correct);
+ similar_text($userAnswer, $correctNormalized, $percent);
+ $maxMatch = max($maxMatch, $percent);
+ }
+
+ $similarityScore = $maxMatch;
+ $isCorrect = $maxMatch >= $essayThreshold;
}
@endphp
+
{{ $index + 1 }}. {{ $question->question_text }}
@@ -365,7 +397,7 @@
- Jawaban Anda:
+ Jawaban Siswa:
@if ($question->type === 'multiple_choice')
{{ optional($answer)->option->option_text ?? 'Tidak Dijawab' }}
@else
@@ -373,51 +405,15 @@
@endif
- @if ($question->type === 'essay')
-
- Feedback:
- {{ optional($answer)->feedback ?? 'Tidak ada feedback' }}
-
+ @if ($question->type === 'essay' && $similarityScore !== null)
+ Skor Kemiripan: {{ number_format($similarityScore, 2) }}%
+ Feedback: {{ $answer->feedback ?? 'Tidak ada feedback' }}
@endif
@endforeach
-
-
-
Settings
-
Possible account settings
- needed
during the learning process
-
-
-
-
-
-

-
My Profile
-
Ubah data diri kamu
- {{--
--}}
-
-
-
-
-
-

-
My Password
-
Ganti kata sandimu
-
-
-
-
-
-