ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 $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 #21260
50 $this->setDefaultOrderField("seq");
51 }
52 else
53 {
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 {
70 include_once("./Modules/Exercise/classes/class.ilFSStorageExercise.php");
71 $this->fstorage = new ilFSStorageExercise($this->ass->getExerciseId(), $this->ass->getId());
72 $this->fstorage->create();
73 }
74 }
75
76 public function getInvalidItems()
77 {
78 return $this->invalid;
79 }
80
81 protected function getItems()
82 {
83 $data = array();
84
85 $personal = $this->ass->hasPeerReviewPersonalized();
86
87 if($personal)
88 {
89 include_once "Services/User/classes/class.ilUserUtil.php";
90 }
91
92 $peer_review = new ilExPeerReview($this->ass);
93
94 foreach($this->peer_data as $item)
95 {
96 $row = array();
97
98 $row["giver_id"] = $item["giver_id"];
99 $row["peer_id"] = $item["peer_id"];
100 $row["tstamp"] = $item["tstamp"];
101
102 if(!$personal)
103 {
104 $row["seq"] = $item["seq"];
105 }
106 else
107 {
108 $row["name"] = ilUserUtil::getNamePresentation($item["peer_id"]);
109 }
110
111 // validate
112 $row["valid"] = $all_empty = true;
113 $submission = new ilExSubmission($this->ass, $item["peer_id"]);
114 $values = $submission->getPeerReview()->getPeerReviewValues($item["giver_id"], $item["peer_id"]);
115 foreach($this->ass->getPeerReviewCriteriaCatalogueItems() as $crit)
116 {
117 $crit_id = $crit->getId()
118 ? $crit->getId()
119 : $crit->getType();
120 $crit->setPeerReviewContext(
121 $this->ass,
122 $item["giver_id"],
123 $item["peer_id"]
124 );
125 if(!$crit->validate($values[$crit_id]))
126 {
127 $row["valid"] = false;
128 }
129 if($crit->hasValue($values[$crit_id]))
130 {
131 $all_empty = false;
132 }
133 }
134 if($all_empty)
135 {
136 $row["valid"] = false;
137 }
138 if(!$row["valid"])
139 {
140 $this->invalid++;
141 }
142
143 $data[] = $row;
144 }
145
146 $this->setData($data);
147 }
148
149 public function numericOrdering($a_field)
150 {
151 if(in_array($a_field, array("seq")))
152 {
153 return true;
154 }
155 return false;
156 }
157
158 protected function fillRow($a_set)
159 {
160 global $ilCtrl;
161
162 if(isset($a_set["seq"]))
163 {
164 $this->tpl->setVariable("VAL_SEQ", $a_set["seq"]);
165 }
166 else
167 {
168 $this->tpl->setVariable("VAL_SEQ", $a_set["name"]);
169 }
170
171 if($a_set["tstamp"])
172 {
173 $a_set["tstamp"] = ilDatePresentation::formatDate(new ilDateTime($a_set["tstamp"], IL_CAL_DATETIME));
174 }
175 $this->tpl->setVariable("VAL_TSTAMP", $a_set["tstamp"]);
176
177 $this->tpl->setVariable("VAL_STATUS", $a_set["valid"]
178 ? $this->lng->txt("yes")
179 : $this->lng->txt("no")
180 );
181
182 $ilCtrl->setParameter($this->parent_obj, "peer_id", $a_set["peer_id"]);
183 $url = $ilCtrl->getLinkTarget($this->parent_obj, "editPeerReviewItem");
184 $ilCtrl->setParameter($this->parent_obj, "pid", "");
185
186 $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("edit"));
187 $this->tpl->setVariable("URL_ACTION", $url);
188 }
189}
190
191?>
An exception for terminatinating execution or to throw for unit testing.
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)
Constructor.
Exercise assignment.
Exercise peer review.
Exercise submission.
Class ilTable2GUI.
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.
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.
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)
Default behaviour is:
global $ilCtrl
Definition: ilias.php:18
$url
Definition: shib_logout.php:72