<?php
// includes/proctor_log.php
include '../../includes/conn.php';
include '../../includes/functions.php';
header('Content-Type: application/json');

$action = $_POST['action'] ;
$student = $_POST['student_id'] ?? ($_SESSION['user_id']);
$meta = $_POST['meta'] ?? null;

try {
  $stmt = $pdo->prepare("INSERT INTO proctor_logs (student_id, action, meta, created_at) VALUES (?, ?, ?, NOW())");
  $stmt->execute([$student, $action, $meta]);
  echo json_encode(['ok' => true]);
} catch (Exception $e) {
  http_response_code(500);
  echo json_encode(['ok' => false, 'error' => $e->getMessage()]);
}
