ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAssignmentsTableGUI.php
Go to the documentation of this file.
1<?php
2
20
27{
30 protected int $exc_id;
31
35 public function __construct(
36 object $a_parent_obj,
37 string $a_parent_cmd,
38 int $a_exc_id
39 ) {
41 global $DIC;
42
43 $this->ctrl = $DIC->ctrl();
44 $this->lng = $DIC->language();
45 $ilCtrl = $DIC->ctrl();
46 $lng = $DIC->language();
47 $this->types = ilExAssignmentTypes::getInstance();
48
49 $this->exc_id = $a_exc_id;
50 $this->setId("excass" . $this->exc_id);
51
52 $request = $DIC->exercise()->internal()->gui()->request();
53 $this->random_manager = $DIC->exercise()->internal()->domain()->assignment()->randomAssignments(
54 $request->getExercise()
55 );
56
57 parent::__construct($a_parent_obj, $a_parent_cmd);
58
59 $this->setTitle($lng->txt("exc_assignments"));
60 $this->setTopCommands(true);
61
62 // if you add pagination and disable the unlimited setting:
63 // fix saving of ordering of single pages!
64 $this->setLimit(9999);
65
66 $this->addColumn("", "", "1", true);
67 $this->addColumn($this->lng->txt("title"), "title");
68 $this->addColumn($this->lng->txt("exc_assignment_type"), "type");
69 $this->addColumn($this->lng->txt("exc_presentation_order"), "order_val");
70 $this->addColumn($this->lng->txt("exc_start_time"), "start_time");
71 $this->addColumn($this->lng->txt("exc_deadline"), "deadline");
72 $this->addColumn($this->lng->txt("exc_mandatory"), "mandatory");
73 $this->addColumn($this->lng->txt("exc_peer_review"), "peer");
74 $this->addColumn($this->lng->txt("exc_instruction"), "", "30%");
75 $this->addColumn($this->lng->txt("actions"));
76
77 $this->setDefaultOrderField("val_order");
78 $this->setDefaultOrderDirection("asc");
79
80 //$this->setDefaultOrderField("name");
81 //$this->setDefaultOrderDirection("asc");
82
83 $this->setEnableHeader(true);
84 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
85 $this->setRowTemplate("tpl.exc_assignments_row.html", "components/ILIAS/Exercise");
86 //$this->disable("footer");
87 $this->setEnableTitle(true);
88 $this->setSelectAllCheckbox("id");
89
90 $this->addMultiCommand("confirmAssignmentsDeletion", $lng->txt("delete"));
91
92 $this->addCommandButton("orderAssignmentsByDeadline", $lng->txt("exc_order_by_deadline"));
93 $this->addCommandButton("saveAssignmentOrder", $lng->txt("exc_save_order"));
94 //$this->addCommandButton("addAssignment", $lng->txt("exc_add_assignment"));
95
97 foreach ($data as $idx => $row) {
98 // #14450
99 if ($row["peer"]) {
100 $data[$idx]["peer_invalid"] = true;
101 $peer_review = new ilExPeerReview(new ilExAssignment($row["id"]));
102 $peer_reviews = $peer_review->validatePeerReviewGroups();
103 if (is_array($peer_reviews)) {
104 $data[$idx]["peer_invalid"] = $peer_reviews["invalid"];
105 }
106 if (is_null($peer_reviews)) {
107 $data[$idx]["peer_invalid"] = false;
108 }
109 }
110 $data[$idx]["ass_type"] = $this->types->getById($row["type"]);
111 $data[$idx]["type"] = $data[$idx]["ass_type"]->getTitle();
112 }
113 $this->setData($data);
114 }
115
116 public function numericOrdering(string $a_field): bool
117 {
118 // #12000
119 if (in_array($a_field, array("order_val", "deadline", "start_time"))) {
120 return true;
121 }
122 return false;
123 }
124
128 protected function fillRow(array $a_set): void
129 {
131 $ilCtrl = $this->ctrl;
132
133 $this->tpl->setVariable("ID", $a_set["id"]);
134
135 $ass = new ilExAssignment($a_set["id"]);
136
137 $dl = "";
138 if ($ass->getDeadlineMode() == ilExAssignment::DEADLINE_ABSOLUTE) {
139 if ($a_set["deadline"] > 0) {
140 $dl = ilDatePresentation::formatDate(new ilDateTime($a_set["deadline"], IL_CAL_UNIX));
141 if ($a_set["deadline2"] > 0) {
142 $dl .= "<br />(" . ilDatePresentation::formatDate(new ilDateTime(
143 $a_set["deadline2"],
145 )) . ")";
146 }
147 $this->tpl->setVariable("TXT_DEADLINE", $dl);
148 } else {
149 $this->tpl->setVariable("TXT_DEADLINE", "-");
150 }
151 } elseif ($ass->getDeadlineMode() === ilExAssignment::DEADLINE_ABSOLUTE_INDIVIDUAL) {
152 $this->tpl->setVariable("TXT_DEADLINE", $this->lng->txt("exc_fixed_date_individual"));
153 } else {
154 if ($ass->getRelativeDeadline() > 0) {
155 $dl = "" . $ass->getRelativeDeadline() . " " . $this->lng->txt("days");
156 }
157 if ($ass->getRelDeadlineLastSubmission() > 0) {
158 if ($dl != "") {
159 $dl .= " / ";
160 }
161 $dl .= ilDatePresentation::formatDate(new ilDateTime($ass->getRelDeadlineLastSubmission(), IL_CAL_UNIX));
162 }
163 $this->tpl->setVariable("TXT_DEADLINE", $dl);
164 }
165 if ($a_set["start_time"] > 0) {
166 $this->tpl->setVariable(
167 "TXT_START_TIME",
168 ilDatePresentation::formatDate(new ilDateTime($a_set["start_time"], IL_CAL_UNIX))
169 );
170 }
171 $this->tpl->setVariable(
172 "TXT_INSTRUCTIONS",
173 nl2br(trim(ilStr::shortenTextExtended(strip_tags($a_set["instruction"]), 200, true)))
174 );
175
176 if (!$this->random_manager->isActivated()) {
177 if ($a_set["mandatory"]) {
178 $this->tpl->setVariable("TXT_MANDATORY", $lng->txt("yes"));
179 } else {
180 $this->tpl->setVariable("TXT_MANDATORY", $lng->txt("no"));
181 }
182 } else {
183 $this->tpl->setVariable("TXT_MANDATORY", $lng->txt("exc_random"));
184 }
185
186 $ilCtrl->setParameter($this->parent_obj, "ass_id", $a_set["id"]);
187
188 if ($a_set["peer"]) {
189 $this->tpl->setVariable("TXT_PEER", $lng->txt("yes") . " (" . $a_set["peer_min"] . ")");
190
191 if ($a_set["peer_invalid"]) {
192 $this->tpl->setVariable("TXT_PEER_INVALID", $lng->txt("exc_peer_reviews_invalid_warning"));
193 }
194
195 if ($ass->afterDeadlineStrict()) { // see #22246
196 $this->tpl->setVariable("TXT_PEER_OVERVIEW", $lng->txt("exc_peer_review_overview"));
197 $this->tpl->setVariable(
198 "CMD_PEER_OVERVIEW",
199 $ilCtrl->getLinkTargetByClass("ilexpeerreviewgui", "showPeerReviewOverview")
200 );
201 }
202 } else {
203 $this->tpl->setVariable("TXT_PEER", $lng->txt("no"));
204 }
205
206 $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
207 $this->tpl->setVariable("TXT_TYPE", $a_set["type"]);
208 $this->tpl->setVariable("ORDER_VAL", $a_set["order_val"]);
209
210 $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
211 $this->tpl->setVariable(
212 "CMD_EDIT",
213 $ilCtrl->getLinkTarget($this->parent_obj, "editAssignment")
214 );
215
216 $ilCtrl->setParameter($this->parent_obj, "ass_id", null);
217 }
218}
Manages random mandatory assignments of an exercise (business logic)
const IL_CAL_UNIX
Mandatory RandomAssignmentsManager $random_manager
numericOrdering(string $a_field)
Should this field be sorted numeric?
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
Exercise assignment.
static getAssignmentDataOfExercise(int $a_exc_id)
Exercise peer review.
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...
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(?object $a_parent_obj, string $a_parent_cmd="", string $a_template_context="")
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="")
setEnableTitle(bool $a_enabletitle)
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)
setEnableHeader(bool $a_enableheader)
setDefaultOrderField(string $a_defaultorderfield)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setTopCommands(bool $a_val)
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26