ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
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('sport');
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->addCommandButton('create',$this->lng->txt('crs_wiz_back'));
81 
82  $this->initObjectiveAssignments();
83 
84  }
85 
93  protected function fillRow($a_set)
94  {
95  foreach($a_set['sub'] as $sub_data)
96  {
97  // Indentation
98  for($i = $sub_data['depth'];$i > 1;$i--)
99  {
100  $this->tpl->touchBlock('begin_depth');
101  $this->tpl->touchBlock('end_depth');
102  }
103 
104  $this->tpl->setCurrentBlock('chapter');
105  include_once('Modules/LearningModule/classes/class.ilLMObject.php');
106 
107  if($this->objective_lm->isChapterAssigned($a_set['id'],$sub_data['id']))
108  {
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',ilUtil::getTypeIconPath($sub_data['type'],$sub_data['id'],'tiny'));
115  $this->tpl->setVariable('CHAP_TYPE_ALT',$this->lng->txt('obj_'.$sub_data['type']));
116  $this->tpl->parseCurrentBlock();
117 
118 
119  }
120  if(count($a_set['sub']))
121  {
122  $this->tpl->setVariable('TXT_CHAPTER',$this->lng->txt('objs_st'));
123  }
124 
125  $this->tpl->setVariable('VAL_ID',$a_set['id']);
126 
127  if($this->objective_lm->isAssigned($a_set['id']))
128  {
129  $this->tpl->setVariable('VAL_CHECKED','checked="checked"');
130  }
131 
132  $this->tpl->setVariable('ROW_TYPE_IMG',ilUtil::getTypeIconPath($a_set['type'],$a_set['obj_id'],'tiny'));
133  $this->tpl->setVariable('ROW_TYPE_ALT',$this->lng->txt('obj_'.$a_set['type']));
134 
135  $this->tpl->setVariable('VAL_TITLE',$a_set['title']);
136  if(strlen($a_set['description']))
137  {
138  $this->tpl->setVariable('VAL_DESC',$a_set['description']);
139  }
140  }
141 
149  public function parse($a_assignable)
150  {
151  global $objDefinition;
152 
153  $materials = array();
154  foreach($a_assignable as $node)
155  {
156  // no side blocks here
157  if($objDefinition->isSideBlock($node['type']))
158  {
159  continue;
160  }
161 
162  $tmp_data = array();
163  $subobjects = array();
164 
165  if($node['type'] == 'lm')
166  {
167  include_once('./Modules/LearningModule/classes/class.ilLMObject.php');
168 
169 
170  // Chapters and pages
171  foreach($chapters = $this->getAllSubObjects($node['child']) as $chapter => $chapter_data)
172  {
173  $sub['title'] = ilLMObject::_lookupTitle($chapter);
174  $sub['id'] = $chapter;
175  $sub['depth'] = $chapter_data['depth'];
176  $sub['type'] = $chapter_data['type'];
177 
178  $subobjects[] = $sub;
179  }
180  }
181 
182  $tmp_data['sub'] = $subobjects;
183  $tmp_data['title'] = $node['title'];
184  $tmp_data['description'] = $node['description'];
185  $tmp_data['type'] = $node['type'];
186  $tmp_data['id'] = $node['child'];
187  $tmp_date['obj_id'] = $node['obj_id'];
188 
189  $materials[] = $tmp_data;
190  }
191 
192  $this->setData($materials);
193  }
194 
201  protected function getAllSubObjects($a_ref_id)
202  {
203  $tree = new ilTree(ilObject::_lookupObjId($a_ref_id));
204  $tree->setTableNames('lm_tree','lm_data');
205  $tree->setTreeTablePK("lm_id");
206 
207  foreach($tree->getSubTree($tree->getNodeData($tree->getRootId())) as $node)
208  {
209  if($node['type'] == 'st' or $node['type'] == 'pg')
210  {
211  $depth = $node['depth'] - 1;
212  $child = $node['child'];
213  $chapter[$child]['depth'] = $depth;
214  $chapter[$child]['type'] = $node['type'];
215  }
216  }
217  return $chapter ? $chapter : array();
218  }
219 
220 
227  protected function initObjectiveAssignments()
228  {
229  include_once('./Modules/Course/classes/class.ilCourseObjective.php');
230  $this->objective = new ilCourseObjective($this->course_obj,$this->objective_id);
231 
232  include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
233  $this->objective_lm = new ilCourseObjectiveMaterials($this->objective_id);
234  }
235 }
236 ?>