halaman-psikolog #1

Merged
Mahayoga merged 52 commits from halaman-psikolog into master 2026-07-06 12:37:30 +07:00
3 changed files with 101 additions and 23 deletions
Showing only changes of commit d07e24e39b - Show all commits

View File

@ -28,6 +28,7 @@ public function getNotAnswered(Request $request) {
$data_ujian[] = [
'id_soal' => $detail->id_soal,
'soal' => $detail->pertanyaan,
'skor' => 0
];
}
}
@ -58,22 +59,40 @@ public function getAllAnswer(Request $request) {
foreach($detail_test as $detail) {
$data_soal = DataSoalModel::where('id_soal', $detail->id_soal)->first();
$data_jawaban = $detail->jawaban;
$skor = null;
if($data_jawaban == 'a') {
$data_jawaban = $data_soal->jawaban_a;
$skor = 1;
} else if($data_jawaban == 'b') {
$data_jawaban = $data_soal->jawaban_b;
$skor = 2;
} else if($data_jawaban == 'c') {
$data_jawaban = $data_soal->jawaban_c;
$skor = 3;
} else if($data_jawaban == 'd') {
$data_jawaban = $data_soal->jawaban_d;
$skor = 4;
} else if($data_jawaban == 'e') {
$data_jawaban = $data_soal->jawaban_e;
} else {
$data_jawaban = 'Tidak menjawab';
}
if($detail->jawaban == 'a' && $data_soal->is_reverse == 1) {
$skor = 4;
} else if($detail->jawaban == 'b' && $data_soal->is_reverse == 1) {
$skor = 3;
} else if($detail->jawaban == 'c' && $data_soal->is_reverse == 1) {
$skor = 2;
} else if($detail->jawaban == 'd' && $data_soal->is_reverse == 1) {
$skor = 1;
}
$data_ujian[] = [
'id_soal' => $detail->id_soal,
'jawaban' => $data_jawaban,
'is_reverse' => $data_soal->is_reverse,
'skor' => $skor,
'jawaban_key' => $detail->jawaban,
'soal' => $data_soal->pertanyaan
];
@ -134,6 +153,19 @@ public function index(Request $request)
foreach($detail_test as $detail) {
$data_soal = DataSoalModel::where('id_soal', $detail->id_soal)->first();
$data_jawaban = $detail->jawaban;
if($data_soal->is_reverse == 1) {
if($data_jawaban == 'a') {
$totalScore += 4;
} else if($data_jawaban == 'b') {
$totalScore += 3;
} else if($data_jawaban == 'c') {
$totalScore += 2;
} else if($data_jawaban == 'd') {
$totalScore += 1;
} else if($data_jawaban == 'e') {
$totalScore += 0;
}
} else {
if($data_jawaban == 'a') {
$totalScore += 1;
} else if($data_jawaban == 'b') {
@ -146,6 +178,8 @@ public function index(Request $request)
$totalScore += 5;
}
}
}
$data_aswered = [
'total_question' => $question_count,
'answered' => $answered,

View File

@ -0,0 +1,30 @@
<?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->enum('jawaban_benar', [0, 1])->default(0)->change();
$table->renameColumn('jawaban_benar', 'is_reverse');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('soal', function (Blueprint $table) {
$table->renameColumn('is_reverse', 'jawaban_benar');
$table->enum('jawaban_benar', ['a', 'b', 'c', 'd', 'e'])->change();
});
}
};

View File

@ -81,7 +81,7 @@
<h4 class="card-title">
Tingkat Kecemasan
</h4>
@if ($data_aswered['totalScore'] >= 20)
@if ($data_aswered['totalScore'] <= 20)
<h2 class="mt-4 text-success">
Normal
</h2>
@ -295,6 +295,7 @@
<th>No</th>
<th>Pertanyaan</th>
<th>Jawaban</th>
<th>Skor</th>
</tr>
</thead>
<tbody></tbody>
@ -530,18 +531,31 @@ function showInsight(type) {
data: null,
render: function(data, type, row) {
let renderedJawaban = null;
if(row.jawaban_key == 'a') {
renderedJawaban = `<span class="badge text-bg-primary">${row.jawaban}</span>`;
score = 1;
} else if(row.jawaban_key == 'b') {
renderedJawaban = `<span class="badge" style="background-color: #fc7938; color: white;">${row.jawaban}</span>`;
score = 2;
} else if(row.jawaban_key == 'c') {
if(row.is_reverse == 1) {
renderedJawaban = `<span class="badge text-bg-danger">${row.jawaban}</span>`;
score = 3;
} else if(row.jawaban_key == 'd') {
} else {
renderedJawaban = `<span class="badge text-bg-primary">${row.jawaban}</span>`;
}
} else if(row.jawaban_key == 'b') {
if(row.is_reverse == 1) {
renderedJawaban = `<span class="badge text-bg-warning">${row.jawaban}</span>`;
score = 4;
} else {
renderedJawaban = `<span class="badge" style="background-color: #fc7938; color: white;">${row.jawaban}</span>`;
}
} else if(row.jawaban_key == 'c') {
if(row.is_reverse == 1) {
renderedJawaban = `<span class="badge" style="background-color: #fc7938; color: white;">${row.jawaban}</span>`;
} else {
renderedJawaban = `<span class="badge text-bg-warning">${row.jawaban}</span>`;
}
} else if(row.jawaban_key == 'd') {
if(row.is_reverse == 1) {
renderedJawaban = `<span class="badge text-bg-primary">${row.jawaban}</span>`;
} else {
renderedJawaban = `<span class="badge text-bg-danger">${row.jawaban}</span>`;
}
} else if(row.jawaban_key == 'e') {
renderedJawaban = `<span class="badge text-bg-success">${row.jawaban}</span>`;
score = 5;
@ -552,10 +566,7 @@ function showInsight(type) {
}
},
{
data: null,
render: function(data, type, row) {
return `<span>${score}</span>`;
}
data: 'skor',
}
]
});
@ -582,6 +593,9 @@ function showInsight(type) {
render: function(data, type, row, meta) {
return `<span class="badge text-bg-secondary">Tidak dijawab</span>`;
}
},
{
data: 'skor'
}
]
});