ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC;
34 
35  $this->ctrl = $DIC->ctrl();
36  $ilCtrl = $DIC->ctrl();
37 
38  $this->ass = $a_ass;
39  $this->user_id = $a_user_id;
40  $this->peer_data = $a_peer_data;
41 
42  parent::__construct($a_parent_obj, $a_parent_cmd);
43 
44  $this->setLimit(9999);
45 
46  $this->setTitle($a_ass->getTitle() . ": " . $this->lng->txt("exc_peer_review") .
47  " - " . $this->lng->txt("exc_peer_review_give"));
48 
49  if (!$this->ass->hasPeerReviewPersonalized()) {
50  $this->addColumn($this->lng->txt("id"), "seq");
51  #21260
52  $this->setDefaultOrderField("seq");
53  } else {
54  $this->addColumn($this->lng->txt("exc_peer_review_recipient"), "name");
55  #21260
56  $this->setDefaultOrderField("name");
57  }
58  $this->addColumn($this->lng->txt("last_update"), "tstamp");
59  $this->addColumn($this->lng->txt("valid"), "valid");
60  $this->addColumn($this->lng->txt("action"), "");
61 
62  $this->setRowTemplate("tpl.exc_peer_review_row.html", "Modules/Exercise");
63 
64  $this->disable("numinfo");
65 
66  $this->getItems();
67 
68  if ($this->ass->hasPeerReviewFileUpload()) {
69  include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
70  $this->fstorage = new ilFSStorageExercise($this->ass->getExerciseId(), $this->ass->getId());
71  $this->fstorage->create();
72  }
73  }
74 
75  public function getInvalidItems()
76  {
77  return $this->invalid;
78  }
79 
80  protected function getItems()
81  {
82  $data = array();
83 
84  $personal = $this->ass->hasPeerReviewPersonalized();
85 
86  if ($personal) {
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  $row = array();
94 
95  if (ilObject::_lookupType($item["peer_id"]) != "usr") {
96  continue;
97  }
98 
99  $row["giver_id"] = $item["giver_id"];
100  $row["peer_id"] = $item["peer_id"];
101  $row["tstamp"] = $item["tstamp"];
102 
103  if (!$personal) {
104  $row["seq"] = $item["seq"];
105  } else {
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  $crit_id = $crit->getId()
115  ? $crit->getId()
116  : $crit->getType();
117  $crit->setPeerReviewContext(
118  $this->ass,
119  $item["giver_id"],
120  $item["peer_id"]
121  );
122  if (!$crit->validate($values[$crit_id])) {
123  $row["valid"] = false;
124  }
125  if ($crit->hasValue($values[$crit_id])) {
126  $all_empty = false;
127  }
128  }
129  if ($all_empty) {
130  $row["valid"] = false;
131  }
132  if (!$row["valid"]) {
133  $this->invalid++;
134  }
135 
136  $data[] = $row;
137  }
138 
139  $this->setData($data);
140  }
141 
142  public function numericOrdering($a_field)
143  {
144  if (in_array($a_field, array("seq"))) {
145  return true;
146  }
147  return false;
148  }
149 
150  protected function fillRow($a_set)
151  {
153 
154  if (isset($a_set["seq"])) {
155  $this->tpl->setVariable("VAL_SEQ", $a_set["seq"]);
156  } else {
157  $this->tpl->setVariable("VAL_SEQ", $a_set["name"]);
158  }
159 
160  if ($a_set["tstamp"]) {
161  $a_set["tstamp"] = ilDatePresentation::formatDate(new ilDateTime($a_set["tstamp"], IL_CAL_DATETIME));
162  }
163  $this->tpl->setVariable("VAL_TSTAMP", $a_set["tstamp"]);
164 
165  $this->tpl->setVariable(
166  "VAL_STATUS",
167  $a_set["valid"]
168  ? $this->lng->txt("yes")
169  : $this->lng->txt("no")
170  );
171 
172  $ilCtrl->setParameter($this->parent_obj, "peer_id", $a_set["peer_id"]);
173  $url = $ilCtrl->getLinkTarget($this->parent_obj, "editPeerReviewItem");
174  $ilCtrl->setParameter($this->parent_obj, "pid", "");
175 
176  $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("edit"));
177  $this->tpl->setVariable("URL_ACTION", $url);
178  }
179 }
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
Exercise assignment.
const IL_CAL_DATETIME
global $DIC
Definition: saml.php:7
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
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.
Class ilTable2GUI.
$values
Date and time handling
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, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
setRowTemplate($a_template, $a_template_dir="")
Set row template.
static _lookupType($a_id, $a_reference=false)
lookup object type
__construct($a_parent_obj, $a_parent_cmd, ilExAssignment $a_ass, $a_user_id, array $a_peer_data)
Constructor.
$row
disable($a_module_name)
diesables particular modules of table
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.
Exercise submission //TODO: This class has to much static methods related to delivered "files"...
$url
setLimit($a_limit=0, $a_default_limit=0)