Bitrix Site Manager

CLAnswer::GetList

CDBResult
CLAnswer::GetList(
 array arOrder = Array("ID"=>"DESC"),
 array arFilter = Array()
);

The GetList method returns a selection of answers 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 answer UD;
  • SORT - sort index;
  • CORRECT - whether the answer is correct or not;
  • ANSWER - answer text;
  • RAND - random order.
Sort order can be one of the following:
  • asc - ascending;
  • desc - descending;

    Optional. The default is descending.
arFilter An array in the format array("filtered field"=>"filter value" [, ...]). The following values are possible:
  • ID - the answer ID;
  • SORT - sort index;
  • QUESTION_ID - the question ID;
  • ANSWER - answer text (wildcards allowed: [%_]);
  • CORRECT - whether the answer is correct or not (Y|N);
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
  • CLAnswer::GetByID
  • Answer fields
  • Example

    
    <?
    if (CModule::IncludeModule("learning"))
    {
        $QUESTION_ID = 290;
        $res = CLAnswer::GetList(
            Array("SORT"=>"DESC"), 
            Array("QUESTION_ID" => $QUESTION_ID)
        );
    
        while ($arAnswer = $res->GetNext())
        {
            echo "Answer name: ".$arAnswer["ANSWER"]."<br>";
        }
    }
    ?>

    
    <?
    
    if (CModule::IncludeModule("learning"))
    {
        $QUESTION_ID = 290;
    
        $res = CLAnswer::GetList(
            Array("SORT"=>"ASC"), 
            Array("QUESTION_ID" => $QUESTION_ID, "?ANSWER" => "sys")
        );
    
        while ($arAnswer = $res->GetNext())
        {
            echo "Answer name: ".$arAnswer["ANSWER"]."<br>";
        }
    }
    ?>

    
    <?
    
    if (CModule::IncludeModule("learning"))
    {
        $QUESTION_ID = 290;
    
        $res = CLAnswer::GetList(
            Array(), 
            Array("QUESTION_ID" => $QUESTION_ID, "CORRECT" => "Y")
        );
    
        while ($arAnswer = $res->GetNext())
        {
            echo "Answer name: ".$arAnswer["ANSWER"]."<br>";
        }
    }
    ?>

    
    <?
    
    if (CModule::IncludeModule("learning"))
    {
        $QUESTION_ID = 290;
    
        $res = CLAnswer::GetList(
            Array("TIMESTAMP_X" => "ASC", "SORT"=>"ASC"), 
            Array("QUESTION_ID" => $QUESTION_ID)
        );
    
        while ($arAnswer = $res->GetNext())
        {
            echo "Answer name: ".$arAnswer["ANSWER"]."<br>";
        }
    }
    ?>

    
    <?
    
    if (CModule::IncludeModule("learning"))
    {
        $QUESTION_ID = 290;
    
        $res = CLAnswer::GetList(
            Array("RAND"=>""), 
            Array("QUESTION_ID" => $QUESTION_ID)
        );
    
        while ($arAnswer = $res->GetNext())
        {
            echo "Answer name: ".$arAnswer["ANSWER"]."<br>";
        }
    }
    ?>