//$portion_status = $portion['portion_status']; $result = array('success' => true, 'portion_status' => $portion['portion_status'], 'x' => $portion['X'], 'y' => $portion['Y']); } else { $result = array('success' => false, 'error' => 'portion_id is null'); } echo json_encode($result); die; } else { if ($action == 'update_portion_status') { header("Content-Type: application/json"); $portion_id = isset($_POST['portion_id']) ? (int) $_POST['portion_id'] : null; $portion_status = isset($_POST['portion_status']) ? (int) $_POST['portion_status'] : null; $X = isset($_POST['x']) ? (int) $_POST['x'] : 0; $Y = isset($_POST['y']) ? (int) $_POST['y'] : 0; if ($portion_id && $portion_status) { $question_model->update_portion(null, null, $portion_status, $X, $Y, $portion_id); $result = array('success' => true); } else { $result = array('success' => false, 'error' => 'portion_id is null'); } echo json_encode($result); die; } else { if ($action == 'delete_portion') { header("Content-Type: application/json"); $portion_id = isset($_POST['portion_id']) ? (int) $_POST['portion_id'] : null; if ($portion_id) { $question_model->delete_portion($portion_id); $result = array('success' => true); } else { $result = array('success' => false, 'error' => 'portion_id is null');