ILIAS  release_8 Revision v8.24
class.ilDclRatingFieldModel.php
Go to the documentation of this file.
1<?php
2
20{
21 public function getRecordQuerySortObject(
22 string $direction = "asc",
23 bool $sort_by_status = false
25 // FSX Bugfix 0015735: The average is multiplied with 10000 and added to the amount of votes
26 $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";
27 $select_str = " average.rating AS field_{$this->getId()},";
28
29 $sql_obj = new ilDclRecordQueryObject();
30 $sql_obj->setSelectStatement($select_str);
31 $sql_obj->setJoinStatement($join_str);
32 $sql_obj->setOrderStatement("field_{$this->getId()} " . $direction . ", ID ASC");
33
34 return $sql_obj;
35 }
36
38 $filter_value = "",
39 ?ilDclBaseFieldModel $sort_field = null
41 global $DIC;
42 $ilDB = $DIC['ilDB'];
43
44 if (!$sort_field instanceof $this) {
45 $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";
46 }
47 // FSX Bugfix 0015735: The average is multiplied with 10000 and added to the amount of votes
48 $where_additions = " AND average.rating >= " . $ilDB->quote($filter_value * 10000, 'integer');
49
50 $sql_obj = new ilDclRecordQueryObject();
51 $sql_obj->setWhereStatement($where_additions);
52 $sql_obj->setJoinStatement($join_str);
53
54 return $sql_obj;
55 }
56}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28