Documentation

CCourse::GetCourseContent

CDBResult
CCourse::GetCourseContent(
 int COURSE_ID,
 array arAddSelectFileds = Array("DETAIL_TEXT", "DETAIL_TEXT_TYPE", "DETAIL_PICTURE")
);

The GetCourseContent method returns a list of active chapters and lessons sorted in the ascending order.

Remarks

Fields in the returned list have the same names as the course's chapters and lessons. The required fields are:
  • ID - the lesson or chapter ID;
  • NAME - the lesson or chapter name;
  • CHAPTER_ID - the parent chapter ID; 
  • SORT - sort index;
  • DEPTH_LEVEL - required nesting level; 
  • TYPE - type of the required object ("LE" - lesson, "CH" - chapter).

To obtain other fields, use the arAddSelectFileds array. The method returns the course tree. If "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "DETAIL_PICTURE" are not used, you are recommended to pass an empty arAddSelectFileds (arAddSelectFileds = Array()).

Parameters

ParameterDescription
COURSE_ID The course ID.
arAddSelectFileds An array of additional fields. Possible fields are:
  • PREVIEW_TEXT - short course description;
  • PREVIEW_TEXT_TYPE - format of the short course description (text/html);
  • PREVIEW_PICTURE - the picture ID in the preview image table;
  • DETAIL_TEXT_TYPE - format of the detailed description (text/html);
  • DETAIL_PICTURE - the picture ID in the detail view image table;
  • DETAIL_TEXT - detailed description.

By default, the following array is passed:

arAddSelectFileds = 
    Array("DETAIL_TEXT", 
          "DETAIL_TEXT_TYPE", 
          "DETAIL_PICTURE")

Return Values

The method returns an instance of the CDBResult object.

See Also

  • Lesson fields
  • Chapter fields
  • CDBResult
    CLesson::GetList
    CChapter::GetList
    CChapter::GetTreeList

    Example

    
    <?
    if (CModule::IncludeModule("learning"))
    {
        $res = CCourse::GetCourseContent($COURSE_ID = 105, Array());
    
        while ($arContent = $res->GetNext())
        {
            echo str_repeat("&nbsp;&nbsp;&nbsp;&nbsp;", $arContent["DEPTH_LEVEL"]);
            echo ($arContent["TYPE"]=="CH" ? "+": "-").$arContent["NAME"]."<br>";
        }
    
        /*
        The above example will output something similar to:
    
        +Chapter 1
          +Chapter 1.1
            -Lesson 1.1.1
          +Chapter 1.2
        +Chapter 2
          -Lesson 2
        +Chapter 3
          +Chapter 3.1
            -Lesson 3.1.1
            -Lesson 3.1.2
            +Chapter 3.1.1
        */
    }
    ?>
  • © «Bitrix24», 2001-2024