19 declare(strict_types=1);
    32         $order_stmt = $order_by === TopListOrder::BY_TIME ? 
'tst_pass_result.workingtime' : 
'percentage';
    34         $result = $this->db->query(
    36                         SELECT tst_result_cache.*, round(points/maxpoints*100,2) as percentage, tst_pass_result.workingtime, usr_data.usr_id, usr_data.firstname, usr_data.lastname    38                         INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi    39                         INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi    40                         INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi    41                         INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi AND tst_pass_result.pass = tst_result_cache.pass    42                         INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi    43                         WHERE object_reference.ref_id = ' . $this->db->quote($object->
getRefId(), 
'integer') .
    44             ' ORDER BY ' . $order_stmt . 
' DESC'    47         while ($row = $this->db->fetchAssoc($result)) {
    54         $a_test_ref_id = $object->
getRefId();
    55         $result = $this->db->query(
    57                         SELECT COUNT(tst_pass_result.workingtime) cnt    59                         INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi    60                         INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi    61                         INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi    62                         INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi    63                                 AND tst_pass_result.pass = tst_result_cache.pass    64                         INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi    65                         WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id, 
'integer') . 
'    66                         AND tst_active.user_fi != ' . $this->db->quote($a_user_id, 
'integer') . 
'    67                         AND round(reached_points/max_points*100) >=    69                                 SELECT round(reached_points/max_points*100)    71                                 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi    72                                 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi    73                                 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi    74                                 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi    75                                         AND tst_pass_result.pass = tst_result_cache.pass    76                                 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id, 
'integer') . 
'    77                                 AND tst_active.user_fi = ' . $this->db->quote($a_user_id, 
'integer') . 
'    81         $row = $this->db->fetchAssoc($result);
    82         $better_participants = $row[
'cnt'];
    83         $own_placement = $better_participants + 1;
    85         $result = $this->db->query(
    87                         SELECT COUNT(tst_pass_result.workingtime) cnt    89                         INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi    90                         INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi    91                         INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi    92                         INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi    93                                 AND tst_pass_result.pass = tst_result_cache.pass    94                         INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi    95                         WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id, 
'integer')
    97         $row = $this->db->fetchAssoc($result);
    98         $number_total = $row[
'cnt'];
   100         $result = $this->db->query(
   102                 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage ,   103                         tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname   104                 FROM object_reference   105                 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi   106                 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi   107                 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi   108                 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi   109                         AND tst_pass_result.pass = tst_result_cache.pass   110                 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi   112                 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id, 
'integer') . 
'   113                 AND tst_active.user_fi = ' . $this->db->quote($a_user_id, 
'integer') . 
'   116                         SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage,   117                                 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname   118                         FROM object_reference   119                         INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi   120                         INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi   121                         INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi   122                         INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi   123                                 AND tst_pass_result.pass = tst_result_cache.pass   124                         INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi   125                         WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id, 
'integer') . 
'   126                         AND tst_active.user_fi != ' . $this->db->quote($a_user_id, 
'integer') . 
'   127                         AND round(reached_points/max_points*100) >=   129                                 SELECT round(reached_points/max_points*100)   130                                 FROM object_reference   131                                 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi   132                                 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi   133                                 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi   134                                 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi   135                                         AND tst_pass_result.pass = tst_result_cache.pass   136                                 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id, 
'integer') . 
'   137                                 AND tst_active.user_fi = ' . $this->db->quote($a_user_id, 
'integer') . 
'   139                         ORDER BY round(reached_points/max_points*100) ASC   143                         SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage,   144                                 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname   145                         FROM object_reference   146                         INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi   147                         INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi   148                         INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi   149                         INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi   150                                 AND tst_pass_result.pass = tst_result_cache.pass   151                         INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi   152                         WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id, 
'integer') . 
'   153                         AND tst_active.user_fi != ' . $this->db->quote($a_user_id, 
'integer') . 
'   154                         AND round(reached_points/max_points*100) <=   156                                 SELECT round(reached_points/max_points*100)   157                                 FROM object_reference   158                                 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi   159                                 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi   160                                 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi   161                                 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi   162                                         AND tst_pass_result.pass = tst_result_cache.pass   163                                 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id, 
'integer') . 
'   164                                 AND tst_active.user_fi = ' . $this->db->quote($a_user_id, 
'integer') . 
'   166                         ORDER BY round(reached_points/max_points*100) ASC   169                 ORDER BY round(reached_points/max_points*100) DESC, tstamp ASC   181         while ($row = $this->db->fetchAssoc($result)) {
   186         if ($number_total > $i) {
   193         $a_test_ref_id = $object->
getRefId();
   194         $result = $this->db->query(
   196                         SELECT COUNT(tst_pass_result.workingtime) cnt   197                         FROM object_reference   198                         INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi   199                         INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi   200                         INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi   201                         INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi   202                                 AND tst_pass_result.pass = tst_result_cache.pass   203                         INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi   204                         WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id, 
'integer') . 
'   205                         AND tst_active.user_fi != ' . $this->db->quote($a_user_id, 
'integer') . 
'   209                                 FROM object_reference   210                                 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi   211                                 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi   212                                 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi   213                                 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi   214                                         AND tst_pass_result.pass = tst_result_cache.pass   215                                 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id, 
'integer') . 
'   216                                 AND tst_active.user_fi = ' . $this->db->quote($a_user_id, 
'integer') . 
'   220         $row = $this->db->fetchAssoc($result);
   221         $better_participants = $row[
'cnt'];
   222         $own_placement = $better_participants + 1;
   224         $result = $this->db->query(
   226                         SELECT COUNT(tst_pass_result.workingtime) cnt   227                         FROM object_reference   228                         INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi   229                         INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi   230                         INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi   231                         INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi   232                                 AND tst_pass_result.pass = tst_result_cache.pass   233                         INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi   234                         WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id, 
'integer')
   236         $row = $this->db->fetchAssoc($result);
   237         $number_total = $row[
'cnt'];
   239         $result = $this->db->query(
   241                 SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage ,   242                         tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname   243                 FROM object_reference   244                 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi   245                 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi   246                 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi   247                 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi   248                         AND tst_pass_result.pass = tst_result_cache.pass   249                 INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi   251                 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id, 
'integer') . 
'   252                 AND tst_active.user_fi = ' . $this->db->quote($a_user_id, 
'integer') . 
'   255                         SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage,   256                                 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname   257                         FROM object_reference   258                         INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi   259                         INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi   260                         INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi   261                         INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi   262                                 AND tst_pass_result.pass = tst_result_cache.pass   263                         INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi   264                         WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id, 
'integer') . 
'   265                         AND tst_active.user_fi != ' . $this->db->quote($a_user_id, 
'integer') . 
'   268                                 SELECT tst_pass_result.workingtime   269                                 FROM object_reference   270                                 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi   271                                 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi   272                                 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi   273                                 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi   274                                         AND tst_pass_result.pass = tst_result_cache.pass   275                                 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id, 
'integer') . 
'   276                                 AND tst_active.user_fi = ' . $this->db->quote($a_user_id, 
'integer') . 
'   278                         ORDER BY workingtime DESC   282                         SELECT tst_result_cache.*, round(reached_points/max_points*100) as percentage,   283                                 tst_pass_result.workingtime, usr_id, usr_data.firstname, usr_data.lastname   284                         FROM object_reference   285                         INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi   286                         INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi   287                         INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi   288                         INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi   289                                 AND tst_pass_result.pass = tst_result_cache.pass   290                         INNER JOIN usr_data ON usr_data.usr_id = tst_active.user_fi   291                         WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id, 
'integer') . 
'   292                         AND tst_active.user_fi != ' . $this->db->quote($a_user_id, 
'integer') . 
'   295                                 SELECT tst_pass_result.workingtime   296                                 FROM object_reference   297                                 INNER JOIN tst_tests ON object_reference.obj_id = tst_tests.obj_fi   298                                 INNER JOIN tst_active ON tst_tests.test_id = tst_active.test_fi   299                                 INNER JOIN tst_result_cache ON tst_active.active_id = tst_result_cache.active_fi   300                                 INNER JOIN tst_pass_result ON tst_active.active_id = tst_pass_result.active_fi   301                                         AND tst_pass_result.pass = tst_result_cache.pass   302                                 WHERE object_reference.ref_id = ' . $this->db->quote($a_test_ref_id, 
'integer') . 
'   303                                 AND tst_active.user_fi = ' . $this->db->quote($a_user_id, 
'integer') . 
'   305                         ORDER BY workingtime DESC   308                 ORDER BY workingtime ASC   313         $i = $own_placement - (($better_participants >= 3) ? 3 : $better_participants);
   319         while ($row = $this->db->fetchAssoc($result)) {
   324         if ($number_total > $i) {
 getHighscoreTopNum(int $a_retval=10)
Gets the number of entries which are to be shown in the top-rankings table. 
 
__construct(private readonly \ilDBInterface $db)
 
getGeneralToplist(\ilObjTest $object, TopListOrder $order_by)
 
getUserToplistByWorkingtime(\ilObjTest $object, int $a_user_id)
 
getUserToplistByPercentage(\ilObjTest $object, int $a_user_id)