[ Mini Kiebo ]
Server: Windows NT AKFAR_SERVER 10.0 build 26200 (Windows 10) AMD64
Path:
D:
/
xampp
/
htdocs
/
ujian
/
application
/
controllers
/
[
Home
]
File: apicbt.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Apicbt extends CI_Controller { public function __construct() { parent::__construct(); } public function cek_jadwal_ujian() { // Ambil JSON body $input = json_decode(file_get_contents('php://input'), true); $kode_mk = $input['kode_mk'] ?? null; $jenis = $input['jenis'] ?? null; // ========================= // VALIDASI PARAMETER // ========================= if (!$kode_mk || !$jenis) { return $this->response([ "responseCode" => "400", "responseMessage" => "Parameter tidak lengkap" ]); } // ========================= // LOGIKA CEK JADWAL // ========================= $cek = $this->cek_jadwal($kode_mk, $jenis); if (!$cek['status']) { return $this->response([ "responseCode" => "201", "responseMessage" => $cek['message'] ]); } return $this->response([ "responseCode" => "000", "responseMessage" => "Jadwal ujian tersedia" ]); } // ========================= // Logic // ========================= private function cek_jadwal($kode_mk, $jenis) { // contoh sederhana (silakan sesuaikan query) $this->db->like('tes_nama', $kode_mk); $this->db->where('tes_detail', $jenis); // kondisi waktu: NOW() between (tes_begin_time - 1 jam) dan (tes_end_time + 1 jam) $this->db->where('NOW() >= DATE_SUB(tes_begin_time, INTERVAL 1 HOUR)', null, false); $this->db->where('NOW() <= DATE_ADD(tes_end_time, INTERVAL 1 HOUR)', null, false); $jadwal = $this->db->get('cbt_tes')->row(); if (!$jadwal) { return [ 'status' => false, 'message' => 'Jadwal ujian tidak ditemukan' ]; } return [ 'status' => true ]; } // ========================= // HELPER RESPONSE JSON // ========================= private function response($data) { header('Content-Type: application/json'); echo json_encode($data); exit; } }