$test_data["items"] = $db_con->selectEntries(false, 'dragdrop_items', array("where" => "item_test_ID = " . $_GET['test_id'])); } else { //retrieve without solutions (so they are not accessible from browser when test is performed) $test_data["items"] = $db_con->selectEntries(false, 'dragdrop_items', array("select" => "item_ID, item_text", "where" => "item_test_ID = " . $_GET['test_id'])); } //else shuffle($test_data["items"]); //items should be in random order $test_data["containers"] = $db_con->selectEntries(true, 'dragdrop_containers', array("where" => "container_test_ID = " . $_GET['test_id'])); $test_data["db_error"] .= $db_con->getErrorMessage(); print json_encode($test_data); } else { if (isset($_POST['delete_test'])) { $test_id = $_POST['selected_test_id']; $db_con = new Db_Connection(); $db_con->deleteEntries(false, 'tests', array("where" => "test_ID = " . $test_id)); $db_con->deleteEntries(false, 'dragdrop_items', array("where" => "item_test_ID = " . $test_id)); $db_con->deleteEntries(true, 'dragdrop_containers', array("where" => "container_test_ID = " . $test_id)); if ($db_con->getErrorMessage() !== '') { $error = true; $error_msg = 'The following error has occurred while deleting the test: ' . $db_con->getErrorMessage(); } else { $deleted_successfully = true; } //else include INCLUDE_PATH . 'index.php'; } else { if (isset($_GET['check_test'])) { $temp_solution = $_GET['check_test']; $db_con = new Db_Connection(); $test_items = $db_con->selectEntries(false, 'dragdrop_items', array("where" => "item_test_ID = " . $_GET['check_test_id']));
$question_data['incorrect_answers'][] = $incorrect['incorrect_text']; } //foreach $question_data["db_error"] = $db_con->getErrorMessage(); print json_encode($question_data); } else { if (isset($_POST['delete_test'])) { $test_id = $_POST['selected_test_id']; $db_con = new Db_Connection(); //delete questions: $lookups = $db_con->selectEntries(false, 'dynmc_lookup', array("where" => "lookup_test_ID = " . $test_id)); for ($i = 0; $i < sizeof($lookups); $i++) { deleteQuestion($lookups[$i]['lookup_question_ID'], $test_id); } //for $db_con->deleteEntries(true, 'tests', array("where" => "test_ID = " . $test_id)); if ($db_con->getErrorMessage() !== '') { $error = true; $error_msg = 'The following error has occurred while deleting the test: ' . $db_con->getErrorMessage(); } else { $deleted_successfully = true; } //else include INCLUDE_PATH . 'index.php'; } else { if (isset($_GET['new_option'])) { resumeAndCheckSession(); $timestamp = $_GET['timestamp']; if (sizeof($_SESSION[$timestamp]['options'][$_GET['question_ID']]) > 0) { $_SESSION[$timestamp]['current_option'] = array_shift($_SESSION[$timestamp]['options'][$_GET['question_ID']]); print $_SESSION[$timestamp]['current_option'][1];
for ($j = 0; $j < strlen($test_data["questions"][$i]["question_correct_answer"]); $j++) { $dummy .= 'X'; } //for $test_data["questions"][$i]["question_correct_answer"] = $dummy; } //foreach } //if $test_data["db_error"] .= $db_con->getErrorMessage(); print json_encode($test_data); } else { if (isset($_POST['delete_test'])) { $test_id = $_POST['selected_test_id']; $db_con = new Db_Connection(); $db_con->deleteEntries(false, 'tests', array("where" => "test_ID = " . $test_id)); $db_con->deleteEntries(false, 'crossword_questions', array("where" => "question_test_ID = " . $test_id)); $db_con->deleteEntries(true, 'crossword_grid', array("where" => "grid_test_ID = " . $test_id)); if ($db_con->getErrorMessage() !== '') { $error = true; $error_msg = 'The following error has occurred while deleting the test: ' . $db_con->getErrorMessage(); } else { $deleted_successfully = true; } //else include INCLUDE_PATH . 'index.php'; } else { if (isset($_GET['check_test'])) { $temp_solution = $_GET['check_test']; $db_con = new Db_Connection(); $questions = $db_con->selectEntries(false, 'crossword_questions', array("where" => "question_test_ID = " . $_GET['check_test_id']));