<?php
// ajax/update_question_session.php
require '../config.php';
header('Content-Type: application/json');
$input = json_decode(file_get_contents('php://input'), true);
$id = intval($input['id'] ?? 0);
$session_id = intval($input['session_id'] ?? 0);
if (!$id || !$session_id){ echo json_encode(['success'=>false,'message'=>'Missing parameters']); exit; }
try {
  $stmt = $dbh->prepare("UPDATE questions SET session_id = :sid WHERE id = :id");
  $stmt->execute([':sid'=>$session_id, ':id'=>$id]);
  echo json_encode(['success'=>true]);
} catch(Exception $e){
  echo json_encode(['success'=>false,'message'=>$e->getMessage()]);
}
