当前位置: 首页>>代码示例>>PHP>>正文


PHP CCourse::CourseGetLinkedLesson方法代码示例

本文整理汇总了PHP中CCourse::CourseGetLinkedLesson方法的典型用法代码示例。如果您正苦于以下问题:PHP CCourse::CourseGetLinkedLesson方法的具体用法?PHP CCourse::CourseGetLinkedLesson怎么用?PHP CCourse::CourseGetLinkedLesson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCourse的用法示例。


在下文中一共展示了CCourse::CourseGetLinkedLesson方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: CanUserViewLessonAsPublic

 public static function CanUserViewLessonAsPublic($arParams)
 {
     // Parse options (user_id from $arParams will be automaticaly resolved)
     $options = self::ParseParamsWithUser($arParams, array('COURSE_ID' => array('type' => 'strictly_castable_to_integer', 'mandatory' => true), 'LESSON_ID' => array('type' => 'strictly_castable_to_integer', 'mandatory' => true)));
     // Is it course?
     $linkedLessonId = CCourse::CourseGetLinkedLesson($options['COURSE_ID']);
     if ($linkedLessonId === false) {
         return false;
     }
     // Access denied
     $lessonId = $options['LESSON_ID'];
     $breakOnLessonId = $linkedLessonId;
     // save resources
     // Is lesson included into given course?
     $isLessonChildOfCourse = false;
     $arOPathes = CLearnLesson::GetListOfParentPathes($lessonId, $breakOnLessonId);
     foreach ($arOPathes as $oPath) {
         $topLessonId = $oPath->GetTop();
         if ($topLessonId !== false && $topLessonId == $linkedLessonId) {
             $isLessonChildOfCourse = true;
             break;
         }
     }
     if (!$isLessonChildOfCourse) {
         return false;
     }
     // Access denied
     // Check permissions for course
     $isCourseAccessible = self::CanUserViewLessonContent(array('lesson_id' => $linkedLessonId));
     // Permissions for all lessons/chapters in public are equivalent to course permissions
     return $isCourseAccessible;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:32,代码来源:clearnaccessmacroses.php

示例2: LessonIdByCertId

 public static function LessonIdByCertId($certId)
 {
     $rc = CCertification::GetByID($certId);
     if ($rc === false) {
         throw new LearnException('', LearnException::EXC_ERR_ALL_GIVEUP);
     }
     $row = $rc->Fetch();
     if (!isset($row['COURSE_ID'])) {
         throw new LearnException('', LearnException::EXC_ERR_ALL_GIVEUP);
     }
     $lessonId = CCourse::CourseGetLinkedLesson($row['COURSE_ID']);
     if ($lessonId === false) {
         throw new LearnException('', LearnException::EXC_ERR_ALL_GIVEUP);
     }
     return $lessonId;
 }
开发者ID:Satariall,项目名称:izurit,代码行数:16,代码来源:certification.php

示例3: CLearnPath

     // Lesson is not given, so try get chapter_id
     if (isset($_REQUEST['CHAPTER_ID'])) {
         if (CLearnPath::IsUrlencodedPath($_REQUEST['CHAPTER_ID'])) {
             $LESSON_PATH = new CLearnPath();
             $LESSON_PATH->ImportUrlencoded($_REQUEST['CHAPTER_ID']);
             $lessonID = (int) $LESSON_PATH->GetBottom();
         } elseif (substr($_REQUEST['CHAPTER_ID'], 0, 1) === '0') {
             $lessonID = (int) substr($_REQUEST['CHAPTER_ID'], 1);
         } else {
             $lessonID = (int) CLearnLesson::LessonIdByChapterId($_REQUEST['CHAPTER_ID']);
         }
     }
 }
 $linkedLessonId = false;
 if ($arParams["COURSE_ID"] > 0) {
     $linkedLessonId = CCourse::CourseGetLinkedLesson($arParams["COURSE_ID"]);
 }
 if ($arParams["CHECK_PERMISSIONS"] !== 'N') {
     $isAccessible = false;
     try {
         if ($lessonID > 0) {
             $arPermissionsParams = array('COURSE_ID' => $arParams['COURSE_ID'], 'LESSON_ID' => $lessonID);
             $isAccessible = CLearnAccessMacroses::CanUserViewLessonAsPublic($arPermissionsParams, $allowAccessViaLearningGroups = false);
         } elseif ($linkedLessonId !== false) {
             $arPermissionsParams = array('lesson_id' => $linkedLessonId);
             $isAccessible = CLearnAccessMacroses::CanUserViewLessonContent($arPermissionsParams, $allowAccessViaLearningGroups = false);
         }
     } catch (Exception $e) {
         $isAccessible = false;
         // access denied
     }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:component.php

示例4: CourseBecomeLesson

 /**
  * WARNING: don't use this method, it's for internal use only
  * 
  * Convert course to non-course lesson (course will be removed,
  * but lesson will stay exists)
  * 
  * WARNING: this method terminates (by die()/exit()) current execution flow
  * when SQL server error occured. It's due to bug in CDatabase::Update() in main
  * module (version info:
  *    define("SM_VERSION","11.0.12");
  *    define("SM_VERSION_DATE","2012-02-21 17:00:00"); // YYYY-MM-DD HH:MI:SS
  * )
  *
  * @param int $courseId (returned by GetLinkedCourse($lessonId) )
  * 
  * @access private
  */
 protected static function CourseBecomeLesson($courseId)
 {
     global $DB;
     self::_EnsureArgsStrictlyCastableToIntegers($courseId);
     $linkedLessonId = CCourse::CourseGetLinkedLesson($courseId);
     if ($linkedLessonId === false) {
         return false;
     }
     // Check certificates (if exists => forbid removing course)
     $certificate = CCertification::GetList(array(), array("COURSE_ID" => $courseId, 'CHECK_PERMISSIONS' => 'N'));
     if ($certificate === false || $certificate->GetNext()) {
         return false;
     }
     // Remove tests
     $tests = CTest::GetList(array(), array("COURSE_ID" => $courseId));
     if ($tests === false) {
         return false;
     }
     while ($arTest = $tests->Fetch()) {
         if (!CTest::Delete($arTest["ID"])) {
             return false;
         }
     }
     // Remove all prohibitions for lessons in context of course to be removed
     // and remove prohibitions for course to be removed in context of all other courses
     self::PublishProhibitionPurge($linkedLessonId, self::PUBLISH_PROHIBITION_PURGE_ALL_LESSONS_IN_COURSE_CONTEXT | self::PUBLISH_PROHIBITION_PURGE_LESSON_IN_ALL_COURSE_CONTEXT);
     $rc = $DB->Query("DELETE FROM b_learn_course\n\t\t\tWHERE ID=" . (string) (int) $courseId, true);
     // reload cache of LINKED_LESSON_ID -> COURSE_ID
     self::GetCourseToLessonMap_ReloadCache();
     CLearnCacheOfLessonTreeComponent::MarkAsDirty();
     /**
      * This code will be useful after bug in CDatabase::Update()
      * and CDatabase::Insert() will be solved and $ignore_errors setted
      * to true in Insert()/Update() call above.
      */
     if ($rc === false) {
         throw new LearnException('EA_SQLERROR', LearnException::EXC_ERR_ALL_GIVEUP);
     }
     // If data not updated
     if ($rc === 0) {
         throw new LearnException('EA_OTHER: data not updated', LearnException::EXC_ERR_ALL_GIVEUP);
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:60,代码来源:clearnlesson.php

示例5: _MakeItems

 protected function _MakeItems($TITLE, $TYPE, $RES_ID, $PARENT_ID)
 {
     global $APPLICATION;
     if ($PARENT_ID === 0) {
         $linkToParentLessonId = CCourse::CourseGetLinkedLesson($this->COURSE_ID);
     } else {
         $linkToParentLessonId = (int) $PARENT_ID;
     }
     $createUnilesson = false;
     if ($TYPE == "LES") {
         $arFields = array('NAME' => $TITLE);
         $createUnilesson = true;
     } elseif ($TYPE == "CHA") {
         $arFields = array('NAME' => $TITLE);
         $createUnilesson = true;
     } elseif ($TYPE == "QUE") {
         $arFields = array("NAME" => $TITLE, "LESSON_ID" => $linkToParentLessonId);
         $cl = new CLQuestion();
     } elseif ($TYPE == "TES") {
         $arFields = array("NAME" => $TITLE, "COURSE_ID" => $this->COURSE_ID);
         $cl = new CTest();
     } elseif ($TYPE === 'TMK') {
         $arFields = array();
         $cl = new CLTestMark();
     } else {
         return $PARENT_ID;
     }
     $r = new CDataXML();
     if (!$r->Load($this->package_dir . "/" . strtolower($RES_ID) . ".xml")) {
         $r = false;
     }
     if ($r !== false) {
         if ($TYPE == "QUE") {
             if (($data = $r->SelectNodes("/questestinterop/item/presentation/")) && ($resp = $r->SelectNodes("/questestinterop/item/resprocessing/"))) {
                 $arQ = array();
                 $arData = $data->__toArray();
                 $arResp = $resp->__toArray();
                 if (is_set($arData["#"]["material"][0]["#"], "mattext")) {
                     $arQ["NAME"] = $arData["#"]["material"][0]["#"]["mattext"][0]["#"];
                 }
                 if (is_set($arData["#"]["material"][0]["#"], "matimage")) {
                     $imageDescription = '';
                     if (is_set($arData["#"]["material"][0]["#"], 'image_description')) {
                         $imageDescription = $arData["#"]["material"][0]["#"]['image_description'][0]['#'];
                     }
                     $arQ["FILE_ID"] = array("MODULE_ID" => "learning", "name" => basename($arData["#"]["material"][0]["#"]["matimage"][0]["@"]["uri"]), "tmp_name" => $this->package_dir . "/" . $arData["#"]["material"][0]["#"]["matimage"][0]["@"]["uri"], "size" => @filesize($this->package_dir . "/" . $arData["#"]["material"][0]["#"]["matimage"][0]["@"]["uri"]), "type" => $arData["#"]["material"][0]["#"]["matimage"][0]["@"]["imagtype"], 'description' => $imageDescription);
                 }
                 if (is_set($arData["#"]["response_lid"][0]["@"], "rcardinality")) {
                     switch ($arData["#"]["response_lid"][0]["@"]["rcardinality"]) {
                         case "Multiple":
                             $arQ["QUESTION_TYPE"] = 'M';
                             break;
                         case "Text":
                             $arQ["QUESTION_TYPE"] = 'T';
                             break;
                         case "Sort":
                             $arQ["QUESTION_TYPE"] = 'R';
                             break;
                         default:
                             $arQ["QUESTION_TYPE"] = 'S';
                             break;
                     }
                 }
                 if (is_set($arResp["#"]["respcondition"][0]["#"], "setvar")) {
                     $arQ["POINT"] = $arResp["#"]["respcondition"][0]["#"]["setvar"][0]['#'];
                 }
                 //Additional
                 if ($bx = $r->SelectNodes("/questestinterop/item/bitrix/")) {
                     $arQ = array_merge($arQ, $this->_MakeFields($bx->__toArray(), $TYPE));
                     unset($bx);
                 }
                 $arFields = array_merge($arFields, $arQ);
                 $cl = new CLQuestion();
                 $ID = $cl->Add($arFields);
                 if ($ID > 0) {
                     $PARENT_ID = $ID;
                     $arCorrect = array();
                     if (is_set($arResp["#"]["respcondition"][0]["#"], "conditionvar") && is_set($arResp["#"]["respcondition"][0]["#"]["conditionvar"][0]["#"], "varequal")) {
                         foreach ($arResp["#"]["respcondition"][0]["#"]["conditionvar"][0]["#"]["varequal"] as $ar) {
                             $arCorrect[] = $ar["#"];
                         }
                     }
                     if (is_set($arData["#"]["response_lid"][0]["#"], "render_choice") && is_set($arData["#"]["response_lid"][0]["#"]["render_choice"][0]["#"], "response_label")) {
                         $i = 0;
                         foreach ($arData["#"]["response_lid"][0]["#"]["render_choice"][0]["#"]["response_label"] as $ar) {
                             $i += 10;
                             $cl = new CLAnswer();
                             $arFields = array("QUESTION_ID" => $PARENT_ID, "SORT" => $i, "CORRECT" => in_array($ar["@"]["ident"], $arCorrect) ? "Y" : "N", "ANSWER" => $ar["#"]["material"][0]["#"]["mattext"][0]["#"]);
                             $AswerID = $cl->Add($arFields);
                             $res = $AswerID > 0;
                             if (!$res) {
                                 if ($e = $APPLICATION->GetException()) {
                                     $this->arWarnings[$TYPE][] = array("TITLE" => $TITLE, "TEXT" => $e->GetString());
                                 }
                             }
                         }
                     }
                 } else {
                     if ($e = $APPLICATION->GetException()) {
                         $this->arWarnings[$TYPE][] = array("TITLE" => $TITLE, "TEXT" => $e->GetString());
//.........这里部分代码省略.........
开发者ID:Satariall,项目名称:izurit,代码行数:101,代码来源:import.php

示例6: GetFilter

    public static function GetFilter($arFilter)
    {
        global $DBType;
        if (!is_array($arFilter)) {
            $arFilter = array();
        }
        $arSqlSearch = array();
        foreach ($arFilter as $key => $val) {
            $res = CLearnHelper::MkOperationFilter($key);
            $key = $res["FIELD"];
            $cOperationType = $res["OPERATION"];
            $key = strtoupper($key);
            switch ($key) {
                case "ID":
                case "SORT":
                case "LESSON_ID":
                case "POINT":
                    $arSqlSearch[] = CLearnHelper::FilterCreate("CQ." . $key, $val, "number", $bFullJoin, $cOperationType);
                    break;
                case "COURSE_ID":
                    // was:	$arSqlSearch[] = CLearnHelper::FilterCreate("C.".$key, $val, "number", $bFullJoin, $cOperationType);
                    $courseLessonId = CCourse::CourseGetLinkedLesson($val);
                    if ($courseLessonId === false) {
                        break;
                    }
                    // it is not a course, so skipping
                    if ($DBType === 'oracle') {
                        // This subquery gets ids of all childs lesson for given $courseLessonId
                        $subQuery = "\n\t\t\t\t\t\t\tSELECT TLE.TARGET_NODE\n\t\t\t\t\t\t\tFROM b_learn_lesson_edges TLE\n\t\t\t\t\t\t\tSTART WITH TLE.SOURCE_NODE=" . ($courseLessonId + 0) . "\n\t\t\t\t\t\t\tCONNECT BY NOCYCLE PRIOR TLE.TARGET_NODE = TLE.SOURCE_NODE";
                        // But we need also $courseLessonId itself, so final clause will be:
                        $arSqlSearch[] = '(CQ.LESSON_ID IN (' . $subQuery . ')
							OR CQ.LESSON_ID = ' . ($courseLessonId + 0) . ')';
                    } elseif ($DBType === 'mysql' || $DBType === 'mssql') {
                        // MySQL & MSSQL supports "WHERE IN(...)" clause for more than 10 000 elements
                        // add to sql "WHERE" constraint: lessons id only from given array
                        $sqlCourseLessonsIdsList = '';
                        $oTree = CLearnLesson::GetTree($courseLessonId);
                        $arChildLessonForCourse = $oTree->GetLessonsIdListInTree();
                        // root lesson not in tree, so add it
                        $arChildLessonForCourse[] = $courseLessonId;
                        // We need escape data for SQL
                        $arChildLessonForCourseEscaped = array_map('intval', $arChildLessonForCourse);
                        $sqlCourseLessonsIdsList = implode(', ', $arChildLessonForCourseEscaped);
                        if (strlen($sqlCourseLessonsIdsList) > 0) {
                            $arSqlSearch[] = 'CQ.LESSON_ID IN (' . $sqlCourseLessonsIdsList . ')';
                        }
                    } else {
                        throw new LearnException('Unsupported DB engine: ' . $DBType, LearnException::EXC_ERR_ALL_GIVEUP);
                    }
                    break;
                case "NAME":
                    $arSqlSearch[] = CLearnHelper::FilterCreate("CQ." . $key, $val, "string", $bFullJoin, $cOperationType);
                    break;
                case "QUESTION_TYPE":
                case "ACTIVE":
                case "SELF":
                case "CORRECT_REQUIRED":
                    $arSqlSearch[] = CLearnHelper::FilterCreate("CQ." . $key, $val, "string_equal", $bFullJoin, $cOperationType);
                    break;
            }
        }
        return $arSqlSearch;
    }
开发者ID:andy-profi,项目名称:bxApiDocs,代码行数:63,代码来源:question.php

示例7: _CreateAttemptQuestions

 protected static function _CreateAttemptQuestions($arCallbackSqlFormer, $ATTEMPT_ID)
 {
     global $APPLICATION, $DB, $DBType;
     $ATTEMPT_ID = intval($ATTEMPT_ID);
     $attempt = CTestAttempt::GetByID($ATTEMPT_ID);
     if (!($arAttempt = $attempt->Fetch())) {
         $APPLICATION->ThrowException(GetMessage("LEARNING_BAD_ATTEMPT_ID_EX"), "ERROR_NO_ATTEMPT_ID");
         return false;
     }
     $test = CTest::GetByID($arAttempt["TEST_ID"]);
     if (!($arTest = $test->Fetch())) {
         $APPLICATION->ThrowException(GetMessage("LEARNING_BAD_TEST_ID_EX"), "ERROR_NO_TEST_ID");
         return false;
     }
     $strSql = "DELETE FROM b_learn_test_result WHERE ATTEMPT_ID = " . $ATTEMPT_ID;
     if (!$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__)) {
         return false;
     }
     /**
      * QUESTIONS_FROM values:
      * 'L' - X questions from every lesson in course
      * 'C' - X questions from every lesson from every chapter in the course
      *       In this case questions taken from immediate lessons of all chapters (X per chapter) in the course.
      *       In new data model it means, get X questions from every lesson in the course, except
      *       1) immediate lessons-childs of the course and
      *       2) lessons, contains other lessons (because, in old data model chapters doesn't contains questions)
      * 
      * 'H' - all questions from the selected chapter (recursive) in the course 
      *       This case must be ignored, because converter to new data model updates 'H' to 'R', but in case
      *       when chapter is not exists updates didn't become. So QUESTIONS_FROM stayed in 'H' value. And it means,
      *       that there is no chapter exists with QUESTIONS_FROM_ID, so we can't do work. And we should just
      *       ignore, for backward compatibility (so, don't throw an error).
      * 'S' - all questions from the selected lesson (unilesson_id in QUESTIONS_FROM_ID)
      * 'A' - all questions of the course (nothing interesting in QUESTIONS_FROM_ID)
      * 
      * new values:
      * 'R' - all questions from the tree with root at selected lesson (include questions of selected lesson) 
      *       in the course (unilesson_id in QUESTIONS_FROM_ID)
      */
     if ($arTest["QUESTIONS_FROM"] == "C" || $arTest["QUESTIONS_FROM"] == "L") {
         $courseId = $arTest['COURSE_ID'] + 0;
         $courseLessonId = CCourse::CourseGetLinkedLesson($courseId);
         if ($courseLessonId === false) {
             $APPLICATION->ThrowException(GetMessage("LEARNING_BAD_TEST_IS_EMPTY"), "ERROR_TEST_IS_EMPTY");
             return false;
         }
         $clauseAllChildsLessons = CLearnHelper::SQLClauseForAllSubLessons($courseLessonId);
         if ($arTest["QUESTIONS_FROM"] == "C") {
             $strSql = "SELECT Q.ID as QUESTION_ID, TLEUP.SOURCE_NODE as FROM_ID\n\t\t\t\tFROM b_learn_lesson L\n\t\t\t\tINNER JOIN b_learn_question Q ON L.ID = Q.LESSON_ID\n\t\t\t\tINNER JOIN b_learn_lesson_edges TLEUP ON L.ID = TLEUP.TARGET_NODE\n\t\t\t\tLEFT OUTER JOIN b_learn_lesson_edges TLEDOWN ON L.ID = TLEDOWN.SOURCE_NODE " . "WHERE L.ID IN (" . $clauseAllChildsLessons . ") \n" . " AND TLEDOWN.SOURCE_NODE IS NULL \n" . " AND TLEUP.SOURCE_NODE IN (" . $clauseAllChildsLessons . ") \n" . " AND Q.ACTIVE = 'Y' " . ($arTest["INCLUDE_SELF_TEST"] != "Y" ? "AND Q.SELF = 'N' " : "") . "ORDER BY " . ($arTest["RANDOM_QUESTIONS"] == "Y" ? CTest::GetRandFunction() : "L.SORT, Q.SORT");
         } else {
             $strSql = "SELECT Q.ID as QUESTION_ID, L.ID as FROM_ID " . "FROM b_learn_lesson L " . "INNER JOIN b_learn_question Q ON L.ID = Q.LESSON_ID " . "WHERE L.ID IN (" . $clauseAllChildsLessons . ") AND Q.ACTIVE = 'Y' " . ($arTest["INCLUDE_SELF_TEST"] != "Y" ? "AND Q.SELF = 'N' " : "") . "ORDER BY " . ($arTest["RANDOM_QUESTIONS"] == "Y" ? CTest::GetRandFunction() : "L.SORT, Q.SORT");
         }
         if (!($res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__))) {
             return false;
         }
         $Values = array();
         $tmp = array();
         while ($arRecord = $res->Fetch()) {
             if (is_set($tmp, $arRecord["FROM_ID"])) {
                 if ($tmp[$arRecord["FROM_ID"]] < $arTest["QUESTIONS_AMOUNT"]) {
                     $tmp[$arRecord["FROM_ID"]]++;
                 } else {
                     continue;
                 }
             } else {
                 $tmp[$arRecord["FROM_ID"]] = 1;
             }
             $Values[] = $arRecord["QUESTION_ID"];
         }
         if (empty($Values)) {
             $APPLICATION->ThrowException(GetMessage("LEARNING_BAD_TEST_IS_EMPTY"), "ERROR_TEST_IS_EMPTY");
             return false;
         }
         $DB->StartTransaction();
         foreach ($Values as $ID) {
             $strSql = "INSERT INTO b_learn_test_result (ATTEMPT_ID, QUESTION_ID) VALUES (" . $ATTEMPT_ID . "," . $ID . ")";
             if (!$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__)) {
                 $DB->Rollback();
                 return false;
             }
         }
         $DB->Commit();
     } elseif (($arTest["QUESTIONS_FROM"] == "H" || $arTest["QUESTIONS_FROM"] == "S" || $arTest["QUESTIONS_FROM"] == "R") && $arTest["QUESTIONS_FROM_ID"]) {
         $WHERE = '';
         if ($arTest["QUESTIONS_FROM"] == "H") {
             /**
              * 'H' - all questions from the selected chapter (recursive) in the course 
              *       This case must be ignored, because converter to new data model updates 'H' to 'R', but in case
              *       when chapter is not exists updates didn't become. So QUESTIONS_FROM stayed in 'H' value. And it means,
              *       that there is no chapter exists with QUESTIONS_FROM_ID, so we can't do work. And we should just
              *       ignore, for backward compatibility (so, don't throw an error).
              */
             $APPLICATION->ThrowException(GetMessage("LEARNING_BAD_TEST_IS_EMPTY"), "ERROR_TEST_IS_EMPTY");
             return false;
         } elseif ($arTest["QUESTIONS_FROM"] == 'R') {
             $clauseAllChildsLessons = CLearnHelper::SQLClauseForAllSubLessons($arTest['QUESTIONS_FROM_ID']);
             $WHERE = " (L.ID IN(" . $clauseAllChildsLessons . ") OR (L.ID = " . ($arTest['QUESTIONS_FROM_ID'] + 0) . ")) ";
         } elseif ($arTest["QUESTIONS_FROM"] == 'S') {
             $clauseAllChildsLessons = $arTest["QUESTIONS_FROM_ID"] + 0;
             $WHERE = " (L.ID IN(" . $clauseAllChildsLessons . ") OR (L.ID = " . ($arTest['QUESTIONS_FROM_ID'] + 0) . ")) ";
//.........这里部分代码省略.........
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:101,代码来源:attempt.php

示例8: GetPermission

 /**
  * <p>Возвращает право доступа к учебному курсу с идентификатором <i>courseId</i> для текущего пользователя.</p>
  *
  *
  *
  *
  * @param int $courseId  Идентификатор курса. <br><br> До версии 12.0.0 параметр назывался COURSE_ID.
  *
  *
  *
  * @return string <p>Символ права доступа: "D" - запрещён, "R" - чтение, "W" - изменение, "X" -
  * полный доступ (изменение + право изменять права доступа). </p>
  *
  *
  * <h4>Example</h4> 
  * <pre>
  * &lt;?
  * $permission = CCourse::GetPermission($id);
  * if ($permission&lt;"X")
  *     return false;
  * ?&gt;
  * </pre>
  *
  *
  *
  * <h4>See Also</h4> 
  * <ul> <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/setpermission.php">SetPermission</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/getgrouppermissions.php">GetGroupPermissions</a> </li>
  * </ul><a name="examples"></a>
  *
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/learning/classes/ccourse/getpermission.php
  * @author Bitrix
  */
 public static function GetPermission($courseId)
 {
     global $USER;
     static $accessMatrix = false;
     $courseId = (int) $courseId;
     if (!($courseId > 0)) {
         return 'D';
     }
     // access denied
     $linkedLessonId = CCourse::CourseGetLinkedLesson($courseId);
     if (!($linkedLessonId > 0)) {
         return 'D';
     }
     // some troubles, access denied
     $oAccess = CLearnAccess::GetInstance($USER->GetID());
     if ($accessMatrix === false) {
         $accessMatrix = array('X' => CLearnAccess::OP_LESSON_READ | CLearnAccess::OP_LESSON_CREATE | CLearnAccess::OP_LESSON_WRITE | CLearnAccess::OP_LESSON_REMOVE | CLearnAccess::OP_LESSON_LINK_TO_PARENTS | CLearnAccess::OP_LESSON_UNLINK_FROM_PARENTS | CLearnAccess::OP_LESSON_LINK_DESCENDANTS | CLearnAccess::OP_LESSON_UNLINK_DESCENDANTS | CLearnAccess::OP_LESSON_MANAGE_RIGHTS, 'W' => CLearnAccess::OP_LESSON_READ | CLearnAccess::OP_LESSON_CREATE | CLearnAccess::OP_LESSON_WRITE | CLearnAccess::OP_LESSON_REMOVE, 'R' => CLearnAccess::OP_LESSON_READ);
     }
     foreach ($accessMatrix as $oldAccessSymbol => $operations) {
         if ($oAccess->IsBaseAccess($operations) || $oAccess->IsLessonAccessible($linkedLessonId, $operations)) {
             return $oldAccessSymbol;
         }
     }
     // by default, access denied
     return 'D';
 }
开发者ID:rasuldev,项目名称:torino,代码行数:63,代码来源:course.php

示例9: IncludeModuleLangFile

        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;
}
$isReadOnly = true;
try {
    if ($oAccess->IsLessonAccessible($linkedLessonId, CLearnAccess::OP_LESSON_WRITE)) {
        $isReadOnly = false;
开发者ID:Satariall,项目名称:izurit,代码行数:31,代码来源:learn_test_admin.php

示例10: _MakeItems

 protected function _MakeItems($TITLE, $TYPE, $LAUNCH, $PARENT_ID)
 {
     global $APPLICATION;
     if ($PARENT_ID === 0) {
         $linkToParentLessonId = CCourse::CourseGetLinkedLesson($this->COURSE_ID);
     } else {
         $linkToParentLessonId = (int) $PARENT_ID;
     }
     if ($TYPE == "LES") {
         $arFields = array('NAME' => $TITLE, 'LAUNCH' => $LAUNCH, 'DETAIL_TEXT_TYPE' => "file");
     } elseif ($TYPE == "CHA") {
         $arFields = array('NAME' => $TITLE);
     } else {
         return $PARENT_ID;
     }
     // properties (in context of parent) by default
     $arProperties = array('SORT' => 500);
     $ID = CLearnLesson::Add($arFields, false, $linkToParentLessonId, $arProperties);
     if ($ID > 0) {
         return $ID;
     } else {
         if ($e = $APPLICATION->GetException()) {
             $this->arWarnings[$TYPE][] = array("TITLE" => $TITLE, "TEXT" => $e->GetString());
         }
     }
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:26,代码来源:scorm.php

示例11: serialize

    $arParams['LESSON_PATH'] = '';
    if (isset($_REQUEST['LESSON_PATH']) && strlen($_REQUEST['LESSON_PATH'])) {
        $arParams['LESSON_PATH'] = $_REQUEST['LESSON_PATH'];
    }
}
$strUrlencodedLessonPath = '';
if (strlen($arParams['LESSON_PATH']) > 0) {
    $strUrlencodedLessonPath = 'LESSON_PATH=' . $arParams['LESSON_PATH'];
}
$ratingTransistor = '';
if ($arParams['LESSON_ID'] > 0) {
    $arRatingData = CRatings::GetRatingVoteResult('LEARN_LESSON', $arParams['LESSON_ID']);
    $ratingTransistor = serialize($arRatingData);
}
$delayed = false;
$courseLessonId = CCourse::CourseGetLinkedLesson($arParams['COURSE_ID']);
if (CLearnParsePermissionsFromFilter::isRegisteredAsAvailableCourse($courseLessonId)) {
    $arGroupsPeriods = CLearnAccessMacroses::getActiveLearningGroupsPeriod($courseLessonId, $USER->getId());
    if ($arGroupsPeriods['IS_EXISTS']) {
        $arResult['LEARNING_GROUP_ACTIVE_FROM'] = $arGroupsPeriods['ACTIVE_FROM'];
        $arResult['LEARNING_GROUP_ACTIVE_TO'] = $arGroupsPeriods['ACTIVE_TO'];
        $activeFromMap = CLearnAccessMacroses::getActiveLearningChaptersPeriod($courseLessonId, $USER->getId());
        if ($activeFromMap !== false) {
            $arResult['LEARNING_GROUP_CHAPTERS_ACTIVE_FROM'] = $activeFromMap;
        }
        $oPath = new CLearnPath();
        $oPath->ImportUrlencoded($arParams['LESSON_PATH']);
        $arPath = $oPath->GetPathAsArray();
        if (count($arPath) >= 2) {
            $secondLevelLesson = $arPath[1];
            if (isset($arResult['LEARNING_GROUP_CHAPTERS_ACTIVE_FROM'][$secondLevelLesson])) {
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:component.php

示例12: array

            // 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"));
    if ($arResult["QUESTION"]["ID"]) {
        array_unshift($arAreaButtons, array("TEXT" => GetMessage("LEARNING_COURSES_QUESTION_EDIT"), "TITLE" => GetMessage("LEARNING_COURSES_QUESTION_EDIT"), "URL" => 'javascript:' . $APPLICATION->GetPopupLink(array("URL" => "/bitrix/admin/learn_question_edit.php?lang=" . LANGUAGE_ID . "&ID=" . $arResult["QUESTION"]["ID"] . "&COURSE_ID=" . $arResult["TEST"]["COURSE_ID"] . "&LESSON_ID=" . $arResult["QUESTION"]["LESSON_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-question"));
    }
    $this->AddIncludeAreaIcons($arAreaButtons);
}
$this->IncludeComponentTemplate();
开发者ID:Satariall,项目名称:izurit,代码行数:31,代码来源:component.php

示例13: array

    if ($contextLessonId > 0) {
        if (CLearnAccessMacroses::CanUserAddLessonToParentLesson(array('parent_lesson_id' => $contextLessonId))) {
            $arMenuButtons[] = array("TEXT" => GetMessage("LEARNING_COURSES_LESSON_ADD"), "TITLE" => GetMessage("LEARNING_COURSES_LESSON_ADD"), "URL" => 'javascript:' . $APPLICATION->GetPopupLink(array("URL" => "/bitrix/admin/learn_unilesson_edit.php?lang=" . LANGUAGE_ID . "&PARENT_LESSON_ID=" . $contextLessonId . "&bxpublic=Y&from_module=learning&return_url=" . urlencode($addReturnUrl["lesson"]), "PARAMS" => array("width" => 700, 'height' => 500, 'resize' => false))), "ICON" => "bx-context-toolbar-create-icon", "ID" => "bx-context-toolbar-create-lesson");
            $arMenuButtons[] = array("TEXT" => GetMessage("LEARNING_COURSES_CHAPTER_ADD"), "TITLE" => GetMessage("LEARNING_COURSES_CHAPTER_ADD"), "URL" => 'javascript:' . $APPLICATION->GetPopupLink(array("URL" => "/bitrix/admin/learn_unilesson_edit.php?lang=" . LANGUAGE_ID . "&PARENT_LESSON_ID=" . $contextLessonId . "&bxpublic=Y&from_module=learning&return_url=" . urlencode($addReturnUrl["lesson"]), "PARAMS" => array("width" => 700, 'height' => 500, 'resize' => false))), "ICON" => "bx-context-toolbar-create-icon", "ID" => "bx-context-toolbar-create-chapter");
        }
        if (CLearnAccessMacroses::CanUserEditLesson(array('lesson_id' => $contextLessonId))) {
            $arMenuButtons[] = array("TEXT" => GetMessage("LEARNING_COURSES_TEST_ADD"), "TITLE" => GetMessage("LEARNING_COURSES_TEST_ADD"), "URL" => 'javascript:' . $APPLICATION->GetPopupLink(array("URL" => "/bitrix/admin/learn_test_edit.php?lang=" . LANGUAGE_ID . "&COURSE_ID=" . $arParams["COURSE_ID"] . "&bxpublic=Y&from_module=learning&return_url=" . urlencode($addReturnUrl["test"]), "PARAMS" => array("width" => 700, 'height' => 500, 'resize' => false))), "ICON" => "bx-context-toolbar-create-icon", "ID" => "bx-context-toolbar-create-test");
        }
        if (CLearnAccessMacroses::CanUserAddLessonWithoutParentLesson()) {
            $arMenuButtons[] = array("TEXT" => GetMessage("LEARNING_COURSES_COURSE_ADD"), "TITLE" => GetMessage("LEARNING_COURSES_COURSE_ADD"), "URL" => 'javascript:' . $APPLICATION->GetPopupLink(array("URL" => "/bitrix/admin/learn_course_edit.php?lang=" . LANGUAGE_ID . "&bxpublic=Y&from_module=learning&return_url=" . urlencode($addReturnUrl["course"]), "PARAMS" => array("width" => 700, 'height' => 500, 'resize' => false))), "ICON" => "bx-context-toolbar-create-icon", "ID" => "bx-context-toolbar-create-course");
        }
        if (count($arMenuButtons) > 0) {
            $arMenuButtons[] = array("SEPARATOR" => "Y");
        }
        if (CLearnAccessMacroses::CanUserEditLesson(array('lesson_id' => $contextLessonId))) {
            $arMenuButtons[] = array("TEXT" => GetMessage("LEARNING_COURSES_QUEST_S_ADD"), "TITLE" => GetMessage("LEARNING_COURSES_QUEST_S_ADD"), "URL" => 'javascript:' . $APPLICATION->GetPopupLink(array("URL" => "/bitrix/admin/learn_question_edit.php?lang=" . LANGUAGE_ID . "&COURSE_ID=" . $arParams["COURSE_ID"] . "&LESSON_PATH=" . ($lessonID > 0 ? $lessonID : CCourse::CourseGetLinkedLesson($arParams["COURSE_ID"])) . "&QUESTION_TYPE=S&bxpublic=Y&from_module=learning", "PARAMS" => array("width" => 700, 'height' => 500, 'resize' => false))), "ICON" => "bx-context-toolbar-create-icon", "ID" => "bx-context-toolbar-create-question-s");
            $arMenuButtons[] = array("TEXT" => GetMessage("LEARNING_COURSES_QUEST_M_ADD"), "TITLE" => GetMessage("LEARNING_COURSES_QUEST_M_ADD"), "URL" => 'javascript:' . $APPLICATION->GetPopupLink(array("URL" => "/bitrix/admin/learn_question_edit.php?lang=" . LANGUAGE_ID . "&COURSE_ID=" . $arParams["COURSE_ID"] . "&LESSON_PATH=" . ($lessonID > 0 ? $lessonID : CCourse::CourseGetLinkedLesson($arParams["COURSE_ID"])) . "&QUESTION_TYPE=M&bxpublic=Y&from_module=learning", "PARAMS" => array("width" => 700, 'height' => 500, 'resize' => false))), "ICON" => "bx-context-toolbar-create-icon", "ID" => "bx-context-toolbar-create-question-m");
            $arMenuButtons[] = array("TEXT" => GetMessage("LEARNING_COURSES_QUEST_R_ADD"), "TITLE" => GetMessage("LEARNING_COURSES_QUEST_R_ADD"), "URL" => 'javascript:' . $APPLICATION->GetPopupLink(array("URL" => "/bitrix/admin/learn_question_edit.php?lang=" . LANGUAGE_ID . "&COURSE_ID=" . $arParams["COURSE_ID"] . "&LESSON_PATH=" . ($lessonID > 0 ? $lessonID : CCourse::CourseGetLinkedLesson($arParams["COURSE_ID"])) . "&QUESTION_TYPE=R&bxpublic=Y&from_module=learning", "PARAMS" => array("width" => 700, 'height' => 500, 'resize' => false))), "ICON" => "bx-context-toolbar-create-icon", "ID" => "bx-context-toolbar-create-question-s");
            $arMenuButtons[] = array("TEXT" => GetMessage("LEARNING_COURSES_QUEST_T_ADD"), "TITLE" => GetMessage("LEARNING_COURSES_QUEST_T_ADD"), "URL" => 'javascript:' . $APPLICATION->GetPopupLink(array("URL" => "/bitrix/admin/learn_question_edit.php?lang=" . LANGUAGE_ID . "&COURSE_ID=" . $arParams["COURSE_ID"] . "&LESSON_PATH=" . ($lessonID > 0 ? $lessonID : CCourse::CourseGetLinkedLesson($arParams["COURSE_ID"])) . "&QUESTION_TYPE=T&bxpublic=Y&from_module=learning", "PARAMS" => array("width" => 700, 'height' => 500, 'resize' => false))), "ICON" => "bx-context-toolbar-create-icon", "ID" => "bx-context-toolbar-create-question-m");
        }
    }
    if (count($arMenuButtons) > 0) {
        $arAreaButtons = array(array("TEXT" => GetMessage("MAIN_ADD"), "TITLE" => GetMessage("MAIN_ADD"), "ICON" => "bx-context-toolbar-create-icon", "ID" => "bx-context-toolbar-learning-create", "MENU" => $arMenuButtons));
        $this->AddIncludeAreaIcons($arAreaButtons);
    }
} catch (LearnException $e) {
    ShowError(GetMessage('LEARNING_COURSE_DENIED'));
    return;
    exit;
}
$this->IncludeComponentTemplate($componentPage);
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:31,代码来源:component.php


注:本文中的CCourse::CourseGetLinkedLesson方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。