ILIAS  release_7 Revision v7.30-3-g800a261c036
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
12{
13 protected $exc_id; // [int]
14
15 public function __construct($a_parent_obj, $a_parent_cmd, $a_exc_id)
16 {
17 global $DIC;
18
19 $this->ctrl = $DIC->ctrl();
20 $this->lng = $DIC->language();
21 $ilCtrl = $DIC->ctrl();
22 $lng = $DIC->language();
23
24 $this->exc_id = $a_exc_id;
25 $this->setId("exccritcat" . $this->exc_id);
26
27 parent::__construct($a_parent_obj, $a_parent_cmd);
28
29 $this->setLimit(9999); // because of manual order
30
31 $this->setTitle($lng->txt("exc_criteria_catalogues"));
32
33 $this->addColumn("", "", "1", true);
34 $this->addColumn($this->lng->txt("position"), "pos", "10%");
35 $this->addColumn($this->lng->txt("title"), "title");
36 $this->addColumn($this->lng->txt("exc_criterias"));
37 $this->addColumn($this->lng->txt("exc_assignments"));
38 $this->addColumn($this->lng->txt("actions"));
39
40 $this->setDefaultOrderField("pos");
41 $this->setDefaultOrderDirection("asc");
42
43 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
44 $this->setRowTemplate("tpl.exc_crit_cat_row.html", "Modules/Exercise");
45 $this->setSelectAllCheckbox("id");
46
47 $this->addMultiCommand("confirmDeletion", $lng->txt("delete"));
48
49 if ($this->getItems()) {
50 $this->addCommandButton("saveOrder", $lng->txt("exc_save_order"));
51 }
52 }
53
54 protected function getItems()
55 {
57
58 $data = array();
59
60 $protected = $assigned = array();
61 foreach (ilExAssignment::getInstancesByExercise($this->exc_id) as $ass) {
62 if ($ass->getPeerReviewCriteriaCatalogue()) {
63 $assigned[$ass->getPeerReviewCriteriaCatalogue()][$ass->getId()] = $ass->getTitle();
64
65 $peer_review = new ilExPeerReview($ass);
66 if ($peer_review->hasPeerReviewGroups()) {
67 $protected[$ass->getPeerReviewCriteriaCatalogue()][] = $ass->getId();
68 }
69 }
70 }
71
72 if (sizeof($protected)) {
73 ilUtil::sendInfo($lng->txt("exc_crit_cat_protected_assignment_info"));
74 }
75
76 $pos = 0;
77 foreach (ilExcCriteriaCatalogue::getInstancesByParentId($this->exc_id) as $item) {
78 $pos += 10;
79
80 $crits = array();
81 foreach (ilExcCriteria::getInstancesByParentId($item->getId()) as $crit) {
82 $crits[] = array($crit->getTranslatedType(), $crit->getTitle());
83 }
84
85 $data[] = array(
86 "id" => $item->getId()
87 ,"pos" => $pos
88 ,"title" => $item->getTitle()
89 ,"criterias" => $crits
90 ,"protected" => array_key_exists($item->getId(), $protected)
91 ? $protected[$item->getId()]
92 : null
93 ,"assigned" => array_key_exists($item->getId(), $assigned)
94 ? $assigned[$item->getId()]
95 : null
96 );
97 }
98
99 $this->setData($data);
100
101 return (bool) sizeof($data);
102 }
103
104 public function numericOrdering($a_field)
105 {
106 return in_array($a_field, array("pos"));
107 }
108
109 protected function fillRow($a_set)
110 {
112 $ilCtrl = $this->ctrl;
113
114 $this->tpl->setVariable("ID", $a_set["id"]);
115 $this->tpl->setVariable("POS", $a_set["pos"]);
116 $this->tpl->setVariable("TITLE", $a_set["title"]);
117
118 $ilCtrl->setParameter($this->getParentObject(), "cat_id", $a_set["id"]);
119 $url = $ilCtrl->getLinkTarget($this->getParentObject(), "edit");
120
121 if (sizeof($a_set["criterias"])) {
122 $this->tpl->setCurrentBlock("crit_bl");
123 foreach ($a_set["criterias"] as $crit) {
124 $this->tpl->setVariable("CRIT_TYPE", $crit[0]);
125 $this->tpl->setVariable("CRIT_TITLE", $crit[1]);
126 $this->tpl->parseCurrentBlock();
127 }
128 }
129
130 $this->tpl->setCurrentBlock("action_bl");
131 $this->tpl->setVariable("ACTION_URL", $url);
132 $this->tpl->setVariable("ACTION_TXT", $lng->txt("edit"));
133 $this->tpl->parseCurrentBlock();
134
135 if (is_array($a_set["assigned"])) {
136 foreach ($a_set["assigned"] as $ass_id => $ass_title) {
137 if (is_array($a_set["protected"]) &&
138 in_array($ass_id, $a_set["protected"])) {
139 $this->tpl->setCurrentBlock("ass_protected_bl");
140 $this->tpl->setVariable("ASS_PROTECTED", $lng->txt("exc_crit_cat_protected_assignment"));
141 $this->tpl->parseCurrentBlock();
142 }
143
144 $this->tpl->setCurrentBlock("ass_bl");
145 $this->tpl->setVariable("ASS_TITLE", $ass_title);
146 $this->tpl->parseCurrentBlock();
147 }
148 }
149
150
151 if (!is_array($a_set["protected"])) {
152 $url = $ilCtrl->getLinkTargetByClass("ilExcCriteriaGUI", "");
153
154 $this->tpl->setCurrentBlock("action_bl");
155 $this->tpl->setVariable("ACTION_URL", $url);
156 $this->tpl->setVariable("ACTION_TXT", $lng->txt("exc_edit_criterias"));
157 $this->tpl->parseCurrentBlock();
158
159 $ilCtrl->setParameter($this->getParentObject(), "cat_id", "");
160 }
161 }
162}
An exception for terminatinating execution or to throw for unit testing.
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)
ilTable2GUI constructor.
fillRow($a_set)
Standard Version of Fill Row.
static getInstancesByParentId($a_parent_id)
static getInstancesByParentId($a_parent_id)
Class ilTable2GUI.
getParentObject()
Get parent object.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
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.
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.
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.
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 $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$url