<?php
require_once '../includes/auth.php';

if (!isPenguji()) {
    header('HTTP/1.1 403 Forbidden');
    echo json_encode(['success' => false, 'error' => 'Unauthorized']);
    exit;
}

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['station_id'])) {
    $station_id = intval($_POST['station_id']);
    
    $stmt = $pdo->prepare("SELECT deskripsi, instruksi_peserta, instruksi_penguji FROM stations WHERE id = ?");
    $stmt->execute([$station_id]);
    $station = $stmt->fetch();
    
    if ($station) {
        echo json_encode([
            'success' => true,
            'deskripsi' => $station['deskripsi'],
            'instruksi_peserta' => $station['instruksi_peserta'],
            'instruksi_penguji' => $station['instruksi_penguji']
        ]);
    } else {
        echo json_encode(['success' => false, 'error' => 'Station tidak ditemukan']);
    }
} else {
    echo json_encode(['success' => false, 'error' => 'Invalid request']);
}
?>