WIP: halaman finish ujian
This commit is contained in:
parent
f18c470f14
commit
b1f5b14287
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('soal', function (Blueprint $table) {
|
||||||
|
$table->string('jawaban_a')->nullable()->change();
|
||||||
|
$table->string('jawaban_b')->nullable()->change();
|
||||||
|
$table->string('jawaban_c')->nullable()->change();
|
||||||
|
$table->string('jawaban_d')->nullable()->change();
|
||||||
|
$table->string('jawaban_e')->nullable()->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('soal', function (Blueprint $table) {
|
||||||
|
$table->string('jawaban_a')->change();
|
||||||
|
$table->string('jawaban_b')->change();
|
||||||
|
$table->string('jawaban_c')->change();
|
||||||
|
$table->string('jawaban_d')->change();
|
||||||
|
$table->string('jawaban_e')->change();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -140,7 +140,7 @@
|
||||||
<script>
|
<script>
|
||||||
let getDataInterval = false;
|
let getDataInterval = false;
|
||||||
let checkTobiiInterval = null;
|
let checkTobiiInterval = null;
|
||||||
let tobiiConnectedStatus = true;
|
let tobiiConnectedStatus = false;
|
||||||
const ws = new WebSocket('{{ env("WEBSOCKET_URL") }}');
|
const ws = new WebSocket('{{ env("WEBSOCKET_URL") }}');
|
||||||
let SESSION_ID = '{{ $data_session->id_test_sessions }}';
|
let SESSION_ID = '{{ $data_session->id_test_sessions }}';
|
||||||
let TOKEN_SESSION = '{{ $data_session->token_session }}';
|
let TOKEN_SESSION = '{{ $data_session->token_session }}';
|
||||||
|
|
@ -151,9 +151,10 @@ function showTutorial(step, tutorialId) {
|
||||||
|
|
||||||
if(step === 2 || step === 3) {
|
if(step === 2 || step === 3) {
|
||||||
startTobii();
|
startTobii();
|
||||||
checkTobiiInterval = setInterval(() => {
|
checkTobiiConnection();
|
||||||
checkTobiiConnection();
|
// checkTobiiInterval = setInterval(() => {
|
||||||
}, 2000);
|
// checkTobiiConnection();
|
||||||
|
// }, 2000);
|
||||||
} else {
|
} else {
|
||||||
if(checkTobiiInterval) {
|
if(checkTobiiInterval) {
|
||||||
clearInterval(checkTobiiInterval);
|
clearInterval(checkTobiiInterval);
|
||||||
|
|
@ -282,10 +283,10 @@ function copyLinkTokenTobii() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkTobiiConnection() {
|
function checkTobiiConnection() {
|
||||||
ws.send(JSON.stringify({
|
// ws.send(JSON.stringify({
|
||||||
type: "check_tobii_connection",
|
// type: "check_tobii_connection",
|
||||||
session_id: SESSION_ID,
|
// session_id: SESSION_ID,
|
||||||
}));
|
// }));
|
||||||
|
|
||||||
if(tobiiConnectedStatus) {
|
if(tobiiConnectedStatus) {
|
||||||
$('#status_tobii').text('Status Tobii: Terhubung').removeClass('text-danger').addClass('text-success');
|
$('#status_tobii').text('Status Tobii: Terhubung').removeClass('text-danger').addClass('text-success');
|
||||||
|
|
@ -353,15 +354,6 @@ function stopTobii() {
|
||||||
const data = JSON.parse(event.data);
|
const data = JSON.parse(event.data);
|
||||||
console.log('Received data from WebSocket:', data);
|
console.log('Received data from WebSocket:', data);
|
||||||
|
|
||||||
// if(data.type === 'temp_data') {
|
|
||||||
// console.log('Received temp_data:', data);
|
|
||||||
// if((Date.now() - data.data[0].timestamp) < 5000) {
|
|
||||||
// tobiiConnectedStatus = true;
|
|
||||||
// } else {
|
|
||||||
// tobiiConnectedStatus = false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
if(data.type === 'tobii_data') {
|
if(data.type === 'tobii_data') {
|
||||||
try {
|
try {
|
||||||
moveTheEye(data.gaze_x, data.gaze_y);
|
moveTheEye(data.gaze_x, data.gaze_y);
|
||||||
|
|
@ -370,13 +362,16 @@ function stopTobii() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(data.type === 'status_tobii') {
|
if(data.type === 'status_tobii_device') {
|
||||||
// if(data.status) {
|
if(data.status) {
|
||||||
// tobiiConnectedStatus = true;
|
console.log('Tobii device is connected');
|
||||||
// } else if(!data.status) {
|
tobiiConnectedStatus = true;
|
||||||
// tobiiConnectedStatus = false;
|
} else {
|
||||||
// }
|
console.log('Tobii device is not connected');
|
||||||
// }
|
tobiiConnectedStatus = false;
|
||||||
|
}
|
||||||
|
checkTobiiConnection();
|
||||||
|
}
|
||||||
|
|
||||||
if(data.type === 'reset_start_tobii') {
|
if(data.type === 'reset_start_tobii') {
|
||||||
startTobii();
|
startTobii();
|
||||||
|
|
|
||||||
|
|
@ -180,23 +180,61 @@ function updateTimeLeft() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function finishExam() {
|
function finishExam() {
|
||||||
ws.send(JSON.stringify({
|
Swal.fire({
|
||||||
type: "command",
|
title: 'Alert',
|
||||||
action: "stop",
|
icon: 'question',
|
||||||
session_id: SESSION_ID
|
text: 'Apakah Anda yakin ingin mengakhiri ujian? (aksi tidak dapat dikembalikan)',
|
||||||
}));
|
confirmButtonText: 'Ya',
|
||||||
|
cancelButtonText: 'Tidak',
|
||||||
|
showCancelButton: true,
|
||||||
|
showCloseButton: true,
|
||||||
|
|
||||||
//send_data_to_db
|
}).then((result) => {
|
||||||
ws.send(JSON.stringify({
|
if (result.isConfirmed) {
|
||||||
type: "send_data_to_db",
|
event.preventDefault();
|
||||||
session_id: SESSION_ID
|
let current_num = new URLSearchParams(window.location.search).get('question');
|
||||||
}));
|
let xhttp = new XMLHttpRequest();
|
||||||
|
let the_answer = null;
|
||||||
|
let token = document.getElementById('_token').getAttribute('value');
|
||||||
|
let formData = new FormData();
|
||||||
|
|
||||||
ws.send(JSON.stringify({
|
document.getElementsByName('jawaban_final').forEach(element => {
|
||||||
type: "update_status",
|
if (element.checked) {
|
||||||
status_sessions: false,
|
the_answer = {
|
||||||
session_id: SESSION_ID
|
key: element.id.split('_')[1],
|
||||||
}));
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(the_answer) {
|
||||||
|
formData.append('jawaban_final', the_answer.key);
|
||||||
|
formData.append('_token', token);
|
||||||
|
formData.append('question', current_num);
|
||||||
|
formData.append('id_question', $('#id_question').attr('value'));
|
||||||
|
formData.append('session_id', SESSION_ID);
|
||||||
|
xhttp.open("POST", "{{ route('ujian.store') }}", false);
|
||||||
|
xhttp.send(formData);
|
||||||
|
console.log("sending answer (finish)");
|
||||||
|
}
|
||||||
|
|
||||||
|
ws.send(JSON.stringify({
|
||||||
|
type: "command",
|
||||||
|
action: "stop",
|
||||||
|
session_id: SESSION_ID
|
||||||
|
}));
|
||||||
|
|
||||||
|
//send_data_to_db
|
||||||
|
ws.send(JSON.stringify({
|
||||||
|
type: "send_data_to_db",
|
||||||
|
session_id: SESSION_ID
|
||||||
|
}));
|
||||||
|
|
||||||
|
ws.send(JSON.stringify({
|
||||||
|
type: "update_status",
|
||||||
|
status_sessions: false,
|
||||||
|
session_id: SESSION_ID
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function startTobii() {
|
function startTobii() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue