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 211 of file class.ilRating.php.
References $DIC, $ilDB, $res, and $row.
Referenced by ilRatingCategoryGUI\export().
215 $ilDB = $DIC->database();
218 $q =
"SELECT sub_obj_id, sub_obj_type, rating, category_id, user_id, tstamp " .
219 "FROM il_rating WHERE " .
220 "obj_id = " .
$ilDB->quote((
int) $a_obj_id,
"integer") .
" AND " .
221 "obj_type = " .
$ilDB->quote($a_obj_type,
"text") .
223 if ($a_category_ids) {
224 $q .=
" AND " .
$ilDB->in(
"category_id", $a_category_ids,
"",
"integer");
226 $set =
$ilDB->query($q);
foreach($_POST as $key=> $value) $res
◆ 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 165 of file class.ilRating.php.
References $DIC, and $ilDB.
Referenced by ilObjForumGUI\executeCommand(), ilWikiStat\getAverageRating(), ilDclRatingRecordFieldModel\getExportValue(), ilRatingGUI\getHTML(), ilDclRatingRecordFieldModel\getValue(), and ilRatingGUI\renderDetails().
169 $ilDB = $DIC->database();
171 if (is_array(self::$list_data)) {
172 return self::$list_data[
"all"][$a_obj_type .
"/" . $a_obj_id];
175 $q =
"SELECT AVG(rating) av FROM il_rating" .
176 " WHERE obj_id = " .
$ilDB->quote((
int) $a_obj_id,
"integer") .
177 " AND obj_type = " .
$ilDB->quote($a_obj_type,
"text");
179 $q .=
" AND sub_obj_id = " .
$ilDB->quote((
int) $a_sub_obj_id,
"integer") .
180 " AND " .
$ilDB->equals(
"sub_obj_type", $a_sub_obj_type,
"text",
true);
182 $q .=
" AND sub_obj_type = " .
$ilDB->quote(
"-",
"text");
185 if ($a_category_id !== null) {
186 $q .=
" AND category_id = " .
$ilDB->quote((
int) $a_category_id,
"integer");
188 $q .=
" GROUP BY user_id";
189 $set =
$ilDB->query($q);
191 while ($rec =
$ilDB->fetchAssoc($set)) {
200 return array(
"cnt" => $cnt,
"avg" => $avg);
◆ 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 126 of file class.ilRating.php.
References $DIC, and $ilDB.
Referenced by ilExerciseManagementCollectFilesJob\addCriteriaToExcel(), ilRatingGUI\getHTML(), ilExcCriteriaRating\hasValue(), and ilRatingGUI\renderDetails().
136 $ilDB = $DIC->database();
138 if (is_array(self::$list_data)) {
139 return self::$list_data[
"user"][$a_obj_type .
"/" . $a_obj_id];
142 $q =
"SELECT AVG(rating) av FROM il_rating WHERE " .
143 "user_id = " .
$ilDB->quote($a_user_id,
"integer") .
" AND " .
144 "obj_id = " .
$ilDB->quote((
int) $a_obj_id,
"integer") .
" AND " .
145 "obj_type = " .
$ilDB->quote($a_obj_type,
"text") .
" AND " .
146 "sub_obj_id = " .
$ilDB->quote((
int) $a_sub_obj_id,
"integer") .
" AND " .
147 $ilDB->equals(
"sub_obj_type", $a_sub_obj_type,
"text",
true);
148 if ($a_category_id !== null) {
149 $q .=
" AND category_id = " .
$ilDB->quote((
int) $a_category_id,
"integer");
151 $set =
$ilDB->query($q);
152 $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 238 of file class.ilRating.php.
References $DIC, $id, $ilDB, $ilUser, $res, and $row.
Referenced by ilObjectListGUIPreloader\preload().
242 $ilDB = $DIC->database();
245 $tmp =
$res = $tmp_user = $res_user = array();
248 $q =
"SELECT obj_id, obj_type, user_id, AVG(rating) av" .
250 " WHERE " .
$ilDB->in(
"obj_id", $a_obj_ids,
"",
"integer") .
251 " AND sub_obj_id = " .
$ilDB->quote(0,
"integer") .
252 " GROUP BY obj_id, obj_type, user_id";
253 $set =
$ilDB->query($q);
254 while ($rec =
$ilDB->fetchAssoc($set)) {
255 $tmp[$rec[
"obj_type"] .
"/" . $rec[
"obj_id"]][$rec[
"user_id"]] = (float) $rec[
"av"];
256 if ($rec[
"user_id"] ==
$ilUser->getId()) {
258 $res_user[$rec[
"obj_type"] .
"/" . $rec[
"obj_id"]] = (float) $rec[
"av"];
263 foreach ($tmp as $obj_id => $votes) {
264 $res[$obj_id] = array(
"avg" => array_sum($votes) /
sizeof($votes),
265 "cnt" =>
sizeof($votes));
270 $set =
$ilDB->query(
"SELECT file_id, rating" .
272 " WHERE " .
$ilDB->in(
"file_id", $a_obj_ids,
"",
'integer'));
274 $id =
"file/" .
$row[
"file_id"];
276 $res[
$id] = array(
"avg" => 0,
"cnt" => 0);
277 } elseif (!
$row[
"rating"] && isset(
$res[$id])) {
282 $set =
$ilDB->query(
"SELECT id, rating_overall" .
283 " FROM il_wiki_data" .
284 " WHERE " .
$ilDB->in(
"id", $a_obj_ids,
"",
'integer'));
286 $id =
"wiki/" .
$row[
"id"];
287 if (
$row[
"rating_overall"] && !isset(
$res[$id])) {
288 $res[
$id] = array(
"avg" => 0,
"cnt" => 0);
289 } elseif (!
$row[
"rating_overall"] && isset(
$res[$id])) {
294 $set =
$ilDB->query(
"SELECT id, rating" .
295 " FROM content_object" .
296 " WHERE " .
$ilDB->in(
"id", $a_obj_ids,
"",
'integer'));
298 $id =
"lm/" .
$row[
"id"];
299 if (
$row[
"rating"] && !isset(
$res[$id])) {
300 $res[
$id] = array(
"avg" => 0,
"cnt" => 0);
301 } elseif (!
$row[
"rating"] && isset(
$res[$id])) {
306 self::$list_data = array(
"all" =>
$res,
"user" => $res_user);
if(!array_key_exists('StateId', $_REQUEST)) $id
foreach($_POST as $key=> $value) $res
◆ 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 96 of file class.ilRating.php.
References $DIC, and $ilDB.
Referenced by ilExcCriteriaRating\resetReview(), ilRatingGUI\resetUserRating(), and ilLMPresentationGUI\updatePageRating().
105 $ilDB = $DIC->database();
107 $ilDB->manipulate(
"DELETE FROM il_rating WHERE " .
108 "user_id = " .
$ilDB->quote($a_user_id,
"integer") .
" AND " .
109 "obj_id = " .
$ilDB->quote((
int) $a_obj_id,
"integer") .
" AND " .
110 "obj_type = " .
$ilDB->quote($a_obj_type,
"text") .
" AND " .
111 "sub_obj_id = " .
$ilDB->quote((
int) $a_sub_obj_id,
"integer") .
" AND " .
112 $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 $DIC, and $ilDB.
Referenced by ilRatingGUI\saveRating(), ilExcCriteriaRating\updateFromAjax(), and ilLMPresentationGUI\updatePageRating().
41 $ilDB = $DIC->database();
51 if ($a_user_id == ANONYMOUS_USER_ID) {
56 $ilDB->manipulate(
"DELETE FROM il_rating WHERE " .
57 "user_id = " .
$ilDB->quote($a_user_id,
"integer") .
" AND " .
58 "obj_id = " .
$ilDB->quote((
int) $a_obj_id,
"integer") .
" AND " .
59 "obj_type = " .
$ilDB->quote($a_obj_type,
"text") .
" AND " .
60 "sub_obj_id = " .
$ilDB->quote((
int) $a_sub_obj_id,
"integer") .
" AND " .
61 $ilDB->equals(
"sub_obj_type", $a_sub_obj_type,
"text",
true) .
" AND " .
62 "category_id = " .
$ilDB->quote(0,
"integer"));
65 $ilDB->manipulate(
"DELETE FROM il_rating WHERE " .
66 "user_id = " .
$ilDB->quote($a_user_id,
"integer") .
" AND " .
67 "obj_id = " .
$ilDB->quote((
int) $a_obj_id,
"integer") .
" AND " .
68 "obj_type = " .
$ilDB->quote($a_obj_type,
"text") .
" AND " .
69 "sub_obj_id = " .
$ilDB->quote((
int) $a_sub_obj_id,
"integer") .
" AND " .
70 $ilDB->equals(
"sub_obj_type", $a_sub_obj_type,
"text",
true) .
" AND " .
71 "category_id = " .
$ilDB->quote((
int) $a_category_id,
"integer"));
73 if ((
int) $a_rating) {
74 $ilDB->manipulate(
"INSERT INTO il_rating (user_id, obj_id, obj_type," .
75 "sub_obj_id, sub_obj_type, category_id, rating, tstamp) VALUES (" .
76 $ilDB->quote($a_user_id,
"integer") .
"," .
77 $ilDB->quote((
int) $a_obj_id,
"integer") .
"," .
78 $ilDB->quote($a_obj_type,
"text") .
"," .
79 $ilDB->quote((
int) $a_sub_obj_id,
"integer") .
"," .
80 $ilDB->quote($a_sub_obj_type,
"text") .
"," .
81 $ilDB->quote($a_category_id,
"integer") .
"," .
82 $ilDB->quote((
int) $a_rating,
"integer") .
"," .
83 $ilDB->quote(time(),
"integer") .
")");
◆ $list_data
The documentation for this class was generated from the following file: