ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $lng,$ilCtrl;
52 
53  $this->objective_id = $a_objective_id;
54  $this->course_obj = $a_course_obj;
55 
56  $this->lng = $lng;
57  $this->lng->loadLanguageModule('crs');
58  $this->ctrl = $ilCtrl;
59 
60  parent::__construct($a_parent_obj, 'materialAssignment');
61  $this->setFormName('assignments');
62  $this->addColumn('', 'f', "1");
63  $this->addColumn($this->lng->txt('type'), 'type', "1px");
64  $this->addColumn($this->lng->txt('title'), 'title', '99%');
65 
66  $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
67  $this->setRowTemplate("tpl.crs_objective_list_materials_row.html", "Modules/Course");
68  #$this->disable('sort');
69  #$this->disable('header');
70  #$this->disable('numinfo');
71  #$this->disable('select_all');
72 
73  $this->setDefaultOrderField('title');
74  $this->setLimit(200);
75 
76  $this->setNoEntriesText($this->lng->txt('crs_no_objective_lms_found'));
77 
78 
79  $this->addCommandButton('updateMaterialAssignment', $this->lng->txt('crs_wiz_next'));
80  #$this->addMultiCommand('updateMaterialAssignment', $this->lng->txt('crs_wiz_next'));
81  $this->addCommandButton('create', $this->lng->txt('crs_wiz_back'));
82 
83  $this->initObjectiveAssignments();
84  }
85 
93  protected function fillRow($a_set)
94  {
95  foreach ($a_set['sub'] as $sub_data) {
96  // Indentation
97  for ($i = $sub_data['depth'];$i > 1;$i--) {
98  $this->tpl->touchBlock('begin_depth');
99  $this->tpl->touchBlock('end_depth');
100  }
101 
102  $this->tpl->setCurrentBlock('chapter');
103  include_once('Modules/LearningModule/classes/class.ilLMObject.php');
104 
105  if ($this->objective_lm->isChapterAssigned($a_set['id'], $sub_data['id'])) {
106  $this->tpl->setVariable('CHAP_CHECKED', 'checked="checked"');
107  }
108 
109  $this->tpl->setVariable('CHAPTER_TITLE', ilLMObject::_lookupTitle($sub_data['id']));
110  $this->tpl->setVariable('CHAP_ID', $a_set['id'] . '_' . $sub_data['id']);
111  $this->tpl->setVariable('CHAP_TYPE_IMG', ilObject::_getIcon($sub_data['id'], "tiny", $sub_data['type']));
112  $this->tpl->setVariable('CHAP_TYPE_ALT', $this->lng->txt('obj_' . $sub_data['type']));
113  $this->tpl->parseCurrentBlock();
114  }
115  if (count($a_set['sub'])) {
116  $this->tpl->setVariable('TXT_CHAPTER', $this->lng->txt('objs_st'));
117  }
118 
119  $this->tpl->setVariable('VAL_ID', $a_set['id']);
120 
121  if ($this->objective_lm->isAssigned($a_set['id'])) {
122  $this->tpl->setVariable('VAL_CHECKED', 'checked="checked"');
123  }
124 
125  $this->tpl->setVariable('ROW_TYPE_IMG', ilObject::_getIcon($a_set['obj_id'], "tiny", $a_set['type']));
126  $this->tpl->setVariable('ROW_TYPE_ALT', $this->lng->txt('obj_' . $a_set['type']));
127 
128  $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
129  if (strlen($a_set['description'])) {
130  $this->tpl->setVariable('VAL_DESC', $a_set['description']);
131  }
132  }
133 
141  public function parse($a_assignable)
142  {
143  global $objDefinition;
144 
145  $materials = array();
146  foreach ($a_assignable as $node) {
147  // no side blocks here
148  if ($objDefinition->isSideBlock($node['type'])) {
149  continue;
150  }
151 
152  $tmp_data = array();
153  $subobjects = array();
154 
155  if ($node['type'] == 'lm') {
156  include_once('./Modules/LearningModule/classes/class.ilLMObject.php');
157 
158 
159  // Chapters and pages
160  foreach ($chapters = $this->getAllSubObjects($node['child']) as $chapter => $chapter_data) {
161  $sub['title'] = ilLMObject::_lookupTitle($chapter);
162  $sub['id'] = $chapter;
163  $sub['depth'] = $chapter_data['depth'];
164  $sub['type'] = $chapter_data['type'];
165 
166  $subobjects[] = $sub;
167  }
168  }
169 
170  $tmp_data['sub'] = $subobjects;
171  $tmp_data['title'] = $node['title'];
172  $tmp_data['description'] = $node['description'];
173  $tmp_data['type'] = $node['type'];
174  $tmp_data['id'] = $node['child'];
175  $tmp_data['obj_id'] = $node['obj_id'];
176 
177  $materials[] = $tmp_data;
178  }
179 
180  $this->setData($materials);
181  }
182 
189  protected function getAllSubObjects($a_ref_id)
190  {
191  $tree = new ilTree(ilObject::_lookupObjId($a_ref_id));
192  $tree->setTableNames('lm_tree', 'lm_data');
193  $tree->setTreeTablePK("lm_id");
194 
195  foreach ($tree->getSubTree($tree->getNodeData($tree->getRootId())) as $node) {
196  if ($node['type'] == 'st' or $node['type'] == 'pg') {
197  $depth = $node['depth'] - 1;
198  $child = $node['child'];
199  $chapter[$child]['depth'] = $depth;
200  $chapter[$child]['type'] = $node['type'];
201  }
202  }
203  return $chapter ? $chapter : array();
204  }
205 
206 
213  protected function initObjectiveAssignments()
214  {
215  include_once('./Modules/Course/classes/class.ilCourseObjective.php');
216  $this->objective = new ilCourseObjective($this->course_obj, $this->objective_id);
217 
218  include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
219  $this->objective_lm = new ilCourseObjectiveMaterials($this->objective_id);
220  }
221 }
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
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.
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.
Create styles array
The data for the language used.
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)