ILIAS  release_8 Revision v8.24
class.ilExAssignmentPeerReviewTableGUI.php
Go to the documentation of this file.
1<?php
2
26{
28 protected int $user_id = 0;
29 protected array $peer_data = [];
31 protected int $invalid = 0;
32
33 public function __construct(
34 object $a_parent_obj,
35 string $a_parent_cmd,
36 ilExAssignment $a_ass,
37 int $a_user_id,
38 array $a_peer_data
39 ) {
40 global $DIC;
41
42 $this->ctrl = $DIC->ctrl();
43 $this->ass = $a_ass;
44 $this->user_id = $a_user_id;
45 $this->peer_data = $a_peer_data;
46 $this->setId("exc_peer_rv_fb");
47 parent::__construct($a_parent_obj, $a_parent_cmd);
48
49 $this->setLimit(9999);
50
51 $this->setTitle(
52 $a_ass->getTitle() . ": " . $this->lng->txt("exc_peer_review") .
53 " - " . $this->lng->txt("exc_peer_review_give")
54 );
55
56 if (!$this->ass->hasPeerReviewPersonalized()) {
57 $this->addColumn($this->lng->txt("id"), "seq");
58 #21260
59 $this->setDefaultOrderField("seq");
60 } else {
61 $this->addColumn($this->lng->txt("exc_peer_review_recipient"), "name");
62 #21260
63 $this->setDefaultOrderField("name");
64 }
65 $this->addColumn($this->lng->txt("last_update"), "tstamp");
66 $this->addColumn($this->lng->txt("valid"), "valid");
67 $this->addColumn($this->lng->txt("action"), "");
68
69 $this->setRowTemplate("tpl.exc_peer_review_row.html", "Modules/Exercise");
70
71 $this->disable("numinfo");
72
73 $this->getItems();
74
75 if ($this->ass->hasPeerReviewFileUpload()) {
76 $this->fstorage = new ilFSStorageExercise($this->ass->getExerciseId(), $this->ass->getId());
77 $this->fstorage->create();
78 }
79 }
80
81 public function getInvalidItems(): int
82 {
83 return $this->invalid;
84 }
85
86 protected function getItems(): void
87 {
88 $data = array();
89
90 $personal = $this->ass->hasPeerReviewPersonalized();
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] ?? null)) {
123 $row["valid"] = false;
124 }
125 if ($crit->hasValue($values[$crit_id] ?? null)) {
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(string $a_field): bool
143 {
144 return $a_field === "seq";
145 }
146
150 protected function fillRow(array $a_set): void
151 {
152 $ilCtrl = $this->ctrl;
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}
const IL_CAL_DATETIME
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
numericOrdering(string $a_field)
Should this field be sorted numeric?
__construct(object $a_parent_obj, string $a_parent_cmd, ilExAssignment $a_ass, int $a_user_id, array $a_peer_data)
Exercise assignment.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setData(array $a_data)
Set table data.
disable(string $a_module_name)
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link="", bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$url