ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCourseObjectivePresentationGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 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 
36 include_once 'Modules/Course/classes/class.ilCourseObjectiveResult.php';
37 
39 {
42 
43  var $tpl;
44  var $ctrl;
45  var $lng;
46  var $tabs_gui;
47 
52  function ilCourseObjectivePresentationGUI(&$container_gui)
53  {
54  global $tpl,$ilCtrl,$lng,$ilObjDataCache,$ilTabs,$ilUser;
55 
56  $this->tpl =& $tpl;
57  $this->ctrl =& $ilCtrl;
58  $this->lng =& $lng;
59  $this->tabs_gui =& $ilTabs;
60 
61  $this->container_gui =& $container_gui;
62  $this->container_obj =& $this->container_gui->object;
63 
64  $this->objective_result_obj = new ilCourseObjectiveResult($ilUser->getId());
65 
66  $this->__initCourseObject();
67  }
68 
69 
70 
71  function &executeCommand()
72  {
73  $next_class = $this->ctrl->getNextClass();
74  switch($next_class)
75  {
76  default:
77  $cmd = $this->ctrl->getCmd();
78  if (!$cmd = $this->ctrl->getCmd())
79  {
80  $cmd = "view";
81  }
82  $this->$cmd();
83  break;
84  }
85  }
86 
91  function &getHTML()
92  {
93  $this->view();
94  }
95 
96  function view()
97  {
98  global $rbacsystem,$ilUser,$ilBench;
99 
100  $ilBench->start('Objectives','Objectives_view');
101 
102  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objective_view.html",'Modules/Course');
103  $this->__showButton('askReset',$this->lng->txt('crs_reset_results'));
104 
105  $this->__readObjectivesStatus();
106 
107  $ilBench->stop('Objectives','Objectives_read');
108 
109  // (1) show infos
110  $this->__showInfo();
111 
112  // (2) show objectives
113  $ilBench->start('Objectives','Objectives_objectives');
114  $this->__showObjectives();
115  $ilBench->stop('Objectives','Objectives_objectives');
116 
117  // (3) show lm's
118  $ilBench->start('Objectives','Objectives_lms');
119  $this->__showLearningMaterials();
120  $ilBench->stop('Objectives','Objectives_lms');
121 
122  // (4) show tests
123  $ilBench->start('Objectives','Objectives_tests');
124  $this->__showTests();
125  $ilBench->stop('Objectives','Objectives_tests');
126 
127 
128  // (5) show other resources
129  $ilBench->start('Objectives','Objectives_or');
130  $this->__showOtherResources();
131  $ilBench->stop('Objectives','Objectives_or');
132 
133  $ilBench->stop('Objectives','Objectives_view');
134 
135  $ilBench->save();
136 
137  return true;
138  }
139 
140 
141  function askReset()
142  {
143  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_objectives_ask_reset.html",'Modules/Course');
144 
145  $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
146  $this->tpl->setVariable("INFO_STRING",$this->lng->txt('crs_objectives_reset_sure'));
147  $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt('cancel'));
148  $this->tpl->setVariable("TXT_RESET",$this->lng->txt('reset'));
149 
150  return true;
151  }
152 
153  function reset()
154  {
155  global $ilUser;
156 
157  include_once './Modules/Course/classes/class.ilCourseObjectiveResult.php';
158 
159  // Debug
160  ilObjUser::_writePref($ilUser->getId(),'crs_objectives_force_details_'.$this->course_obj->getId(),0);
161 
162 
163  $tmp_obj_res =& new ilCourseObjectiveResult($ilUser->getId());
164  $tmp_obj_res->reset($this->course_obj->getId());
165 
166  ilUtil::sendSuccess($this->lng->txt('crs_objectives_reseted'));
167  $this->view();
168  }
169 
170 
171 
172  // PRIVATE
173  function __showButton($a_cmd,$a_text,$a_target = '')
174  {
175  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
176 
177  // display button
178  $this->tpl->setCurrentBlock("btn_cell");
179  $this->tpl->setVariable("BTN_LINK",$this->ctrl->getLinkTarget($this,$a_cmd));
180  $this->tpl->setVariable("BTN_TXT",$a_text);
181 
182  if($a_target)
183  {
184  $this->tpl->setVariable("BTN_TARGET",$a_target);
185  }
186 
187  $this->tpl->parseCurrentBlock();
188  }
189 
191  {
192  $this->objective_result_obj->readStatus($this->course_obj->getId());
193  $this->accomplished = $this->objective_result_obj->getAccomplished($this->course_obj->getId());
194  $this->status = $this->objective_result_obj->getStatus($this->course_obj->getId());
195  $this->suggested = $this->objective_result_obj->getSuggested($this->course_obj->getId(),$this->status);
196  }
197 
198  function __showInfo()
199  {
200  include_once './Modules/Course/classes/class.ilCourseObjective.php';
201 
202  if(!count($objective_ids = ilCourseObjective::_getObjectiveIds($this->course_obj->getId())))
203  {
204  return true;
205  }
206 
207  $this->tpl->addBlockfile('INFO_BLOCK','info_block','tpl.crs_objectives_view_info_table.html','Modules/Course');
208  $this->tpl->setVariable("INFO_STRING",$this->lng->txt('crs_objectives_info_'.$this->status));
209 // ilUtil::sendInfo($this->lng->txt('crs_objectives_info_'.$this->status));
210  return true;
211  }
212 
213  function __showObjectives()
214  {
215  include_once './Modules/Course/classes/class.ilCourseObjective.php';
216 
217  if(!count($objective_ids = ilCourseObjective::_getObjectiveIds($this->course_obj->getId())))
218  {
219  return false;
220  }
221  if($_GET['details'])
222  {
223  $_SESSION['crs_details_id'] = $_GET['details'];
224  }
225  $this->details_id = $_SESSION['crs_details_id'] ? $_SESSION['crs_details_id'] : $objective_ids[0];
226 
227  // TODO get status for table header
228  switch($this->status)
229  {
230  case 'none':
231  $status = $this->lng->txt('crs_objective_accomplished');
232  break;
233 
234  case 'pretest':
235  case 'pretest_non_suggest':
236  $status = $this->lng->txt('crs_objective_pretest');
237  break;
238 
239  default:
240  $status = $this->lng->txt('crs_objective_result');
241  }
242 
243  // show table
244  $this->tpl->addBlockfile('OBJECTIVE_BLOCK','objective_block','tpl.crs_objectives_view_table.html','Modules/Course');
245 
246  $this->tpl->setVariable("TBL_TITLE_OBJECTIVES",$this->lng->txt('crs_objectives'));
247 
248  $this->__showHideLinks('objectives');
249 
250  if(isset($_SESSION['crs_hide_objectives']))
251  {
252  return true;
253  }
254 
255  $this->tpl->setVariable('TBL_HEADER_NAME_OBJECTIVES_A',$this->lng->txt('type'));
256 
257  $this->tpl->setVariable('TBL_HEADER_NAME_OBJECTIVES_B',$this->lng->txt('description'));
258 
259  $this->tpl->setVariable('TBL_HEADER_NAME_OBJECTIVES_C',$status);
260 
261 
262  //$max = count($objective_ids) % 2 ? count($objective_ids) + 1 : count($objective_ids);
263  $max = count($objective_ids);
264  for($i = 0; $i < $max; ++$i)
265  {
266  $tmp_objective =& new ilCourseObjective($this->course_obj,$objective_ids[$i]);
267 
268  $this->tpl->setCurrentBlock("objective_row");
269 
270  if($this->details_id == $objective_ids[$i])
271  {
272  $this->tpl->setVariable("OBJ_CLASS_1_OBJECTIVES",'option_value_details');
273  $this->tpl->setVariable("OBJ_CLASS_1_CENTER_OBJECTIVES",'option_value_center_details');
274  }
275  else
276  {
277  $this->tpl->setVariable("OBJ_CLASS_1_OBJECTIVES",'option_value');
278  $this->tpl->setVariable("OBJ_CLASS_1_CENTER_OBJECTIVES",'option_value_center');
279  }
280  $this->tpl->setVariable("OBJ_NR_1_OBJECTIVES",($i + 1).'.');
281 
282  $this->ctrl->setParameter($this,'details',$objective_ids[$i]);
283  $this->tpl->setVariable("OBJ_LINK_1_OBJECTIVES",$this->ctrl->getLinkTarget($this,'view'));
284  $this->tpl->setVariable("OBJ_TITLE_1_OBJECTIVES",$tmp_objective->getTitle());
285 
286  $img = !in_array($objective_ids[$i],$this->suggested) ?
287  ilUtil::getImagePath('icon_ok.gif') :
288  ilUtil::getImagePath('icon_not_ok.gif');
289 
290  $txt = !in_array($objective_ids[$i],$this->suggested) ?
291  $this->lng->txt('crs_objective_accomplished') :
292  $this->lng->txt('crs_objective_not_accomplished');
293 
294  $this->tpl->setVariable("OBJ_STATUS_IMG_1_OBJECTIVES",$img);
295  $this->tpl->setVariable("OBJ_STATUS_ALT_1_OBJECTIVES",$txt);
296 
297 
298  if(isset($objective_ids[$i + $max / 2]))
299  {
300  $tmp_objective =& new ilCourseObjective($this->course_obj,$objective_ids[$i + $max / 2]);
301 
302  $this->tpl->setCurrentBlock("objective_row");
303  if($this->details_id == $objective_ids[$i + $max / 2])
304  {
305  $this->tpl->setVariable("OBJ_CLASS_2_OBJECTIVES",'option_value_details');
306  $this->tpl->setVariable("OBJ_CLASS_2_CENTER_OBJECTIVES",'option_value_center_details');
307  }
308  else
309  {
310  $this->tpl->setVariable("OBJ_CLASS_2_OBJECTIVES",'option_value');
311  $this->tpl->setVariable("OBJ_CLASS_2_CENTER_OBJECTIVES",'option_value_center');
312  }
313  $this->tpl->setVariable("OBJ_NR_2_OBJECTIVES",($i + $max / 2 + 1).'.');
314  $this->ctrl->setParameter($this,'details',$objective_ids[$i + $max / 2]);
315  $this->tpl->setVariable("OBJ_LINK_2_OBJECTIVES",$this->ctrl->getLinkTarget($this,'view'));
316  $this->tpl->setVariable("OBJ_TITLE_2_OBJECTIVES",$tmp_objective->getTitle());
317 
318 
319  $objective_id = $objective_ids[$i + $max / 2];
320 
321  $img = !in_array($objective_id,$this->suggested) ?
322  ilUtil::getImagePath('icon_ok.gif') :
323  ilUtil::getImagePath('icon_not_ok.gif');
324 
325  $txt = !in_array($objective_id,$this->suggested) ?
326  $this->lng->txt('crs_objective_accomplished') :
327  $this->lng->txt('crs_objective_not_accomplished');
328 
329  $this->tpl->setVariable("OBJ_STATUS_IMG_2_OBJECTIVES",$img);
330  $this->tpl->setVariable("OBJ_STATUS_ALT_2_OBJECTIVES",$txt);
331  }
332 
333  $this->tpl->parseCurrentBlock();
334  unset($tmp_objective);
335  }
336  $this->ctrl->setParameter($this,'details','');
337  }
338 
340  {
341  global $rbacsystem,$ilias,$ilUser,$ilObjDataCache;
342 
343  include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
344  include_once './Services/Repository/classes/class.ilRepositoryExplorer.php';
345  include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
346 
347  if(!count($lms = ilCourseObjectiveMaterials::_getAllAssignedMaterials($this->course_obj->getId())))
348  {
349  return false;
350  }
351  if($this->details_id)
352  {
353  $objectives_lm_obj =& new ilCourseObjectiveMaterials($this->details_id);
354  }
355 
356  $lm_continue =& new ilCourseLMHistory($this->course_obj->getRefId(),$ilUser->getId());
357  $continue_data = $lm_continue->getLMHistory();
358 
359  $this->tpl->addBlockfile('LM_BLOCK','lm_block','tpl.crs_objectives_view_lm_table.html','Modules/Course');
360  $this->tpl->setVariable("TBL_TITLE_LMS",$this->lng->txt('crs_learning_materials'));
361 
362 
363  $this->__showHideLinks('lms');
364 
365  if(isset($_SESSION['crs_hide_lms']))
366  {
367  return true;
368  }
369 
370  $this->tpl->setVariable("TBL_HEADER_LMS_TYPE",$this->lng->txt('type'));
371  $this->tpl->setVariable("TBL_HEADER_NAME_LMS",$this->lng->txt('description'));
372 
373  $counter = 1;
374  foreach($lms as $lm_id)
375  {
376  $obj_id = $ilObjDataCache->lookupObjId($lm_id);
377  $obj_type = $ilObjDataCache->lookupType($obj_id);
378 
380 
381  $obj_link = ilRepositoryExplorer::buildLinkTarget($lm_id,$ilObjDataCache->lookupType($obj_id));
382  $obj_frame = ilRepositoryExplorer::buildFrameTarget($ilObjDataCache->lookupType($obj_id),$lm_id,$obj_id);
383  $obj_frame = $obj_frame ? $obj_frame : '';
384  $contentObj = false;
385 
386  if(ilRepositoryExplorer::isClickable($obj_type,$lm_id,$obj_id))
387  {
388  $this->tpl->setCurrentBlock("lm_read");
389  $this->tpl->setVariable("READ_TITLE_LMS",$ilObjDataCache->lookupTitle($obj_id));
390  $this->tpl->setVariable("READ_TARGET_LMS",$obj_frame);
391  $this->tpl->setVariable("READ_LINK_LMS", $obj_link);
392  $this->tpl->parseCurrentBlock();
393  }
394  else
395  {
396  $this->tpl->setCurrentBlock("lm_visible");
397  $this->tpl->setVariable("VISIBLE_LINK_LMS",$ilObjDataCache->lookupTitle($obj_id));
398  $this->tpl->parseCurrentBlock();
399  }
400  // add to desktop link
401  if(!$ilUser->isDesktopItem($lm_id,$obj_type) and
402  ($this->course_obj->getAboStatus() == $this->course_obj->ABO_ENABLED))
403  {
404  if ($rbacsystem->checkAccess('read',$lm_id))
405  {
406  $this->tpl->setCurrentBlock("lm_desklink");
407  $this->ctrl->setParameterByClass(get_class($this->container_gui),'item_ref_id',$lm_id);
408  $this->ctrl->setParameterByClass(get_class($this->container_gui),'item_id',$lm_id);
409  $this->ctrl->setParameterByClass(get_class($this->container_gui),'type',$obj_type);
410 
411  $this->tpl->setVariable("DESK_LINK_LMS",$this->ctrl->getLinkTarget($this->container_gui,'addToDesk'));
412  $this->tpl->setVariable("TXT_DESK_LMS", $this->lng->txt("to_desktop"));
413  $this->tpl->parseCurrentBlock();
414  }
415  }
416 
417  // CONTINUE LINK
418  if(isset($continue_data[$lm_id]))
419  {
420  $this->tpl->setCurrentBlock("lm_continuelink");
421  $this->tpl->setVariable("CONTINUE_LINK_LMS",'ilias.php?baseClass=ilLMPresentationGUI&ref_id='.$lm_id.'&obj_id='.
422  $continue_data[$lm_id]['lm_page_id']);
423 
424  $target = '';
425  $this->tpl->setVariable("CONTINUE_LINK_TARGET",$obj_frame);
426  $this->tpl->setVariable("TXT_CONTINUE_LMS",$this->lng->txt('continue_work'));
427  $this->tpl->parseCurrentBlock();
428  }
429 
430  // Description
431  if(strlen($ilObjDataCache->lookupDescription($obj_id)))
432  {
433  $this->tpl->setCurrentBlock("lms_description");
434  $this->tpl->setVariable("DESCRIPTION_LMS",$ilObjDataCache->lookupDescription($obj_id));
435  $this->tpl->parseCurrentBlock();
436  }
437  // LAST ACCESS
438  if(isset($continue_data["$lm_id"]))
439  {
440  $this->tpl->setVariable("TEXT_INFO_LMS",$this->lng->txt('last_access'));
441  $this->tpl->setVariable('INFO_LMS',ilDatePresentation::formatDate(new ilDateTime($continue_data[$lm_id]['last_access'],IL_CAL_UNIX)));
442 
443  }
444  elseif($obj_type == 'lm')
445  {
446  $this->tpl->setVariable("INFO_LMS",$this->lng->txt('not_accessed'));
447  }
448 
449  if($this->details_id)
450  {
451  $objectives_lm_obj->setLMRefId($lm_id);
452  if($objectives_lm_obj->checkExists())
453  {
454  $objectives_lm_obj =& new ilCourseObjectiveMaterials($this->details_id);
455 
456  if($conditions_ok)
457  {
458  foreach($objectives_lm_obj->getChapters() as $lm_obj_data)
459  {
460  if($lm_obj_data['ref_id'] != $lm_id)
461  {
462  continue;
463  }
464 
465  include_once './Modules/LearningModule/classes/class.ilLMObject.php';
466 
467 
468  $this->tpl->setCurrentBlock("chapters");
469 
470  if($lm_obj_data['type'] == 'st')
471  {
472  $this->tpl->setVariable("TXT_CHAPTER",$this->lng->txt('chapter'));
473  }
474  else
475  {
476  $this->tpl->setVariable("TXT_CHAPTER",$this->lng->txt('page'));
477  }
478  $this->tpl->setVariable("CHAPTER_LINK_LMS","ilias.php?baseClass=ilLMPresentationGUI&ref_id=".
479  $lm_obj_data['ref_id'].
480  '&obj_id='.$lm_obj_data['obj_id']);
481  $this->tpl->setVariable("CHAPTER_LINK_TARGET_LMS",$obj_frame);
482  $this->tpl->setVariable("CHAPTER_TITLE",ilLMObject::_lookupTitle($lm_obj_data['obj_id']));
483  $this->tpl->parseCurrentBlock();
484  }
485  }
486  $this->tpl->setVariable("OBJ_CLASS_CENTER_LMS",'option_value_center_details');
487  $this->tpl->setVariable("OBJ_CLASS_LMS",'option_value_details');
488  }
489  else
490  {
491  $this->tpl->setVariable("OBJ_CLASS_CENTER_LMS",'option_value_center');
492  $this->tpl->setVariable("OBJ_CLASS_LMS",'option_value');
493  }
494  }
495  else
496  {
497  $this->tpl->setVariable("OBJ_CLASS_CENTER_LMS",'option_value_center');
498  $this->tpl->setVariable("OBJ_CLASS_LMS",'option_value');
499  }
500  $this->tpl->setCurrentBlock("lm_row");
501  $this->tpl->setVariable('IMG_TYPE_MAT',ilUtil::getImagePath('icon_'.$obj_type.'.gif'));
502  $this->tpl->setVariable('TXT_IMG_MAT',$this->lng->txt('obj_'.$obj_type));
503  $this->tpl->setVariable("OBJ_NR_LMS",$counter.'.');
504  $this->tpl->parseCurrentBlock();
505 
506  ++$counter;
507  }
508  }
509 
510  function __showTests()
511  {
512  global $ilias,$rbacsystem,$ilObjDataCache,$ilUser;
513 
514  include_once './Modules/Course/classes/class.ilCourseObjectiveMaterials.php';
515 
516  if(!count($tests = $this->__getAllTests()))
517  {
518  return false;
519  }
520 
521  $this->tpl->addBlockfile('TEST_BLOCK','test_block','tpl.crs_objectives_view_tst_table.html','Modules/Course');
522  $this->tpl->setVariable("TBL_TITLE_TST",$this->lng->txt('tests'));
523 
524 
525  $this->__showHideLinks('tst');
526 
527  if(isset($_SESSION['crs_hide_tst']))
528  {
529  return true;
530  }
531 
532  $this->tpl->setVariable("TBL_HEADER_WIDTH_TST_1","75%");
533  $this->tpl->setVariable("TBL_HEADER_NAME_TST_1",$this->lng->txt('description'));
534 
535  $this->tpl->setVariable("TBL_HEADER_WIDTH_TST","5%");
536  $this->tpl->setVariable("TBL_HEADER_NAME_TST",$this->lng->txt('crs_nr'));
537 
538  $this->tpl->setVariable("TBL_HEADER_WIDTH_TST_2","20%");
539  $this->tpl->setVariable("TBL_HEADER_NAME_TST_2",'');
540  $counter = 1;
541  foreach($tests as $tst_id)
542  {
543  $obj_id = $ilObjDataCache->lookupObjId($tst_id);
544  $obj_type = $ilObjDataCache->lookupType($obj_id);
545 
547 
548  $obj_link = ilRepositoryExplorer::buildLinkTarget($tst_id,$obj_type);
549  $obj_link = "ilias.php?baseClass=ilObjTestGUI&ref_id=".$tst_id."&cmd=infoScreen";
550  $obj_frame = '';
551 
552  if(ilRepositoryExplorer::isClickable($obj_type,$tst_id,$obj_id))
553  {
554  $this->tpl->setCurrentBlock("tst_read");
555  $this->tpl->setVariable("READ_TITLE_TST",$ilObjDataCache->lookupTitle($obj_id));
556  $this->tpl->setVariable("READ_TARGET_TST",$obj_frame);
557  $this->tpl->setVariable("READ_LINK_TST", $obj_link.'&crs_show_result='.$this->course_obj->getRefId());
558  $this->tpl->parseCurrentBlock();
559  }
560  else
561  {
562  $this->tpl->setCurrentBlock("tst_visible");
563  $this->tpl->setVariable("VISIBLE_LINK_TST",$ilObjDataCache->lookupTitle($obj_id));
564  $this->tpl->parseCurrentBlock();
565  }
566  // add to desktop link
567  if(!$ilUser->isDesktopItem($tst_id,$obj_type) and
568  ($this->course_obj->getAboStatus() == $this->course_obj->ABO_ENABLED))
569  {
570  if ($rbacsystem->checkAccess('read',$tst_id))
571  {
572  $this->tpl->setCurrentBlock("tst_desklink");
573  $this->ctrl->setParameterByClass(get_class($this->container_gui),'item_ref_id',$tst_id);
574  $this->ctrl->setParameterByClass(get_class($this->container_gui),'item_id',$tst_id);
575  $this->ctrl->setParameterByClass(get_class($this->container_gui),'type',$obj_type);
576  $this->tpl->setVariable("DESK_LINK_TST",$this->ctrl->getLinkTarget($this->container_gui,'addToDesk'));
577 
578  $this->tpl->setVariable("TXT_DESK_TST", $this->lng->txt("to_desktop"));
579  $this->tpl->parseCurrentBlock();
580  }
581  }
582 
583  $this->tpl->setCurrentBlock("tst_row");
584  $this->tpl->setVariable("OBJ_TITLE_TST",$ilObjDataCache->lookupTitle($obj_id));
585  $this->tpl->setVariable("OBJ_NR_TST",$counter.'.');
586 
587  // Check if test is assigned to objective
588  include_once('Modules/Course/classes/class.ilCourseObjectiveQuestion.php');
589  if($this->details_id and ilCourseObjectiveQuestion::_isTestAssignedToObjective($tst_id,$this->details_id))
590  {
591  $this->tpl->setVariable("OBJ_CLASS_CENTER_TST",'option_value_center_details');
592  $this->tpl->setVariable("OBJ_CLASS_TST",'option_value_details');
593  }
594  else
595  {
596  $this->tpl->setVariable("OBJ_CLASS_CENTER_TST",'option_value_center');
597  $this->tpl->setVariable("OBJ_CLASS_TST",'option_value');
598  }
599  $this->tpl->parseCurrentBlock();
600  ++$counter;
601  }
602  }
603 
605  {
606  global $ilias,$rbacsystem,$ilObjDataCache,$objDefinition;
607 
608  if(!count($ors = $this->__getOtherResources()))
609  {
610  return false;
611  }
612 
613  $this->tpl->addBlockfile('RESOURCES_BLOCK','resources_block','tpl.crs_objectives_view_or_table.html','Modules/Course');
614  $this->tpl->setVariable("TBL_TITLE_OR",$this->lng->txt('crs_other_resources'));
615 
616 
617  $this->__showHideLinks('or');
618 
619  if(isset($_SESSION['crs_hide_or']))
620  {
621  return true;
622  }
623 
624  $this->tpl->setCurrentBlock("tbl_header_columns_or");
625  $this->tpl->setVariable("TBL_HEADER_WIDTH_OR","5%");
626  $this->tpl->setVariable("TBL_HEADER_NAME_OR",$this->lng->txt('type'));
627  $this->tpl->parseCurrentBlock();
628 
629  $this->tpl->setCurrentBlock("tbl_header_columns_or");
630  $this->tpl->setVariable("TBL_HEADER_WIDTH_OR","75%");
631  $this->tpl->setVariable("TBL_HEADER_NAME_OR",$this->lng->txt('description'));
632  $this->tpl->parseCurrentBlock();
633 
634  $this->tpl->setCurrentBlock("tbl_header_columns_or");
635  $this->tpl->setVariable("TBL_HEADER_WIDTH_OR","20%");
636  $this->tpl->setVariable("TBL_HEADER_NAME_OR",'');
637  $this->tpl->parseCurrentBlock();
638 
639  $counter = 1;
640  foreach($ors as $or_id)
641  {
642  $obj_id = $ilObjDataCache->lookupObjId($or_id);
643  $obj_type = $ilObjDataCache->lookupType($obj_id);
644 
645  // do not show side block items
646  if ($objDefinition->isSideBlock($obj_type))
647  {
648  continue;
649  }
650 
652 
653  $obj_link = ilRepositoryExplorer::buildLinkTarget($or_id,$obj_type);
654  $obj_frame = ilRepositoryExplorer::buildFrameTarget($obj_type,$or_id,$obj_id);
655  $obj_frame = $obj_frame ? $obj_frame : '';
656 
657  if(ilRepositoryExplorer::isClickable($obj_type,$or_id,$obj_id))
658  {
659  $this->tpl->setCurrentBlock("or_read");
660  $this->tpl->setVariable("READ_TITLE_OR",$ilObjDataCache->lookupTitle($obj_id));
661  $this->tpl->setVariable("READ_TARGET_OR",$obj_frame);
662  $this->tpl->setVariable("READ_LINK_OR", $obj_link);
663  $this->tpl->parseCurrentBlock();
664  }
665  else
666  {
667  $this->tpl->setCurrentBlock("or_visible");
668  $this->tpl->setVariable("VISIBLE_LINK_OR",$ilObjDataCache->lookupTitle($obj_id));
669  $this->tpl->parseCurrentBlock();
670  }
671  // add to desktop link
672  if(!$ilias->account->isDesktopItem($or_id,$obj_type) and
673  ($this->course_obj->getAboStatus() == $this->course_obj->ABO_ENABLED))
674  {
675  if ($rbacsystem->checkAccess('read',$or_id))
676  {
677  $this->tpl->setCurrentBlock("or_desklink");
678  $this->ctrl->setParameterByClass(get_class($this->container_gui),'item_ref_id',$or_id);
679  $this->ctrl->setParameterByClass(get_class($this->container_gui),'item_id',$or_id);
680  $this->ctrl->setParameterByClass(get_class($this->container_gui),'type',$obj_type);
681 
682  $this->tpl->setVariable("DESK_LINK_OR",$this->ctrl->getLinkTarget($this->container_gui,'addToDesk'));
683 
684  $this->tpl->setVariable("TXT_DESK_OR", $this->lng->txt("to_desktop"));
685  $this->tpl->parseCurrentBlock();
686  }
687  }
688 
689  $this->tpl->setCurrentBlock("or_row");
690  $this->tpl->setVariable("OBJ_TITLE_OR",$ilObjDataCache->lookupTitle($obj_id));
691  $this->tpl->setVariable('IMG_TYPE_OR',ilUtil::getTypeIconPath($obj_type,$obj_id,'small'));
692  $this->tpl->setVariable("TXT_IMG_OR",$this->lng->txt('obj_'.$obj_type));
693  $this->tpl->setVariable("OBJ_CLASS_CENTER_OR",'option_value_center');
694  $this->tpl->setVariable("OBJ_CLASS_OR",'option_value');
695  $this->tpl->parseCurrentBlock();
696 
697  ++$counter;
698  }
699  }
700 
701 
702  function __getAllTests()
703  {
704  foreach($items = $this->course_obj->items_obj->getItems() as $node)
705  {
706  switch($node['type'])
707  {
708  case 'tst':
709  $tests[] = $node['ref_id'];
710  break;
711  }
712  }
713  return $tests ? $tests : array();
714  }
715 
717  {
718  include_once('Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
719  $assigned = ilCourseObjectiveMaterials::_getAllAssignedMaterials($this->course_obj->getId());
720 
721  foreach($items = $this->course_obj->items_obj->getItems() as $node)
722  {
723  if(in_array($node['ref_id'],$assigned))
724  {
725  continue;
726  }
727  if($node['type'] == 'tst')
728  {
729  continue;
730  }
731  $all_lms[] = $node['ref_id'];
732  }
733  return $all_lms ? $all_lms : array();
734  }
735 
736 
737  function __showHideLinks($a_part)
738  {
739  if($_GET['show_hide_'.$a_part] == 1)
740  {
741  unset($_SESSION['crs_hide_'.$a_part]);
742  }
743  if($_GET['show_hide_'.$a_part] == 2)
744  {
745  $_SESSION['crs_hide_'.$a_part] = true;
746  }
747 
748  $this->ctrl->setParameter($this,'show_hide_'.$a_part,$_SESSION['crs_hide_'.$a_part] ? 1 : 2);
749  $this->tpl->setVariable("LINK_HIDE_SHOW_".strtoupper($a_part),$this->ctrl->getLinkTarget($this,'view'));
750  $this->tpl->setVariable("TXT_HIDE_SHOW_".strtoupper($a_part),$_SESSION['crs_hide_'.$a_part] ?
751  $this->lng->txt('crs_show_link_'.$a_part) :
752  $this->lng->txt('crs_hide_link_'.$a_part));
753 
754  $this->ctrl->setParameter($this,'show_hide_'.$a_part,'');
755 
756  $this->tpl->setVariable("HIDE_SHOW_IMG_".strtoupper($a_part),$_SESSION['crs_hide_'.$a_part] ?
757  ilUtil::getImagePath('a_down.gif') :
758  ilUtil::getImagePath('a_up.gif'));
759 
760  return true;
761  }
762 
763 
764 
766  {
767  global $tree;
768 
769  if($this->container_obj->getType() == 'crs')
770  {
771  // Container is course
772  $this->course_obj =& $this->container_obj;
773  }
774  else
775  {
776  $course_ref_id = $tree->checkForParentType($this->container_obj->getRefId(),'crs');
777  $this->course_obj =& ilObjectFactory::getInstanceByRefId($course_ref_id);
778  }
779  $this->course_obj->initCourseItemObject();
780  return true;
781  }
782 
783 } // END class.ilCourseObjectivePresentationGUI
784 ?>