:</td> <td> <table> <?php if ($str_QUESTION_TYPE == "T") { ?> <tr> <td><textarea rows="5" cols="50" name="RESPONSE"><?php echo $str_RESPONSE; ?> </textarea></td> </tr> <?php } else { $arR = explode(',', $str_RESPONSE); $r = CLAnswer::GetList(array("ID" => "ASC"), array("QUESTION_ID" => $str_QUESTION_ID)); while ($arAnswers = $r->GetNext()) { ?> <tr> <td> <?php if ($str_QUESTION_TYPE == "M") { ?> <input type="checkbox" name="RESPONSE[]" value="<?php echo $arAnswers["ID"]; ?> " <?php if (in_array($arAnswers["ID"], $arR)) { echo "checked"; } ?>
{ global $arNewIDs; if ($tmp = $answers->ExtractFields("str_ANSWER_")) { return $tmp; } elseif (list($key, $val) = each($arNewIDs)) { global $str_ANSWER_ID, $str_ANSWER_CORRECT, $str_ANSWER_ANSWER, $str_ANSWER_SORT; $str_ANSWER_ID = $val; $str_ANSWER_CORRECT = ""; $str_ANSWER_ANSWER = ""; $str_ANSWER_SORT = "10"; return true; } return false; } $SINGLE_ID = ""; $answers = CLAnswer::GetList(array("SORT" => "ASC", "ID" => "ASC"), array("QUESTION_ID" => $ID)); while ($r = _GetOldAndNew($answers)) { if ($bVarsFromForm) { $DB->InitTableVarsForEdit("b_learn_answer", "ANSWER_" . $str_ANSWER_ID . "_", "str_ANSWER_"); if ($str_QUESTION_TYPE == "S" && isset($_POST["ANSWER_CORRECT"])) { $SINGLE_ID = $_POST["ANSWER_CORRECT"]; } } ?> <tr> <td align="center" width="40" style="text-align:center;"><?php echo $str_ANSWER_ID > 0 ? $str_ANSWER_ID : ""; ?> </td> <?php if ($str_QUESTION_TYPE != "R") {
/** * <p>Метод удаляет вопрос с идентификатором ID.</p> * * * @param int $ID Идентификатор вопроса. * * @return bool <p>Метод возвращает <i>true</i> в случае успешного удаления вопроса, в * противном случае возвращает <i>false</i>.</p> * * <h4>Example</h4> * <pre> * <? * if (CModule::IncludeModule("learning")) * { * $COURSE_ID = 97; * $QUESTION_ID = 600; * * if (CCourse::GetPermission($COURSE_ID) >= 'W') * { * @set_time_limit(0); * $DB->StartTransaction(); * if (!CLQuestion::Delete($QUESTION_ID)) * { * echo "Error!"; * $DB->Rollback(); * } * else * $DB->Commit(); * } * } * ?> * </pre> * * * <h4>See Also</h4> * <ul><li> <a href="http://dev.1c-bitrix.ru/api_help/learning/classes/clquestion/index.php">CLQuestion</a>::<a * href="http://dev.1c-bitrix.ru/api_help/learning/classes/clquestion/add.php">Add</a> </li></ul><a name="examples"></a> * * * @static * @link http://dev.1c-bitrix.ru/api_help/learning/classes/clquestion/delete.php * @author Bitrix */ public static function Delete($ID) { global $DB, $USER_FIELD_MANAGER; $ID = intval($ID); if ($ID < 1) { return false; } $strSql = "SELECT FILE_ID FROM b_learn_question WHERE ID = " . $ID; $r = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); if (!($arQuestion = $r->Fetch())) { return false; } $answers = CLAnswer::GetList(array(), array("QUESTION_ID" => $ID)); while ($arAnswer = $answers->Fetch()) { if (!CLAnswer::Delete($arAnswer["ID"])) { return false; } } $arAttempts = array(); $strSql = "SELECT ATTEMPT_ID FROM b_learn_test_result WHERE QUESTION_ID = " . $ID; $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); while ($ar = $res->Fetch()) { $arAttempts[] = $ar["ATTEMPT_ID"]; } //Attempts to recount //Results $strSql = "DELETE FROM b_learn_test_result WHERE QUESTION_ID = " . $ID; if (!$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__)) { return false; } foreach ($arAttempts as $ATTEMPT_ID) { CTestAttempt::RecountQuestions($ATTEMPT_ID); CTestAttempt::OnAttemptChange($ATTEMPT_ID); } $strSql = "DELETE FROM b_learn_question WHERE ID = " . $ID; if (!$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__)) { return false; } $USER_FIELD_MANAGER->delete('LEARNING_QUESTIONS', $ID); CFile::Delete($arQuestion["FILE_ID"]); CEventLog::add(array('AUDIT_TYPE_ID' => 'LEARNING_REMOVE_ITEM', 'MODULE_ID' => 'learning', 'ITEM_ID' => 'Q #' . $ID, 'DESCRIPTION' => 'question removed')); foreach (GetModuleEvents('learning', 'OnAfterQuestionDelete', true) as $arEvent) { ExecuteModuleEventEx($arEvent, array($ID, $arQuestion)); } return true; }
// For backward compatibility with template` $arLesson['ID'] = $arLesson['LESSON_ID']; // Resolve links "?COURSE_ID={SELF}". Don't relay on it, this behaviour // can be changed in future without any notifications. if (isset($arLesson['DETAIL_TEXT'])) { $arLesson['DETAIL_TEXT'] = CLearnHelper::PatchLessonContentLinks($arLesson['DETAIL_TEXT'], $arParams['COURSE_ID']); } if (isset($arLesson['PREVIEW_TEXT'])) { $arLesson['PREVIEW_TEXT'] = CLearnHelper::PatchLessonContentLinks($arLesson['PREVIEW_TEXT'], $arParams['COURSE_ID']); } //arResult $arResult = array("LESSON" => $arLesson, "QUESTIONS" => array(), "QUESTIONS_COUNT" => 0, "ERROR_MESSAGE" => ""); //Questions $obquestion = CLQuestion::GetList($arOrder = array("SORT" => "ASC", "ID" => "ASC"), $arFilter = array("LESSON_ID" => $arParams["LESSON_ID"], "ACTIVE" => "Y", "SELF" => "Y", 'CHECK_PERMISSIONS' => 'N')); while ($arQuestion = $obquestion->GetNext()) { $obanswer = CLAnswer::GetList(array("SORT" => "ASC"), array("QUESTION_ID" => $arQuestion["ID"])); // 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']); } $arQuestion["FILE"] = CFile::GetFileArray($arQuestion["FILE_ID"]); $arQuestion["ANSWERS"] = array(); while ($arAnswer = $obanswer->GetNext()) { $arQuestion["ANSWERS"][] = $arAnswer; } if ($arQuestion["QUESTION_TYPE"] == "R") { $arQuestion["ANSWERS_ORIGINAL"] = $arQuestion["ANSWERS"]; shuffle($arQuestion["ANSWERS"]); } $arResult["QUESTIONS"][] = $arQuestion;
function GetByID($ID) { return CLAnswer::GetList($arOrder = array(), $arFilter = array("ID" => $ID)); }
/** * <p>Метод удаляет вопрос с идентификатором ID.</p> * * * * * @param int $ID Идентификатор вопроса. * * * * @return bool <p>Метод возвращает <i>true</i> в случае успешного удаления вопроса, в * противном случае возвращает <i>false</i>.</p> * * * <h4>Example</h4> * <pre> * <? * if (CModule::IncludeModule("learning")) * { * $COURSE_ID = 97; * $QUESTION_ID = 600; * * if (CCourse::GetPermission($COURSE_ID) >= 'W') * { * @set_time_limit(0); * $DB->StartTransaction(); * if (!CLQuestion::Delete($QUESTION_ID)) * { * echo "Error!"; * $DB->Rollback(); * } * else * $DB->Commit(); * } * } * ?> * </pre> * * * * <h4>See Also</h4> * <ul><li> <a href="http://dev.1c-bitrix.ru/api_help/learning/classes/clquestion/index.php">CLQuestion</a>::<a * href="http://dev.1c-bitrix.ru/api_help/learning/classes/clquestion/add.php">Add</a> </li></ul><a name="examples"></a> * * * @static * @link http://dev.1c-bitrix.ru/api_help/learning/classes/clquestion/delete.php * @author Bitrix */ public static function Delete($ID) { global $DB; $ID = intval($ID); if ($ID < 1) return false; $strSql = "SELECT FILE_ID FROM b_learn_question WHERE ID = ".$ID; $r = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__); if (!$arQuestion = $r->Fetch()) return false; $answers = CLAnswer::GetList(Array(), Array("QUESTION_ID" => $ID)); while($arAnswer = $answers->Fetch()) { if(!CLAnswer::Delete($arAnswer["ID"])) return false; } $arAttempts = Array(); $strSql = "SELECT ATTEMPT_ID FROM b_learn_test_result WHERE QUESTION_ID = ".$ID; $res = $DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__); while($ar = $res->Fetch()) $arAttempts[] = $ar["ATTEMPT_ID"]; //Attempts to recount //Results $strSql = "DELETE FROM b_learn_test_result WHERE QUESTION_ID = ".$ID; if (!$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__)) return false; foreach($arAttempts as $ATTEMPT_ID) { CTestAttempt::RecountQuestions($ATTEMPT_ID); CTestAttempt::OnAttemptChange($ATTEMPT_ID); } $strSql = "DELETE FROM b_learn_question WHERE ID = ".$ID; if (!$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__)) return false; CFile::Delete($arQuestion["FILE_ID"]); return true; }
if ($arResult["NAV"]["END_PAGE"] - $arParams["PAGE_WINDOW"] + 1 >= 1) { $arResult["NAV"]["START_PAGE"] = $arResult["NAV"]["END_PAGE"] - $arParams["PAGE_WINDOW"] + 1; } } $rsQuestion = CLQuestion::GetList(array(), array("ID" => $arResult["QBAR"][$arResult["NAV"]["PAGE_NUMBER"]]["QUESTION_ID"])); $arResult["QUESTION"] = $rsQuestion->GetNext(); // Resolve links "?COURSE_ID={SELF}". Don't relay on it, this behaviour // can be changed in future without any notifications. if (isset($arResult["QUESTION"]['DESCRIPTION'])) { $arResult["QUESTION"]['DESCRIPTION'] = CLearnHelper::PatchLessonContentLinks($arResult["QUESTION"]['DESCRIPTION'], $arParams['COURSE_ID']); } $arResult["QUESTION"]["FILE"] = CFile::GetFileArray($arResult["QUESTION"]["FILE_ID"]); //Answers $arResult["QUESTION"]["ANSWERS"] = array(); $arSort = $arTest["RANDOM_ANSWERS"] == "Y" || $arResult["QUESTION"]["QUESTION_TYPE"] == "R" ? array("RAND" => "RAND", "SORT" => "ASC") : array("SORT" => "ASC"); $rsAnswer = CLAnswer::GetList($arSort, array("QUESTION_ID" => $arResult["QUESTION"]["ID"])); while ($arAnswer = $rsAnswer->GetNext()) { $arResult["QUESTION"]["ANSWERS"][] = $arAnswer; } } } $arResult["SAFE_REDIRECT_PAGE"] = htmlspecialcharsbx($arResult["REDIRECT_PAGE"]); } $linkedLessonId = CCourse::CourseGetLinkedLesson($arResult['TEST']['COURSE_ID']); $bCanEdit = $linkedLessonId !== false && (CLearnAccessMacroses::CanUserEditLesson(array('lesson_id' => $linkedLessonId)) || $USER->IsAdmin()); if ($bCanEdit) { $deleteReturnUrl = ""; if ($parent = $this->GetParent()) { $deleteReturnUrl = CComponentEngine::MakePathFromTemplate($parent->arResult["URL_TEMPLATES"]["test.list"], array("COURSE_ID" => $arResult["TEST"]["COURSE_ID"])); } $arAreaButtons = array(array("TEXT" => GetMessage("LEARNING_COURSES_TEST_EDIT"), "TITLE" => GetMessage("LEARNING_COURSES_TEST_EDIT"), "URL" => 'javascript:' . $APPLICATION->GetPopupLink(array("URL" => "/bitrix/admin/learn_test_edit.php?lang=" . LANGUAGE_ID . "&ID=" . $arResult["TEST"]["ID"] . "&COURSE_ID=" . $arResult["TEST"]["COURSE_ID"] . "&bxpublic=Y&from_module=learning", "PARAMS" => array("width" => 700, 'height' => 500, 'resize' => false))), "ICON" => "bx-context-toolbar-edit-icon", "ID" => "bx-context-toolbar-edit-test"), array("TEXT" => GetMessage("LEARNING_COURSES_TEST_DELETE"), "TITLE" => GetMessage("LEARNING_COURSES_TEST_DELETE"), "URL" => "javascript:if(confirm('" . GetMessage("LEARNING_COURSES_TEST_DELETE_CONF") . "'))jsUtils.Redirect([], '" . CUtil::JSEscape("/bitrix/admin/learn_test_admin.php?ID=" . $arParams["TEST_ID"] . "&action=delete&lang=" . LANGUAGE_ID . "&" . bitrix_sessid_get() . "&COURSE_ID=" . $arParams["COURSE_ID"]) . (strlen($deleteReturnUrl) ? "&return_url=" . urlencode($deleteReturnUrl) : "") . "')", "ICON" => "bx-context-toolbar-delete-icon", "ID" => "bx-context-toolbar-delete-test"), array("SEPARATOR" => "Y"));