<?php
session_start();
if (!isset($_SESSION['user_id'])) {
    exit('<div class="alert alert-danger">Unauthorized</div>');
}

require_once '../config.php';
require_once '../lib/exam_utils.php';

$class = trim((string) ($_POST['class'] ?? ''));
$subjectId = (int) ($_POST['subject'] ?? 0);
$type = trim((string) ($_POST['type'] ?? ''));

if ($class === '' || !$subjectId) {
    echo '<div class="alert alert-info">Select a class and subject to load the question bank.</div>';
    exit;
}

$items = getQuestionBankItems($class, $subjectId, $type !== '' ? $type : null, 40);
echo buildQuestionBankHtml($items);

