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