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