ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilRating Class Reference

Class ilRating. More...

+ Collaboration diagram for ilRating:

Static Public Member Functions

static writeRatingForUserAndObject ($a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id, $a_rating)
 Write rating for a user and an object.
static getRatingForUserAndObject ($a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id)
 Get rating for a user and an object.
static getOverallRatingForObject ($a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type)
 Get overall rating for an object.

Detailed Description

Class ilRating.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 35 of file class.ilRating.php.

Member Function Documentation

static ilRating::getOverallRatingForObject (   $a_obj_id,
  $a_obj_type,
  $a_sub_obj_id,
  $a_sub_obj_type 
)
static

Get overall rating for an object.

Parameters
int$a_obj_idObject ID
string$a_obj_typeObject Type
int$a_sub_obj_idSubobject ID
string$a_sub_obj_typeSubobject Type

Definition at line 101 of file class.ilRating.php.

References DB_FETCHMODE_ASSOC.

Referenced by ilRatingGUI\getHTML().

{
global $ilDB;
$q = "SELECT count(*) as cnt, AVG(rating) as av FROM il_rating WHERE ".
"obj_id = ".$ilDB->quote($a_obj_id)." AND ".
"obj_type = ".$ilDB->quote($a_obj_type)." AND ".
"sub_obj_id = ".$ilDB->quote($a_sub_obj_id)." AND ".
"sub_obj_type = ".$ilDB->quote($a_sub_obj_type);
$set = $ilDB->query($q);
$rec = $set->fetchRow(DB_FETCHMODE_ASSOC);
return array("cnt" => $rec["cnt"], "avg" => $rec["av"]);
}

+ Here is the caller graph for this function:

static ilRating::getRatingForUserAndObject (   $a_obj_id,
  $a_obj_type,
  $a_sub_obj_id,
  $a_sub_obj_type,
  $a_user_id 
)
static

Get rating for a user and an object.

Parameters
int$a_obj_idObject ID
string$a_obj_typeObject Type
int$a_sub_obj_idSubobject ID
string$a_sub_obj_typeSubobject Type
int$a_user_idUser ID

Definition at line 77 of file class.ilRating.php.

References DB_FETCHMODE_ASSOC.

Referenced by ilRatingGUI\getHTML().

{
global $ilDB;
$q = "SELECT * FROM il_rating WHERE ".
"user_id = ".$ilDB->quote($a_user_id)." AND ".
"obj_id = ".$ilDB->quote($a_obj_id)." AND ".
"obj_type = ".$ilDB->quote($a_obj_type)." AND ".
"sub_obj_id = ".$ilDB->quote($a_sub_obj_id)." AND ".
"sub_obj_type = ".$ilDB->quote($a_sub_obj_type);
$set = $ilDB->query($q);
$rec = $set->fetchRow(DB_FETCHMODE_ASSOC);
return $rec["rating"];
}

+ Here is the caller graph for this function:

static ilRating::writeRatingForUserAndObject (   $a_obj_id,
  $a_obj_type,
  $a_sub_obj_id,
  $a_sub_obj_type,
  $a_user_id,
  $a_rating 
)
static

Write rating for a user and an object.

Parameters
int$a_obj_idObject ID
string$a_obj_typeObject Type
int$a_sub_obj_idSubobject ID
string$a_sub_obj_typeSubobject Type
int$a_user_idUser ID
int$a_ratingRating

Definition at line 47 of file class.ilRating.php.

Referenced by ilRatingGUI\saveRating().

{
global $ilDB;
if ($a_user_id == ANONYMOUS_USER_ID)
{
return;
}
$q = "REPLACE INTO il_rating (user_id, obj_id, obj_type,".
"sub_obj_id, sub_obj_type, rating) VALUES (".
$ilDB->quote($a_user_id).",".
$ilDB->quote($a_obj_id).",".
$ilDB->quote($a_obj_type).",".
$ilDB->quote($a_sub_obj_id).",".
$ilDB->quote($a_sub_obj_type).",".
$ilDB->quote($a_rating).")";
$ilDB->query($q);
}

+ Here is the caller graph for this function:


The documentation for this class was generated from the following file: