55 lines
1.4 KiB
PHP
55 lines
1.4 KiB
PHP
<?php
|
|
$file = 'includes/app.php';
|
|
$content = file_get_contents($file);
|
|
|
|
$old_func = <<<'EOL'
|
|
function assessment_category_options(): array
|
|
{
|
|
return [
|
|
'تشخيصي',
|
|
'واجب',
|
|
'مشاركة',
|
|
'مشروع',
|
|
'أداء',
|
|
'اختبار قصير',
|
|
'اختبار نهائي',
|
|
];
|
|
}
|
|
EOL;
|
|
|
|
$new_func = <<<'EOL'
|
|
function assessment_category_options(): array
|
|
{
|
|
try {
|
|
$stmt = db()->query("SELECT name FROM assessment_categories WHERE status = 'enabled' ORDER BY name ASC");
|
|
$categories = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
|
return $categories ?: [];
|
|
} catch (\PDOException $e) {
|
|
// Fallback in case table doesn't exist yet or db error
|
|
return [
|
|
'تشخيصي',
|
|
'واجب',
|
|
'مشاركة',
|
|
'مشروع',
|
|
'أداء',
|
|
'اختبار قصير',
|
|
'اختبار نهائي',
|
|
];
|
|
}
|
|
}
|
|
EOL;
|
|
|
|
$new_content = str_replace($old_func, $new_func, $content);
|
|
|
|
if ($new_content === $content) {
|
|
echo "Failed to replace. Let's try regex replace\n";
|
|
$new_content = preg_replace('/function assessment_category_options\(\): array\s*\{.*?\}/s', $new_func, $content);
|
|
if ($new_content === $content) {
|
|
echo "Regex replace also failed.\n";
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
file_put_contents($file, $new_content);
|
|
echo "Successfully updated assessment_category_options() in includes/app.php\n";
|