query($sql); // Check if the query was successful if (!$result) { die("Query failed: " . $conn->error); } // School Information define('SCHOOL_NAME', 'HANDS OF LOVE - KABAGA'); define('PO_BOX', 'P.O. Box 1234, KAMPALA'); define('PHONE_NUMBERS', '(256) 456-7890'); function getGrade($score) { if (!is_numeric($score) || $score < 0 || $score > 100) { return "Invalid score"; } // Define grade thresholds $grades = [ 'D1' => [85, 100], 'D2' => [80, 84], 'C3' => [75, 79], 'C4' => [66, 74], 'C5' => [56, 65], 'C6' => [50, 55], 'P7' => [45, 49], 'P8' => [40, 44], 'F9' => [0, 39], ]; // Determine the grade based on the score foreach ($grades as $grade => $range) { if ($score >= $range[0] && $score <= $range[1]) { return $grade; } } return "F"; // Default case, should not reach here } function determineGrade($paper1, $paper2) { // Check for X grade when either paper has a score of 0 if ($paper1 === "0" || $paper2 === "0") { return ""; } // Check grades and return appropriate letter if (($paper1 === "D1" && $paper2 === "D1") || ($paper1 === "D1" && $paper2 === "D2") || ($paper1 === "D2" && $paper2 === "D1") || ($paper1 === "D2" && $paper2 === "D2")) { return "A"; } elseif (($paper1 === "D1" && $paper2 === "C3") || ($paper1 === "D2" && $paper2 === "C3") || ($paper1 === "C3" && $paper2 === "C3")) { return "B"; } elseif (($paper1 === "D1" && $paper2 === "C4") || ($paper1 === "D2" && $paper2 === "C4") || ($paper1 === "C3" && $paper2 === "C4") || ($paper1 === "C5" && $paper2 === "C5")) { return "C"; } elseif (($paper1 === "D1" && $paper2 === "C5") || ($paper1 === "D2" && $paper2 === "C5") || ($paper1 === "C3" && $paper2 === "C5") || ($paper1 === "C4" && $paper2 === "C5")) { return "D"; } elseif (($paper1 === "D1" && $paper2 === "C6") || ($paper1 === "D2" && $paper2 === "C6") || ($paper1 === "C3" && $paper2 === "C6") || ($paper1 === "C4" && $paper2 === "C6") || ($paper1 === "C5" && $paper2 === "C6") || ($paper1 === "C6" && $paper2 === "C6") || ($paper1 === "D1" && $paper2 === "P7") || ($paper1 === "D2" && $paper2 === "P7") || ($paper1 === "C3" && $paper2 === "P7") || ($paper1 === "C4" && $paper2 === "P7") || ($paper1 === "C5" && $paper2 === "P7") || ($paper1 === "D1" && $paper2 === "P8") || ($paper1 === "D2" && $paper2 === "P8") || ($paper1 === "C3" && $paper2 === "P8") || ($paper1 === "C4" && $paper2 === "P8")) { return "E"; } elseif (($paper1 === "C6" && $paper2 === "P7") || ($paper1 === "P7" && $paper2 === "P7") || ($paper1 === "P7" && $paper2 === "P8") || ($paper1 === "C5" && $paper2 === "P8") || ($paper1 === "C6" && $paper2 === "P8") || ($paper1 === "P8" && $paper2 === "P8") || ($paper1 === "D1" && $paper2 === "F9") || ($paper1 === "C6" && $paper2 === "F9")) { return "O"; } elseif (($paper1 === "P8" && $paper2 === "F9") || ($paper1 === "F9" && $paper2 === "F9")) { return "F"; } } function determineGradeThreePapers($paper1, $paper2, $paper3) { // Check for empty score when any paper has a score of 0 if ($paper1 === "0" || $paper2 === "0" || $paper3 === "0") { return ""; // Return empty string instead of "X" } // Grading logic if (($paper1 === "D1" && $paper2 === "D1" && $paper3 === "C3") || ($paper1 === "D1" && $paper2 === "D2" && $paper3 === "C3") || ($paper1 === "D2" && $paper2 === "D2" && $paper3 === "C3")) { return "A"; } elseif (($paper1 === "D1" && $paper2 === "D1" && $paper3 === "C4") || ($paper1 === "C3" && $paper2 === "C3" && $paper3 === "C4") ) { return "B"; } elseif (($paper1 === "D1" && $paper2 === "D1" && $paper3 === "C5") || ($paper1 === "C4" && $paper2 === "C4" && $paper3 === "C5")) { return "C"; } elseif (($paper1 === "D1" && $paper2 === "D1" && $paper3 === "C6") || ($paper1 === "C5" && $paper2 === "C5" && $paper3 === "C6")) { return "D"; } elseif (($paper1 === "D1" && $paper2 === "D1" && $paper3 === "P7") || ($paper1 === "C6" && $paper2 === "C6" && $paper3 === "P7") || ($paper1 === "P8" && $paper2 === "C6" && $paper3 === "C5")) { return "E"; } elseif (($paper1 === "F9" && $paper2 === "F9" && $paper3 === "F9") || ($paper1 === "F9" && $paper2 === "F9" && $paper3 === "P7") || ($paper1 === "D1" && $paper2 === "D1" && $paper3 === "F9") || ($paper1 === "P8" && $paper2 === "P8" && $paper3 === "F9") || ($paper1 === "P8" && $paper2 === "P8" && $paper3 === "P8") || ($paper1 === "P7" && $paper2 === "P7" && $paper3 === "P7")) { return "O"; } elseif (($paper1 === "F9" && $paper2 === "F9" && $paper3 === "P8") || ($paper1 === "F9" && $paper2 === "F9" && $paper3 === "F9")) { return "F"; } return "F"; // Default case if no other conditions are met } ?>
Phone:
Subject | Criteria | P1 | P2 | P3 | P4 | P5 | P6 | P7 | Grade |
---|---|---|---|---|---|---|---|---|---|
{$subject['name']} | {$subject['criteria']} | " . ($subject['marks'][0] !== null && $subject['marks'][0] !== "0" ? $subject['marks'][0] : '') . " | " . ($subject['marks'][1] !== null && $subject['marks'][1] !== "0" ? $subject['marks'][1] : '') . " | " . ($subject['marks'][2] !== null && $subject['marks'][2] !== "0" ? $subject['marks'][2] : '') . " | " . ($subject['marks'][3] !== null && $subject['marks'][3] !== "0" ? $subject['marks'][3] : '') . " | " . ($subject['marks'][4] !== null && $subject['marks'][4] !== "0" ? $subject['marks'][4] : '') . " | " . ($subject['marks'][5] !== null && $subject['marks'][5] !== "0" ? $subject['marks'][5] : '') . " | " . ($subject['marks'][6] !== null && $subject['marks'][6] !== "0" ? $subject['marks'][6] : '') . " | {$final_grade} |