ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilAssignmentsTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
12{
16 protected $types;
17
21 protected $random_manager;
22
26 public function __construct($a_parent_obj, $a_parent_cmd, $a_exc_id)
27 {
28 global $DIC;
29
30 $this->ctrl = $DIC->ctrl();
31 $this->lng = $DIC->language();
32 $ilCtrl = $DIC->ctrl();
33 $lng = $DIC->language();
34 $this->types = ilExAssignmentTypes::getInstance();
35
36 $this->exc_id = $a_exc_id;
37 $this->setId("excass" . $this->exc_id);
38
39 $request = $DIC->exercise()->internal()->request();
40 $this->random_manager = $DIC->exercise()->internal()->service()->getRandomAssignmentManager(
41 $request->getRequestedExercise()
42 );
43
44 parent::__construct($a_parent_obj, $a_parent_cmd);
45
46 $this->setTitle($lng->txt("exc_assignments"));
47 $this->setTopCommands(true);
48
49 // if you add pagination and disable the unlimited setting:
50 // fix saving of ordering of single pages!
51 $this->setLimit(9999);
52
53 $this->addColumn("", "", "1", true);
54 $this->addColumn($this->lng->txt("title"), "title");
55 $this->addColumn($this->lng->txt("exc_assignment_type"), "type");
56 $this->addColumn($this->lng->txt("exc_presentation_order"), "order_val");
57 $this->addColumn($this->lng->txt("exc_start_time"), "start_time");
58 $this->addColumn($this->lng->txt("exc_deadline"), "deadline");
59 $this->addColumn($this->lng->txt("exc_mandatory"), "mandatory");
60 $this->addColumn($this->lng->txt("exc_peer_review"), "peer");
61 $this->addColumn($this->lng->txt("exc_instruction"), "", "30%");
62 $this->addColumn($this->lng->txt("actions"));
63
64 $this->setDefaultOrderField("val_order");
65 $this->setDefaultOrderDirection("asc");
66
67 //$this->setDefaultOrderField("name");
68 //$this->setDefaultOrderDirection("asc");
69
70 $this->setEnableHeader(true);
71 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
72 $this->setRowTemplate("tpl.exc_assignments_row.html", "Modules/Exercise");
73 //$this->disable("footer");
74 $this->setEnableTitle(true);
75 $this->setSelectAllCheckbox("id");
76
77 $this->addMultiCommand("confirmAssignmentsDeletion", $lng->txt("delete"));
78
79 $this->addCommandButton("orderAssignmentsByDeadline", $lng->txt("exc_order_by_deadline"));
80 $this->addCommandButton("saveAssignmentOrder", $lng->txt("exc_save_order"));
81 //$this->addCommandButton("addAssignment", $lng->txt("exc_add_assignment"));
82
84 foreach ($data as $idx => $row) {
85 // #14450
86 if ($row["peer"]) {
87 $data[$idx]["peer_invalid"] = true;
88 $peer_review = new ilExPeerReview(new ilExAssignment($row["id"]));
89 $peer_reviews = $peer_review->validatePeerReviewGroups();
90 $data[$idx]["peer_invalid"] = $peer_reviews["invalid"];
91 }
92 $data[$idx]["ass_type"] = $this->types->getById($row["type"]);
93 $data[$idx]["type"] = $data[$idx]["ass_type"]->getTitle();
94 }
95
96 $this->setData($data);
97 }
98
99 public function numericOrdering($a_field)
100 {
101 // #12000
102 if (in_array($a_field, array("order_val", "deadline", "start_time"))) {
103 return true;
104 }
105 return false;
106 }
107
111 protected function fillRow($d)
112 {
115
116 $this->tpl->setVariable("ID", $d["id"]);
117
118 $ass = new ilExAssignment($d["id"]);
119
120 if ($ass->getDeadlineMode() == ilExAssignment::DEADLINE_ABSOLUTE) {
121 if ($d["deadline"] > 0) {
123 if ($d["deadline2"] > 0) {
124 $dl .= "<br />(" . ilDatePresentation::formatDate(new ilDateTime(
125 $d["deadline2"],
127 )) . ")";
128 }
129 $this->tpl->setVariable("TXT_DEADLINE", $dl);
130 } else {
131 $this->tpl->setVariable("TXT_DEADLINE", "-");
132 }
133 } else {
134 if ($ass->getRelativeDeadline() > 0) {
135 $dl = "" . $ass->getRelativeDeadline() . " " . $this->lng->txt("days");
136 }
137 if ($ass->getRelDeadlineLastSubmission() > 0) {
138 if ($dl != "") {
139 $dl .= " / ";
140 }
141 $dl .= ilDatePresentation::formatDate(new ilDateTime($ass->getRelDeadlineLastSubmission(), IL_CAL_UNIX));
142 }
143 $this->tpl->setVariable("TXT_DEADLINE", $dl);
144 }
145 if ($d["start_time"] > 0) {
146 $this->tpl->setVariable(
147 "TXT_START_TIME",
149 );
150 }
151 $this->tpl->setVariable(
152 "TXT_INSTRUCTIONS",
153 nl2br(trim(ilUtil::shortenText(strip_tags($d["instruction"]), 200, true)))
154 );
155
156 if (!$this->random_manager->isActivated()) {
157 if ($d["mandatory"]) {
158 $this->tpl->setVariable("TXT_MANDATORY", $lng->txt("yes"));
159 } else {
160 $this->tpl->setVariable("TXT_MANDATORY", $lng->txt("no"));
161 }
162 } else {
163 $this->tpl->setVariable("TXT_MANDATORY", $lng->txt("exc_random"));
164 }
165
166 $ilCtrl->setParameter($this->parent_obj, "ass_id", $d["id"]);
167
168 if ($d["peer"]) {
169 $this->tpl->setVariable("TXT_PEER", $lng->txt("yes") . " (" . $d["peer_min"] . ")");
170
171 if ($d["peer_invalid"]) {
172 $this->tpl->setVariable("TXT_PEER_INVALID", $lng->txt("exc_peer_reviews_invalid_warning"));
173 }
174
175 if ($ass->afterDeadlineStrict()) { // see #22246
176 $this->tpl->setVariable("TXT_PEER_OVERVIEW", $lng->txt("exc_peer_review_overview"));
177 $this->tpl->setVariable(
178 "CMD_PEER_OVERVIEW",
179 $ilCtrl->getLinkTargetByClass("ilexpeerreviewgui", "showPeerReviewOverview")
180 );
181 }
182 } else {
183 $this->tpl->setVariable("TXT_PEER", $lng->txt("no"));
184 }
185
186 $this->tpl->setVariable("TXT_TITLE", $d["title"]);
187 $this->tpl->setVariable("TXT_TYPE", $d["type"]);
188 $this->tpl->setVariable("ORDER_VAL", $d["order_val"]);
189
190 $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
191 $this->tpl->setVariable(
192 "CMD_EDIT",
193 $ilCtrl->getLinkTarget($this->parent_obj, "editAssignment")
194 );
195 }
196}
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_UNIX
__construct($a_parent_obj, $a_parent_cmd, $a_exc_id)
Constructor.
numericOrdering($a_field)
Should this field be sorted numeric?
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
static getInstance()
Get instance.
Exercise assignment.
static getAssignmentDataOfExercise($a_exc_id)
Get assignments data of an exercise in an array.
Exercise peer review.
Class ilTable2GUI.
setTopCommands($a_val)
Set top commands (display command buttons on top of table, too)
setEnableHeader($a_enableheader)
Set Enable Header.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
setData($a_data)
set table data @access public
setEnableTitle($a_enabletitle)
Set Enable Title.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46