Bitrix Site Manager

CTestAttempt::GetList

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

The GetList method returns a selection of attempts 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 attempt ID;
  • TEST_ID - the test ID;
  • STUDENT_ID - the student ID;
  • DATE_START - the time when an attempt was started;
  • DATE_END - the time when an attempt was completed;
  • STATUS - the attempt status;
  • SCORE - score;
  • MAX_SCORE - maximum score;
  • COMPLETED - indicates that the test is completed;
  • QUESTIONS - the number of questions;
  • USER_NAME - the student name;
  • TEST_NAME - the test name.
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 attempt ID;
  • TEST_ID - the test ID;
  • STUDENT_ID - the student ID;
  • SCORE - score;
  • MAX_SCORE - maximum score;
  • QUESTIONS - the number of questions;
  • STATUS - status of the attempt: B - started, D - aborted, F - completed;
  • COMPLETED - indicates whether the test is completed (Y|N);
  • DATE_START - the time when an attempt started;
  • DATE_END - the time when an attempt was completed;
  • USER - the user (searches by values of the ID, LOGIN, NAME, LAST_NAME fields);
  • 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

  • CDBResult
  • CTestAttempt::GetByID
  • Attempt fields
  • Example

    
    <?
    if (CModule::IncludeModule("learning"))
    {
        $TEST_ID = 45;
        $res = CTestAttempt::GetList(
            Array("ID" => "ASC"), 
            Array("TEST_ID" => $TEST_ID)
        );
    
        while ($arAttempt = $res->GetNext())
        {
            echo "Attempt ID:".$arAttempt["ID"]."; Date start: ".$arAttempt["DATE_START"]."; Test name: ".$arAttempt["TEST_NAME"]."<br>";
        }
    }
    ?>

    
    <?
    
    if (CModule::IncludeModule("learning"))
    {
        $TEST_ID = 45;
        $STUDENT_ID = 3;
    
        $res = CTestAttempt::GetList(
            Array("SCORE" => "DESC"), 
            Array("CHECK_PERMISSIONS" => "N", "TEST_ID" => $TEST_ID, "STUDENT_ID" => $STUDENT_ID)
        );
    
        while ($arAttempt = $res->GetNext())
        {
            echo "Attempt ID:".$arAttempt["ID"]."; Date start: ".$arAttempt["DATE_START"]."; Test name: ".$arAttempt["TEST_NAME"]."<br>";
        }
    }
    ?>