ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilExcCriteriaCatalogueTableGUI.php
Go to the documentation of this file.
1<?php
2
26{
27 protected int $exc_id;
28 protected \ilGlobalTemplateInterface $main_tpl;
29
30 public function __construct(
31 object $a_parent_obj,
32 string $a_parent_cmd,
33 int $a_exc_id
34 ) {
35 global $DIC;
36 $this->main_tpl = $DIC->ui()->mainTemplate();
37
38 $this->ctrl = $DIC->ctrl();
39 $this->lng = $DIC->language();
40 $ilCtrl = $DIC->ctrl();
41 $lng = $DIC->language();
42
43 $this->exc_id = $a_exc_id;
44 $this->setId("exccritcat" . $this->exc_id);
45
46 parent::__construct($a_parent_obj, $a_parent_cmd);
47
48 $this->setLimit(9999); // because of manual order
49
50 $this->setTitle($lng->txt("exc_criteria_catalogues"));
51
52 $this->addColumn("", "", "1", true);
53 $this->addColumn($this->lng->txt("position"), "pos", "10%");
54 $this->addColumn($this->lng->txt("title"), "title");
55 $this->addColumn($this->lng->txt("exc_criterias"));
56 $this->addColumn($this->lng->txt("exc_assignments"));
57 $this->addColumn($this->lng->txt("actions"));
58
59 $this->setDefaultOrderField("pos");
60 $this->setDefaultOrderDirection("asc");
61
62 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
63 $this->setRowTemplate("tpl.exc_crit_cat_row.html", "components/ILIAS/Exercise");
64 $this->setSelectAllCheckbox("id");
65
66 $this->addMultiCommand("confirmDeletion", $lng->txt("delete"));
67
68 if ($this->getItems()) {
69 $this->addCommandButton("saveOrder", $lng->txt("exc_save_order"));
70 }
71 }
72
76 protected function getItems(): bool
77 {
79
80 $data = array();
81
82 $protected = $assigned = array();
83 foreach (ilExAssignment::getInstancesByExercise($this->exc_id) as $ass) {
84 if ($ass->getPeerReviewCriteriaCatalogue()) {
85 $assigned[$ass->getPeerReviewCriteriaCatalogue()][$ass->getId()] = $ass->getTitle();
86
87 $peer_review = new ilExPeerReview($ass);
88 if ($peer_review->hasPeerReviewGroups()) {
89 $protected[$ass->getPeerReviewCriteriaCatalogue()][] = $ass->getId();
90 }
91 }
92 }
93
94 if ($protected !== []) {
95 $this->main_tpl->setOnScreenMessage('info', $lng->txt("exc_crit_cat_protected_assignment_info"));
96 }
97
98 $pos = 0;
99 foreach (ilExcCriteriaCatalogue::getInstancesByParentId($this->exc_id) as $item) {
100 $pos += 10;
101
102 $crits = array();
103 foreach (ilExcCriteria::getInstancesByParentId($item->getId()) as $crit) {
104 $crits[] = array($crit->getTranslatedType(), $crit->getTitle());
105 }
106
107 $data[] = array(
108 "id" => $item->getId()
109 ,"pos" => $pos
110 ,"title" => $item->getTitle()
111 ,"criterias" => $crits
112 ,"protected" => array_key_exists($item->getId(), $protected)
113 ? $protected[$item->getId()]
114 : null
115 ,"assigned" => array_key_exists($item->getId(), $assigned)
116 ? $assigned[$item->getId()]
117 : null
118 );
119 }
120
121 $this->setData($data);
122
123 return (bool) count($data);
124 }
125
126 public function numericOrdering(string $a_field): bool
127 {
128 return $a_field === "pos";
129 }
130
131 protected function fillRow(array $a_set): void
132 {
134 $ilCtrl = $this->ctrl;
135
136 $this->tpl->setVariable("ID", $a_set["id"]);
137 $this->tpl->setVariable("POS", $a_set["pos"]);
138 $this->tpl->setVariable("TITLE", $a_set["title"]);
139
140 $ilCtrl->setParameter($this->getParentObject(), "cat_id", $a_set["id"]);
141 $url = $ilCtrl->getLinkTarget($this->getParentObject(), "edit");
142
143 if (count($a_set["criterias"]) !== 0) {
144 $this->tpl->setCurrentBlock("crit_bl");
145 foreach ($a_set["criterias"] as $crit) {
146 $this->tpl->setVariable("CRIT_TYPE", $crit[0]);
147 $this->tpl->setVariable("CRIT_TITLE", $crit[1]);
148 $this->tpl->parseCurrentBlock();
149 }
150 }
151
152 $this->tpl->setCurrentBlock("action_bl");
153 $this->tpl->setVariable("ACTION_URL", $url);
154 $this->tpl->setVariable("ACTION_TXT", $lng->txt("edit"));
155 $this->tpl->parseCurrentBlock();
156
157 if (is_array($a_set["assigned"])) {
158 foreach ($a_set["assigned"] as $ass_id => $ass_title) {
159 if (is_array($a_set["protected"]) &&
160 in_array($ass_id, $a_set["protected"])) {
161 $this->tpl->setCurrentBlock("ass_protected_bl");
162 $this->tpl->setVariable("ASS_PROTECTED", $lng->txt("exc_crit_cat_protected_assignment"));
163 $this->tpl->parseCurrentBlock();
164 }
165
166 $this->tpl->setCurrentBlock("ass_bl");
167 $this->tpl->setVariable("ASS_TITLE", $ass_title);
168 $this->tpl->parseCurrentBlock();
169 }
170 }
171
172
173 if (!is_array($a_set["protected"])) {
174 $url = $ilCtrl->getLinkTargetByClass("ilExcCriteriaGUI", "");
175
176 $this->tpl->setCurrentBlock("action_bl");
177 $this->tpl->setVariable("ACTION_URL", $url);
178 $this->tpl->setVariable("ACTION_TXT", $lng->txt("exc_edit_criterias"));
179 $this->tpl->parseCurrentBlock();
180
181 $ilCtrl->setParameter($this->getParentObject(), "cat_id", "");
182 }
183 }
184}
setParameter(object $a_gui_obj, string $a_parameter, $a_value)
@inheritDoc
static getInstancesByExercise(int $a_exc_id)
Exercise peer review.
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, int $a_exc_id)
fillRow(array $a_set)
Standard Version of Fill Row.
static getInstancesByParentId(int $a_parent_id)
static getInstancesByParentId(int $a_parent_id)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
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="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
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)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
ilLanguage $lng
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68