ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
11{
12 protected $ass; // [ilExAssignment]
13 protected $user_id; // [int]
14 protected $peer_data; // [array]
15 protected $fstorage; // [ilFSStorageExercise]
16 protected $invalid; // [int]
17
27 public function __construct($a_parent_obj, $a_parent_cmd, ilExAssignment $a_ass, $a_user_id, array $a_peer_data)
28 {
29 global $DIC;
30
31 $this->ctrl = $DIC->ctrl();
32 $ilCtrl = $DIC->ctrl();
33
34 $this->ass = $a_ass;
35 $this->user_id = $a_user_id;
36 $this->peer_data = $a_peer_data;
37
38 parent::__construct($a_parent_obj, $a_parent_cmd);
39
40 $this->setLimit(9999);
41
42 $this->setTitle($a_ass->getTitle() . ": " . $this->lng->txt("exc_peer_review") .
43 " - " . $this->lng->txt("exc_peer_review_give"));
44
45 if (!$this->ass->hasPeerReviewPersonalized()) {
46 $this->addColumn($this->lng->txt("id"), "seq");
47 #21260
48 $this->setDefaultOrderField("seq");
49 } else {
50 $this->addColumn($this->lng->txt("exc_peer_review_recipient"), "name");
51 #21260
52 $this->setDefaultOrderField("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->setRowTemplate("tpl.exc_peer_review_row.html", "Modules/Exercise");
59
60 $this->disable("numinfo");
61
62 $this->getItems();
63
64 if ($this->ass->hasPeerReviewFileUpload()) {
65 $this->fstorage = new ilFSStorageExercise($this->ass->getExerciseId(), $this->ass->getId());
66 $this->fstorage->create();
67 }
68 }
69
70 public function getInvalidItems()
71 {
72 return $this->invalid;
73 }
74
75 protected function getItems()
76 {
77 $data = array();
78
79 $personal = $this->ass->hasPeerReviewPersonalized();
80
81 if ($personal) {
82 }
83
84 $peer_review = new ilExPeerReview($this->ass);
85
86 foreach ($this->peer_data as $item) {
87 $row = array();
88
89 if (ilObject::_lookupType($item["peer_id"]) != "usr") {
90 continue;
91 }
92
93 $row["giver_id"] = $item["giver_id"];
94 $row["peer_id"] = $item["peer_id"];
95 $row["tstamp"] = $item["tstamp"];
96
97 if (!$personal) {
98 $row["seq"] = $item["seq"];
99 } else {
100 $row["name"] = ilUserUtil::getNamePresentation($item["peer_id"]);
101 }
102
103 // validate
104 $row["valid"] = $all_empty = true;
105 $submission = new ilExSubmission($this->ass, $item["peer_id"]);
106 $values = $submission->getPeerReview()->getPeerReviewValues($item["giver_id"], $item["peer_id"]);
107 foreach ($this->ass->getPeerReviewCriteriaCatalogueItems() as $crit) {
108 $crit_id = $crit->getId()
109 ? $crit->getId()
110 : $crit->getType();
111 $crit->setPeerReviewContext(
112 $this->ass,
113 $item["giver_id"],
114 $item["peer_id"]
115 );
116 if (!$crit->validate($values[$crit_id])) {
117 $row["valid"] = false;
118 }
119 if ($crit->hasValue($values[$crit_id])) {
120 $all_empty = false;
121 }
122 }
123 if ($all_empty) {
124 $row["valid"] = false;
125 }
126 if (!$row["valid"]) {
127 $this->invalid++;
128 }
129
130 $data[] = $row;
131 }
132
133 $this->setData($data);
134 }
135
136 public function numericOrdering($a_field)
137 {
138 if (in_array($a_field, array("seq"))) {
139 return true;
140 }
141 return false;
142 }
143
144 protected function fillRow($a_set)
145 {
147
148 if (isset($a_set["seq"])) {
149 $this->tpl->setVariable("VAL_SEQ", $a_set["seq"]);
150 } else {
151 $this->tpl->setVariable("VAL_SEQ", $a_set["name"]);
152 }
153
154 if ($a_set["tstamp"]) {
155 $a_set["tstamp"] = ilDatePresentation::formatDate(new ilDateTime($a_set["tstamp"], IL_CAL_DATETIME));
156 }
157 $this->tpl->setVariable("VAL_TSTAMP", $a_set["tstamp"]);
158
159 $this->tpl->setVariable(
160 "VAL_STATUS",
161 $a_set["valid"]
162 ? $this->lng->txt("yes")
163 : $this->lng->txt("no")
164 );
165
166 $ilCtrl->setParameter($this->parent_obj, "peer_id", $a_set["peer_id"]);
167 $url = $ilCtrl->getLinkTarget($this->parent_obj, "editPeerReviewItem");
168 $ilCtrl->setParameter($this->parent_obj, "pid", "");
169
170 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("edit"));
171 $this->tpl->setVariable("URL_ACTION", $url);
172 }
173}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
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)
Constructor.
Exercise assignment.
Exercise peer review.
Exercise submission //TODO: This class has to much static methods related to delivered "files".
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilTable2GUI.
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.
setLimit($a_limit=0, $a_default_limit=0)
set max.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
disable($a_module_name)
diesables particular modules of table
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:
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$url
$DIC
Definition: xapitoken.php:46