ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  function __construct($a_parent_obj, $a_parent_cmd, $a_exc_id)
22  {
23  global $ilCtrl, $lng;
24 
25  $this->exc_id = $a_exc_id;
26  $this->setId("excass".$this->exc_id);
27 
28  parent::__construct($a_parent_obj, $a_parent_cmd);
29 
30  $this->setTitle($lng->txt("exc_assignments"));
31  $this->setTopCommands(true);
32 
33  // if you add pagination and disable the unlimited setting:
34  // fix saving of ordering of single pages!
35  $this->setLimit(9999);
36 
37  $this->addColumn("", "", "1", true);
38  $this->addColumn($this->lng->txt("title"), "title");
39  $this->addColumn($this->lng->txt("exc_assignment_type"), "type");
40  $this->addColumn($this->lng->txt("exc_presentation_order"), "order_val");
41  $this->addColumn($this->lng->txt("exc_start_time"), "start_time");
42  $this->addColumn($this->lng->txt("exc_deadline"), "deadline");
43  $this->addColumn($this->lng->txt("exc_mandatory"), "mandatory");
44  $this->addColumn($this->lng->txt("exc_peer_review"), "peer");
45  $this->addColumn($this->lng->txt("exc_instruction"), "", "30%");
46  $this->addColumn($this->lng->txt("actions"));
47 
48  $this->setDefaultOrderField("val_order");
49  $this->setDefaultOrderDirection("asc");
50 
51  //$this->setDefaultOrderField("name");
52  //$this->setDefaultOrderDirection("asc");
53 
54  $this->setEnableHeader(true);
55  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
56  $this->setRowTemplate("tpl.exc_assignments_row.html", "Modules/Exercise");
57  //$this->disable("footer");
58  $this->setEnableTitle(true);
59  $this->setSelectAllCheckbox("id");
60 
61  $this->addMultiCommand("confirmAssignmentsDeletion", $lng->txt("delete"));
62 
63  $this->addCommandButton("orderAssignmentsByDeadline", $lng->txt("exc_order_by_deadline"));
64  $this->addCommandButton("saveAssignmentOrder", $lng->txt("exc_save_order"));
65  //$this->addCommandButton("addAssignment", $lng->txt("exc_add_assignment"));
66 
67  $types_map = array(
68  ilExAssignment::TYPE_UPLOAD => $lng->txt("exc_type_upload"),
69  ilExAssignment::TYPE_UPLOAD_TEAM => $lng->txt("exc_type_upload_team"),
70  ilExAssignment::TYPE_BLOG => $lng->txt("exc_type_blog"),
71  ilExAssignment::TYPE_PORTFOLIO => $lng->txt("exc_type_portfolio"),
72  ilExAssignment::TYPE_TEXT => $lng->txt("exc_type_text"),
73  );
74 
75  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
76  include_once("./Modules/Exercise/classes/class.ilExPeerReview.php");
78  foreach($data as $idx => $row)
79  {
80  // #14450
81  if($row["peer"])
82  {
83  $data[$idx]["peer_invalid"] = true;
84  $peer_review = new ilExPeerReview(new ilExAssignment($row["id"]));
85  $peer_reviews = $peer_review->validatePeerReviewGroups();
86  $data[$idx]["peer_invalid"] = $peer_reviews["invalid"];
87  }
88 
89  $data[$idx]["type"] = $types_map[$row["type"]];
90  }
91 
92  $this->setData($data);
93  }
94 
95  function numericOrdering($a_field)
96  {
97  // #12000
98  if(in_array($a_field, array("order_val", "deadline", "start_time")))
99  {
100  return true;
101  }
102  return false;
103  }
104 
108  protected function fillRow($d)
109  {
110  global $lng, $ilCtrl;
111 
112  $this->tpl->setVariable("ID", $d["id"]);
113 
114  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
115  $ass = new ilExAssignment($d["id"]);
116 
117  if ($d["deadline"] > 0)
118  {
120  if($d["deadline2"] > 0)
121  {
122  $dl .= "<br />(".ilDatePresentation::formatDate(new ilDateTime($d["deadline2"],IL_CAL_UNIX)).")";
123  }
124  $this->tpl->setVariable("TXT_DEADLINE", $dl);
125  }
126  if ($d["start_time"] > 0)
127  {
128  $this->tpl->setVariable("TXT_START_TIME",
130  }
131  $this->tpl->setVariable("TXT_INSTRUCTIONS",
132  nl2br(trim(ilUtil::shortenText(strip_tags($d["instruction"]), 200, true))));
133 
134  if ($d["mandatory"])
135  {
136  $this->tpl->setVariable("TXT_MANDATORY", $lng->txt("yes"));
137  }
138  else
139  {
140  $this->tpl->setVariable("TXT_MANDATORY", $lng->txt("no"));
141  }
142 
143  $ilCtrl->setParameter($this->parent_obj, "ass_id", $d["id"]);
144 
145  if ($d["peer"])
146  {
147  $this->tpl->setVariable("TXT_PEER", $lng->txt("yes")." (".$d["peer_min"].")");
148 
149  if($d["peer_invalid"])
150  {
151  $this->tpl->setVariable("TXT_PEER_INVALID", $lng->txt("exc_peer_reviews_invalid_warning"));
152  }
153 
154  if ($ass->afterDeadlineStrict()) // see #22246
155  {
156  $this->tpl->setVariable("TXT_PEER_OVERVIEW", $lng->txt("exc_peer_review_overview"));
157  $this->tpl->setVariable("CMD_PEER_OVERVIEW",
158  $ilCtrl->getLinkTargetByClass("ilexpeerreviewgui", "showPeerReviewOverview"));
159  }
160  }
161  else
162  {
163  $this->tpl->setVariable("TXT_PEER", $lng->txt("no"));
164  }
165 
166  $this->tpl->setVariable("TXT_TITLE", $d["title"]);
167  $this->tpl->setVariable("TXT_TYPE", $d["type"]);
168  $this->tpl->setVariable("ORDER_VAL", $d["order_val"]);
169 
170  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
171  $this->tpl->setVariable("CMD_EDIT",
172  $ilCtrl->getLinkTarget($this->parent_obj, "editAssignment"));
173  }
174 
175 }
176 ?>
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.
const IL_CAL_UNIX
setId($a_val)
Set id.
for($col=0; $col< 50; $col++) $d
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.
static formatDate(ilDateTime $date)
Format a date public.
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.
global $lng
Definition: privfeed.php:17
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.
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.
setLimit($a_limit=0, $a_default_limit=0)