<?php
chdir('../');
session_start();
require_once('public/connection.php');

header('Content-Type: application/json');

if (!isset($_SESSION['staff_id'])) {
    echo json_encode(['status'=>0, 'message'=>'Unauthorized']);
    exit;
}

$id = isset($_POST['id']) ? intval($_POST['id']) : 0;

if ($id > 0) {
    $stmt = $conn->prepare("DELETE FROM questions WHERE id = ?");
    $stmt->bind_param("i", $id);

    if ($stmt->execute()) {
        echo json_encode(['status'=>1, 'message'=>'Question deleted successfully.']);
    } else {
        echo json_encode(['status'=>0, 'message'=>'Failed to delete question.']);
    }

    $stmt->close();
} else {
    echo json_encode(['status'=>0, 'message'=>'Invalid Question ID.']);
}
