ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
4 include_once("./Services/Table/classes/class.ilTable2GUI.php");
5 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
6 
16 {
17 
21  public function __construct($a_parent_obj, $a_parent_cmd, $a_exc_id)
22  {
23  global $DIC;
24 
25  $this->ctrl = $DIC->ctrl();
26  $this->lng = $DIC->language();
27  $ilCtrl = $DIC->ctrl();
28  $lng = $DIC->language();
29 
30  $this->exc_id = $a_exc_id;
31  $this->setId("excass" . $this->exc_id);
32 
33  parent::__construct($a_parent_obj, $a_parent_cmd);
34 
35  $this->setTitle($lng->txt("exc_assignments"));
36  $this->setTopCommands(true);
37 
38  // if you add pagination and disable the unlimited setting:
39  // fix saving of ordering of single pages!
40  $this->setLimit(9999);
41 
42  $this->addColumn("", "", "1", true);
43  $this->addColumn($this->lng->txt("title"), "title");
44  $this->addColumn($this->lng->txt("exc_assignment_type"), "type");
45  $this->addColumn($this->lng->txt("exc_presentation_order"), "order_val");
46  $this->addColumn($this->lng->txt("exc_start_time"), "start_time");
47  $this->addColumn($this->lng->txt("exc_deadline"), "deadline");
48  $this->addColumn($this->lng->txt("exc_mandatory"), "mandatory");
49  $this->addColumn($this->lng->txt("exc_peer_review"), "peer");
50  $this->addColumn($this->lng->txt("exc_instruction"), "", "30%");
51  $this->addColumn($this->lng->txt("actions"));
52 
53  $this->setDefaultOrderField("val_order");
54  $this->setDefaultOrderDirection("asc");
55 
56  //$this->setDefaultOrderField("name");
57  //$this->setDefaultOrderDirection("asc");
58 
59  $this->setEnableHeader(true);
60  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
61  $this->setRowTemplate("tpl.exc_assignments_row.html", "Modules/Exercise");
62  //$this->disable("footer");
63  $this->setEnableTitle(true);
64  $this->setSelectAllCheckbox("id");
65 
66  $this->addMultiCommand("confirmAssignmentsDeletion", $lng->txt("delete"));
67 
68  $this->addCommandButton("orderAssignmentsByDeadline", $lng->txt("exc_order_by_deadline"));
69  $this->addCommandButton("saveAssignmentOrder", $lng->txt("exc_save_order"));
70  //$this->addCommandButton("addAssignment", $lng->txt("exc_add_assignment"));
71 
72  $types_map = array(
73  ilExAssignment::TYPE_UPLOAD => $lng->txt("exc_type_upload"),
74  ilExAssignment::TYPE_UPLOAD_TEAM => $lng->txt("exc_type_upload_team"),
75  ilExAssignment::TYPE_BLOG => $lng->txt("exc_type_blog"),
76  ilExAssignment::TYPE_PORTFOLIO => $lng->txt("exc_type_portfolio"),
77  ilExAssignment::TYPE_TEXT => $lng->txt("exc_type_text"),
78  );
79 
80  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
81  include_once("./Modules/Exercise/classes/class.ilExPeerReview.php");
83  foreach ($data as $idx => $row) {
84  // #14450
85  if ($row["peer"]) {
86  $data[$idx]["peer_invalid"] = true;
87  $peer_review = new ilExPeerReview(new ilExAssignment($row["id"]));
88  $peer_reviews = $peer_review->validatePeerReviewGroups();
89  $data[$idx]["peer_invalid"] = $peer_reviews["invalid"];
90  }
91 
92  $data[$idx]["type"] = $types_map[$row["type"]];
93  }
94 
95  $this->setData($data);
96  }
97 
98  public function numericOrdering($a_field)
99  {
100  // #12000
101  if (in_array($a_field, array("order_val", "deadline", "start_time"))) {
102  return true;
103  }
104  return false;
105  }
106 
110  protected function fillRow($d)
111  {
112  $lng = $this->lng;
114 
115  $this->tpl->setVariable("ID", $d["id"]);
116 
117  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
118  $ass = new ilExAssignment($d["id"]);
119 
120  if ($d["deadline"] > 0) {
121  $dl = ilDatePresentation::formatDate(new ilDateTime($d["deadline"], IL_CAL_UNIX));
122  if ($d["deadline2"] > 0) {
123  $dl .= "<br />(" . ilDatePresentation::formatDate(new ilDateTime($d["deadline2"], IL_CAL_UNIX)) . ")";
124  }
125  $this->tpl->setVariable("TXT_DEADLINE", $dl);
126  }
127  if ($d["start_time"] > 0) {
128  $this->tpl->setVariable(
129  "TXT_START_TIME",
131  );
132  }
133  $this->tpl->setVariable(
134  "TXT_INSTRUCTIONS",
135  nl2br(trim(ilUtil::shortenText(strip_tags($d["instruction"]), 200, true)))
136  );
137 
138  if ($d["mandatory"]) {
139  $this->tpl->setVariable("TXT_MANDATORY", $lng->txt("yes"));
140  } else {
141  $this->tpl->setVariable("TXT_MANDATORY", $lng->txt("no"));
142  }
143 
144  $ilCtrl->setParameter($this->parent_obj, "ass_id", $d["id"]);
145 
146  if ($d["peer"]) {
147  $this->tpl->setVariable("TXT_PEER", $lng->txt("yes") . " (" . $d["peer_min"] . ")");
148 
149  if ($d["peer_invalid"]) {
150  $this->tpl->setVariable("TXT_PEER_INVALID", $lng->txt("exc_peer_reviews_invalid_warning"));
151  }
152 
153  if ($ass->afterDeadlineStrict()) { // see #22246
154  $this->tpl->setVariable("TXT_PEER_OVERVIEW", $lng->txt("exc_peer_review_overview"));
155  $this->tpl->setVariable(
156  "CMD_PEER_OVERVIEW",
157  $ilCtrl->getLinkTargetByClass("ilexpeerreviewgui", "showPeerReviewOverview")
158  );
159  }
160  } else {
161  $this->tpl->setVariable("TXT_PEER", $lng->txt("no"));
162  }
163 
164  $this->tpl->setVariable("TXT_TITLE", $d["title"]);
165  $this->tpl->setVariable("TXT_TYPE", $d["type"]);
166  $this->tpl->setVariable("ORDER_VAL", $d["order_val"]);
167 
168  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
169  $this->tpl->setVariable(
170  "CMD_EDIT",
171  $ilCtrl->getLinkTarget($this->parent_obj, "editAssignment")
172  );
173  }
174 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
static getAssignmentDataOfExercise($a_exc_id)
Get assignments data of an exercise in an array.
Exercise assignment.
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
global $DIC
Definition: saml.php:7
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
const IL_CAL_UNIX
setId($a_val)
Set id.
global $ilCtrl
Definition: ilias.php:18
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Exercise peer review.
setTopCommands($a_val)
Set top commands (display command buttons on top of table, too)
Class ilTable2GUI.
addMultiCommand($a_cmd, $a_text)
Add Command button.
Date and time handling
setRowTemplate($a_template, $a_template_dir="")
Set row template.
Create styles array
The data for the language used.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
__construct($a_parent_obj, $a_parent_cmd, $a_exc_id)
Constructor.
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.
setEnableHeader($a_enableheader)
Set Enable Header.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
setEnableTitle($a_enabletitle)
Set Enable Title.
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
setLimit($a_limit=0, $a_default_limit=0)