exec(file_get_contents('db/migrations/005_create_school_settings_table.sql')); } if (file_exists('db/migrations/006_create_grading_scales_table.sql')) { $pdo->exec(file_get_contents('db/migrations/006_create_grading_scales_table.sql')); } $stmt = $pdo->query("SELECT setting_key, setting_value FROM school_settings"); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $settings[$row['setting_key']] = $row['setting_value']; } } catch (Exception $e) { die("Could not connect to the database: " . $e->getMessage()); } $school_name = $settings['school_name'] ?? ''; // Grading Scales $grading_scales = []; try { $stmt = $pdo->query("SELECT id, section, grade_name, min_score, max_score FROM grading_scales ORDER BY section, min_score DESC"); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $grading_scales[$row['section']][] = $row; } } catch (Exception $e) { die("Could not fetch grading scales: " . $e->getMessage()); } $sections = ['Nursery', 'Primary', 'Secondary']; ?>