ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilExAssignmentPeerReviewTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once './Services/Table/classes/class.ilTable2GUI.php';
5include_once './Modules/Exercise/classes/class.ilExAssignment.php';
6include_once './Services/Rating/classes/class.ilRatingGUI.php';
7
15{
16 protected $ass; // [ilExAssignment]
17 protected $user_id; // [int]
18 protected $peer_data; // [array]
19 protected $read_only; // [array]
20 protected $fstorage; // [ilFSStorageExercise]
21
34 public function __construct($a_parent_obj, $a_parent_cmd, ilExAssignment $a_ass, $a_user_id, array $a_peer_data, $a_title, $a_cancel_cmd, $a_read_only = false)
35 {
36 global $ilCtrl;
37
38 $this->ass = $a_ass;
39 $this->user_id = $a_user_id;
40 $this->peer_data = $a_peer_data;
41 $this->read_only = $a_read_only;
42
43 parent::__construct($a_parent_obj, $a_parent_cmd);
44
45 $this->setLimit(9999);
46
47 if(!$this->ass->hasPeerReviewPersonalized())
48 {
49 $this->addColumn($this->lng->txt("id"), "seq");
50 }
51 else if(!$this->read_only)
52 {
53 $this->addColumn($this->lng->txt("exc_peer_review_recipient"), "name");
54 }
55 else
56 {
57 $this->addColumn($this->lng->txt("exc_peer_review_giver"), "name");
58 }
59 if(!$this->read_only)
60 {
61 $this->addColumn($this->lng->txt("exc_submission"), "");
62 }
63
64 $this->addColumn($this->lng->txt("exc_peer_review_rating"), "mark");
65
66 if(!$this->read_only)
67 {
68 $this->addColumn($this->lng->txt("exc_peer_review_comment"), "");
69 }
70 else
71 {
72 $this->addColumn($this->lng->txt("exc_peer_review"), "");
73 }
74
75 $this->addColumn($this->lng->txt("last_update"), "tstamp");
76
77 $this->setDefaultOrderField("tstamp");
78
79 $this->setRowTemplate("tpl.exc_peer_review_row.html", "Modules/Exercise");
80 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
81
82 $this->setTitle($a_ass->getTitle().": ".$this->lng->txt("exc_peer_review")." - ".$this->lng->txt($a_title));
83
84 if(!$this->read_only)
85 {
86 $this->addCommandButton("updatePeerReview", $this->lng->txt("save"));
87 }
88 else
89 {
90 include_once "Services/User/classes/class.ilUserUtil.php";
91 $this->setDescription($this->lng->txt("exc_peer_review_recipient").
92 ": ".ilUserUtil::getNamePresentation($a_user_id));
93 }
94
95 $this->addCommandButton($a_cancel_cmd, $this->lng->txt("cancel"));
96
97 $this->disable("numinfo");
98
99 $this->getItems();
100
101 if($this->ass->hasPeerReviewFileUpload())
102 {
103 include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
104 $this->fstorage = new ilFSStorageExercise($this->ass->getExerciseId(), $this->ass->getId());
105 $this->fstorage->create();
106 }
107 }
108
109 protected function getItems()
110 {
111 $data = array();
112
113 $personal = $this->ass->hasPeerReviewPersonalized();
114
115 if($personal)
116 {
117 include_once "Services/User/classes/class.ilUserUtil.php";
118 }
119
120 foreach($this->peer_data as $idx => $item)
121 {
122 $row = array();
123
124 $row["giver_id"] = $item["giver_id"];
125 $row["peer_id"] = $item["peer_id"];
126 $row["submission"] = "";
127 $row["mark"] = (int)round(ilRating::getRatingForUserAndObject($this->ass->getId(),
128 "ass", $item["peer_id"], "peer", $item["giver_id"]));
129 $row["comment"] = $item["pcomment"];
130 $row["tstamp"] = $item["tstamp"];
131
132 if(!$personal)
133 {
134 $row["seq"] = $idx+1;
135 }
136 else if(!$this->read_only)
137 {
138 $row["name"] = ilUserUtil::getNamePresentation($item["peer_id"]);
139 }
140 else
141 {
142 $row["name"] = ilUserUtil::getNamePresentation($item["giver_id"]);
143 }
144
145 $data[] = $row;
146 }
147
148 $this->setData($data);
149 }
150
151 public function numericOrdering($a_field)
152 {
153 if(in_array($a_field, array("mark", "tstamp", "seq")))
154 {
155 return true;
156 }
157 return false;
158 }
159
160 protected function fillRow($a_set)
161 {
162 global $ilCtrl;
163
164 if(isset($a_set["seq"]))
165 {
166 $this->tpl->setVariable("VAL_SEQ", $a_set["seq"]);
167 }
168 else
169 {
170 $this->tpl->setVariable("VAL_SEQ", $a_set["name"]);
171 }
172
173 if($a_set["tstamp"])
174 {
175 $a_set["tstamp"] = ilDatePresentation::formatDate(new ilDateTime($a_set["tstamp"], IL_CAL_DATETIME));
176 }
177 $this->tpl->setVariable("VAL_TSTAMP", $a_set["tstamp"]);
178
179
180 // rating
181 $ilCtrl->setParameter($this->parent_obj, "peer_id", $a_set["peer_id"]);
182 $rating = new ilRatingGUI();
183 $rating->setObject($this->ass->getId(), "ass", $a_set["peer_id"], "peer");
184 $rating->setUserId($a_set["giver_id"]);
185 $this->tpl->setVariable("ID_RATING", "rtr_".$a_set["peer_id"]);
186 if(!$this->read_only)
187 {
188 $this->tpl->setVariable("VAL_RATING", $rating->getHTML(false, true,
189 "il.ExcPeerReview.saveComments(".$a_set["peer_id"].", %rating%)"));
190 }
191 else
192 {
193 $this->tpl->setVariable("VAL_RATING", $rating->getHTML(false, false));
194 }
195 $ilCtrl->setParameter($this->parent_obj, "peer_id", "");
196
197
198 // submission
199
200 $uploads = null;
201 if($this->ass->hasPeerReviewFileUpload())
202 {
203 $path = $this->fstorage->getPeerReviewUploadPath($a_set["peer_id"], $a_set["giver_id"]);
204 $uploads = glob($path."/*.*");
205 }
206
207 if(!$this->read_only)
208 {
209 $ilCtrl->setParameter($this->parent_obj, "seq", $a_set["seq"]);
210
211 $file_info = ilExAssignment::getDownloadedFilesInfoForTableGUIS($this->parent_obj, $this->ass->getExerciseId(), $this->ass->getType(), $this->ass->getId(), $a_set["peer_id"]);
212
213 $ilCtrl->setParameter($this->parent_obj, "seq", "");
214
215 $this->tpl->setVariable("VAL_LAST_SUBMISSION", $file_info["last_submission"]["value"]);
216 $this->tpl->setVariable("TXT_LAST_SUBMISSION", $file_info["last_submission"]["txt"]);
217
218 $this->tpl->setVariable("TXT_SUBMITTED_FILES", $file_info["files"]["txt"]);
219 $this->tpl->setVariable("VAL_SUBMITTED_FILES", $file_info["files"]["count"]);
220
221 if($file_info["files"]["download_url"])
222 {
223 $this->tpl->setCurrentBlock("download_link");
224 $this->tpl->setVariable("LINK_DOWNLOAD", $file_info["files"]["download_url"]);
225 $this->tpl->setVariable("TXT_DOWNLOAD", $file_info["files"]["download_txt"]);
226 $this->tpl->parseCurrentBlock();
227 }
228
229 if($file_info["files"]["download_new_url"])
230 {
231 $this->tpl->setCurrentBlock("download_link");
232 $this->tpl->setVariable("LINK_NEW_DOWNLOAD", $file_info["files"]["download_new_url"]);
233 $this->tpl->setVariable("TXT_NEW_DOWNLOAD", $file_info["files"]["download_new_txt"]);
234 $this->tpl->parseCurrentBlock();
235 }
236
237 $idx = $a_set["giver_id"]."__".$a_set["peer_id"];
238
239 // file edit link
240 if($this->ass->hasPeerReviewFileUpload())
241 {
242 $ilCtrl->setParameter($this->parent_obj, "fu", $idx);
243 $ilCtrl->setParameter($this->parent_obj, "fsmode", "peer");
244 $url = $ilCtrl->getLinkTargetByClass("ilfilesystemgui", "listFiles");
245 $ilCtrl->setParameter($this->parent_obj, "fsmode", "");
246 $ilCtrl->setParameter($this->parent_obj, "fu", "");
247
248 $this->tpl->setCurrentBlock("file_edit_bl");
249 $this->tpl->setVariable("FILE_EDIT_URL", $url);
250 $this->tpl->setVariable("FILE_EDIT_CAPTION", $uploads
251 ? $this->lng->txt("exc_peer_edit_file")
252 : $this->lng->txt("exc_peer_upload_file"));
253 $this->tpl->parseCurrentBlock();
254 }
255
256 $this->tpl->setCurrentBlock("pcomment_edit_bl");
257 $this->tpl->setVariable("VAL_ID", $idx);
258 $this->tpl->setVariable("VAL_PCOMMENT_EDIT", $a_set["comment"]);
259 $this->tpl->parseCurrentBlock();
260 }
261 else
262 {
263 $this->tpl->setCurrentBlock("pcomment_static_bl");
264 $this->tpl->setVariable("VAL_PCOMMENT_STATIC", $a_set["comment"]);
265 $this->tpl->parseCurrentBlock();
266 }
267
268 // list existing files
269 if($uploads)
270 {
271 $idx = $a_set["giver_id"]."__".$a_set["peer_id"];
272
273 $ilCtrl->setParameter($this->parent_obj, "fu", $idx);
274
275 foreach($uploads as $upload)
276 {
277 $ilCtrl->setParameter($this->parent_obj, "fuf", md5($upload));
278 $url = $ilCtrl->getLinkTarget($this->parent_obj, "downloadPeerReview");
279 $ilCtrl->setParameter($this->parent_obj, "fuf", "");
280
281 $this->tpl->setCurrentBlock("file_static_bl");
282 $this->tpl->setVariable("FILE_NAME", basename($upload));
283 $this->tpl->setVariable("FILE_URL", $url);
284 $this->tpl->parseCurrentBlock();
285 }
286
287 $ilCtrl->setParameter($this->parent_obj, "fu", "");
288 }
289 }
290}
291
292?>
const IL_CAL_DATETIME
static formatDate(ilDateTime $date)
Format a date @access public.
@classDescription Date and time handling
numericOrdering($a_field)
Should this field be sorted numeric?
__construct($a_parent_obj, $a_parent_cmd, ilExAssignment $a_ass, $a_user_id, array $a_peer_data, $a_title, $a_cancel_cmd, $a_read_only=false)
Constructor.
Exercise assignment.
static getDownloadedFilesInfoForTableGUIS($a_parent_obj, $a_exercise_id, $a_ass_type, $a_ass_id, $a_user_id, $a_parent_cmd=null)
Class ilRatingGUI.
static getRatingForUserAndObject($a_obj_id, $a_obj_type, $a_sub_obj_id, $a_sub_obj_type, $a_user_id, $a_category_id=null)
Get rating for a user and an object.
Class ilTable2GUI.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="")
Add a column to the header.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setDescription($a_val)
Set description.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
disable($a_module_name)
diesables particular modules of table
setLimit($a_limit=0, $a_default_limit=0)
set max.
static getNamePresentation($a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true)
Default behaviour is:
global $ilCtrl
Definition: ilias.php:18
$path
Definition: index.php:22