<?php if(file_exists('../../../'.$_REQUEST['tenant'].'/config.php')) {
    require_once('../../../'.$_REQUEST['tenant'].'/config.php');
}
if(file_exists('/config.php')) {
    require_once('/config.php'); 
}


$assignment_id = $_POST['assignment_id'];
$action = $_POST['action'];

$status = ($action === 'started') ? 1 : 2; // 1 = In Progress, 2 = Completed

$sql = "UPDATE admin_assignments SET status = ? WHERE id = ?";
$stmt = $con->prepare($sql);
$stmt->bind_param('ii', $status, $assignment_id);

if ($stmt->execute()) {
    echo 'success';
} else {
    echo 'error';
}

$stmt->close();
$con->close();
?>