<?php
// Test script for Bangla and English grading functions

// Include the marksheet file to access the functions
require_once 'reports/marksheet.php';

echo "<h2>Testing Bangla and English Grading Functions</h2>\n";

// Test Bangla grading function
echo "<h3>Bangla Grading Tests:</h3>\n";

// Test case 1: Pass - Both CQ average and MCQ >= pass marks
$cq_marks = [40, 35]; // Average = 37.5
$mcq_marks = 25;
$total_marks = 100;
$pass_marks = 33;
$result = calculateBanglaGrade($cq_marks, $mcq_marks, $total_marks, $pass_marks);
echo "Test 1 - CQ: [40, 35], MCQ: 25 => Grade: $result (Expected: Pass)<br>\n";

// Test case 2: Fail - CQ average < pass marks
$cq_marks = [30, 25]; // Average = 27.5
$mcq_marks = 30;
$result = calculateBanglaGrade($cq_marks, $mcq_marks, $total_marks, $pass_marks);
echo "Test 2 - CQ: [30, 25], MCQ: 30 => Grade: $result (Expected: F)<br>\n";

// Test case 3: Fail - MCQ < pass marks
$cq_marks = [40, 35]; // Average = 37.5
$mcq_marks = 20;
$result = calculateBanglaGrade($cq_marks, $mcq_marks, $total_marks, $pass_marks);
echo "Test 3 - CQ: [40, 35], MCQ: 20 => Grade: $result (Expected: F)<br>\n";

// Test case 4: Pass with grade
$cq_marks = [45, 40]; // Average = 42.5
$mcq_marks = 30;
$result = calculateBanglaGrade($cq_marks, $mcq_marks, $total_marks, $pass_marks);
echo "Test 4 - CQ: [45, 40], MCQ: 30 => Grade: $result (Expected: B or better)<br>\n";

echo "<br>\n";

// Test English grading function
echo "<h3>English Grading Tests:</h3>\n";

// Test case 1: Pass - CQ average >= 33
$cq_marks = [35, 31]; // Average = 33
$total_marks = 100;
$pass_marks = 33;
$result = calculateEnglishGrade($cq_marks, $total_marks, $pass_marks);
echo "Test 1 - CQ: [35, 31] => Grade: $result (Expected: Pass)<br>\n";

// Test case 2: Fail - CQ average < 33
$cq_marks = [30, 32]; // Average = 31
$result = calculateEnglishGrade($cq_marks, $total_marks, $pass_marks);
echo "Test 2 - CQ: [30, 32] => Grade: $result (Expected: F)<br>\n";

// Test case 3: Pass with good grade
$cq_marks = [40, 36]; // Average = 38
$result = calculateEnglishGrade($cq_marks, $total_marks, $pass_marks);
echo "Test 3 - CQ: [40, 36] => Grade: $result (Expected: C or better)<br>\n";

// Test case 4: Single CQ mark
$cq_marks = [35]; // Average = 35
$result = calculateEnglishGrade($cq_marks, $total_marks, $pass_marks);
echo "Test 4 - CQ: [35] => Grade: $result (Expected: Pass)<br>\n";

echo "<br>\n";

// Test English Grammar (should use same logic as English)
echo "<h3>English Grammar Grading Tests:</h3>\n";

// Test case 1: Pass - CQ average >= 33
$cq_marks = [34, 32]; // Average = 33
$result = calculateEnglishGrade($cq_marks, $total_marks, $pass_marks);
echo "Test 1 - CQ: [34, 32] => Grade: $result (Expected: Pass)<br>\n";

// Test case 2: Fail - CQ average < 33
$cq_marks = [30, 30]; // Average = 30
$result = calculateEnglishGrade($cq_marks, $total_marks, $pass_marks);
echo "Test 2 - CQ: [30, 30] => Grade: $result (Expected: F)<br>\n";
?>