<?php
include($_SERVER['DOCUMENT_ROOT'] . '/includes/include_all.inc.php');

header('Content-Type: application/json');

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $caseId = $_POST['caseId'];
    $instructorNotes = $_POST['instructorNotes'];

    $stmt = $pdo->prepare("UPDATE wp_groupusers_data SET instructor_notes = ? WHERE id = ?");
    $result = $stmt->execute([$instructorNotes, $caseId]);

    if ($result) {
        echo json_encode(['success' => true]);
    } else {
        echo json_encode(['success' => false, 'error' => 'Failed to update case']);
    }
} else {
    echo json_encode(['success' => false, 'error' => 'Invalid request method']);
}