if (!empty($filter_user)) { $arFilter["USER"] = $filter_user; } if ($lAdmin->EditAction()) { foreach ($FIELDS as $ID => $arFields) { if (!$lAdmin->IsUpdated($ID)) { continue; } $ID = IntVal($ID); $res = CTestAttempt::GetList(array(), array('ID' => $ID, 'ACCESS_OPERATIONS' => CLearnAccess::OP_LESSON_READ | CLearnAccess::OP_LESSON_WRITE)); if (!$res->Fetch()) { continue; } $DB->StartTransaction(); $ob = new CTestAttempt(); if (!$ob->Update($ID, $arFields)) { if ($e = $APPLICATION->GetException()) { $lAdmin->AddUpdateError(GetMessage("SAVE_ERROR") . $ID . ": " . $e->GetString(), $ID); $DB->Rollback(); } } else { $bCOMPLETED = false; if (is_set($arFields, "COMPLETED") && $arFields["COMPLETED"] == "Y") { $bCOMPLETED = true; } $ob->OnAttemptChange($ID, $bCOMPLETED); } $DB->Commit(); } } // group and single actions processing
$arResult["CURRENT_MARK"] = ""; if (isset($sessAttemptID) && intval($sessAttemptID) > 0) { $arResult["COMPLETE_PERCENT"] = CTestResult::GetPercent(@$sessAttemptID); if ($arResult["COMPLETE_PERCENT"]) { $arResult["CURRENT_MARK"] = CLTestMark::GetByPercent($arTest["ID"], $arResult["COMPLETE_PERCENT"]); } } if ($bTestCreate) { $sessIncorrectMessage = null; //If old attempt exists? if ($arAttempt = _AttemptExists($arParams["TEST_ID"])) { $sessAttemptID = $arAttempt["ID"]; if ($arAttempt["STATUS"] == "N") { $arFields = array("~DATE_START" => CDatabase::CurrentTimeFunction(), "DATE_END" => false, "STATUS" => "B"); $ta = new CTestAttempt(); $res = $ta->Update($arAttempt["ID"], $arFields); } LocalRedirect($arResult["REDIRECT_PAGE"]); } //Check attempt limit if ($arTest["ATTEMPT_LIMIT"] > 0 && $arTest["ATTEMPT_LIMIT"] <= CTestAttempt::GetCount($arParams["TEST_ID"], $USER->GetID())) { $sessAttemptError = GetMessage("LEARNING_LIMIT_ERROR"); LocalRedirect($arResult["REDIRECT_PAGE"]); } //Check min time between attempts if ($arTest["MIN_TIME_BETWEEN_ATTEMPTS"] > 0) { CTimeZone::Disable(); $rsPrevAttempt = CTestAttempt::GetList(array("DATE_END" => "DESC"), array("TEST_ID" => $arParams["TEST_ID"], "STUDENT_ID" => $USER->GetID())); CTimeZone::Enable(); if ($arPrevAttempt = $rsPrevAttempt->GetNext()) { $prevTime = strtotime($arPrevAttempt["DATE_END"]);
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; $aContext = array(array("ICON" => "btn_list", "TEXT" => GetMessage("LEARNING_BACK_TO_ADMIN"), "LINK" => "learn_attempt_admin.php?lang=" . LANG, "TITLE" => GetMessage("LEARNING_BACK_TO_ADMIN"))); $context = new CAdminContextMenu($aContext); $context->Show(); CAdminMessage::ShowMessage(GetMessage("LEARNING_BAD_ATTEMPT_ID_EX")); require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php"; die; } $aTabs = array(array("DIV" => "edit1", "ICON" => "main_user_edit", "TAB" => GetMessage("LEARNING_ADMIN_TAB1"), "TITLE" => GetMessage("LEARNING_ADMIN_TAB1_EX"))); $aTabs[] = $USER_FIELD_MANAGER->EditFormTab("LEARN_ATTEMPT"); $tabControl = new CAdminForm("attemptTabControl", $aTabs); if (!$bBadAttempt && $_SERVER["REQUEST_METHOD"] == "POST" && strlen($Update) > 0 && check_bitrix_sessid()) { $ta = new CTestAttempt(); $arFields = array("SCORE" => $SCORE, "MAX_SCORE" => $MAX_SCORE, "COMPLETED" => $COMPLETED == "Y" ? "Y" : "N", "STATUS" => $STATUS, "DATE_START" => $DATE_START, "DATE_END" => $DATE_END); $USER_FIELD_MANAGER->EditFormAddFields("LEARN_ATTEMPT", $arFields); $res = $ta->Update($ID, $arFields); if (!$res) { if ($e = $APPLICATION->GetException()) { $message = new CAdminMessage(GetMessage("LEARNING_ERROR"), $e); } $bVarsFromForm = true; } else { if (strlen($apply) <= 0) { if (strlen($return_url) > 0) { LocalRedirect($return_url); } else { LocalRedirect("/bitrix/admin/learn_attempt_admin.php?lang=" . LANG . GetFilterParams("filter_", false)); } } LocalRedirect("/bitrix/admin/learn_attempt_edit.php?ID=" . $ID . "&tabControl_active_tab=" . urlencode($tabControl_active_tab) . GetFilterParams("filter_", false)); }