ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
4 include_once './Services/Table/classes/class.ilTable2GUI.php';
5 include_once './Modules/Exercise/classes/class.ilExAssignment.php';
6 include_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 
33  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)
34  {
35  global $ilCtrl;
36 
37  $this->ass = $a_ass;
38  $this->user_id = $a_user_id;
39  $this->peer_data = $a_peer_data;
40  $this->read_only = $a_read_only;
41 
42  parent::__construct($a_parent_obj, $a_parent_cmd);
43 
44  $this->setLimit(9999);
45 
46  $this->addColumn($this->lng->txt("id"), "seq");
47  if(!$this->read_only)
48  {
49  $this->addColumn($this->lng->txt("exc_submission"), "");
50  }
51  $this->addColumn($this->lng->txt("exc_peer_review_rating"), "mark");
52  $this->addColumn($this->lng->txt("exc_peer_review_comment"), "");
53  $this->addColumn($this->lng->txt("last_update"), "tstamp");
54 
55  $this->setDefaultOrderField("tstamp");
56 
57  $this->setRowTemplate("tpl.exc_peer_review_row.html", "Modules/Exercise");
58  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
59 
60  $this->setTitle($a_ass->getTitle().": ".$this->lng->txt("exc_peer_review")." - ".$this->lng->txt($a_title));
61 
62  if(!$this->read_only)
63  {
64  $this->addCommandButton("updatePeerReview", $this->lng->txt("save"));
65  }
66  $this->addCommandButton($a_cancel_cmd, $this->lng->txt("cancel"));
67 
68  $this->disable("numinfo");
69 
70  $this->getItems();
71  }
72 
73  protected function getItems()
74  {
75  $data = array();
76 
77  foreach($this->peer_data as $idx => $item)
78  {
79  $row = array();
80 
81  $row["seq"] = $idx+1;
82  $row["giver_id"] = $item["giver_id"];
83  $row["peer_id"] = $item["peer_id"];
84  $row["submission"] = "";
85  $row["mark"] = (int)round(ilRating::getRatingForUserAndObject($this->ass->getId(),
86  "ass", $item["peer_id"], "peer", $item["giver_id"]));
87  $row["comment"] = $item["pcomment"];
88  $row["tstamp"] = $item["tstamp"];
89 
90  $data[] = $row;
91  }
92 
93  $this->setData($data);
94  }
95 
96  public function numericOrdering($a_field)
97  {
98  if(in_array($a_field, array("mark", "tstamp")))
99  {
100  return true;
101  }
102  return false;
103  }
104 
105  protected function fillRow($a_set)
106  {
107  global $ilCtrl;
108 
109  $this->tpl->setVariable("VAL_SEQ", $a_set["seq"]);
110 
111  if($a_set["tstamp"])
112  {
113  $a_set["tstamp"] = ilDatePresentation::formatDate(new ilDateTime($a_set["tstamp"], IL_CAL_DATETIME));
114  }
115  $this->tpl->setVariable("VAL_TSTAMP", $a_set["tstamp"]);
116 
117 
118  // rating
119  $ilCtrl->setParameter($this->parent_obj, "peer_id", $a_set["peer_id"]);
120  $rating = new ilRatingGUI();
121  $rating->setObject($this->ass->getId(), "ass", $a_set["peer_id"], "peer");
122  $rating->setUserId($a_set["giver_id"]);
123  $this->tpl->setVariable("ID_RATING", "rtr_".$a_set["peer_id"]);
124  if(!$this->read_only)
125  {
126  $this->tpl->setVariable("VAL_RATING", $rating->getHTML(false, true,
127  "il.ExcPeerReview.saveComments(".$a_set["peer_id"].", %rating%)"));
128  }
129  else
130  {
131  $this->tpl->setVariable("VAL_RATING", $rating->getHTML(false, false));
132  }
133  $ilCtrl->setParameter($this->parent_obj, "peer_id", "");
134 
135 
136  // submission
137 
138  if(!$this->read_only)
139  {
140  $ilCtrl->setParameter($this->parent_obj, "seq", $a_set["seq"]);
141 
142  $file_info = ilExAssignment::getDownloadedFilesInfoForTableGUIS($this->parent_obj, $this->ass->getExerciseId(), $this->ass->getType(), $this->ass->getId(), $a_set["peer_id"]);
143 
144  $ilCtrl->setParameter($this->parent_obj, "seq", "");
145 
146  $this->tpl->setVariable("VAL_LAST_SUBMISSION", $file_info["last_submission"]["value"]);
147  $this->tpl->setVariable("TXT_LAST_SUBMISSION", $file_info["last_submission"]["txt"]);
148 
149  $this->tpl->setVariable("TXT_SUBMITTED_FILES", $file_info["files"]["txt"]);
150  $this->tpl->setVariable("VAL_SUBMITTED_FILES", $file_info["files"]["count"]);
151 
152  if($file_info["files"]["download_url"])
153  {
154  $this->tpl->setCurrentBlock("download_link");
155  $this->tpl->setVariable("LINK_DOWNLOAD", $file_info["files"]["download_url"]);
156  $this->tpl->setVariable("TXT_DOWNLOAD", $file_info["files"]["download_txt"]);
157  $this->tpl->parseCurrentBlock();
158  }
159 
160  if($file_info["files"]["download_new_url"])
161  {
162  $this->tpl->setCurrentBlock("download_link");
163  $this->tpl->setVariable("LINK_NEW_DOWNLOAD", $file_info["files"]["download_new_url"]);
164  $this->tpl->setVariable("TXT_NEW_DOWNLOAD", $file_info["files"]["download_new_txt"]);
165  $this->tpl->parseCurrentBlock();
166  }
167 
168 
169  $this->tpl->setCurrentBlock("pcomment_edit_bl");
170  $idx = $a_set["giver_id"]."__".$a_set["peer_id"];
171  $this->tpl->setVariable("VAL_ID", $idx);
172  $this->tpl->setVariable("VAL_PCOMMENT_EDIT", $a_set["comment"]);
173  $this->tpl->parseCurrentBlock();
174  }
175  else
176  {
177  $this->tpl->setCurrentBlock("pcomment_static_bl");
178  $this->tpl->setVariable("VAL_PCOMMENT_STATIC", $a_set["comment"]);
179  $this->tpl->parseCurrentBlock();
180  }
181  }
182 }
183 
184 ?>