4 include_once(
"./Services/Rating/classes/class.ilRating.php");
16 protected $id =
"rtg_";
22 $lng->loadLanguageModule(
"rating");
32 $next_class = $ilCtrl->getNextClass($this);
33 $cmd = $ilCtrl->getCmd();
51 function setObject($a_obj_id, $a_obj_type, $a_sub_obj_id = 0, $a_sub_obj_type =
"")
55 $this->obj_id = $a_obj_id;
56 $this->obj_type = $a_obj_type;
57 $this->sub_obj_id = $a_sub_obj_id;
58 $this->sub_obj_type = $a_sub_obj_type;
59 $this->
id =
"rtg_".$this->obj_id.
"_".$this->obj_type.
"_".$this->sub_obj_id.
"_".
74 $this->userid = $a_userid;
94 $this->your_rating_text = $a_val;
104 return $this->your_rating_text;
114 $ttpl =
new ilTemplate(
"tpl.rating_input.html",
true,
true,
"Services/Rating");
118 if ($this->
getUserId() != ANONYMOUS_USER_ID)
121 $this->sub_obj_id, $this->sub_obj_type, $this->
getUserId());
127 $this->sub_obj_id, $this->sub_obj_type);
129 for($i = 1; $i <= 5; $i++)
131 if ($i == $user_rating)
133 $ttpl->setCurrentBlock(
"rating_mark");
134 $ttpl->setVariable(
"SRC_MARK",
136 $ttpl->parseCurrentBlock();
139 $ttpl->setCurrentBlock(
"rating_icon");
140 if ($rating[
"avg"] >= $i)
142 $ttpl->setVariable(
"SRC_ICON",
145 else if ($rating[
"avg"] + 1 <= $i)
147 $ttpl->setVariable(
"SRC_ICON",
152 $nr = round(($rating[
"avg"] + 1 - $i) * 10);
153 $ttpl->setVariable(
"SRC_ICON",
156 $ttpl->setVariable(
"ALT_ICON",
"(".$i.
"/5)");
157 $ttpl->parseCurrentBlock();
159 $ttpl->setCurrentBlock(
"rating_icon");
160 if ($rating[
"cnt"] == 0)
162 $tt = $lng->txt(
"rat_not_rated_yet");
164 else if ($rating[
"cnt"] == 1)
166 $tt = $lng->txt(
"rat_one_rating");
171 sprintf($lng->txt(
"rat_nr_ratings"), $rating[
"cnt"]);
173 include_once(
"./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
175 if ($rating[
"cnt"] > 0)
177 $ttpl->setCurrentBlock(
"rat_nr");
178 $ttpl->setVariable(
"RT_NR", $rating[
"cnt"]);
179 $ttpl->parseCurrentBlock();
182 if ($this->
getUserId() != ANONYMOUS_USER_ID)
184 include_once(
"./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
186 $ov->setTrigger(
"tr_".$this->
id,
"click",
"tr_".$this->
id);
189 $ttpl->setCurrentBlock(
"act_rat_start");
190 $ttpl->setVariable(
"ID", $this->
id);
192 $ttpl->parseCurrentBlock();
195 $ttpl->setCurrentBlock(
"act_rat_end");
197 $ttpl->parseCurrentBlock();
200 $ttpl->parseCurrentBlock();
203 if ($this->
getUserId() != ANONYMOUS_USER_ID)
205 $rating = $user_rating;
208 for($i = 1; $i <= 5; $i++)
210 $ttpl->setCurrentBlock(
"rating_link");
211 $ilCtrl->setParameter($this,
"rating", $i);
212 $ttpl->setVariable(
"HREF_RATING", $ilCtrl->getLinkTarget($this,
"saveRating"));
215 $ttpl->setVariable(
"SRC_ICON",
220 $ttpl->setVariable(
"SRC_ICON",
223 $ttpl->setVariable(
"ALT_ICON",
"(".$i.
"/5)");
224 $ttpl->parseCurrentBlock();
226 $ttpl->setCurrentBlock(
"user_rating");
227 $ttpl->setVariable(
"ID", $this->
id);
232 : $lng->txt(
"rating_your_rating");
233 $ttpl->setVariable(
"TXT_YOUR_RATING", $rate_text);
234 $ttpl->parseCurrentBlock();
237 $ttpl->setVariable(
"TTID", $this->
id);
248 $this->sub_obj_id, $this->sub_obj_type, $this->
getUserId(),