<?php
// Simple script to verify paths are correct
session_start();
// Include database configuration
require_once '../../config/database.php';
// Verify user is logged in as admin
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
echo "You must be logged in as an admin to use this page.";
exit;
}
// Check critical paths
$critical_paths = [
'question_banks' => [
'redirect' => '../question_banks.php',
'target' => 'banks.php',
'status' => 'Unknown'
],
'exam_schedules' => [
'redirect' => 'exam_schedules.php',
'target' => 'schedules.php',
'status' => 'Unknown'
]
];
// Check question_banks.php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $critical_paths['question_banks']['redirect']);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if (strpos($response, 'Location: ' . $critical_paths['question_banks']['target']) !== false) {
$critical_paths['question_banks']['status'] = 'OK';
} else {
$critical_paths['question_banks']['status'] = 'FAIL';
}
// Check exam_schedules.php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $critical_paths['exam_schedules']['redirect']);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if (strpos($response, 'Location: ' . $critical_paths['exam_schedules']['target']) !== false) {
$critical_paths['exam_schedules']['status'] = 'OK';
} else {
$critical_paths['exam_schedules']['status'] = 'FAIL';
}
// Display results
echo "<!DOCTYPE html>
<html>
<head>
<title>Navigation Path Test</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
table { border-collapse: collapse; width: 100%; }
th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
th { background-color: #f2f2f2; }
.ok { color: green; font-weight: bold; }
.fail { color: red; font-weight: bold; }
</style>
</head>
<body>
<h1>Navigation Path Test</h1>
<p>This script tests critical navigation paths in the exams module.</p>
<table>
<tr>
<th>Path</th>
<th>Redirect From</th>
<th>Target</th>
<th>Status</th>
</tr>";
foreach ($critical_paths as $name => $path) {
$status_class = $path['status'] === 'OK' ? 'ok' : 'fail';
echo "<tr>
<td>{$name}</td>
<td>{$path['redirect']}</td>
<td>{$path['target']}</td>
<td class='{$status_class}'>{$path['status']}</td>
</tr>";
}
echo "</table>
<h2>Debug Information</h2>
<p>The following link tests should open the correct pages:</p>
<ul>
<li><a href='../question_banks.php' target='_blank'>Question Banks (should redirect to banks.php)</a></li>
<li><a href='exam_schedules.php' target='_blank'>Exam Schedules (should redirect to schedules.php)</a></li>
<li><a href='questions.php?bank_id=1' target='_blank'>Questions for Bank ID 1</a></li>
<li><a href='add_question.php?bank_id=1' target='_blank'>Add Question to Bank ID 1</a></li>
</ul>
<p><a href='./'>Back to Exam Management</a></p>
</body>
</html>";
?>