This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.  
 More...
 | 
| static  | writeRatingForUserAndObject (int $a_obj_id, string $a_obj_type, ?int $a_sub_obj_id, ?string $a_sub_obj_type, int $a_user_id, int $a_rating, int $a_category_id=0) | 
|   | Write rating for a user and an object.  More...
  | 
|   | 
| static  | resetRatingForUserAndObject (int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type, int $a_user_id) | 
|   | Reset rating for a user and an object.  More...
  | 
|   | 
| static  | getRatingForUserAndObject (int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type, int $a_user_id, int $a_category_id=null) | 
|   | Get rating for a user and an object.  More...
  | 
|   | 
| static  | getOverallRatingForObject (int $a_obj_id, string $a_obj_type, int $a_sub_obj_id=null, string $a_sub_obj_type=null, int $a_category_id=null) | 
|   | Get overall rating for an object.  More...
  | 
|   | 
| static  | getExportData (int $a_obj_id, string $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 (int $a_obj_id, string $a_obj_type) | 
|   | 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. 
ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.
If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilRating
- Author
 - Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de 
 
Definition at line 24 of file class.ilRating.php.
 
◆ getExportData()
  
  
      
        
          | static ilRating::getExportData  | 
          ( | 
          int  | 
          $a_obj_id,  | 
         
        
           | 
           | 
          string  | 
          $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 225 of file class.ilRating.php.
References $DIC, $ilDB, $q, and $res.
Referenced by ilRatingCategoryGUI\export().
  232         $ilDB = $DIC->database();
   235         $q = 
"SELECT sub_obj_id, sub_obj_type, rating, category_id, user_id, tstamp " .
   236             "FROM il_rating WHERE " .
   237             "obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") . 
" AND " .
   238             "obj_type = " . 
$ilDB->quote($a_obj_type, 
"text") .
   240         if ($a_category_ids) {
   241             $q .= 
" AND " . 
$ilDB->in(
"category_id", $a_category_ids, 
"", 
"integer");
   244         while ($row = 
$ilDB->fetchAssoc($set)) {
 
 
 
 
◆ getOverallRatingForObject()
  
  
      
        
          | static ilRating::getOverallRatingForObject  | 
          ( | 
          int  | 
          $a_obj_id,  | 
         
        
           | 
           | 
          string  | 
          $a_obj_type,  | 
         
        
           | 
           | 
          int  | 
          $a_sub_obj_id = null,  | 
         
        
           | 
           | 
          string  | 
          $a_sub_obj_type = null,  | 
         
        
           | 
           | 
          int  | 
          $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 174 of file class.ilRating.php.
References $DIC, $ilDB, and $q.
Referenced by ilWikiStat\getAverageRating(), ilDclRatingRecordFieldModel\getExportValue(), ilRatingGUI\getHTML(), ilObjForumGUI\getSafePostCommands(), ilDclRatingRecordFieldModel\getValue(), and ilRatingGUI\renderDetails().
  183         $ilDB = $DIC->database();
   185         if (isset(self::$list_data[
"all"][$a_obj_type . 
"/" . $a_obj_id])) {
   186             return self::$list_data[
"all"][$a_obj_type . 
"/" . $a_obj_id];
   189         $q = 
"SELECT AVG(rating) av FROM il_rating" .
   190             " WHERE obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") .
   191             " AND obj_type = " . 
$ilDB->quote($a_obj_type, 
"text");
   193             $q .= 
" AND sub_obj_id = " . 
$ilDB->quote($a_sub_obj_id, 
"integer") .
   194                 " AND " . 
$ilDB->equals(
"sub_obj_type", $a_sub_obj_type, 
"text", 
true);
   196             $q .= 
" AND sub_obj_type = " . 
$ilDB->quote(
"-", 
"text"); 
   199         if ($a_category_id !== null) {
   200             $q .= 
" AND category_id = " . 
$ilDB->quote($a_category_id, 
"integer");
   202         $q .= 
" GROUP BY user_id";
   205         while ($rec = 
$ilDB->fetchAssoc($set)) {
   214         return array(
"cnt" => $cnt, 
"avg" => $avg);
 
 
 
 
◆ getRatingForUserAndObject()
  
  
      
        
          | static ilRating::getRatingForUserAndObject  | 
          ( | 
          int  | 
          $a_obj_id,  | 
         
        
           | 
           | 
          string  | 
          $a_obj_type,  | 
         
        
           | 
           | 
          int  | 
          $a_sub_obj_id,  | 
         
        
           | 
           | 
          string  | 
          $a_sub_obj_type,  | 
         
        
           | 
           | 
          int  | 
          $a_user_id,  | 
         
        
           | 
           | 
          int  | 
          $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 135 of file class.ilRating.php.
References $DIC, $ilDB, and $q.
Referenced by ilRatingGUI\getHTML(), ilExcCriteriaRating\hasValue(), ilExerciseManagementCollectFilesJob\isExcelNeeded(), and ilRatingGUI\renderDetails().
  145         $ilDB = $DIC->database();
   147         if (isset(self::$list_data[
"user"][$a_obj_type . 
"/" . $a_obj_id])) {
   148             return self::$list_data[
"user"][$a_obj_type . 
"/" . $a_obj_id] ?? 0;
   151         $q = 
"SELECT AVG(rating) av FROM il_rating WHERE " .
   152             "user_id = " . 
$ilDB->quote($a_user_id, 
"integer") . 
" AND " .
   153             "obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") . 
" AND " .
   154             "obj_type = " . 
$ilDB->quote($a_obj_type, 
"text") . 
" AND " .
   155             "sub_obj_id = " . 
$ilDB->quote($a_sub_obj_id, 
"integer") . 
" AND " .
   156             $ilDB->equals(
"sub_obj_type", $a_sub_obj_type, 
"text", 
true);
   157         if ($a_category_id !== null) {
   158             $q .= 
" AND category_id = " . 
$ilDB->quote($a_category_id, 
"integer");
   161         $rec = 
$ilDB->fetchAssoc($set);
   162         return (
float) $rec[
"av"];
 
 
 
 
◆ hasRatingInListGUI()
  
  
      
        
          | static ilRating::hasRatingInListGUI  | 
          ( | 
          int  | 
          $a_obj_id,  | 
         
        
           | 
           | 
          string  | 
          $a_obj_type  | 
         
        
           | 
          ) | 
           |  | 
         
       
   | 
  
static   | 
  
 
Definition at line 327 of file class.ilRating.php.
  331         return isset(self::$list_data[
"all"][$a_obj_type . 
"/" . $a_obj_id]);
  
 
 
◆ preloadListGUIData()
  
  
      
        
          | static ilRating::preloadListGUIData  | 
          ( | 
          array  | 
          $a_obj_ids | ) | 
           | 
         
       
   | 
  
static   | 
  
 
Preload rating data for list guis. 
- Parameters
 - 
  
  
 
Definition at line 255 of file class.ilRating.php.
References $DIC, $id, $ilDB, $q, and $res.
Referenced by ilObjectListGUIPreloader\preload().
  260         $ilDB = $DIC->database();
   261         $ilUser = $DIC->user();
   263         $tmp = 
$res = $res_user = array();
   266         $q = 
"SELECT obj_id, obj_type, user_id, AVG(rating) av" .
   268             " WHERE " . 
$ilDB->in(
"obj_id", $a_obj_ids, 
"", 
"integer") .
   269             " AND sub_obj_id = " . 
$ilDB->quote(0, 
"integer") .
   270             " GROUP BY obj_id, obj_type, user_id";
   272         while ($rec = 
$ilDB->fetchAssoc($set)) {
   273             $tmp[$rec[
"obj_type"] . 
"/" . $rec[
"obj_id"]][$rec[
"user_id"]] = (float) $rec[
"av"];
   274             if ($rec[
"user_id"] == $ilUser->getId()) {
   276                 $res_user[$rec[
"obj_type"] . 
"/" . $rec[
"obj_id"]] = (float) $rec[
"av"];
   281         foreach ($tmp as $obj_id => $votes) {
   282             $res[$obj_id] = array(
"avg" => array_sum($votes) / 
sizeof($votes),
   283                 "cnt" => 
sizeof($votes));
   288         $set = 
$ilDB->query(
"SELECT file_id, rating" .
   290             " WHERE " . 
$ilDB->in(
"file_id", $a_obj_ids, 
"", 
'integer'));
   291         while ($row = 
$ilDB->fetchAssoc($set)) {
   292             $id = 
"file/" . $row[
"file_id"];
   293             if ($row[
"rating"] && !isset(
$res[
$id])) {
   294                 $res[
$id] = array(
"avg" => 0, 
"cnt" => 0);
   295             } elseif (!$row[
"rating"] && isset(
$res[$id])) {
   300         $set = 
$ilDB->query(
"SELECT id, rating_overall" .
   301             " FROM il_wiki_data" .
   302             " WHERE " . 
$ilDB->in(
"id", $a_obj_ids, 
"", 
'integer'));
   303         while ($row = 
$ilDB->fetchAssoc($set)) {
   304             $id = 
"wiki/" . $row[
"id"];
   305             if ($row[
"rating_overall"] && !isset(
$res[$id])) {
   306                 $res[
$id] = array(
"avg" => 0, 
"cnt" => 0);
   307             } elseif (!$row[
"rating_overall"] && isset(
$res[$id])) {
   312         $set = 
$ilDB->query(
"SELECT id, rating" .
   313             " FROM content_object" .
   314             " WHERE " . 
$ilDB->in(
"id", $a_obj_ids, 
"", 
'integer'));
   315         while ($row = 
$ilDB->fetchAssoc($set)) {
   316             $id = 
"lm/" . $row[
"id"];
   317             if ($row[
"rating"] && !isset(
$res[$id])) {
   318                 $res[
$id] = array(
"avg" => 0, 
"cnt" => 0);
   319             } elseif (!$row[
"rating"] && isset(
$res[$id])) {
   324         self::$list_data = array(
"all" => 
$res, 
"user" => $res_user);
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins 
 
 
 
 
◆ resetRatingForUserAndObject()
  
  
      
        
          | static ilRating::resetRatingForUserAndObject  | 
          ( | 
          int  | 
          $a_obj_id,  | 
         
        
           | 
           | 
          string  | 
          $a_obj_type,  | 
         
        
           | 
           | 
          int  | 
          $a_sub_obj_id,  | 
         
        
           | 
           | 
          string  | 
          $a_sub_obj_type,  | 
         
        
           | 
           | 
          int  | 
          $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 105 of file class.ilRating.php.
References $DIC, and $ilDB.
Referenced by ilExcCriteriaRating\resetReview(), ilRatingGUI\resetUserRating(), and ilLMPresentationGUI\updatePageRating().
  114         $ilDB = $DIC->database();
   116         $ilDB->manipulate(
"DELETE FROM il_rating WHERE " .
   117             "user_id = " . 
$ilDB->quote($a_user_id, 
"integer") . 
" AND " .
   118             "obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") . 
" AND " .
   119             "obj_type = " . 
$ilDB->quote($a_obj_type, 
"text") . 
" AND " .
   120             "sub_obj_id = " . 
$ilDB->quote($a_sub_obj_id, 
"integer") . 
" AND " .
   121             $ilDB->equals(
"sub_obj_type", $a_sub_obj_type, 
"text", 
true));
 
 
 
 
◆ writeRatingForUserAndObject()
  
  
      
        
          | static ilRating::writeRatingForUserAndObject  | 
          ( | 
          int  | 
          $a_obj_id,  | 
         
        
           | 
           | 
          string  | 
          $a_obj_type,  | 
         
        
           | 
           | 
          ?int  | 
          $a_sub_obj_id,  | 
         
        
           | 
           | 
          ?string  | 
          $a_sub_obj_type,  | 
         
        
           | 
           | 
          int  | 
          $a_user_id,  | 
         
        
           | 
           | 
          int  | 
          $a_rating,  | 
         
        
           | 
           | 
          int  | 
          $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 39 of file class.ilRating.php.
References $DIC, $ilDB, and ANONYMOUS_USER_ID.
Referenced by ilRatingGUI\saveRating(), ilExcCriteriaRating\updateFromAjax(), and ilLMPresentationGUI\updatePageRating().
   50         $ilDB = $DIC->database();
    65             $ilDB->manipulate(
"DELETE FROM il_rating WHERE " .
    66                 "user_id = " . 
$ilDB->quote($a_user_id, 
"integer") . 
" AND " .
    67                 "obj_id = " . 
$ilDB->quote($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(0, 
"integer"));
    74         $ilDB->manipulate(
"DELETE FROM il_rating WHERE " .
    75             "user_id = " . 
$ilDB->quote($a_user_id, 
"integer") . 
" AND " .
    76             "obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") . 
" AND " .
    77             "obj_type = " . 
$ilDB->quote($a_obj_type, 
"text") . 
" AND " .
    78             "sub_obj_id = " . 
$ilDB->quote((
int) $a_sub_obj_id, 
"integer") . 
" AND " .
    79             $ilDB->equals(
"sub_obj_type", $a_sub_obj_type, 
"text", 
true) . 
" AND " .
    80             "category_id = " . 
$ilDB->quote($a_category_id, 
"integer"));
    83             $ilDB->manipulate(
"INSERT INTO il_rating (user_id, obj_id, obj_type," .
    84                 "sub_obj_id, sub_obj_type, category_id, rating, tstamp) VALUES (" .
    85                 $ilDB->quote($a_user_id, 
"integer") . 
"," .
    86                 $ilDB->quote($a_obj_id, 
"integer") . 
"," .
    87                 $ilDB->quote($a_obj_type, 
"text") . 
"," .
    88                 $ilDB->quote((
int) $a_sub_obj_id, 
"integer") . 
"," .
    89                 $ilDB->quote($a_sub_obj_type, 
"text") . 
"," .
    90                 $ilDB->quote($a_category_id, 
"integer") . 
"," .
    91                 $ilDB->quote($a_rating, 
"integer") . 
"," .
    92                 $ilDB->quote(time(), 
"integer") . 
")");
 
 
 
 
◆ $list_data
  
  
      
        
          | array ilRating::$list_data = [] | 
         
       
   | 
  
staticprotected   | 
  
 
 
The documentation for this class was generated from the following file: