Bitrix Site Manager

CTest::GetList

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

The GetList method returns a selection of tests filtered by arFilter and sorted in the arOrder order. The current user access permissions are respected.

Parameters

ParameterDescription
arOrder An array in the format array("filter field"=>"sort order" [, ...]). The sorting field can have the following values:
  • ID - the test ID;
  • SORT - sort index;
  • NAME - the test name;
  • SORT - sort index;
  • TIMESTAMP_X - the date when the test was modified;
Optional sort order can be one of the following:
  • asc - ascending;
  • desc - descending (default).
arFilter An array in the format array("filtered field"=>"filter value" [, ...]). The following values are possible:
  • ID - the test ID;
  • SORT - sort index;
  • COURSE_ID - the course ID;
  • ATTEMPT_LIMIT - number of attempts;
  • TIME_LIMIT - testing session time limit (in minutes);
  • NAME - the test name (wildcards allowed [%_]); 
  • DESCRIPTION - the test description (wildcards allowed [%_]); 
  • ACTIVE - active state flag (Y|N);
  • APPROVED - whether test results are checked automatically (Y|N);
  • INCLUDE_SELF_TEST - whether self-check questions are included in the test (Y/N);
  • RANDOM_QUESTIONS - indicates that the questions are displayed in random order (Y|N);
  • RANDOM_ANSWERS - indicates the random order of answers (Y/N);
  • QUESTIONS_FROM - indicates which questions are included in test: A - of the whole course, C - of each chapter, L - of each lesson;
  • PASSAGE_TYPE - the test process design: 
0 - a student cannot switch to the next question without answering the current one and cannot change their answers;
1 - a student can switch to the next question without answering the current one but cannot change their answers;
3 - a student can switch to the next question without answering the current one and can change their answers;
  • MIN_PERMISSION - minimum access permission level. "R" by default. See CCourse::SetPermission for available access permissions;
  • CHECK_PERMISSIONS - the level of access permission will 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

Example


<?
if (CModule::IncludeModule("learning"))
{
    $COURSE_ID = 97;
    $res = CTest::GetList(
        Array("SORT"=>"ASC"), 
        Array("ACTIVE" => "Y", "COURSE_ID" => $COURSE_ID)
    );

    while ($arTest = $res->GetNext())
    {
        echo "Test name: ".$arTest["NAME"]."<br>";
    }
}
?>


<?

if (CModule::IncludeModule("learning"))
{
    $res = CTest::GetList(
        Array("SORT"=>"ASC"), 
        Array("?NAME" => "Site")
    );

    while ($arTest = $res->GetNext())
    {
        echo "Test name: ".$arTest["NAME"]."<br>";
    }
}
?>


<?

if (CModule::IncludeModule("learning"))
{
    $COURSE_ID = 97;

    $res = CTest::GetList(
        Array("NAME" => "ASC", "SORT"=>"ASC"), 
        Array("COURSE_ID" => $COURSE_ID, "APPROVED" => "Y")
    );

    while ($arTest = $res->GetNext())
    {
        echo "Test name: ".$arTest["NAME"]."<br>";
    }
}
?>


<?

if (CModule::IncludeModule("learning"))
{
    $COURSE_ID = 97;

    $res = CTest::GetList(
        Array("TIMESTAMP_X" => "ASC", "SORT"=>"ASC"), 
        Array("CHECK_PERMISSIONS" => "N", "COURSE_ID" => $COURSE_ID)
    );

    while ($arTest = $res->GetNext())
    {
        echo "Test name: ".$arTest["NAME"]."<br>";
    }
}
?>