plugin->test_constructor_gatekeeper();
$test_id = get_input("id");
$test_section_id = get_input("section");
$ids = get_input("item");
if (!is_array($ids) && $ids != "") $ids = array($ids);
$forward_to = "tests/test/{$test_id}/items";
$input_values = get_inputs();
$_SESSION['input_values'] = $input_values;
if (get_input("add_to_test_button", false)) {
$test_section = $TeKe->plugin->loadType("testSection", $test_section_id);
$position = count($test_section->getItems());
foreach ($ids as $id) {
$obj = $TeKe->plugin->loadType("", $id);
$new_id = $obj->copy(true);
$new_obj = $TeKe->plugin->loadType("", $new_id);
$new_obj->setTestSection($test_section_id, $new_id);
$position++;
$new_obj->setPosition($position, $new_id);
}
forward($forward_to);
} else if (get_input('section_delete_button', false)) {
if (!is_array($ids)) {
$TeKe->add_system_message(_("Delete failed"), 'error');
forward($forward_to);
} else {
$delete_failed = false;
foreach ($ids as $id) {
if (!$TeKe->plugin->deleteType("", $id)) {
$delete_failed = true;
}
}
$test_section = $TeKe->plugin->loadType("testSection", $test_section_id);
$test_section->reorderItems();
if ($delete_failed) {
$TeKe->add_system_message(_("At least one of the deletions failed."), 'error');
forward($forward_to);
}
}
$TeKe->add_system_message(_("Deleted"));
} else {
$TeKe->add_system_message(_("No action"));
}
forward($forward_to);
?>