<?php
// Script to fix the combineEnglishSubjects function in bulk_print_marksheets.php
$file_path = 'reports/bulk_print_marksheets.php';
$content = file_get_contents($file_path);

// Find and replace the problematic lines
$pattern = '/(\$combined\[\'marks_obtained\'\] = \$combined\[\'cq_marks\'\] \+ \$combined\[\'mcq_marks\'\];\s*)\$combined\[\'full_marks\'\] = \$combined\[\'full_marks\'\] \/ \$count;\s*\$combined\[\'pass_marks\'\] = \$combined\[\'pass_marks\'\] \/ \$count;/s';

$replacement = '$1            // For combined subjects, full_marks should represent the total marks for all combined subjects
            // not an average. This ensures the total marks calculation is correct.
            // $combined[\'full_marks\'] = $combined[\'full_marks\'] / $count;
            // $combined[\'pass_marks\'] = $combined[\'pass_marks\'] / $count;';

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

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

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