Documentation

CLQuestion::GetList

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

The GetList method returns the list of questions filtered by arFilter and sorted in the arOrder order.

Parameters

ParameterDescription
arOrder An array in the format array("filter field"=>"sort order" [, ...]). The sorting field can have the following values:
  • ID - the question ID;
  • NAME - the question name;
  • ACTIVE - active state flag;
  • SORT - sort index;
  • SELF - self-check question;
  • POINT - score;
  • TYPE - the type of the question;
  • TIMESTAMP_X - the date when the question was modified.
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 question ID;
  • NAME - the question name (wildcards allowed [%_]);
  • SORT - sort index;
  • ACTIVE - active state flag (Y|N);
  • LESSON_ID - the lesson ID;
  • POINT - the score;
  • COURSE_ID - the course ID;
  • QUESTION_TYPE - the question type (S - single choice, M - multiple choice);
  • SELF - defines whether the self-check question.
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
  • CLQuestion::GetByID
  • Question fields

    Example

    
    <?
    
    if (CModule::IncludeModule("learning"))
    {
        $LESSON_ID = 426;
    
        $res = CLQuestion::GetList(
            Array("TIMESTAMP_X" => "ASC", "SORT"=>"ASC"), 
            Array("LESSON_ID" => $LESSON_ID)
        );
    
        while ($arQuestion = $res->GetNext())
        {
            echo "Question name: ".$arQuestion["NAME"]."<br>";
        }
    }
    ?>

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

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

    
    <?
    
    if (CModule::IncludeModule("learning"))
    {
        $COURSE_ID = 97;
    
        $res = CLQuestion::GetList(
            Array("NAME" => "ASC", "SORT"=>"ASC"), 
            Array("COURSE_ID" => $COURSE_ID, "!SELF" => "Y")
        );
    
        while ($arQuestion = $res->GetNext())
        {
            echo "Question name: ".$arQuestion["NAME"]."<br>";
        }
    }
    ?>
  • © «Bitrix24», 2001-2024