$prevTime = strtotime($arPrevAttempt["DATE_END"]); $timeDiff = floor((time() - strtotime($arPrevAttempt["DATE_END"])) / 60); //time difference in minutes if ($timeDiff < $arTest["MIN_TIME_BETWEEN_ATTEMPTS"]) { $nextAttemptAfter = $arTest["MIN_TIME_BETWEEN_ATTEMPTS"] - $timeDiff; $nextAttemptAfterD = floor($nextAttemptAfter / (60 * 24)); $nextAttemptAfterH = floor(($nextAttemptAfter - $nextAttemptAfterD * 60 * 24) / 60); $nextAttemptAfterM = $nextAttemptAfter - $nextAttemptAfterD * 60 * 24 - $nextAttemptAfterH * 60; $sessAttemptError = GetMessage("LEARNING_TEST_TIME_INTERVAL_ERROR") . " " . ($nextAttemptAfterD > 0 ? $nextAttemptAfterD . " " . GetMessage("LEARNING_TEST_TIME_INTERVAL_ERROR_D") . " " : "") . ($nextAttemptAfterH > 0 ? $nextAttemptAfterH . " " . GetMessage("LEARNING_TEST_TIME_INTERVAL_ERROR_H") . " " : "") . $nextAttemptAfterM . " " . GetMessage("LEARNING_TEST_TIME_INTERVAL_ERROR_M") . ""; LocalRedirect($arResult["REDIRECT_PAGE"]); } } } //Add new attempt $rsAttempt = new CTestAttempt(); $attemptID = $rsAttempt->Add(array("TEST_ID" => $arParams["TEST_ID"], "STUDENT_ID" => $USER->GetID(), "STATUS" => "B")); if (!$attemptID) { $sessAttemptError = ($ex = $APPLICATION->GetException()) ? $ex->GetString() : GetMessage("LEARNING_ATTEMPT_CREATE_ERROR"); LocalRedirect($arResult["REDIRECT_PAGE"]); } //Create test questions $success = CTestAttempt::CreateAttemptQuestions($attemptID); if (!$success) { $sessAttemptError = ($ex = $APPLICATION->GetException()) ? $ex->GetString() : GetMessage("LEARNING_ATTEMPT_CREATE_ERROR"); CTestAttempt::Delete($attemptID); LocalRedirect($arResult["REDIRECT_PAGE"]); } $sessAttemptID = $attemptID; LocalRedirect($arResult["REDIRECT_PAGE"]); } elseif ($bPostAnswer) { $sessIncorrectMessage = null;