ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilCourseObjectiveMaterialAssignmentTableGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once('./Services/Table/classes/class.ilTable2GUI.php');
25 
35 {
36  private $objective = null;
37  private $objective_lm = null;
38 
39  private $objective_id = 0;
40  private $course_obj;
41 
49  public function __construct($a_parent_obj, $a_course_obj, $a_objective_id)
50  {
51  global $DIC;
52 
53  $lng = $DIC['lng'];
54  $ilCtrl = $DIC['ilCtrl'];
55 
56  $this->objective_id = $a_objective_id;
57  $this->course_obj = $a_course_obj;
58 
59  $this->lng = $lng;
60  $this->lng->loadLanguageModule('crs');
61  $this->ctrl = $ilCtrl;
62 
63  parent::__construct($a_parent_obj, 'materialAssignment');
64  $this->setFormName('assignments');
65  $this->addColumn('', 'f', "1");
66  $this->addColumn($this->lng->txt('type'), 'type', "1px");
67  $this->addColumn($this->lng->txt('title'), 'title', '99%');
68 
69  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
70  $this->setRowTemplate("tpl.crs_objective_list_materials_row.html", "Modules/Course");
71  #$this->disable('sort');
72  #$this->disable('header');
73  #$this->disable('numinfo');
74  #$this->disable('select_all');
75 
76  $this->setDefaultOrderField('title');
77  $this->setLimit(200);
78 
79  $this->setNoEntriesText($this->lng->txt('crs_no_objective_lms_found'));
80 
81 
82  $this->addCommandButton('updateMaterialAssignment', $this->lng->txt('crs_wiz_next'));
83  #$this->addMultiCommand('updateMaterialAssignment', $this->lng->txt('crs_wiz_next'));
84  $this->addCommandButton('create', $this->lng->txt('crs_wiz_back'));
85 
86  $this->initObjectiveAssignments();
87  }
88 
96  protected function fillRow($a_set)
97  {
98  foreach ($a_set['sub'] as $sub_data) {
99  // Indentation
100  for ($i = $sub_data['depth'];$i > 1;$i--) {
101  $this->tpl->touchBlock('begin_depth');
102  $this->tpl->touchBlock('end_depth');
103  }
104 
105  $this->tpl->setCurrentBlock('chapter');
106  include_once('Modules/LearningModule/classes/class.ilLMObject.php');
107 
108  if ($this->objective_lm->isChapterAssigned($a_set['id'], $sub_data['id'])) {
109  $this->tpl->setVariable('CHAP_CHECKED', 'checked="checked"');
110  }
111 
112  $this->tpl->setVariable('CHAPTER_TITLE', ilLMObject::_lookupTitle($sub_data['id']));
113  $this->tpl->setVariable('CHAP_ID', $a_set['id'] . '_' . $sub_data['id']);
114  $this->tpl->setVariable('CHAP_TYPE_IMG', ilObject::_getIcon($sub_data['id'], "tiny", $sub_data['type']));
115  $this->tpl->setVariable('CHAP_TYPE_ALT', $this->lng->txt('obj_' . $sub_data['type']));
116  $this->tpl->parseCurrentBlock();
117  }
118  if (count($a_set['sub'])) {
119  $this->tpl->setVariable('TXT_CHAPTER', $this->lng->txt('objs_st'));
120  }
121 
122  $this->tpl->setVariable('VAL_ID', $a_set['id']);
123 
124  if ($this->objective_lm->isAssigned($a_set['id'])) {
125  $this->tpl->setVariable('VAL_CHECKED', 'checked="checked"');
126  }
127 
128  $this->tpl->setVariable('ROW_TYPE_IMG', ilObject::_getIcon($a_set['obj_id'], "tiny", $a_set['type']));
129  $this->tpl->setVariable('ROW_TYPE_ALT', $this->lng->txt('obj_' . $a_set['type']));
130 
131  $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
132  if (strlen($a_set['description'])) {
133  $this->tpl->setVariable('VAL_DESC', $a_set['description']);
134  }
135  }
136 
144  public function parse($a_assignable)
145  {
146  global $DIC;
147 
148  $objDefinition = $DIC['objDefinition'];
149 
150  $materials = array();
151  foreach ($a_assignable as $node) {
152  // no side blocks here
153  if ($objDefinition->isSideBlock($node['type'])) {
154  continue;
155  }
156 
157  $tmp_data = array();
158  $subobjects = array();
159 
160  if ($node['type'] == 'lm') {
161  include_once('./Modules/LearningModule/classes/class.ilLMObject.php');
162 
163 
164  // Chapters and pages
165  foreach ($chapters = $this->getAllSubObjects($node['child']) as $chapter => $chapter_data) {
166  $sub['title'] = ilLMObject::_lookupTitle($chapter);
167  $sub['id'] = $chapter;
168  $sub['depth'] = $chapter_data['depth'];
169  $sub['type'] = $chapter_data['type'];
170 
171  $subobjects[] = $sub;
172  }
173  }
174 
175  $tmp_data['sub'] = $subobjects;
176  $tmp_data['title'] = $node['title'];
177  $tmp_data['description'] = $node['description'];
178  $tmp_data['type'] = $node['type'];
179  $tmp_data['id'] = $node['child'];
180  $tmp_data['obj_id'] = $node['obj_id'];
181 
182  $materials[] = $tmp_data;
183  }
184 
185  $this->setData($materials);
186  }
187 
194  protected function getAllSubObjects($a_ref_id)
195  {
196  $tree = new ilTree(ilObject::_lookupObjId($a_ref_id));
197  $tree->setTableNames('lm_tree', 'lm_data');
198  $tree->setTreeTablePK("lm_id");
199 
200  foreach ($tree->getSubTree($tree->getNodeData($tree->getRootId())) as $node) {
201  if ($node['type'] == 'st' or $node['type'] == 'pg') {
202  $depth = $node['depth'] - 1;
203  $child = $node['child'];
204  $chapter[$child]['depth'] = $depth;
205  $chapter[$child]['type'] = $node['type'];
206  }
207  }
208  return $chapter ? $chapter : array();
209  }
210 
211 
218  protected function initObjectiveAssignments()
219  {
220  include_once('./Modules/Course/classes/class.ilCourseObjective.php');
221  $this->objective = new ilCourseObjective($this->course_obj, $this->objective_id);
222 
223  include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
224  $this->objective_lm = new ilCourseObjectiveMaterials($this->objective_id);
225  }
226 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
__construct($a_parent_obj, $a_course_obj, $a_objective_id)
Constructor.
global $DIC
Definition: saml.php:7
static _lookupTitle($a_obj_id)
Lookup title.
setNoEntriesText($a_text)
Set text for an empty table.
TableGUI for material assignments of course objectives.
global $ilCtrl
Definition: ilias.php:18
class ilCourseObjectiveMaterials
Class ilTable2GUI.
class ilcourseobjective
static _lookupObjId($a_id)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setFormName($a_formname="")
Set Form name.
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.
$i
Definition: disco.tpl.php:19
getAllSubObjects($a_ref_id)
get all subobject (structure and page objects) of a lm
setLimit($a_limit=0, $a_default_limit=0)