ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 $fstorage; // [ilFSStorageExercise]
20  protected $invalid; // [int]
21 
31  public function __construct($a_parent_obj, $a_parent_cmd, ilExAssignment $a_ass, $a_user_id, array $a_peer_data)
32  {
33  global $ilCtrl;
34 
35  $this->ass = $a_ass;
36  $this->user_id = $a_user_id;
37  $this->peer_data = $a_peer_data;
38 
39  parent::__construct($a_parent_obj, $a_parent_cmd);
40 
41  $this->setLimit(9999);
42 
43  $this->setTitle($a_ass->getTitle().": ".$this->lng->txt("exc_peer_review").
44  " - ".$this->lng->txt("exc_peer_review_give"));
45 
46  if(!$this->ass->hasPeerReviewPersonalized())
47  {
48  $this->addColumn($this->lng->txt("id"), "seq");
49  }
50  else
51  {
52  $this->addColumn($this->lng->txt("exc_peer_review_recipient"), "name");
53  }
54  $this->addColumn($this->lng->txt("last_update"), "tstamp");
55  $this->addColumn($this->lng->txt("valid"), "valid");
56  $this->addColumn($this->lng->txt("action"), "");
57 
58  $this->setDefaultOrderField("tstamp");
59 
60  $this->setRowTemplate("tpl.exc_peer_review_row.html", "Modules/Exercise");
61 
62  $this->disable("numinfo");
63 
64  $this->getItems();
65 
66  if($this->ass->hasPeerReviewFileUpload())
67  {
68  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
69  $this->fstorage = new ilFSStorageExercise($this->ass->getExerciseId(), $this->ass->getId());
70  $this->fstorage->create();
71  }
72  }
73 
74  public function getInvalidItems()
75  {
76  return $this->invalid;
77  }
78 
79  protected function getItems()
80  {
81  $data = array();
82 
83  $personal = $this->ass->hasPeerReviewPersonalized();
84 
85  if($personal)
86  {
87  include_once "Services/User/classes/class.ilUserUtil.php";
88  }
89 
90  $peer_review = new ilExPeerReview($this->ass);
91 
92  foreach($this->peer_data as $item)
93  {
94  $row = array();
95 
96  $row["giver_id"] = $item["giver_id"];
97  $row["peer_id"] = $item["peer_id"];
98  $row["tstamp"] = $item["tstamp"];
99 
100  if(!$personal)
101  {
102  $row["seq"] = $item["seq"];
103  }
104  else
105  {
106  $row["name"] = ilUserUtil::getNamePresentation($item["peer_id"]);
107  }
108 
109  // validate
110  $row["valid"] = $all_empty = true;
111  $submission = new ilExSubmission($this->ass, $item["peer_id"]);
112  $values = $submission->getPeerReview()->getPeerReviewValues($item["giver_id"], $item["peer_id"]);
113  foreach($this->ass->getPeerReviewCriteriaCatalogueItems() as $crit)
114  {
115  $crit_id = $crit->getId()
116  ? $crit->getId()
117  : $crit->getType();
118  $crit->setPeerReviewContext(
119  $this->ass,
120  $item["giver_id"],
121  $item["peer_id"]
122  );
123  if(!$crit->validate($values[$crit_id]))
124  {
125  $row["valid"] = false;
126  }
127  if($crit->hasValue($values[$crit_id]))
128  {
129  $all_empty = false;
130  }
131  }
132  if($all_empty)
133  {
134  $row["valid"] = false;
135  }
136  if(!$row["valid"])
137  {
138  $this->invalid++;
139  }
140 
141  $data[] = $row;
142  }
143 
144  $this->setData($data);
145  }
146 
147  public function numericOrdering($a_field)
148  {
149  if(in_array($a_field, array("seq")))
150  {
151  return true;
152  }
153  return false;
154  }
155 
156  protected function fillRow($a_set)
157  {
158  global $ilCtrl;
159 
160  if(isset($a_set["seq"]))
161  {
162  $this->tpl->setVariable("VAL_SEQ", $a_set["seq"]);
163  }
164  else
165  {
166  $this->tpl->setVariable("VAL_SEQ", $a_set["name"]);
167  }
168 
169  if($a_set["tstamp"])
170  {
171  $a_set["tstamp"] = ilDatePresentation::formatDate(new ilDateTime($a_set["tstamp"], IL_CAL_DATETIME));
172  }
173  $this->tpl->setVariable("VAL_TSTAMP", $a_set["tstamp"]);
174 
175  $this->tpl->setVariable("VAL_STATUS", $a_set["valid"]
176  ? $this->lng->txt("yes")
177  : $this->lng->txt("no")
178  );
179 
180  $ilCtrl->setParameter($this->parent_obj, "peer_id", $a_set["peer_id"]);
181  $url = $ilCtrl->getLinkTarget($this->parent_obj, "editPeerReviewItem");
182  $ilCtrl->setParameter($this->parent_obj, "pid", "");
183 
184  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("edit"));
185  $this->tpl->setVariable("URL_ACTION", $url);
186  }
187 }
188 
189 ?>
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
Exercise assignment.
const IL_CAL_DATETIME
$url
Definition: shib_logout.php:72
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
List all peers to be reviewed for user.
Exercise peer review.
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, $a_return_data_array=false)
Default behaviour is:
Class ilTable2GUI.
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
setRowTemplate($a_template, $a_template_dir="")
Set row template.
__construct($a_parent_obj, $a_parent_cmd, ilExAssignment $a_ass, $a_user_id, array $a_peer_data)
Constructor.
disable($a_module_name)
diesables particular modules of table
Exercise submission.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setLimit($a_limit=0, $a_default_limit=0)