ILIAS  eassessment Revision 61809
 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 15 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 87 of file class.ilRating.php.

References $ilDB.

Referenced by ilRatingGUI\getHTML().

{
global $ilDB;
$q = "SELECT count(*) as cnt, AVG(rating) as av FROM il_rating WHERE ".
"obj_id = ".$ilDB->quote((int) $a_obj_id, "integer")." AND ".
"obj_type = ".$ilDB->quote($a_obj_type, "text")." AND ".
"sub_obj_id = ".$ilDB->quote((int) $a_sub_obj_id, "integer")." AND ".
$ilDB->equals("sub_obj_type", $a_sub_obj_type, "text", true);
$set = $ilDB->query($q);
$rec = $ilDB->fetchAssoc($set);
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 63 of file class.ilRating.php.

References $ilDB.

Referenced by ilRatingGUI\getHTML().

{
global $ilDB;
$q = "SELECT * FROM il_rating WHERE ".
"user_id = ".$ilDB->quote($a_user_id, "integer")." AND ".
"obj_id = ".$ilDB->quote((int) $a_obj_id, "integer")." AND ".
"obj_type = ".$ilDB->quote($a_obj_type, "text")." AND ".
"sub_obj_id = ".$ilDB->quote((int) $a_sub_obj_id, "integer")." AND ".
$ilDB->equals("sub_obj_type", $a_sub_obj_type, "text", true);
$set = $ilDB->query($q);
$rec = $ilDB->fetchAssoc($set);
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 27 of file class.ilRating.php.

References $ilDB.

Referenced by ilRatingGUI\saveRating().

{
global $ilDB;
if ($a_user_id == ANONYMOUS_USER_ID)
{
return;
}
$ilDB->manipulate("DELETE FROM il_rating WHERE ".
"user_id = ".$ilDB->quote($a_user_id, "integer")." AND ".
"obj_id = ".$ilDB->quote((int) $a_obj_id, "integer")." AND ".
"obj_type = ".$ilDB->quote($a_obj_type, "text")." AND ".
"sub_obj_id = ".$ilDB->quote((int) $a_sub_obj_id, "integer")." AND ".
$ilDB->equals("sub_obj_type", $a_sub_obj_type, "text", true));
$ilDB->manipulate("INSERT INTO il_rating (user_id, obj_id, obj_type,".
"sub_obj_id, sub_obj_type, rating) VALUES (".
$ilDB->quote($a_user_id, "integer").",".
$ilDB->quote((int) $a_obj_id, "integer").",".
$ilDB->quote($a_obj_type, "text").",".
$ilDB->quote((int) $a_sub_obj_id, "integer").",".
$ilDB->quote($a_sub_obj_type, "text").",".
$ilDB->quote((int) $a_rating, "integer").")");
}

+ Here is the caller graph for this function:


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