ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilDclRatingFieldModel.php
Go to the documentation of this file.
1<?php
2
10{
11
20 public function getRecordQuerySortObject($direction = "asc", $sort_by_status = false)
21 {
22 // FSX Bugfix 0015735: The average is multiplied with 10000 and added to the amount of votes
23 $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";
24 $select_str = " average.rating AS field_{$this->getId()},";
25
26 $sql_obj = new ilDclRecordQueryObject();
27 $sql_obj->setSelectStatement($select_str);
28 $sql_obj->setJoinStatement($join_str);
29 $sql_obj->setOrderStatement("field_{$this->getId()} " . $direction);
30
31 return $sql_obj;
32 }
33
34
42 public function getRecordQueryFilterObject($filter_value = "", ilDclBaseFieldModel $sort_field = null)
43 {
44 global $DIC;
45 $ilDB = $DIC['ilDB'];
46
47 if (!$sort_field instanceof $this) {
48 $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";
49 }
50 // FSX Bugfix 0015735: The average is multiplied with 10000 and added to the amount of votes
51 $where_additions = " AND average.rating >= " . $ilDB->quote($filter_value * 10000, 'integer');
52
53 $sql_obj = new ilDclRecordQueryObject();
54 $sql_obj->setWhereStatement($where_additions);
55 $sql_obj->setJoinStatement($join_str);
56
57 return $sql_obj;
58 }
59}
An exception for terminatinating execution or to throw for unit testing.
Class ilDclBaseFieldModel.
Class ilDclRatingFieldModel.
getRecordQueryFilterObject($filter_value="", ilDclBaseFieldModel $sort_field=null)
Returns a query-object for building the record-loader-sql-query.
getRecordQuerySortObject($direction="asc", $sort_by_status=false)
Returns a query-object for building the record-loader-sql-query.
Class ilDclRecordQueryObject.
global $DIC
Definition: goto.php:24
global $ilDB