<?php
// Script to fix the syntax error and properly handle combined subjects' full_marks and pass_marks
$file_path = 'reports/bulk_print_marksheets.php';

// Read the file content
$content = file_get_contents($file_path);

// Fix the syntax error by removing the incorrect else block
$pattern = '/(\s*\}\s*else\s*\{\s*\/\/ Fallback to defaults\s*if \(\!isset\(\$result\[\'full_marks\'\]\) \|\| \$result\[\'full_marks\'\] == 0\) \{[\s\S]*?\$result\[\'pass_marks\'\] = 40;\s*\}[\s\S]*?\}[\s\S]*?\}\s*\}\s*)/s';

$replacement = '
            }
        }';

$content = preg_replace($pattern, $replacement, $content);

// Write the fixed content back to the file
file_put_contents($file_path, $content);

echo "Fix v4 applied successfully!\n";
?>