28                 $a_user_id, $a_rating)
 
   32                 if ($a_user_id == ANONYMOUS_USER_ID)
 
   37                 $ilDB->manipulate(
"DELETE FROM il_rating WHERE ".
 
   38                         "user_id = ".$ilDB->quote($a_user_id, 
"integer").
" AND ".
 
   39                         "obj_id = ".$ilDB->quote((
int) $a_obj_id, 
"integer").
" AND ".
 
   40                         "obj_type = ".$ilDB->quote($a_obj_type, 
"text").
" AND ".
 
   41                         "sub_obj_id = ".$ilDB->quote((
int) $a_sub_obj_id, 
"integer").
" AND ".
 
   42                         $ilDB->equals(
"sub_obj_type", $a_sub_obj_type, 
"text", 
true));
 
   44                 $ilDB->manipulate(
"INSERT INTO il_rating (user_id, obj_id, obj_type,".
 
   45                         "sub_obj_id, sub_obj_type, rating) VALUES (".
 
   46                         $ilDB->quote($a_user_id, 
"integer").
",".
 
   47                         $ilDB->quote((
int) $a_obj_id, 
"integer").
",".
 
   48                         $ilDB->quote($a_obj_type, 
"text").
",".
 
   49                         $ilDB->quote((
int) $a_sub_obj_id, 
"integer").
",".
 
   50                         $ilDB->quote($a_sub_obj_type, 
"text").
",".
 
   51                         $ilDB->quote((
int) $a_rating, 
"integer").
")");
 
   68                 $q = 
"SELECT * FROM il_rating WHERE ".
 
   69                         "user_id = ".$ilDB->quote($a_user_id, 
"integer").
" AND ".
 
   70                         "obj_id = ".$ilDB->quote((
int) $a_obj_id, 
"integer").
" AND ".
 
   71                         "obj_type = ".$ilDB->quote($a_obj_type, 
"text").
" AND ".
 
   72                         "sub_obj_id = ".$ilDB->quote((
int) $a_sub_obj_id, 
"integer").
" AND ".
 
   73                         $ilDB->equals(
"sub_obj_type", $a_sub_obj_type, 
"text", 
true);
 
   74                 $set = $ilDB->query($q);
 
   75                 $rec = $ilDB->fetchAssoc($set);
 
   76                 return $rec[
"rating"];
 
   91                 $q = 
"SELECT count(*) as cnt, AVG(rating) as av FROM il_rating WHERE ".
 
   92                         "obj_id = ".$ilDB->quote((
int) $a_obj_id, 
"integer").
" AND ".
 
   93                         "obj_type = ".$ilDB->quote($a_obj_type, 
"text").
" AND ".
 
   94                         "sub_obj_id = ".$ilDB->quote((
int) $a_sub_obj_id, 
"integer").
" AND ".
 
   95                         $ilDB->equals(
"sub_obj_type", $a_sub_obj_type, 
"text", 
true);
 
   96                 $set = $ilDB->query($q);
 
   97                 $rec = $ilDB->fetchAssoc($set);
 
   98                 return array(
"cnt" => $rec[
"cnt"], 
"avg" => $rec[
"av"]);