Documentation

CLesson::GetList

CDBResult
CLesson::GetList(
 array arOrder = Array("TIMESTAMP_X"=>"DESC"),
 array arFilter = Array()
);

The GetList method returns the list of lessons filtered by arFilter and sorted in the arOrder order. The current user access permissions are considered.

Parameters

ParameterDescription
arOrder An array in the format array("filter field"=>"sort order" [, ...]). The sorting field can have the following values:
  • ID - the lesson ID;
  • NAME - the lesson name;
  • ACTIVE - active state flag;
  • SORT - sort index;
  • TIMESTAMP_X - the date when the lesson was modified;
  • CREATED_BY - the ID of the user who has created the lesson;
  • CHAPTER_NAME - chapter name;
  • DATE_CREATE - the date when the lesson was created.
Sort order can be one of the following:
  • asc - ascending;
  • desc - descending;

    Optional. The default value is descending.
arFilter An array in the format array("filtered field"=>"filter value" [, ...]). The following values are possible:
  • ID - the lesson ID;
  • NAME - the lesson name (wildcards allowed: [%_]);
  • SORT - sort index;
  • ACTIVE - active state flag (Y/N);
  • TIMESTAMP_X - the date when the lesson was modified;
  • DATE_CREATE - the date when the lesson was created;
  • CHAPTER_ID - the chapter ID. To obtain a list of parent chapters, set this item to an empty string;
  • COURSE_ID - the course ID;
  • CREATED_BY - the ID of the user who has created the lesson;
  • DETAIL_TEXT - detailed description (wildcards allowed: [%_]);
  • PREVIEW_TEXT - short lesson description (wildcards allowed [%_]);
  • MIN_PERMISSION - minimum access permission level. "R" by default. See CCourse::SetPermission for available access permissions;
  • CHECK_PERMISSIONS - specifies that the access permissions are to be checked. If set to "N", the check is not performed.
The following logic can be specified at the beginning of the field name:
  • "!" - not equal;
  • "<" - less than;
  • "<=" - less or equal;
  • ">" - more than;
  • ">=" - more or equal.
"filter values"  is a single value or an array.

Optional. By default, records are not filtered.

Return Values

The method returns an instance of the CDBResult object.

See Also

  • CDBResult
  • CLesson::GetByID
  • Lesson fields

    Example

    
    <?
    if (CModule::IncludeModule("learning"))
    {
        $COURSE_ID = 8;
        $res = CLesson::GetList(
            Array("SORT"=>"ASC"), 
            Array("ACTIVE" => "Y", "COURSE_ID" => $COURSE_ID)
        );
    
        while ($arLesson = $res->GetNext())
        {
            echo "Lesson name: ".$arLesson["NAME"]."<br>";
        }
    }
    ?>

    
    <?
    
    if (CModule::IncludeModule("learning"))
    {
        $res = CLesson::GetList(
            Array("SORT"=>"ASC"), 
            Array("?NAME" => "Site")
        );
    
        while ($arLesson = $res->GetNext())
        {
            echo "Lesson name: ".$arLesson["NAME"]."<br>";
        }
    }
    ?>

    
    <?
    
    if (CModule::IncludeModule("learning"))
    {
        $COURSE_ID = 8;
    
        $res = CLesson::GetList(
            Array("NAME" => "ASC", "SORT"=>"ASC"), 
            Array("CHECK_PERMISSIONS" => "N", "COURSE_ID" => $COURSE_ID)
        );
    
        while ($arLesson = $res->GetNext())
        {
            echo "Lesson name: ".$arLesson["NAME"]."<br>";
        }
    }
    ?>

    
    <?
    
    if (CModule::IncludeModule("learning"))
    {
        $COURSE_ID = 8;
    
        $res = CLesson::GetList(
            Array("NAME" => "ASC", "SORT"=>"ASC"), 
            Array("CHECK_PERMISSIONS" => "N", "CHAPTER_ID" => "", "COURSE_ID" => $COURSE_ID)
        );
    
        while ($arLesson = $res->GetNext())
        {
            echo "Lesson name: ".$arLesson["NAME"]."<br>";
        }
    }
    ?>
  • © «Bitrix24», 2001-2024
    Up