ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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", "Modules/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  {
130  $lng = $this->lng;
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  } else {
152  if ($ass->getRelativeDeadline() > 0) {
153  $dl = "" . $ass->getRelativeDeadline() . " " . $this->lng->txt("days");
154  }
155  if ($ass->getRelDeadlineLastSubmission() > 0) {
156  if ($dl != "") {
157  $dl .= " / ";
158  }
159  $dl .= ilDatePresentation::formatDate(new ilDateTime($ass->getRelDeadlineLastSubmission(), IL_CAL_UNIX));
160  }
161  $this->tpl->setVariable("TXT_DEADLINE", $dl);
162  }
163  if ($a_set["start_time"] > 0) {
164  $this->tpl->setVariable(
165  "TXT_START_TIME",
166  ilDatePresentation::formatDate(new ilDateTime($a_set["start_time"], IL_CAL_UNIX))
167  );
168  }
169  $this->tpl->setVariable(
170  "TXT_INSTRUCTIONS",
171  nl2br(trim(ilStr::shortenTextExtended(strip_tags($a_set["instruction"]), 200, true)))
172  );
173 
174  if (!$this->random_manager->isActivated()) {
175  if ($a_set["mandatory"]) {
176  $this->tpl->setVariable("TXT_MANDATORY", $lng->txt("yes"));
177  } else {
178  $this->tpl->setVariable("TXT_MANDATORY", $lng->txt("no"));
179  }
180  } else {
181  $this->tpl->setVariable("TXT_MANDATORY", $lng->txt("exc_random"));
182  }
183 
184  $ilCtrl->setParameter($this->parent_obj, "ass_id", $a_set["id"]);
185 
186  if ($a_set["peer"]) {
187  $this->tpl->setVariable("TXT_PEER", $lng->txt("yes") . " (" . $a_set["peer_min"] . ")");
188 
189  if ($a_set["peer_invalid"]) {
190  $this->tpl->setVariable("TXT_PEER_INVALID", $lng->txt("exc_peer_reviews_invalid_warning"));
191  }
192 
193  if ($ass->afterDeadlineStrict()) { // see #22246
194  $this->tpl->setVariable("TXT_PEER_OVERVIEW", $lng->txt("exc_peer_review_overview"));
195  $this->tpl->setVariable(
196  "CMD_PEER_OVERVIEW",
197  $ilCtrl->getLinkTargetByClass("ilexpeerreviewgui", "showPeerReviewOverview")
198  );
199  }
200  } else {
201  $this->tpl->setVariable("TXT_PEER", $lng->txt("no"));
202  }
203 
204  $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
205  $this->tpl->setVariable("TXT_TYPE", $a_set["type"]);
206  $this->tpl->setVariable("ORDER_VAL", $a_set["order_val"]);
207 
208  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
209  $this->tpl->setVariable(
210  "CMD_EDIT",
211  $ilCtrl->getLinkTarget($this->parent_obj, "editAssignment")
212  );
213 
214  $ilCtrl->setParameter($this->parent_obj, "ass_id", null);
215  }
216 }
setData(array $a_data)
setTopCommands(bool $a_val)
Exercise assignment.
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...
setFormAction(string $a_form_action, bool $a_multipart=false)
setEnableTitle(bool $a_enabletitle)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
const IL_CAL_UNIX
ilLanguage $lng
setId(string $a_val)
global $DIC
Definition: feed.php:28
static getAssignmentDataOfExercise(int $a_exc_id)
Exercise peer review.
Manages random mandatory assignments of an exercise (business logic)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
__construct(Container $dic, ilPlugin $plugin)
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
setLimit(int $a_limit=0, int $a_default_limit=0)
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)
__construct(?object $a_parent_obj, string $a_parent_cmd="", string $a_template_context="")
Mandatory RandomAssignmentsManager $random_manager
addMultiCommand(string $a_cmd, string $a_text)
setEnableHeader(bool $a_enableheader)