24 include_once(
"./Services/Rating/classes/class.ilRating.php");
40 $lng->loadLanguageModule(
"rating");
50 $next_class = $ilCtrl->getNextClass($this);
51 $cmd = $ilCtrl->getCmd();
69 function setObject($a_obj_id, $a_obj_type, $a_sub_obj_id = 0, $a_sub_obj_type =
"")
73 $this->obj_id = $a_obj_id;
74 $this->obj_type = $a_obj_type;
75 $this->sub_obj_id = $a_sub_obj_id;
76 $this->sub_obj_type = $a_sub_obj_type;
90 $this->userid = $a_userid;
100 return $this->userid;
110 $ttpl =
new ilTemplate(
"tpl.rating_input.html",
true,
true,
"Services/Rating");
114 $this->sub_obj_id, $this->sub_obj_type);
115 if ($rating[
"cnt"] >= 1)
117 for($i = 1; $i <= 5; $i++)
119 $ttpl->setCurrentBlock(
"rating_icon");
120 if ($rating[
"avg"] >= $i)
122 $ttpl->setVariable(
"SRC_ICON",
125 else if ($rating[
"avg"] + 1 <= $i)
127 $ttpl->setVariable(
"SRC_ICON",
132 $nr = round(($rating[
"avg"] + 1 - $i) * 10);
133 $ttpl->setVariable(
"SRC_ICON",
136 $ttpl->setVariable(
"ALT_ICON",
"(".$i.
"/5)");
137 $ttpl->parseCurrentBlock();
139 $ttpl->setCurrentBlock(
"rating_icon");
140 $ttpl->setVariable(
"TXT_OVERALL_RATING", $lng->txt(
"rating_average_rating"));
141 $ttpl->setVariable(
"NR_USERS",
142 sprintf($lng->txt(
"rating_nr_users"), $rating[
"cnt"]));
143 $ttpl->setVariable(
"VAL_OVERALL_RATING",
"(".round($rating[
"avg"], 1).
"/5)");
144 $ttpl->parseCurrentBlock();
148 if ($this->
getUserId() != ANONYMOUS_USER_ID)
151 $this->sub_obj_id, $this->sub_obj_type, $this->
getUserId());
154 for($i = 1; $i <= 5; $i++)
156 $ttpl->setCurrentBlock(
"rating_link");
157 $ilCtrl->setParameter($this,
"rating", $i);
158 $ttpl->setVariable(
"HREF_RATING", $ilCtrl->getLinkTarget($this,
"saveRating"));
161 $ttpl->setVariable(
"SRC_ICON",
166 $ttpl->setVariable(
"SRC_ICON",
169 $ttpl->setVariable(
"ALT_ICON",
"(".$i.
"/5)");
170 $ttpl->parseCurrentBlock();
172 $ttpl->setCurrentBlock(
"user_rating");
175 $ttpl->setVariable(
"TXT_YOUR_RATING", $lng->txt(
"rating_your_rating"));
178 $ttpl->setVariable(
"VAL_RATING",
"(".$rating.
"/5)");
180 $ttpl->parseCurrentBlock();
192 $this->sub_obj_id, $this->sub_obj_type, $this->
getUserId(),