예제 #1
0
 //Check test result
 $testResultID = intval($_REQUEST["TEST_RESULT"]);
 $arFields = array("ID" => $testResultID, "ATTEMPT_ID" => $sessAttemptID, 'CHECK_PERMISSIONS' => 'N');
 if ($arTest["PASSAGE_TYPE"] < 2) {
     $arFields["ANSWERED"] = "N";
 }
 $rsTestResult = CTestResult::GetList(array(), $arFields);
 if (!($arTestResult = $rsTestResult->GetNext())) {
     $sessAttemptID = null;
     $sessAttemptError = GetMessage("LEARNING_RESPONSE_SAVE_ERROR");
     LocalRedirect($arResult["REDIRECT_PAGE"]);
 }
 //Save User answer
 if ($arTest["TIME_LIMIT"] == 0 || $arTest["TIME_LIMIT"] * 60 >= time() - MakeTimeStamp($arAttempt["DATE_START"])) {
     if ($arTest["PASSAGE_TYPE"] == 0 || array_key_exists("answer", $_REQUEST)) {
         $result = CTestResult::AddResponse($testResultID, $_REQUEST["answer"]);
         if (!$result) {
             $sessAttemptID = null;
             $sessAttemptError = ($ex = $APPLICATION->GetException()) ? $ex->GetString() : GetMessage("LEARNING_RESPONSE_SAVE_ERROR");
             LocalRedirect($arResult["REDIRECT_PAGE"]);
         } else {
             $rsQuestion = CLQuestion::GetByID($arTestResult["QUESTION_ID"]);
             if ($arQuestion = $rsQuestion->GetNext()) {
                 // Resolve links "?COURSE_ID={SELF}". Don't relay on it, this behaviour
                 // can be changed in future without any notifications.
                 if (isset($arQuestion['DESCRIPTION'])) {
                     $arQuestion['DESCRIPTION'] = CLearnHelper::PatchLessonContentLinks($arQuestion['DESCRIPTION'], $arParams['COURSE_ID']);
                 }
                 if ($arQuestion["QUESTION_TYPE"] != "T") {
                     if ($arTest["SHOW_ERRORS"] == "Y" && $result["CORRECT"] == "N" && $result["ANSWERED"] == "Y" && $arQuestion["INCORRECT_MESSAGE"]) {
                         $sessIncorrectMessage = $arQuestion;