Ejemplo n.º 1
0
 function getRatingData($user, $showGraph = false)
 {
     require_once ROOT_DIR . '/Drivers/marmot_inc/UserRating.php';
     //Set default rating data
     $ratingData = array('average' => 0, 'count' => 0, 'user' => 0);
     //Get rating data for the resource
     $sql = "SELECT AVG(rating) average, count(rating) count from econtent_rating where recordId =  '{$this->recordId}'";
     $rating = new EContentRating();
     $rating->query($sql);
     if ($rating->N > 0) {
         $rating->fetch();
         $ratingData['average'] = number_format($rating->average, 2);
         $ratingData['count'] = $rating->count;
     }
     //Get user rating
     if (isset($user) && $user != false) {
         $rating = new EContentRating();
         $rating->userId = $user->id;
         $rating->recordId = $this->recordId;
         $rating->find();
         if ($rating->N) {
             $rating->fetch();
             $ratingData['user'] = $rating->rating;
         }
     }
     return $ratingData;
 }
Ejemplo n.º 2
0
 /**
  * Get ratings as a tab separated file
  *
  * First column : ItemId
  * Second Column : Rating Average (should be between 0 and 5, decimals are accepted)
  * Third column : Total votes
  * It is VERY important that the frist column represents the "itemId"
  * has the same id that the one you are sending us with your catalog,
  * because that is what we use to link your products with its ratings
  */
 function getRatingInfo()
 {
     require_once ROOT_DIR . '/Drivers/marmot_inc/UserRating.php';
     $ratings = new UserRating();
     $ratings->query("SELECT record_id, AVG(rating) as averageRating, count(resource.id) as numRatings from user_rating INNER JOIN resource on resourceid = resource.id GROUP BY record_id");
     $tabbedData = '';
     while ($ratings->fetch()) {
         $tabbedData .= "{$ratings->record_id}\t{$ratings->averageRating}\t{$ratings->numRatings}\r\n";
     }
     //Get eContent Ratings as well
     require_once ROOT_DIR . '/sys/eContent/EContentRating.php';
     $eContentRatings = new EContentRating();
     $eContentRatings->query("SELECT recordId, AVG(rating)as averageRating, count(id) as numRatings FROM `econtent_rating` GROUP BY recordId");
     while ($eContentRatings->fetch()) {
         $tabbedData .= "econtentRecord{$eContentRatings->recordId}\t{$eContentRatings->averageRating}\t{$eContentRatings->numRatings}\r\n";
     }
     return $tabbedData;
 }
Ejemplo n.º 3
0
 function rating()
 {
     require_once ROOT_DIR . '/sys/eContent/EContentRating.php';
     $econtentRating = new EContentRating();
     $query = "SELECT AVG(rating) as avgRating from econtent_rating where recordId = {$this->id}";
     $econtentRating->query($query);
     if ($econtentRating->N > 0) {
         $econtentRating->fetch();
         if ($econtentRating->avgRating == 0) {
             return -2.5;
         } else {
             return $econtentRating->avgRating;
         }
     } else {
         return -2.5;
     }
 }