//$response['test_status'] = $status;
    $response['remaining'] = $remaining;
    $response['time_left'] = $timeLeft;
    echo json_encode($response);
}
if (isset($_POST['pause'])) {
    $userId = $_SESSION['user_id'];
    $testId = $_SESSION['active_test_id'];
    $courseId = $_SESSION['courseId'];
    $test = getTestById($testId);
    $duration = $test['duration'];
    $startedAt = $test['started_at'];
    list($remaining, $timer) = countDown($startedAt, $duration);
    $newDuration = $remaining / 60;
    //converts time from seconds to minnutes
    $query = select("SELECT * FROM test_info WHERE test_id ='{$testId}'")[0];
    if ($query['paused'] == 0) {
        mysql_query("UPDATE users SET paused_tests = paused_tests + 1 WHERE id = '{$userId}'");
        $sql = "UPDATE test_info SET duration = '{$newDuration}', course_id ='{$courseId}', paused = 1 WHERE test_id = '{$testId}'";
        mysql_query($sql);
    } else {
        /*$sql = "UPDATE test_info SET duration = '$newDuration', status = 1  WHERE test_id = '{$testId}'";
          mysql_query($sql);*/
    }
}
// delete saved test on request
if (isset($_GET['del'])) {
    if (deleteTest($_GET['del'])) {
        redirect('department');
    }
}
<?php

if (isset($_POST["box_tests"])) {
    foreach ($_POST["box_tests"] as $f_testid) {
        deleteTest((int) $f_testid);
    }
} else {
    $f_testid = (int) readGetVar('testid');
    deleteTest($f_testid);
}
gotoLocation('test-manager.php' . getURLAddon('?action=', array('action', 'testid')));
function deleteTest($i_testid)
{
    global $g_db, $srv_settings;
    $g_db->Execute("DELETE FROM " . $srv_settings['table_prefix'] . "tests_attempts WHERE testid=" . $i_testid);
    //9917//9917
    if ($g_db->Execute("DELETE FROM " . $srv_settings['table_prefix'] . "groups_tests WHERE testid=" . $i_testid) === false) {
        showDBError(__FILE__, 1);
    }
    if ($g_db->Execute("DELETE FROM " . $srv_settings['table_prefix'] . "tests_questions WHERE testid=" . $i_testid) === false) {
        showDBError(__FILE__, 2);
    }
    if ($g_db->Execute("DELETE FROM " . $srv_settings['table_prefix'] . "tests WHERE testid=" . $i_testid) === false) {
        showDBError(__FILE__, 3);
    }
}