ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDclRatingFieldModel.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 public function getRecordQuerySortObject(
24 string $direction = "asc",
25 bool $sort_by_status = false
27 // FSX Bugfix 0015735: The average is multiplied with 10000 and added to the amount of votes
28 $join_str = "LEFT JOIN (SELECT (ROUND(AVG(rating), 1) * 10000 + COUNT(rating)) as rating, obj_id FROM il_rating GROUP BY obj_id) AS average ON average.obj_id = record.id";
29 $select_str = " average.rating AS field_{$this->getId()},";
30
31 $sql_obj = new ilDclRecordQueryObject();
32 $sql_obj->setSelectStatement($select_str);
33 $sql_obj->setJoinStatement($join_str);
34 $sql_obj->setOrderStatement("field_{$this->getId()} " . $direction . ", ID ASC");
35
36 return $sql_obj;
37 }
38
40 $filter_value = "",
41 ?ilDclBaseFieldModel $sort_field = null
43 global $DIC;
44 $ilDB = $DIC['ilDB'];
45
46 if (!$sort_field instanceof $this) {
47 $join_str = "LEFT JOIN (SELECT (ROUND(AVG(rating), 1) * 10000 + COUNT(rating)) as rating, obj_id FROM il_rating GROUP BY obj_id) AS average ON average.obj_id = record.id";
48 }
49 // FSX Bugfix 0015735: The average is multiplied with 10000 and added to the amount of votes
50 $where_additions = " AND average.rating >= " . $ilDB->quote($filter_value * 10000, 'integer');
51
52 $sql_obj = new ilDclRecordQueryObject();
53 $sql_obj->setWhereStatement($where_additions);
54
55 if (isset($join_str)) {
56 $sql_obj->setJoinStatement($join_str);
57 }
58
59 return $sql_obj;
60 }
61}
getRecordQuerySortObject(string $direction="asc", bool $sort_by_status=false)
Returns a query-object for building the record-loader-sql-query.
getRecordQueryFilterObject( $filter_value="", ?ilDclBaseFieldModel $sort_field=null)
Returns a query-object for building the record-loader-sql-query.
global $DIC
Definition: shib_login.php:26