本文整理汇总了PHP中CCourse::GetByID方法的典型用法代码示例。如果您正苦于以下问题:PHP CCourse::GetByID方法的具体用法?PHP CCourse::GetByID怎么用?PHP CCourse::GetByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCourse
的用法示例。
在下文中一共展示了CCourse::GetByID方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CheckFields
function CheckFields(&$arFields, $ID = false)
{
global $DB, $APPLICATION;
if ($ID === false && !is_set($arFields, "STUDENT_ID")) {
$APPLICATION->ThrowException(GetMessage("LEARNING_BAD_USER_ID"), "EMPTY_STUDENT_ID");
return false;
} elseif (is_set($arFields, "STUDENT_ID")) {
$dbResult = CUser::GetByID($arFields["STUDENT_ID"]);
if (!$dbResult->Fetch()) {
$APPLICATION->ThrowException(GetMessage("LEARNING_BAD_USER_ID_EX"), "ERROR_NO_STUDENT_ID");
return false;
}
}
if ($ID === false && !is_set($arFields, "COURSE_ID")) {
$APPLICATION->ThrowException(GetMessage("LEARNING_BAD_COURSE_ID"), "ERROR_EMPTY_COURSE_ID");
return false;
} elseif (is_set($arFields, "COURSE_ID")) {
if ($bCheckRights) {
$r = CCourse::GetByID($arFields["COURSE_ID"]);
} else {
$r = CCourse::GetList(array(), array("ID" => $arFields["COURSE_ID"], 'CHECK_PERMISSIONS' => 'N'));
}
if (!$r->Fetch()) {
$APPLICATION->ThrowException(GetMessage("LEARNING_BAD_COURSE_ID_EX"), "ERROR_NO_COURSE_ID");
return false;
}
}
if (is_set($arFields, "STUDENT_ID") && is_set($arFields, "COURSE_ID")) {
$res = CCertification::GetList(array(), array("STUDENT_ID" => $arFields["STUDENT_ID"], "COURSE_ID" => $arFields["COURSE_ID"]));
if ($res->Fetch()) {
$APPLICATION->ThrowException(GetMessage("LEARNING_BAD_CERTIFICATE_DUPLICATE"), "ERROR_CERTIFICATE_DUPLICATE");
return false;
}
}
if (is_set($arFields, "DATE_CREATE") && !$DB->IsDate($arFields["DATE_CREATE"], false, LANG, "FULL")) {
$APPLICATION->ThrowException(GetMessage("LEARNING_BAD_DATE_CREATE"), "EMPTY_DATE_CREATE");
return false;
}
if (is_set($arFields, "PUBLIC_PROFILE") && $arFields["PUBLIC"] != "N") {
$arFields["PUBLIC_PROFILE"] = "Y";
}
if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "N") {
$arFields["ACTIVE"] = "Y";
}
if (is_set($arFields, "FROM_ONLINE") && $arFields["FROM_ONLINE"] != "N") {
$arFields["FROM_ONLINE"] = "Y";
}
return true;
}
示例2: CCoursePackage
function CCoursePackage($COURSE_ID)
{
global $DB;
$this->ID = intval($COURSE_ID);
//Course exists?
$res = CCourse::GetByID($this->ID);
if (!($this->arCourse = $res->Fetch())) {
$this->LAST_ERROR = GetMessage("LEARNING_BAD_COURSE_ID_EX");
return false;
}
$res = CCourse::GetSite($this->ID);
if ($arSite = $res->GetNext()) {
$charset = $arSite["CHARSET"];
} else {
$this->LAST_ERROR = GetMessage("LEARNING_BAD_SITE_ID_EX");
return false;
}
//Define charset
if (strlen($charset) <= 0) {
if (defined("SITE_CHARSET") && strlen(SITE_CHARSET) > 0) {
$charset = SITE_CHARSET;
} else {
$charset = "windows-1251";
}
}
$this->charset = $charset;
//Get chapters, lessons, questions
$this->_GetCourseContent($this->arCourse['LESSON_ID']);
//Get tests
$strSql = "SELECT T.*, " . $DB->DateToCharFunction("T.TIMESTAMP_X") . " as TIMESTAMP_X " . "FROM b_learn_test T " . "WHERE T.COURSE_ID = " . intval($this->ID) . " " . "ORDER BY SORT ASC ";
$res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
while ($arRes = $res->Fetch()) {
$r = ++$this->RefID;
$this->arItems[$r] = $this->_CreateContent("TES", $arRes, $r);
$this->strItems .= '<item identifier="TES' . $r . '" identifierref="RES' . $r . '"><title>' . htmlspecialcharsbx($arRes["NAME"]) . '</title>';
$marksRes = $DB->Query("SELECT * FROM b_learn_test_mark WHERE TEST_ID = '" . (string) (int) $arRes['ID'] . "'", false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
while ($arMarksRes = $marksRes->Fetch()) {
$r = ++$this->RefID;
$this->arItems[$r] = $this->CreateTMK($arMarksRes, $r);
$this->strItems .= '<item identifier="TMK' . $r . '" identifierref="RES' . $r . '">' . '<title>' . htmlspecialcharsbx($arMarksRes['MARK'] . ' (' . $arMarksRes['DESCRIPTION'] . ')') . '</title>' . '</item>';
}
$this->strItems .= '</item>';
$this->strResourses .= '<resource identifier="RES' . $r . '" type="webcontent" href="res' . $r . '.xml">' . $this->_GetResourceFiles($r) . '</resource>';
}
}
示例3: Update
//.........这里部分代码省略.........
* <h4>See Also</h4>
* <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/learning/fields.php#course">Поля курса</a> </li> <li> <a
* href="http://dev.1c-bitrix.ru/api_help/learning/classes/ccourse/index.php">CCourse</a>::<a
* href="http://dev.1c-bitrix.ru/api_help/learning/classes/ccourse/add.php">Add</a> </li> </ul> <a name="examples"></a>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/learning/classes/ccourse/update.php
* @author Bitrix
*/
public function Update($ID, $arFields)
{
global $DB;
$ID = intval($ID);
if ($ID < 1) {
return false;
}
if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y") {
$arFields["ACTIVE"] = "N";
}
if (is_set($arFields, "DESCRIPTION_TYPE") && $arFields["DESCRIPTION_TYPE"] != "html") {
$arFields["DESCRIPTION_TYPE"] = "text";
}
if (is_set($arFields, "DETAIL_TEXT_TYPE") && $arFields["DETAIL_TEXT_TYPE"] != "html") {
$arFields["DETAIL_TEXT_TYPE"] = "text";
}
if (is_set($arFields, "PREVIEW_TEXT_TYPE") && $arFields["PREVIEW_TEXT_TYPE"] != "html") {
$arFields["PREVIEW_TEXT_TYPE"] = "text";
}
if (is_set($arFields, "RATING") && !in_array($arFields["RATING"], array("Y", "N"))) {
$arFields["RATING"] = NULL;
}
if (is_set($arFields, "RATING_TYPE") && !in_array($arFields["RATING_TYPE"], array("like", "standart_text", "like_graphic", "standart"))) {
$arFields["RATING_TYPE"] = NULL;
}
$lessonId = self::CourseGetLinkedLesson($ID);
if ($this->CheckFields($arFields, $ID) && $lessonId !== false) {
if (array_key_exists('ID', $arFields)) {
unset($arFields["ID"]);
}
$arFieldsLesson = $arFields;
$arFieldsToUnset = array('GROUP_ID', 'SITE_ID');
foreach ($arFieldsToUnset as $key => $value) {
if (array_key_exists($value, $arFieldsLesson)) {
unset($arFieldsLesson[$value]);
}
}
//Sites
if (is_set($arFields, "SITE_ID")) {
$str_LID = "''";
foreach ($arFields["SITE_ID"] as $lang) {
$str_LID .= ", '" . $DB->ForSql($lang) . "'";
}
$strSql = "DELETE FROM b_learn_course_site WHERE COURSE_ID=" . $ID;
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
$strSql = "INSERT INTO b_learn_course_site(COURSE_ID, SITE_ID) " . "SELECT " . $ID . ", LID " . "FROM b_lang " . "WHERE LID IN (" . $str_LID . ") ";
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
CLearnLesson::Update($lessonId, $arFieldsLesson);
if ($ID && (is_set($arFields, "NAME") || is_set($arFields, "DESCRIPTION") || is_set($arFields, 'DETAIL_TEXT'))) {
if (CModule::IncludeModule("search")) {
$rsCourse = CCourse::GetByID($ID);
if ($arCourse = $rsCourse->Fetch()) {
$arGroupPermissions = CCourse::GetGroupPermissions($arCourse["ID"]);
if (is_set($arFields, "SITE_ID")) {
$arSiteIds = array();
foreach ($arFields["SITE_ID"] as $lang) {
$rsSitePaths = CSitePath::GetList(array(), array("SITE_ID" => $lang, "TYPE" => "C"));
if ($arSitePaths = $rsSitePaths->Fetch()) {
$strPath = $arSitePaths["PATH"];
} else {
$strPath = "";
}
$arSiteIds[$lang] = str_replace("#COURSE_ID#", $ID, $strPath);
}
$detailText = '';
if ($arCourse["DETAIL_TEXT_TYPE"] !== 'text') {
$detailText = CSearch::KillTags($arCourse['DETAIL_TEXT']);
} else {
$detailText = strip_tags($arCourse['DETAIL_TEXT']);
}
$dataBody = '';
if (strlen($detailText) > 0) {
$dataBody = $detailText;
} else {
$dataBody = $arCourse['NAME'];
}
$arSearchIndex = array("LAST_MODIFIED" => $arCourse["TIMESTAMP_X"], "TITLE" => $arCourse["NAME"], "BODY" => $dataBody, "SITE_ID" => $arSiteIds, "PERMISSIONS" => $arGroupPermissions);
CSearch::Index("learning", "C" . $ID, $arSearchIndex);
}
CSearch::ChangePermission("learning", $arGroupPermissions, false, "C" . $arCourse["ID"]);
}
}
}
global $CACHE_MANAGER;
$CACHE_MANAGER->ClearByTag('LEARN_COURSE_' . $ID);
return true;
}
return false;
}
示例4: IncludeModuleLangFile
// second system's prolog
if (IsModuleInstalled('learning') && defined('LEARNING_FAILED_TO_LOAD_REASON')) {
echo LEARNING_FAILED_TO_LOAD_REASON;
} else {
CAdminMessage::ShowMessage(GetMessage('LEARNING_MODULE_NOT_FOUND'));
}
require $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/epilog_admin.php';
// system's epilog
exit;
}
require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/learning/prolog.php";
IncludeModuleLangFile(__FILE__);
$aContext = array();
$oAccess = CLearnAccess::GetInstance($USER->GetID());
$COURSE_ID = intval($COURSE_ID);
$course = CCourse::GetByID($COURSE_ID);
$bBadCourse = true;
try {
if ($arCourse = $course->Fetch()) {
$linkedLessonId = CCourse::CourseGetLinkedLesson($COURSE_ID);
if ($linkedLessonId !== false && $oAccess->IsLessonAccessible($linkedLessonId, CLearnAccess::OP_LESSON_READ)) {
$bBadCourse = false;
} else {
$bBadCourse = true;
}
} else {
$bBadCourse = true;
}
} catch (Exception $e) {
$bBadCourse = true;
}
示例5: GetMessage
}
if ($COURSE_ID > 0) {
$APPLICATION->SetTitle(str_replace("#ID#", $COURSE_ID, GetMessage("LEARNING_EDIT_TITLE2")));
} else {
$APPLICATION->SetTitle(GetMessage("LEARNING_EDIT_TITLE1"));
}
//Defaults
$str_ACTIVE = "Y";
$str_SORT = "500";
$str_DETAIL_TEXT_TYPE = $str_PREVIEW_TEXT_TYPE = "text";
$res = false;
if ($COURSE_ID > 0) {
$course = new CCourse();
$linkedLessonId = CCourse::CourseGetLinkedLesson($COURSE_ID);
if ($oAccess->IsLessonAccessible($linkedLessonId, CLearnAccess::OP_LESSON_READ)) {
$res = $course->GetByID($COURSE_ID);
} else {
$APPLICATION->SetTitle(GetMessage('LEARNING_ACCESS_D'));
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_unilesson_admin.php?lang=" . LANG . '&PARENT_LESSON_ID=-1' . GetFilterParams("filter_"), "TITLE" => GetMessage("LEARNING_BACK_TO_ADMIN")));
$context = new CAdminContextMenu($aContext);
$context->Show();
CAdminMessage::ShowMessage(GetMessage("LEARNING_BAD_COURSE"));
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";
die;
}
}
if ($res === false || !$res->ExtractFields("str_")) {
$COURSE_ID = 0;
} else {
$str_SITE_ID = array();
示例6: str_replace
$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;
if ($arTest["NEXT_QUESTION_ON_ERROR"] == "N" && $arTest["PASSAGE_TYPE"] == 2) {
$arResult["REDIRECT_PAGE"] = str_replace("#PAGE_ID#", array_key_exists($arParams["PAGE_NUMBER_VARIABLE"], $_REQUEST) ? $arResult["NAV"]["PAGE_NUMBER"] - 1 : 1, $arResult["PAGE_TEMPLATE"]);
}
}
} elseif ($arQuestion["EMAIL_ANSWER"] == "Y") {
$rsLesson = CLearnLesson::GetList(array(), array("LESSON_ID" => $arQuestion['LESSON_ID'], "CHECK_PERMISSIONS" => "N"));
if ($arLesson = $rsLesson->GetNext()) {
$rsTeacher = CUser::GetByID($arLesson["CREATED_BY"]);
if ($arTeacher = $rsTeacher->GetNext()) {
$courseName = "";
$rsCourse = CCourse::GetByID($arTest["COURSE_ID"]);
if ($arCourse = $rsCourse->GetNext()) {
$courseName = $arCourse["NAME"];
}
$arEventFields = array("ID" => $testResultID, "ATTEMPT_ID" => $sessAttemptID, "TEST_NAME" => $arTest["NAME"], "COURSE_NAME" => $courseName, "USER" => "(" . $USER->GetLogin() . ")" . (strlen($USER->GetFullName()) > 0 ? " " . $USER->GetFullName() : ""), "DATE" => date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), time()), "QUESTION_TEXT" => $arQuestion["NAME"], "ANSWER_TEXT" => $_REQUEST["answer"], "EMAIL_FROM" => COption::GetOptionString("main", "email_from", "nobody@nobody.com"), "EMAIL_TO" => $arTeacher["EMAIL"], "MESSAGE_TITLE" => GetMessage("LEARNING_NEW_TEXT_ANSWER"));
$arrSITE = LANG;
CEvent::Send("NEW_LEARNING_TEXT_ANSWER", $arrSITE, $arEventFields, "N");
}
}
}
}
}
}
}
//If it was the last question, finish the attempt
if ($arTest["PASSAGE_TYPE"] < 2) {
示例7: CheckFields
function CheckFields(&$arFields, $ID = false)
{
global $DB;
$arMsg = array();
if ((is_set($arFields, "NAME") || $ID === false) && strlen($arFields["NAME"]) <= 0) {
$arMsg[] = array("id" => "NAME", "text" => GetMessage("LEARNING_BAD_NAME"));
}
if ($ID === false && !is_set($arFields, "COURSE_ID")) {
$arMsg[] = array("id" => "COURSE_ID", "text" => GetMessage("LEARNING_BAD_COURSE_ID"));
}
if (is_set($arFields, "COURSE_ID")) {
$r = CCourse::GetByID($arFields["COURSE_ID"]);
if (!$r->Fetch()) {
$arMsg[] = array("id" => "COURSE_ID", "text" => GetMessage("LEARNING_BAD_COURSE_ID_EX"));
}
}
if ($arFields["APPROVED"] == "Y" && is_set($arFields, "COMPLETED_SCORE") && (intval($arFields["COMPLETED_SCORE"]) <= 0 || intval($arFields["COMPLETED_SCORE"]) > 100)) {
$arMsg[] = array("id" => "COMPLETED_SCORE", "text" => GetMessage("LEARNING_BAD_COMPLETED_SCORE"));
}
if (is_set($arFields, "PREVIOUS_TEST_ID") && intval($arFields["PREVIOUS_TEST_ID"]) != 0) {
$r = CTest::GetByID($arFields["PREVIOUS_TEST_ID"]);
if (!$r->Fetch()) {
$arMsg[] = array("id" => "PREVIOUS_TEST_ID", "text" => GetMessage("LEARNING_BAD_PREVIOUS_TEST"));
}
}
if (is_set($arFields, "PREVIOUS_TEST_SCORE") && (intval($arFields["PREVIOUS_TEST_SCORE"]) <= 0 || intval($arFields["PREVIOUS_TEST_SCORE"]) > 100) && intval($arFields["PREVIOUS_TEST_ID"]) != 0) {
$arMsg[] = array("id" => "PREVIOUS_TEST_SCORE", "text" => GetMessage("LEARNING_BAD_COMPLETED_SCORE"));
}
if (!empty($arMsg)) {
$e = new CAdminException($arMsg);
$GLOBALS["APPLICATION"]->ThrowException($e);
return false;
}
//Defaults
if (is_set($arFields, "QUESTIONS_FROM") && !in_array($arFields["QUESTIONS_FROM"], array("A", "C", "L", "H", "S", 'R'))) {
$arFields["QUESTIONS_FROM"] = "A";
}
if (is_set($arFields, "QUESTIONS_AMOUNT") && intval($arFields["QUESTIONS_AMOUNT"]) <= 0) {
$arFields["QUESTIONS_AMOUNT"] = "0";
}
if (is_set($arFields, "QUESTIONS_FROM_ID") && intval($arFields["QUESTIONS_FROM_ID"]) <= 0) {
$arFields["QUESTIONS_FROM_ID"] = "0";
}
if (is_set($arFields, "ACTIVE") && $arFields["ACTIVE"] != "Y") {
$arFields["ACTIVE"] = "N";
}
if (is_set($arFields, "APPROVED") && $arFields["APPROVED"] != "Y") {
$arFields["APPROVED"] = "N";
}
if ($arFields["APPROVED"] == "N") {
$arFields["COMPLETED_SCORE"] = "";
}
if (is_set($arFields, "INCLUDE_SELF_TEST") && $arFields["INCLUDE_SELF_TEST"] != "Y") {
$arFields["INCLUDE_SELF_TEST"] = "N";
}
if (is_set($arFields, "RANDOM_QUESTIONS") && $arFields["RANDOM_QUESTIONS"] != "Y") {
$arFields["RANDOM_QUESTIONS"] = "N";
}
if (is_set($arFields, "RANDOM_ANSWERS") && $arFields["RANDOM_ANSWERS"] != "Y") {
$arFields["RANDOM_ANSWERS"] = "N";
}
if (is_set($arFields, "DESCRIPTION_TYPE") && $arFields["DESCRIPTION_TYPE"] != "html") {
$arFields["DESCRIPTION_TYPE"] = "text";
}
if (is_set($arFields, "PASSAGE_TYPE") && !in_array($arFields["PASSAGE_TYPE"], array("0", "1", "2"))) {
$arFields["PASSAGE_TYPE"] = "0";
}
if (is_set($arFields, "INCORRECT_CONTROL") && $arFields["INCORRECT_CONTROL"] != "Y") {
$arFields["INCORRECT_CONTROL"] = "N";
}
if (is_set($arFields, "SHOW_ERRORS") && $arFields["SHOW_ERRORS"] != "Y") {
$arFields["SHOW_ERRORS"] = "N";
$arFields["NEXT_QUESTION_ON_ERROR"] = "Y";
}
if (is_set($arFields, "NEXT_QUESTION_ON_ERROR") && $arFields["NEXT_QUESTION_ON_ERROR"] != "Y") {
$arFields["NEXT_QUESTION_ON_ERROR"] = "N";
}
return true;
}