ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilExcCriteriaCatalogueTableGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once "Services/Table/classes/class.ilTable2GUI.php";
6 
14 {
15  protected $exc_id; // [int]
16 
17  public function __construct($a_parent_obj, $a_parent_cmd, $a_exc_id)
18  {
19  global $DIC;
20 
21  $this->ctrl = $DIC->ctrl();
22  $this->lng = $DIC->language();
23  $ilCtrl = $DIC->ctrl();
24  $lng = $DIC->language();
25 
26  $this->exc_id = $a_exc_id;
27  $this->setId("exccritcat" . $this->exc_id);
28 
29  parent::__construct($a_parent_obj, $a_parent_cmd);
30 
31  $this->setLimit(9999); // because of manual order
32 
33  $this->setTitle($lng->txt("exc_criteria_catalogues"));
34 
35  $this->addColumn("", "", "1", true);
36  $this->addColumn($this->lng->txt("position"), "pos", "10%");
37  $this->addColumn($this->lng->txt("title"), "title");
38  $this->addColumn($this->lng->txt("exc_criterias"));
39  $this->addColumn($this->lng->txt("exc_assignments"));
40  $this->addColumn($this->lng->txt("actions"));
41 
42  $this->setDefaultOrderField("pos");
43  $this->setDefaultOrderDirection("asc");
44 
45  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
46  $this->setRowTemplate("tpl.exc_crit_cat_row.html", "Modules/Exercise");
47  $this->setSelectAllCheckbox("id");
48 
49  $this->addMultiCommand("confirmDeletion", $lng->txt("delete"));
50 
51  if ($this->getItems()) {
52  $this->addCommandButton("saveOrder", $lng->txt("exc_save_order"));
53  }
54  }
55 
56  protected function getItems()
57  {
58  $lng = $this->lng;
59 
60  $data = array();
61 
62  include_once "Modules/Exercise/classes/class.ilExAssignment.php";
63  include_once "Modules/Exercise/classes/class.ilExcCriteria.php";
64  include_once "Modules/Exercise/classes/class.ilExPeerReview.php";
65 
66  $protected = $assigned = array();
67  foreach (ilExAssignment::getInstancesByExercise($this->exc_id) as $ass) {
68  if ($ass->getPeerReviewCriteriaCatalogue()) {
69  $assigned[$ass->getPeerReviewCriteriaCatalogue()][$ass->getId()] = $ass->getTitle();
70 
71  $peer_review = new ilExPeerReview($ass);
72  if ($peer_review->hasPeerReviewGroups()) {
73  $protected[$ass->getPeerReviewCriteriaCatalogue()][] = $ass->getId();
74  }
75  }
76  }
77 
78  if (sizeof($protected)) {
79  ilUtil::sendInfo($lng->txt("exc_crit_cat_protected_assignment_info"));
80  }
81 
82  $pos = 0;
83  foreach (ilExcCriteriaCatalogue::getInstancesByParentId($this->exc_id) as $item) {
84  $pos += 10;
85 
86  $crits = array();
87  foreach (ilExcCriteria::getInstancesByParentId($item->getId()) as $crit) {
88  $crits[] = array($crit->getTranslatedType(), $crit->getTitle());
89  }
90 
91  $data[] = array(
92  "id" => $item->getId()
93  ,"pos" => $pos
94  ,"title" => $item->getTitle()
95  ,"criterias" => $crits
96  ,"protected" => array_key_exists($item->getId(), $protected)
97  ? $protected[$item->getId()]
98  : null
99  ,"assigned" => array_key_exists($item->getId(), $assigned)
100  ? $assigned[$item->getId()]
101  : null
102  );
103  }
104 
105  $this->setData($data);
106 
107  return (bool) sizeof($data);
108  }
109 
110  public function numericOrdering($a_field)
111  {
112  return in_array($a_field, array("pos"));
113  }
114 
115  protected function fillRow($a_set)
116  {
117  $lng = $this->lng;
119 
120  $this->tpl->setVariable("ID", $a_set["id"]);
121  $this->tpl->setVariable("POS", $a_set["pos"]);
122  $this->tpl->setVariable("TITLE", $a_set["title"]);
123 
124  $ilCtrl->setParameter($this->getParentObject(), "cat_id", $a_set["id"]);
125  $url = $ilCtrl->getLinkTarget($this->getParentObject(), "edit");
126 
127  if (sizeof($a_set["criterias"])) {
128  $this->tpl->setCurrentBlock("crit_bl");
129  foreach ($a_set["criterias"] as $crit) {
130  $this->tpl->setVariable("CRIT_TYPE", $crit[0]);
131  $this->tpl->setVariable("CRIT_TITLE", $crit[1]);
132  $this->tpl->parseCurrentBlock();
133  }
134  }
135 
136  $this->tpl->setCurrentBlock("action_bl");
137  $this->tpl->setVariable("ACTION_URL", $url);
138  $this->tpl->setVariable("ACTION_TXT", $lng->txt("edit"));
139  $this->tpl->parseCurrentBlock();
140 
141  if (is_array($a_set["assigned"])) {
142  foreach ($a_set["assigned"] as $ass_id => $ass_title) {
143  if (is_array($a_set["protected"]) &&
144  in_array($ass_id, $a_set["protected"])) {
145  $this->tpl->setCurrentBlock("ass_protected_bl");
146  $this->tpl->setVariable("ASS_PROTECTED", $lng->txt("exc_crit_cat_protected_assignment"));
147  $this->tpl->parseCurrentBlock();
148  }
149 
150  $this->tpl->setCurrentBlock("ass_bl");
151  $this->tpl->setVariable("ASS_TITLE", $ass_title);
152  $this->tpl->parseCurrentBlock();
153  }
154  }
155 
156 
157  if (!is_array($a_set["protected"])) {
158  $url = $ilCtrl->getLinkTargetByClass("ilExcCriteriaGUI", "");
159 
160  $this->tpl->setCurrentBlock("action_bl");
161  $this->tpl->setVariable("ACTION_URL", $url);
162  $this->tpl->setVariable("ACTION_TXT", $lng->txt("exc_edit_criterias"));
163  $this->tpl->parseCurrentBlock();
164 
165  $ilCtrl->setParameter($this->getParentObject(), "cat_id", "");
166  }
167  }
168 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
global $DIC
Definition: saml.php:7
getParentObject()
Get parent object.
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.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Exercise peer review.
Class ilTable2GUI.
static getInstancesByParentId($a_parent_id)
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.
__construct($a_parent_obj, $a_parent_cmd, $a_exc_id)
static getInstancesByExercise($a_exc_id)
Class ilExcCriteriaCatalogueTableGUI.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
static getInstancesByParentId($a_parent_id)
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.
$url
setLimit($a_limit=0, $a_default_limit=0)