ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
5include_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 $ilCtrl, $lng;
20
21 $this->exc_id = $a_exc_id;
22 $this->setId("exccritcat".$this->exc_id);
23
24 parent::__construct($a_parent_obj, $a_parent_cmd);
25
26 $this->setLimit(9999); // because of manual order
27
28 $this->setTitle($lng->txt("exc_criteria_catalogues"));
29
30 $this->addColumn("", "", "1", true);
31 $this->addColumn($this->lng->txt("position"), "pos", "10%");
32 $this->addColumn($this->lng->txt("title"), "title");
33 $this->addColumn($this->lng->txt("exc_criterias"));
34 $this->addColumn($this->lng->txt("exc_assignments"));
35 $this->addColumn($this->lng->txt("actions"));
36
37 $this->setDefaultOrderField("pos");
38 $this->setDefaultOrderDirection("asc");
39
40 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
41 $this->setRowTemplate("tpl.exc_crit_cat_row.html", "Modules/Exercise");
42 $this->setSelectAllCheckbox("id");
43
44 $this->addMultiCommand("confirmDeletion", $lng->txt("delete"));
45
46 if($this->getItems())
47 {
48 $this->addCommandButton("saveOrder", $lng->txt("exc_save_order"));
49 }
50 }
51
52 protected function getItems()
53 {
54 global $lng;
55
56 $data = array();
57
58 include_once "Modules/Exercise/classes/class.ilExAssignment.php";
59 include_once "Modules/Exercise/classes/class.ilExcCriteria.php";
60 include_once "Modules/Exercise/classes/class.ilExPeerReview.php";
61
62 $protected = $assigned = array();
63 foreach(ilExAssignment::getInstancesByExercise($this->exc_id) as $ass)
64 {
65 if($ass->getPeerReviewCriteriaCatalogue())
66 {
67 $assigned[$ass->getPeerReviewCriteriaCatalogue()][$ass->getId()] = $ass->getTitle();
68
69 $peer_review = new ilExPeerReview($ass);
70 if($peer_review->hasPeerReviewGroups())
71 {
72 $protected[$ass->getPeerReviewCriteriaCatalogue()][] = $ass->getId();
73 }
74 }
75 }
76
77 if(sizeof($protected))
78 {
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 {
85 $pos += 10;
86
87 $crits = array();
88 foreach(ilExcCriteria::getInstancesByParentId($item->getId()) as $crit)
89 {
90 $crits[] = array($crit->getTranslatedType(), $crit->getTitle());
91 }
92
93 $data[] = array(
94 "id" => $item->getId()
95 ,"pos" => $pos
96 ,"title" => $item->getTitle()
97 ,"criterias" => $crits
98 ,"protected" => array_key_exists($item->getId(), $protected)
99 ? $protected[$item->getId()]
100 : null
101 ,"assigned" => array_key_exists($item->getId(), $assigned)
102 ? $assigned[$item->getId()]
103 : null
104 );
105 }
106
107 $this->setData($data);
108
109 return (bool)sizeof($data);
110 }
111
112 public function numericOrdering($a_field)
113 {
114 return in_array($a_field, array("pos"));
115 }
116
117 protected function fillRow($a_set)
118 {
119 global $lng, $ilCtrl;
120
121 $this->tpl->setVariable("ID", $a_set["id"]);
122 $this->tpl->setVariable("POS", $a_set["pos"]);
123 $this->tpl->setVariable("TITLE", $a_set["title"]);
124
125 $ilCtrl->setParameter($this->getParentObject(), "cat_id", $a_set["id"]);
126 $url = $ilCtrl->getLinkTarget($this->getParentObject(), "edit");
127
128 if(sizeof($a_set["criterias"]))
129 {
130 $this->tpl->setCurrentBlock("crit_bl");
131 foreach($a_set["criterias"] as $crit)
132 {
133 $this->tpl->setVariable("CRIT_TYPE", $crit[0]);
134 $this->tpl->setVariable("CRIT_TITLE", $crit[1]);
135 $this->tpl->parseCurrentBlock();
136 }
137 }
138
139 $this->tpl->setCurrentBlock("action_bl");
140 $this->tpl->setVariable("ACTION_URL", $url);
141 $this->tpl->setVariable("ACTION_TXT", $lng->txt("edit"));
142 $this->tpl->parseCurrentBlock();
143
144 if(is_array($a_set["assigned"]))
145 {
146 foreach($a_set["assigned"] as $ass_id => $ass_title)
147 {
148 if(is_array($a_set["protected"]) &&
149 in_array($ass_id, $a_set["protected"]))
150 {
151 $this->tpl->setCurrentBlock("ass_protected_bl");
152 $this->tpl->setVariable("ASS_PROTECTED", $lng->txt("exc_crit_cat_protected_assignment"));
153 $this->tpl->parseCurrentBlock();
154 }
155
156 $this->tpl->setCurrentBlock("ass_bl");
157 $this->tpl->setVariable("ASS_TITLE", $ass_title);
158 $this->tpl->parseCurrentBlock();
159 }
160 }
161
162
163 if(!is_array($a_set["protected"]))
164 {
165 $url = $ilCtrl->getLinkTargetByClass("ilExcCriteriaGUI", "");
166
167 $this->tpl->setCurrentBlock("action_bl");
168 $this->tpl->setVariable("ACTION_URL", $url);
169 $this->tpl->setVariable("ACTION_TXT", $lng->txt("exc_edit_criterias"));
170 $this->tpl->parseCurrentBlock();
171
172 $ilCtrl->setParameter($this->getParentObject(), "cat_id", "");
173 }
174 }
175}
static getInstancesByExercise($a_exc_id)
Exercise peer review.
Class ilExcCriteriaCatalogueTableGUI.
numericOrdering($a_field)
Should this field be sorted numeric?
__construct($a_parent_obj, $a_parent_cmd, $a_exc_id)
Constructor.
fillRow($a_set)
Standard Version of Fill Row.
static getInstancesByParentId($a_parent_id)
static getInstancesByParentId($a_parent_id)
Class ilTable2GUI.
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.
getParentObject()
Get parent object.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
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.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
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 sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$url
Definition: shib_logout.php:72