Class ilRating.
More...
|
static | writeRatingForUserAndObject ($a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id, $a_rating, $a_category_id=0) |
| Write rating for a user and an object. More...
|
|
static | resetRatingForUserAndObject ($a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id) |
| Reset rating for a user and an object. More...
|
|
static | getRatingForUserAndObject ($a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id, $a_category_id=null) |
| Get rating for a user and an object. More...
|
|
static | getOverallRatingForObject ($a_obj_id, $a_obj_type, $a_sub_obj_id=null, $a_sub_obj_type=null, $a_category_id=null) |
| Get overall rating for an object. More...
|
|
static | getExportData ($a_obj_id, $a_obj_type, array $a_category_ids=null) |
| Get export data. More...
|
|
static | preloadListGUIData (array $a_obj_ids) |
| Preload rating data for list guis. More...
|
|
static | hasRatingInListGUI ($a_obj_id, $a_obj_type) |
|
◆ getExportData()
static ilRating::getExportData |
( |
|
$a_obj_id, |
|
|
|
$a_obj_type, |
|
|
array |
$a_category_ids = null |
|
) |
| |
|
static |
Get export data.
- Parameters
-
int | $a_obj_id | |
string | $a_obj_type | |
array | $a_category_ids | |
- Returns
- array
Definition at line 194 of file class.ilRating.php.
References $ilDB, $res, $row, and array.
Referenced by ilRatingCategoryGUI\export().
199 $q =
"SELECT sub_obj_id, sub_obj_type, rating, category_id, user_id, tstamp ".
200 "FROM il_rating WHERE ".
201 "obj_id = ".$ilDB->quote((
int) $a_obj_id,
"integer").
" AND ".
202 "obj_type = ".$ilDB->quote($a_obj_type,
"text").
206 $q .=
" AND ".$ilDB->in(
"category_id", $a_category_ids,
"",
"integer");
208 $set = $ilDB->query($q);
209 while(
$row = $ilDB->fetchAssoc($set))
Create styles array
The data for the language used.
◆ getOverallRatingForObject()
static ilRating::getOverallRatingForObject |
( |
|
$a_obj_id, |
|
|
|
$a_obj_type, |
|
|
|
$a_sub_obj_id = null , |
|
|
|
$a_sub_obj_type = null , |
|
|
|
$a_category_id = null |
|
) |
| |
|
static |
Get overall rating for an object.
- Parameters
-
int | $a_obj_id | Object ID |
string | $a_obj_type | Object Type |
int | $a_sub_obj_id | Subobject ID |
string | $a_sub_obj_type | Subobject Type |
int | $a_category_id | Category ID |
Definition at line 141 of file class.ilRating.php.
References $ilDB, and array.
Referenced by ilWikiStat\getAverageRating(), ilDclRatingRecordFieldModel\getExportValue(), ilRatingGUI\getHTML(), ilDclRatingRecordFieldModel\getValue(), ilObjForumGUI\isTopLevelReplyCommand(), and ilRatingGUI\renderDetails().
145 if(is_array(self::$list_data))
147 return self::$list_data[
"all"][$a_obj_type.
"/".$a_obj_id];
150 $q =
"SELECT AVG(rating) av FROM il_rating".
151 " WHERE obj_id = ".$ilDB->quote((
int) $a_obj_id,
"integer").
152 " AND obj_type = ".$ilDB->quote($a_obj_type,
"text");
155 $q .=
" AND sub_obj_id = ".$ilDB->quote((
int) $a_sub_obj_id,
"integer").
156 " AND ".$ilDB->equals(
"sub_obj_type", $a_sub_obj_type,
"text",
true);
160 $q .=
" AND sub_obj_type = ".$ilDB->quote(
"-",
"text");
163 if ($a_category_id !== null)
165 $q .=
" AND category_id = ".$ilDB->quote((
int) $a_category_id,
"integer");
167 $q .=
" GROUP BY user_id";
168 $set = $ilDB->query($q);
170 while($rec = $ilDB->fetchAssoc($set))
183 return array(
"cnt" => $cnt,
"avg" => $avg);
Create styles array
The data for the language used.
◆ getRatingForUserAndObject()
static ilRating::getRatingForUserAndObject |
( |
|
$a_obj_id, |
|
|
|
$a_obj_type, |
|
|
|
$a_sub_obj_id, |
|
|
|
$a_sub_obj_type, |
|
|
|
$a_user_id, |
|
|
|
$a_category_id = null |
|
) |
| |
|
static |
Get rating for a user and an object.
- Parameters
-
int | $a_obj_id | Object ID |
string | $a_obj_type | Object Type |
int | $a_sub_obj_id | Subobject ID |
string | $a_sub_obj_type | Subobject Type |
int | $a_user_id | User ID |
int | $a_category_id | Category ID |
Definition at line 107 of file class.ilRating.php.
References $ilDB.
Referenced by ilRatingGUI\getHTML(), ilExcCriteriaRating\hasValue(), and ilRatingGUI\renderDetails().
112 if(is_array(self::$list_data))
114 return self::$list_data[
"user"][$a_obj_type.
"/".$a_obj_id];
117 $q =
"SELECT AVG(rating) av FROM il_rating WHERE ".
118 "user_id = ".$ilDB->quote($a_user_id,
"integer").
" AND ".
119 "obj_id = ".$ilDB->quote((
int) $a_obj_id,
"integer").
" AND ".
120 "obj_type = ".$ilDB->quote($a_obj_type,
"text").
" AND ".
121 "sub_obj_id = ".$ilDB->quote((
int) $a_sub_obj_id,
"integer").
" AND ".
122 $ilDB->equals(
"sub_obj_type", $a_sub_obj_type,
"text",
true);
123 if ($a_category_id !== null)
125 $q .=
" AND category_id = ".$ilDB->quote((
int) $a_category_id,
"integer");
127 $set = $ilDB->query($q);
128 $rec = $ilDB->fetchAssoc($set);
◆ hasRatingInListGUI()
static ilRating::hasRatingInListGUI |
( |
|
$a_obj_id, |
|
|
|
$a_obj_type |
|
) |
| |
|
static |
◆ preloadListGUIData()
static ilRating::preloadListGUIData |
( |
array |
$a_obj_ids | ) |
|
|
static |
Preload rating data for list guis.
- Parameters
-
Definition at line 221 of file class.ilRating.php.
References $ilDB, $ilUser, $res, $row, and array.
Referenced by ilObjectListGUIPreloader\preload().
225 $tmp =
$res = $tmp_user = $res_user =
array();
228 $q =
"SELECT obj_id, obj_type, user_id, AVG(rating) av".
230 " WHERE ".$ilDB->in(
"obj_id", $a_obj_ids,
"",
"integer").
231 " AND sub_obj_id = ".$ilDB->quote(0,
"integer").
232 " GROUP BY obj_id, obj_type, user_id";
233 $set = $ilDB->query($q);
234 while($rec = $ilDB->fetchAssoc($set))
236 $tmp[$rec[
"obj_type"].
"/".$rec[
"obj_id"]][$rec[
"user_id"]] = (float)$rec[
"av"];
237 if($rec[
"user_id"] == $ilUser->getId())
240 $res_user[$rec[
"obj_type"].
"/".$rec[
"obj_id"]] = (float)$rec[
"av"];
245 foreach($tmp as $obj_id => $votes)
247 $res[$obj_id] =
array(
"avg"=>array_sum($votes)/
sizeof($votes),
248 "cnt"=>
sizeof($votes));
253 $set = $ilDB->query(
"SELECT file_id, rating".
255 " WHERE ".$ilDB->in(
"file_id", $a_obj_ids,
"", integer));
256 while(
$row = $ilDB->fetchAssoc($set))
258 $id =
"file/".$row[
"file_id"];
259 if(
$row[
"rating"] && !isset(
$res[$id]))
263 else if(!
$row[
"rating"] && isset(
$res[$id]))
269 $set = $ilDB->query(
"SELECT id, rating_overall".
270 " FROM il_wiki_data".
271 " WHERE ".$ilDB->in(
"id", $a_obj_ids,
"", integer));
272 while(
$row = $ilDB->fetchAssoc($set))
274 $id =
"wiki/".$row[
"id"];
275 if(
$row[
"rating_overall"] && !isset(
$res[$id]))
279 else if(!
$row[
"rating_overall"] && isset(
$res[$id]))
285 $set = $ilDB->query(
"SELECT id, rating".
286 " FROM content_object".
287 " WHERE ".$ilDB->in(
"id", $a_obj_ids,
"", integer));
288 while(
$row = $ilDB->fetchAssoc($set))
290 $id =
"lm/".$row[
"id"];
291 if(
$row[
"rating"] && !isset(
$res[$id]))
295 else if(!
$row[
"rating"] && isset(
$res[$id]))
301 self::$list_data =
array(
"all"=>
$res,
"user"=>$res_user);
Create styles array
The data for the language used.
◆ resetRatingForUserAndObject()
static ilRating::resetRatingForUserAndObject |
( |
|
$a_obj_id, |
|
|
|
$a_obj_type, |
|
|
|
$a_sub_obj_id, |
|
|
|
$a_sub_obj_type, |
|
|
|
$a_user_id |
|
) |
| |
|
static |
Reset rating for a user and an object.
- Parameters
-
int | $a_obj_id | Object ID |
string | $a_obj_type | Object Type |
int | $a_sub_obj_id | Subobject ID |
string | $a_sub_obj_type | Subobject Type |
int | $a_user_id | User ID |
Definition at line 83 of file class.ilRating.php.
References $ilDB.
Referenced by ilExcCriteriaRating\resetReview(), ilRatingGUI\resetUserRating(), and ilLMPresentationGUI\updatePageRating().
88 $ilDB->manipulate(
"DELETE FROM il_rating WHERE ".
89 "user_id = ".$ilDB->quote($a_user_id,
"integer").
" AND ".
90 "obj_id = ".$ilDB->quote((
int) $a_obj_id,
"integer").
" AND ".
91 "obj_type = ".$ilDB->quote($a_obj_type,
"text").
" AND ".
92 "sub_obj_id = ".$ilDB->quote((
int) $a_sub_obj_id,
"integer").
" AND ".
93 $ilDB->equals(
"sub_obj_type", $a_sub_obj_type,
"text",
true));
◆ writeRatingForUserAndObject()
static ilRating::writeRatingForUserAndObject |
( |
|
$a_obj_id, |
|
|
|
$a_obj_type, |
|
|
|
$a_sub_obj_id, |
|
|
|
$a_sub_obj_type, |
|
|
|
$a_user_id, |
|
|
|
$a_rating, |
|
|
|
$a_category_id = 0 |
|
) |
| |
|
static |
Write rating for a user and an object.
- Parameters
-
int | $a_obj_id | Object ID |
string | $a_obj_type | Object Type |
int | $a_sub_obj_id | Subobject ID |
string | $a_sub_obj_type | Subobject Type |
int | $a_user_id | User ID |
int | $a_rating | Rating |
int | $a_category_id | Category ID |
Definition at line 30 of file class.ilRating.php.
References $ilDB, and time.
Referenced by ilRatingGUI\saveRating(), ilExcCriteriaRating\updateFromAjax(), and ilLMPresentationGUI\updatePageRating().
35 if ($a_user_id == ANONYMOUS_USER_ID)
42 $ilDB->manipulate(
"DELETE FROM il_rating WHERE ".
43 "user_id = ".$ilDB->quote($a_user_id,
"integer").
" AND ".
44 "obj_id = ".$ilDB->quote((
int) $a_obj_id,
"integer").
" AND ".
45 "obj_type = ".$ilDB->quote($a_obj_type,
"text").
" AND ".
46 "sub_obj_id = ".$ilDB->quote((
int) $a_sub_obj_id,
"integer").
" AND ".
47 $ilDB->equals(
"sub_obj_type", $a_sub_obj_type,
"text",
true).
" AND ".
48 "category_id = ".$ilDB->quote(0,
"integer"));
51 $ilDB->manipulate(
"DELETE FROM il_rating WHERE ".
52 "user_id = ".$ilDB->quote($a_user_id,
"integer").
" AND ".
53 "obj_id = ".$ilDB->quote((
int) $a_obj_id,
"integer").
" AND ".
54 "obj_type = ".$ilDB->quote($a_obj_type,
"text").
" AND ".
55 "sub_obj_id = ".$ilDB->quote((
int) $a_sub_obj_id,
"integer").
" AND ".
56 $ilDB->equals(
"sub_obj_type", $a_sub_obj_type,
"text",
true).
" AND ".
57 "category_id = ".$ilDB->quote((
int) $a_category_id,
"integer"));
61 $ilDB->manipulate(
"INSERT INTO il_rating (user_id, obj_id, obj_type,".
62 "sub_obj_id, sub_obj_type, category_id, rating, tstamp) VALUES (".
63 $ilDB->quote($a_user_id,
"integer").
",".
64 $ilDB->quote((
int) $a_obj_id,
"integer").
",".
65 $ilDB->quote($a_obj_type,
"text").
",".
66 $ilDB->quote((
int) $a_sub_obj_id,
"integer").
",".
67 $ilDB->quote($a_sub_obj_type,
"text").
",".
68 $ilDB->quote($a_category_id,
"integer").
",".
69 $ilDB->quote((
int) $a_rating,
"integer").
",".
70 $ilDB->quote(
time(),
"integer").
")");
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
◆ $list_data
The documentation for this class was generated from the following file: