ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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)
22  {
23  global $ilCtrl, $lng, $ilAccess, $lng;
24 
25  $this->exc = $a_exc;
26  $this->setId("excass".$a_exc->getId());
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");
77  foreach($data as $idx => $row)
78  {
79  // #14450
80  if($row["peer"])
81  {
82  $data[$idx]["peer_invalid"] = true;
83  $ass = new ilExAssignment($row["id"]);
84  $peer_reviews = $ass->validatePeerReviewGroups();
85  $data[$idx]["peer_invalid"] = $peer_reviews["invalid"];
86  }
87 
88  $data[$idx]["type"] = $types_map[$row["type"]];
89  }
90 
91  $this->setData($data);
92  }
93 
94  function numericOrdering($a_field)
95  {
96  // #12000
97  if(in_array($a_field, array("order_val", "deadline", "start_time")))
98  {
99  return true;
100  }
101  return false;
102  }
103 
107  protected function fillRow($d)
108  {
109  global $lng, $ilCtrl;
110 
111  $this->tpl->setVariable("ID", $d["id"]);
112  if ($d["deadline"] > 0)
113  {
114  $this->tpl->setVariable("TXT_DEADLINE",
116  }
117  if ($d["start_time"] > 0)
118  {
119  $this->tpl->setVariable("TXT_START_TIME",
121  }
122  $this->tpl->setVariable("TXT_INSTRUCTIONS",
123  ilUtil::shortenText($d["instruction"], 200, true));
124 
125  if ($d["mandatory"])
126  {
127  $this->tpl->setVariable("TXT_MANDATORY", $lng->txt("yes"));
128  }
129  else
130  {
131  $this->tpl->setVariable("TXT_MANDATORY", $lng->txt("no"));
132  }
133 
134  $ilCtrl->setParameter($this->parent_obj, "ass_id", $d["id"]);
135 
136  if ($d["peer"])
137  {
138  $this->tpl->setVariable("TXT_PEER", $lng->txt("yes")." (".$d["peer_min"].")");
139 
140  if($d["peer_invalid"])
141  {
142  $this->tpl->setVariable("TXT_PEER_INVALID", $lng->txt("exc_peer_reviews_invalid_warning"));
143  }
144 
145  $this->tpl->setVariable("TXT_PEER_OVERVIEW", $lng->txt("exc_peer_review_overview"));
146  $this->tpl->setVariable("CMD_PEER_OVERVIEW",
147  $ilCtrl->getLinkTarget($this->parent_obj, "showPeerReviewOverview"));
148  }
149  else
150  {
151  $this->tpl->setVariable("TXT_PEER", $lng->txt("no"));
152  }
153 
154  $this->tpl->setVariable("TXT_TITLE", $d["title"]);
155  $this->tpl->setVariable("TXT_TYPE", $d["type"]);
156  $this->tpl->setVariable("ORDER_VAL", $d["order_val"]);
157 
158  $this->tpl->setVariable("TXT_EDIT", $lng->txt("edit"));
159  $this->tpl->setVariable("CMD_EDIT",
160  $ilCtrl->getLinkTarget($this->parent_obj, "editAssignment"));
161  }
162 
163 }
164 ?>