From 01258eb92d293deeb66ab2fe42b262dff9a44fcd Mon Sep 17 00:00:00 2001 From: Mahayoga Date: Tue, 19 May 2026 22:36:49 +0700 Subject: [PATCH] WIP: Statistik mata --- .../Controllers/FinishUjianController.php | 48 ++++++- .../user/pages/finish_ujian/index.blade.php | 130 +++++++++++++++++- 2 files changed, 169 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/FinishUjianController.php b/app/Http/Controllers/FinishUjianController.php index 858f64d..8d729fa 100644 --- a/app/Http/Controllers/FinishUjianController.php +++ b/app/Http/Controllers/FinishUjianController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Models\BookingModel; use App\Models\DataSoalModel; use App\Models\DetailTestModel; use App\Models\TestSessionsModel; @@ -73,6 +74,49 @@ public function index(Request $request) $data_session = TestSessionsModel::where('id_test_sessions', $id_session)->first(); if($data_session != null) { + $start = strtotime($data_session->created_at); + $end = strtotime($data_session->updated_at); + $difference = gmdate("i:s", $end - $start); + + $data_booking = BookingModel::where('id_booking', $data_session->id_booking)->first(); + $data_information = [ + 'nama' => $data_booking->nama_lengkap, + 'email' => $data_booking->email, + 'no_hp' => $data_booking->no_telp, + ]; + + $screen_dim = [ + 'width' => $data_session->screen_w, + 'height' => $data_session->screen_h + ]; + + $answered = DetailTestModel::where('id_test_sessions', $id_session)->where('jawaban', '!=', null)->count(); + $question_count = DataSoalModel::all()->count(); + $soalTerjawab = $answered; + $soalTidakTerjawab = $question_count - $answered; + + $totalScore = 0; + $detail_test = DetailTestModel::where('id_test_sessions', $request->id_test_sessions)->get(); + foreach($detail_test as $detail) { + $data_soal = DataSoalModel::where('id_soal', $detail->id_soal)->first(); + $data_jawaban = $detail->jawaban; + if($data_jawaban == 'a') { + $totalScore += 1; + } else if($data_jawaban == 'b') { + $totalScore += 2; + } else if($data_jawaban == 'c') { + $totalScore += 3; + } else if($data_jawaban == 'd') { + $totalScore += 4; + } else if($data_jawaban == 'e') { + $totalScore += 5; + } + } + $data_aswered = [ + 'answered' => $answered, + 'unanswered' => $soalTidakTerjawab, + 'totalScore' => $totalScore + ]; if($data_session->status_session == '0') { return redirect()->route('cek-status.index')->with('error', 'Data sesi tes dinonaktifkan. Silahkan cek status dengan kode untuk informasi lebih lanjut.'); } else if($data_session->status_session == '1') { @@ -80,9 +124,9 @@ public function index(Request $request) 'status_session' => '2', 'is_active' => '0' ]); - return view('user.pages.finish_ujian.index', compact('id_session')); + return view('user.pages.finish_ujian.index', compact('id_session', 'difference', 'data_information', 'screen_dim', 'data_aswered')); } else if($data_session->status_session == '2') { - return view('user.pages.finish_ujian.index', compact('id_session')); + return view('user.pages.finish_ujian.index', compact('id_session', 'difference', 'data_information', 'screen_dim', 'data_aswered')); } } else { return redirect()->route('cek-status.index')->with('error', 'Data sesi tes tidak ditemukan.'); diff --git a/resources/views/user/pages/finish_ujian/index.blade.php b/resources/views/user/pages/finish_ujian/index.blade.php index 4ec63bc..bea9095 100644 --- a/resources/views/user/pages/finish_ujian/index.blade.php +++ b/resources/views/user/pages/finish_ujian/index.blade.php @@ -1,6 +1,23 @@ @section('title', 'Hasil Tes') @extends('user.layouts.index') @section('content') +
@@ -27,6 +44,68 @@
+
+
+
+

Detail Tes/Ujian kamu

+
+
+
+

Informasi Pribadi

+
    +
  • Nama: {{ $data_information['nama'] }}
  • +
  • Email: {{ $data_information['email'] }}
  • +
  • Nomor Handphone: {{ $data_information['no_hp'] }}
  • +
+
+
+
+
+

Informasi Ujian

+
    +
  • Durasi Ujian: {{ $difference }}
  • +
  • Resolusi Layar (saat ujian): {{ $screen_dim['width'] }} x {{ $screen_dim['height'] }}
  • +
  • Jumlah Pergerakan Mata: 0
  • +
+
+
+
+
+

Hasil Ujian (STAI-T)

+
    +
  • Total Skor: {{ $data_aswered['totalScore'] }}
  • +
  • Soal terjawab: {{ $data_aswered['answered'] }}
  • +
  • Soal tidak terjawab: {{ $data_aswered['unanswered'] }}
  • +
+
+
+
+
+
+
+

Avg Velocity

+

+
+ +
+

Fixation Ratio

+

+
+ +
+

Total Eye Distance

+

+
+ +
+

Most Viewed Area

+

+
+
+
+
+
+
@@ -34,6 +113,7 @@ + @@ -85,6 +165,9 @@ let scaleX = null; let scaleY = null; let heatmapInstance = null; + let score = null; + let totalScore = null; + let soalTerjawab = 0; function renderVelocityChart(timeseries) { const base = timeseries.timestamp[0]; @@ -144,9 +227,25 @@ function renderVelocityChart(timeseries) { data: mappedHeatmapData }); heatmapContainer.style.removeProperty('position'); + renderStats(result.statistics); + Swal.close(); } } + function renderStats(stats) { + document.getElementById("avgVelocity") + .innerText = stats.avg_velocity.toFixed(4); + + document.getElementById("fixationRatio") + .innerText = stats.fixation_ratio.toFixed(2) + "%"; + + document.getElementById("totalDistance") + .innerText = stats.total_distance.toFixed(2); + + document.getElementById("mostViewedArea") + .innerText = stats.most_viewed_area; + } + $(document).ready(function() { table = new DataTable("#table-data-hasil-ujian", { searching: false, @@ -171,19 +270,30 @@ function renderVelocityChart(timeseries) { let renderedJawaban = null; if(row.jawaban_key == 'a') { renderedJawaban = `${row.jawaban}`; + score = 1; } else if(row.jawaban_key == 'b') { renderedJawaban = `${row.jawaban}`; + score = 2; } else if(row.jawaban_key == 'c') { renderedJawaban = `${row.jawaban}`; + score = 3; } else if(row.jawaban_key == 'd') { renderedJawaban = `${row.jawaban}`; + score = 4; } else if(row.jawaban_key == 'e') { renderedJawaban = `${row.jawaban}`; + score = 5; } else { renderedJawaban = `${row.jawaban}`; } return renderedJawaban; } + }, + { + data: null, + render: function(data, type, row) { + return `${score}`; + } } ] }); @@ -208,20 +318,27 @@ function renderVelocityChart(timeseries) { const data = JSON.parse(event.data); if(data.type === 'json_file_data') { if(data.data != null) { - data_tobii = data.data; + data_tobii = null; let xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if(this.readyState == 4 && this.status == 200) { - let data = JSON.parse(this.responseText); - if(data.status) { + let data_ = JSON.parse(this.responseText); + $('#total_movement').html(data.data.length + " (1 detik = 3 pergerakan)"); + if(data_.status) { heatmapContainer = document.getElementById('heatmapChart'); clientWidth = heatmapContainer.clientWidth; clientHeight = heatmapContainer.clientHeight; - recordedScreenWidth = data.screen_w; - recordedScreenHeight = data.screen_h; + recordedScreenWidth = data_.screen_w; + recordedScreenHeight = data_.screen_h; scaleX = clientWidth / recordedScreenWidth; scaleY = clientHeight / recordedScreenHeight; + + data_tobii = { + data: data.data, + screen_w: recordedScreenWidth, + screen_h: recordedScreenHeight + }; heatmapInstance = h337.create({ container: heatmapContainer, @@ -229,7 +346,6 @@ function renderVelocityChart(timeseries) { maxOpacity: 0.6, blur: 0.85 }); - Swal.close(); loadData(data_tobii); } else { Swal.fire({ @@ -244,7 +360,7 @@ function renderVelocityChart(timeseries) { } }; - xhttp.open('GET', '{{ route('test-sessions.getScreen', ['id_test_sessions', $id_session]) }}', true); + xhttp.open('GET', '{{ route('test-sessions.getScreen', ['id_test_sessions' => $id_session]) }}', true); xhttp.send(); } }
No Pertanyaan JawabanSkor