<?php
// includes/functions.php

// Secure input data
function clean($data) {
    return htmlspecialchars(strip_tags(trim($data)));
}

// Redirect helper
function redirect($location) {
    header("Location: $location");
    exit();
}

// Format result status for UI [cite: 4]
function getStatusBadge($status) {
    if ($status == 'approved') {
        return "<span style='color:green;'>Published</span>";
    }
    return "<span style='color:orange;'>Pending Approval</span>";
}

// Calculate Grade based on total score [cite: 1]
function calculateGrade($score) {
    if ($score >= 70) return 'A';
    if ($score >= 60) return 'B';
    if ($score >= 50) return 'C';
    if ($score >= 45) return 'D';
    if ($score >= 40) return 'E';
    return 'F';
}
?>