protected function getItems()
 {
     $data = array();
     foreach ($this->peer_data as $idx => $item) {
         $row = array();
         $row["seq"] = $idx + 1;
         $row["giver_id"] = $item["giver_id"];
         $row["peer_id"] = $item["peer_id"];
         $row["submission"] = "";
         $row["mark"] = (int) round(ilRating::getRatingForUserAndObject($this->ass->getId(), "ass", $item["peer_id"], "peer", $item["giver_id"]));
         $row["comment"] = $item["pcomment"];
         $row["tstamp"] = $item["tstamp"];
         $data[] = $row;
     }
     $this->setData($data);
 }
 public static function countGivenFeedback($a_ass_id)
 {
     global $ilDB, $ilUser;
     $cnt = 0;
     include_once './Services/Rating/classes/class.ilRating.php';
     $set = $ilDB->query("SELECT *" . " FROM exc_assignment_peer" . " WHERE ass_id = " . $ilDB->quote($a_ass_id, "integer") . " AND giver_id = " . $ilDB->quote($ilUser->getId(), "integer"));
     while ($row = $ilDB->fetchAssoc($set)) {
         if (trim($row["pcomment"])) {
             $cnt++;
         } else {
             $mark = (int) round(ilRating::getRatingForUserAndObject($a_ass_id, "ass", $row["peer_id"], "peer", $row["giver_id"]));
             if ($mark) {
                 $cnt++;
             }
         }
     }
     return $cnt;
 }
 /**
  * Get HTML for rating of an object (and a user)
  */
 function getHTML()
 {
     global $lng;
     $categories = array();
     if ($this->enable_categories) {
         $categories = ilRatingCategory::getAllForObject($this->obj_id);
     }
     $may_rate = $this->getUserId() != ANONYMOUS_USER_ID;
     $has_overlay = false;
     if ($may_rate || $categories) {
         $has_overlay = true;
     }
     $ttpl = new ilTemplate("tpl.rating_input.html", true, true, "Services/Rating");
     // user rating
     $user_rating = 0;
     if ($may_rate) {
         $user_rating = round(ilRating::getRatingForUserAndObject($this->obj_id, $this->obj_type, $this->sub_obj_id, $this->sub_obj_type, $this->getUserId()));
     }
     // (1) overall rating
     $rating = ilRating::getOverallRatingForObject($this->obj_id, $this->obj_type, $this->sub_obj_id, $this->sub_obj_type);
     for ($i = 1; $i <= 5; $i++) {
         if ($i == $user_rating) {
             $ttpl->setCurrentBlock("rating_mark");
             $ttpl->setVariable("SRC_MARK", ilUtil::getImagePath("icon_rate_marker.png"));
             $ttpl->parseCurrentBlock();
         }
         $ttpl->setCurrentBlock("rating_icon");
         if ($rating["avg"] >= $i) {
             $ttpl->setVariable("SRC_ICON", ilUtil::getImagePath("icon_rate_on.png"));
         } else {
             if ($rating["avg"] + 1 <= $i) {
                 $ttpl->setVariable("SRC_ICON", ilUtil::getImagePath("icon_rate_off.png"));
             } else {
                 $nr = round(($rating["avg"] + 1 - $i) * 10);
                 $ttpl->setVariable("SRC_ICON", ilUtil::getImagePath("icon_rate_{$nr}.png"));
             }
         }
         $ttpl->setVariable("ALT_ICON", "(" . $i . "/5)");
         $ttpl->parseCurrentBlock();
     }
     $ttpl->setCurrentBlock("rating_icon");
     if ($rating["cnt"] == 0) {
         $tt = $lng->txt("rat_not_rated_yet");
     } else {
         if ($rating["cnt"] == 1) {
             $tt = $lng->txt("rat_one_rating");
         } else {
             $tt = sprintf($lng->txt("rat_nr_ratings"), $rating["cnt"]);
         }
     }
     include_once "./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
     ilTooltipGUI::addTooltip($this->id . "_tt", $tt);
     if ($rating["cnt"] > 0) {
         $ttpl->setCurrentBlock("rat_nr");
         $ttpl->setVariable("RT_NR", $rating["cnt"]);
         $ttpl->parseCurrentBlock();
     }
     // add overlay (trigger)
     if ($has_overlay) {
         include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php";
         $ov = new ilOverlayGUI($this->id);
         $ov->setTrigger("tr_" . $this->id, "click", "tr_" . $this->id);
         $ov->add();
         $ttpl->setCurrentBlock("act_rat_start");
         $ttpl->setVariable("ID", $this->id);
         $ttpl->setVariable("SRC_ARROW", ilUtil::getImagePath("mm_down_arrow_dark.png"));
         $ttpl->parseCurrentBlock();
         $ttpl->setCurrentBlock("act_rat_end");
         $ttpl->setVariable("SRC_ARROW", ilUtil::getImagePath("mm_down_arrow_dark.png"));
         $ttpl->parseCurrentBlock();
     }
     $ttpl->parseCurrentBlock();
     // (2) user rating
     if ($has_overlay) {
         $ttpl->setVariable("RATING_DETAILS", $this->renderDetails("rtov_", $may_rate, $categories));
         $ttpl->setCurrentBlock("user_rating");
         $ttpl->setVariable("ID", $this->id);
         $ttpl->parseCurrentBlock();
     }
     $ttpl->setVariable("TTID", $this->id);
     return $ttpl->get();
 }
 public function getAllPeerReviews($a_validate = true)
 {
     global $ilDB;
     $res = array();
     include_once './Services/Rating/classes/class.ilRating.php';
     $set = $ilDB->query("SELECT *" . " FROM exc_assignment_peer" . " WHERE ass_id = " . $ilDB->quote($this->getId(), "integer") . " ORDER BY peer_id");
     while ($row = $ilDB->fetchAssoc($set)) {
         $rating = round(ilRating::getRatingForUserAndObject($this->getId(), "ass", $row["peer_id"], "peer", $row["giver_id"]));
         if (!$a_validate || self::validatePeerReview($row, $rating)) {
             $res[$row["peer_id"]][$row["giver_id"]] = array($row["pcomment"], $rating);
         }
     }
     return $res;
 }
 protected function getItems()
 {
     $data = array();
     $personal = $this->ass->hasPeerReviewPersonalized();
     if ($personal) {
         include_once "Services/User/classes/class.ilUserUtil.php";
     }
     foreach ($this->peer_data as $idx => $item) {
         $row = array();
         $row["giver_id"] = $item["giver_id"];
         $row["peer_id"] = $item["peer_id"];
         $row["submission"] = "";
         $row["mark"] = (int) round(ilRating::getRatingForUserAndObject($this->ass->getId(), "ass", $item["peer_id"], "peer", $item["giver_id"]));
         $row["comment"] = $item["pcomment"];
         $row["tstamp"] = $item["tstamp"];
         if (!$personal) {
             $row["seq"] = $idx + 1;
         } else {
             if (!$this->read_only) {
                 $row["name"] = ilUserUtil::getNamePresentation($item["peer_id"]);
             } else {
                 $row["name"] = ilUserUtil::getNamePresentation($item["giver_id"]);
             }
         }
         $data[] = $row;
     }
     $this->setData($data);
 }