ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilContainerObjectiveGUI.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
25include_once("./Services/Container/classes/class.ilContainerContentGUI.php");
26
36{
37 protected $force_details = 0;
38 protected $loc_settings; // [ilLOSettings]
39
40 const MATERIALS_TESTS = 1;
41 const MATERIALS_OTHER = 2;
42
43 private $output_html = '';
44
52 public function __construct($a_container_gui)
53 {
54 global $lng;
55
56 $this->lng = $lng;
57 parent::__construct($a_container_gui);
58
59 $this->initDetails();
60 }
61
69 public function getDetailsLevel($a_objective_id)
70 {
71 // no details anymore
72 return self::DETAILS_ALL;
73
74 /*
75 if($a_objective_id == $this->force_details)
76 {
77 return self::DETAILS_ALL;
78 }
79 return $this->details_level;
80 */
81 }
82
89 public function getMainContent()
90 {
91 global $lng,$ilTabs,$ilAccess;
92
93 // see bug #7452
94// $ilTabs->setSubTabActive($this->getContainerObject()->getType().'_content');
95
96
97 include_once 'Services/Object/classes/class.ilObjectListGUIFactory.php';
98
99 $tpl = new ilTemplate("tpl.container_page.html", true, true,"Services/Container");
100
101 if($GLOBALS['ilAccess']->checkAccess('write','',$this->getContainerObject()->getRefId()))
102 {
103 // check for results
104 include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
105 if(ilLOUserResults::hasResults($this->getContainerObject()->getId(),$GLOBALS['ilUser']->getId()))
106 {
107 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
108 $ilToolbar = new ilToolbarGUI();
109 $ilToolbar->addButton(
110 $lng->txt('crs_reset_results'),
111 $GLOBALS['ilCtrl']->getLinkTargetByClass(get_class($this->getContainerGUI()),'reset')
112 );
113 }
114
115 }
116
117 // Feedback
118 // @todo
119// $this->__showFeedBack();
120
121 $this->items = $this->getContainerObject()->getSubItems($this->getContainerGUI()->isActiveAdministrationPanel());
122
123 $is_manage = $this->getContainerGUI()->isActiveAdministrationPanel();
124 $is_order = $this->getContainerGUI()->isActiveOrdering();
125
126 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
127 $this->loc_settings = ilLOSettings::getInstanceByObjId($this->getContainerObject()->getId());
128
129 $this->initRenderer();
130
131 if(!$is_manage && !$is_order)
132 {
133 // currently inactive
134 // $this->showStatus($tpl);
135 }
136 if(!$is_manage)
137 {
138 $this->showObjectives($tpl, $is_order);
139
140 // $this->showMaterials($tpl,self::MATERIALS_TESTS, false, !$is_order);
141 if(
142 $this->loc_settings->getQualifiedTest() &&
143 $this->loc_settings->isGeneralQualifiedTestVisible()
144 )
145 {
146 $this->output_html .= $this->renderTest($this->loc_settings->getQualifiedTest(), null, false, true);
147 }
148
149 $this->showMaterials($tpl,self::MATERIALS_OTHER, false, !$is_order);
150 }
151 else
152 {
153 $this->showMaterials($tpl, null, $is_manage);
154 }
155
156 // reset results by setting or for admins
157 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
158 if(
159 ilLOSettings::getInstanceByObjId($this->getContainerObject()->getId())->isResetResultsEnabled() or
160 $GLOBALS['ilAccess']->checkAccess('write','',$this->getContainerObject()->getRefId())
161 )
162 {
163 // check for results
164 include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
165 if(ilLOUserResults::hasResults($this->getContainerObject()->getId(),$GLOBALS['ilUser']->getId()))
166 {
167 if (!$is_manage && !$is_order)
168 {
169 $this->showButton('askReset',$lng->txt('crs_reset_results'));
170 }
171 }
172 }
173
174 $tpl->setVariable('CONTAINER_PAGE_CONTENT',$this->output_html);
175
176 return $tpl->get();
177 }
178
186 public function showStatus($tpl)
187 {
188 global $ilUser,$lng;
189
190 include_once('./Modules/Course/classes/class.ilCourseObjectiveResultCache.php');
191
192 $status = ilCourseObjectiveResultCache::getStatus($ilUser->getId(),$this->getContainerObject()->getId());
193 if($status == IL_OBJECTIVE_STATUS_EMPTY) {
194 return;
195 }
196 $info_tpl = new ilTemplate('tpl.crs_objectives_view_info_table.html',true,true,'Modules/Course');
197 $info_tpl->setVariable("INFO_STRING",$lng->txt('crs_objectives_info_'.$status));
198
199 $this->output_html .= $info_tpl->get();
200 }
201
209 public function showObjectives($a_tpl, $a_is_order = false)
210 {
211 global $lng,$ilSetting;
212
214
215 // get embedded blocks
216 $has_container_page = false;
217 if(!$a_is_order)
218 {
219 $output_html = $this->getContainerGUI()->getContainerPageHTML();
220 if ($output_html != "")
221 {
222 $has_container_page = true;
223 $this->output_html .= $this->insertPageEmbeddedBlocks($output_html);
224 }
225 unset($output_html);
226 }
227
228 // All objectives
229 include_once './Modules/Course/classes/class.ilCourseObjective.php';
230 if(!count($objective_ids = ilCourseObjective::_getObjectiveIds($this->getContainerObject()->getId(),true)))
231 {
232 return false;
233 }
234
235 include_once('./Modules/Course/classes/class.ilCourseObjectiveListGUI.php');
236 $this->objective_list_gui = new ilCourseObjectiveListGUI();
237 $this->objective_list_gui->setContainerObject($this->getContainerGUI());
238 if ($ilSetting->get("icon_position_in_lists") == "item_rows")
239 {
240 $this->objective_list_gui->enableIcon(true);
241 }
242
243 $acc = null;
244 if(!$a_is_order)
245 {
246 include_once "Services/Accordion/classes/class.ilAccordionGUI.php";
247 $acc = new ilAccordionGUI();
248 $acc->setUseSessionStorage(true);
249 $acc->setAllowMultiOpened(true);
250 $acc->setBehaviour(ilAccordionGUI::FIRST_OPEN);
251 $acc->setId("crsobjtv_".$this->container_obj->getId());
252 }
253 else
254 {
255 $this->renderer->addCustomBlock('lobj',$lng->txt('crs_objectives'));
256 }
257
258 $lur_data = $this->parseLOUserResults();
259
260 $has_initial = ilLOSettings::getInstanceByObjId($this->container_obj->getId())->worksWithInitialTest();
261
262 $has_lo_page = false;
263 $obj_cnt = 0;
264 foreach($objective_ids as $objective_id)
265 {
266 include_once './Modules/Course/classes/Objectives/class.ilLOUtils.php';
267 if(
268 $has_initial &&
269 (
270 !isset($lur_data[$objective_id]) or
272 $this->container_obj->getId(),
273 ilLOSettings::getInstanceByObjId($this->container_obj->getId())->getInitialTest(),
274 $objective_id)
275 )
276 )
277 {
278 $lur_data[$objective_id] = array("type"=>ilLOSettings::TYPE_TEST_INITIAL);
279 }
280
281 if($html = $this->renderObjective($objective_id, $has_lo_page, $acc, $lur_data[$objective_id]))
282 {
283 $this->renderer->addItemToBlock('lobj', 'lobj', $objective_id, $html);
284 }
285 $obj_cnt++;
286 }
287
288 // buttons for showing/hiding all objectives
289 if (!$a_is_order && $obj_cnt > 1)
290 {
291 $this->showButton("", $lng->txt("crs_show_all_obj"), "", "crs_show_all_obj_btn");
292 $this->showButton("", $lng->txt("crs_hide_all_obj"), "", "crs_hide_all_obj_btn");
293 $acc->setShowAllElement("crs_show_all_obj_btn");
294 $acc->setHideAllElement("crs_hide_all_obj_btn");
295 }
296
297 if(!$has_container_page && $has_lo_page)
298 {
299 // add core co page css
300 include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
301 $GLOBALS["tpl"]->setVariable("LOCATION_CONTENT_STYLESHEET",
303 $GLOBALS["tpl"]->setCurrentBlock("SyntaxStyle");
304 $GLOBALS["tpl"]->setVariable("LOCATION_SYNTAX_STYLESHEET",
306 $GLOBALS["tpl"]->parseCurrentBlock();
307 }
308
309 // order/block
310 if($a_is_order)
311 {
312 $this->addFooterRow();
313
314 $this->output_html .= $output_html.$this->renderer->getHTML();
315
316 $this->renderer->resetDetails();
317 }
318 // view/accordion
319 else
320 {
321 $this->output_html .= "<div class='ilCrsObjAcc'>".$acc->getHTML()."</div>";
322 }
323 }
324
332 public function addFooterRow()
333 {
334 // no details
335 return;
336
337 /*
338 global $ilCtrl;
339
340 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->getContainerObject()->getRefId());
341 $ilCtrl->setParameterByClass("ilrepositorygui", "details_level", "1");
342 $url = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "");
343 $this->renderer->addDetailsLevel(2, $url, ($this->details_level == self::DETAILS_TITLE));
344
345 $ilCtrl->setParameterByClass("ilrepositorygui", "details_level", "2");
346 $url = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "");
347 $this->renderer->addDetailsLevel(3, $url, ($this->details_level == self::DETAILS_ALL));
348
349 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
350 */
351 }
352
353 protected function renderTest($a_test_ref_id, $a_objective_id, $a_is_initial = false, $a_add_border = false, $a_lo_result = array())
354 {
355
356 $node_data = $GLOBALS['tree']->getNodeData($a_test_ref_id);
357
358 // update ti
359 if($a_objective_id)
360 {
361 if($a_is_initial)
362 {
363 $title = sprintf($this->lng->txt('crs_loc_itst_for_objective'), ilCourseObjective::lookupObjectiveTitle($a_objective_id));
364 }
365 else
366 {
367 $title = sprintf($this->lng->txt('crs_loc_qtst_for_objective'), ilCourseObjective::lookupObjectiveTitle($a_objective_id));
368 }
369 $node_data['objective_id'] = $a_objective_id;
370 $node_data['objective_status'] =
371 (
372 $a_lo_result['status'] == ilLOUserResults::STATUS_COMPLETED ?
373 false :
374 false
375 );
376 }
377 else
378 {
379 $obj_id = ilObject::_lookupObjId($a_test_ref_id);
380 $title = ilObject::_lookupTitle($obj_id);
381
382 $title .= (
383 ' ('.
384 (
385 $a_is_initial
386 ? $this->lng->txt('crs_loc_itest_info')
387 : $this->lng->txt('crs_loc_qtest_info')
388 ).
389 ')'
390 );
391 $node_data['objective_id'] = 0;
392 }
393
394 $node_data['title'] = $title;
395
396 return "<div class='ilContObjectivesViewTestItem'>".$this->renderItem($node_data)."</div>";
397 }
398
406 public function showMaterials($a_tpl,$a_mode = null,$a_is_manage = false,$a_as_accordion = false)
407 {
408 global $ilAccess, $lng;
409
411
412 if (is_array($this->items["_all"]))
413 {
414 $this->objective_map = $this->buildObjectiveMap();
415
416 // all rows
417 $item_r = array();
418
419 $position = 1;
420 foreach($this->items["_all"] as $k => $item_data)
421 {
422 if($a_mode == self::MATERIALS_TESTS and $item_data['type'] != 'tst')
423 {
424 continue;
425 }
426 if ($item_data['type'] == 'itgr')
427 {
428 continue;
429 }
430 if(!$a_is_manage)
431 {
432 // if test object is qualified or initial do not show here
433 if($this->objective_map["test_i"] && $item_data["child"] == $this->objective_map["test_i"])
434 {
435 continue;
436 }
437 if($this->objective_map["test_q"] && $item_data["child"] == $this->objective_map["test_q"])
438 {
439 continue;
440 }
441 }
442
443 if($this->rendered_items[$item_data["child"]] !== true &&
444 !$this->renderer->hasItem($item_data["child"]))
445 {
446 $this->rendered_items[$item_data['child']] = true;
447
448 // TODO: Position (DONE ?)
449 $html = $this->renderItem($item_data,$position++,$a_mode == self::MATERIALS_TESTS ? false : true);
450 if ($html != "")
451 {
452 $item_r[] = array("html" => $html, "id" => $item_data["child"], "type" => $item_data["type"]);
453 }
454 }
455 }
456
457 // if we have at least one item, output the block
458 if (count($item_r) > 0)
459 {
460 if(!$a_as_accordion)
461 {
462 $pos = 0;
463
464 switch($a_mode)
465 {
467 $block_id = "tst";
468 $this->renderer->addTypeBlock($block_id);
469 break;
470
472 $block_id = "oth";
473 $this->renderer->addCustomBlock($block_id, $lng->txt('crs_other_resources'));
474 break;
475
476 // manage
477 default:
478 $block_id = "all";
479 $this->renderer->addCustomBlock($block_id, $lng->txt('content'));
480 break;
481 }
482
483 // :TODO:
484 if ($a_mode != self::MATERIALS_TESTS)
485 {
486 $pos = $this->getItemGroupsHTML();
487 }
488
489 foreach($item_r as $h)
490 {
491 if(!$this->renderer->hasItem($h["id"]))
492 {
493 $this->renderer->addItemToBlock($block_id, $h["type"], $h["id"], $h["html"]);
494 }
495 }
496
497 $this->output_html .= $this->renderer->getHTML();
498 }
499 else
500 {
501 switch($a_mode)
502 {
504 $txt = $lng->txt('objs_tst');
505 break;
506
508 $txt = $lng->txt('crs_other_resources');
509 break;
510 }
511
512 include_once "Services/Accordion/classes/class.ilAccordionGUI.php";
513 $acc = new ilAccordionGUI();
514 $acc->setId("crsobjtvmat".$a_mode."_".$this->container_obj->getId());
515
516 $acc_content = array();
517 foreach($item_r as $h)
518 {
519 $acc_content[] = $h["html"];
520 }
521 $acc->addItem($txt, $this->buildAccordionContent($acc_content));
522
523 $this->output_html .= $acc->getHTML();
524 }
525 }
526 }
527 }
528
529 protected function buildObjectiveMap()
530 {
531 $objective_map = array();
532 include_once './Modules/Course/classes/class.ilCourseObjective.php';
533 // begin-patch lok
534 if(count($objective_ids = ilCourseObjective::_getObjectiveIds($this->getContainerObject()->getId(),true)))
535 // end-patch lok
536 {
537 include_once('./Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
538 foreach($objective_ids as $objective_id)
539 {
540 foreach(ilCourseObjectiveMaterials::_getAssignedMaterials($objective_id) as $mat_ref_id)
541 {
542 $objective_map["material"][$mat_ref_id][] = $objective_id;
543
544 if(!isset($objective_map["names"][$objective_id]))
545 {
546 $objective = new ilCourseObjective($this->getContainerObject(), $objective_id);
547 $objective_map["names"][$objective_id] = $objective->getTitle();
548 }
549 }
550 }
551
552 // initial/qualifying test
553 $tst = $this->loc_settings->getInitialTest();
554 if($tst)
555 {
556 $objective_map["test_i"] = $tst;
557 }
558 $tst = $this->loc_settings->getQualifiedTest();
559 if($tst)
560 {
561 $objective_map["test_q"] = $tst;
562 }
563 }
564
565 return $objective_map;
566 }
567
568 protected function addItemDetails(ilObjectListGUI $a_item_list_gui, array $a_item)
569 {
570 global $lng, $ilCtrl;
571
572 $item_ref_id = $a_item["ref_id"];
573
574 if(is_array($this->objective_map))
575 {
576 $details = array();
577 if(isset($this->objective_map["material"][$item_ref_id]))
578 {
579 // #12965
580 foreach($this->objective_map["material"][$item_ref_id] as $objective_id)
581 {
582 $ilCtrl->setParameterByClass('ilcourseobjectivesgui', 'objective_id', $objective_id);
583 $url = $ilCtrl->getLinkTargetByClass(array('illoeditorgui', 'ilcourseobjectivesgui'), 'edit');
584 $ilCtrl->setParameterByClass('ilcourseobjectivesgui', 'objective_id', '');
585
586 $details[] = array(
587 'desc' => $lng->txt('crs_loc_tab_materials').': ',
588 'target' => '_top',
589 'link' => $url,
590 'name' => $this->objective_map["names"][$objective_id]
591 );
592 }
593 }
594 if($this->objective_map["test_i"] == $item_ref_id)
595 {
596 $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 1);
597 $details[] = array(
598 'desc' => '',
599 'target' => '_top',
600 'link' => $ilCtrl->getLinkTargetByClass('illoeditorgui', 'testOverview'),
601 'name' => $lng->txt('crs_loc_tab_itest')
602 );
603 $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 0);
604 }
605 if($this->objective_map["test_q"] == $item_ref_id)
606 {
607 $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 2);
608 $details[] = array(
609 'desc' => '',
610 'target' => '_top',
611 'link' => $ilCtrl->getLinkTargetByClass('illoeditorgui', 'testOverview'),
612 'name' => $lng->txt('crs_loc_tab_qtest')
613 );
614 $ilCtrl->setParameterByClass('illoeditorgui', 'tt', 0);
615 }
616
617 if(sizeof($details))
618 {
619 $a_item_list_gui->enableItemDetailLinks(true);
620 $a_item_list_gui->setItemDetailLinks($details, $lng->txt('crs_loc_settings_tbl').': ');
621 }
622 else
623 {
624 $a_item_list_gui->enableItemDetailLinks(false);
625 }
626 }
627
628 // order
629 if($this->getContainerGUI()->isActiveOrdering())
630 {
631 $a_item_list_gui->enableCommands(true, true);
632 $a_item_list_gui->enableProperties(false);
633 }
634 // view
635 else if(!$this->getContainerGUI()->isActiveAdministrationPanel())
636 {
637 $a_item_list_gui->enableCommands(true, true);
638 $a_item_list_gui->enableProperties(false);
639 }
640
641 if($a_item['objective_id'])
642 {
643 $a_item_list_gui->setDefaultCommandParameters(array('objective_id' => $a_item['objective_id']));
644
645
646 if($this->loc_settings->getQualifiedTest() == $a_item['ref_id'])
647 {
648 $a_item_list_gui->setConditionTarget($this->getContainerObject()->getRefId(), $a_item['objective_id'], 'lobj');
649 // check conditions of target
650 include_once './Services/AccessControl/classes/class.ilConditionHandler.php';
651 $fullfilled = ilConditionHandler::_checkAllConditionsOfTarget($this->getContainerObject()->getRefId(),$a_item['objective_id'],'lobj');
652 if(!$fullfilled || $a_item['objective_status'])
653 {
654 $a_item_list_gui->disableTitleLink(true);
655 }
656 }
657 include_once './Modules/Course/classes/Objectives/class.ilLOUserResults.php';
659 $this->getContainerObject()->getId(),
660 $GLOBALS['ilUser']->getId(),
661 $a_item['objective_id'],
663
664 $res = $this->updateResult($res,$a_item['ref_id'],$a_item['objective_id'],$GLOBALS['ilUser']->getId());
665
666 if($res['is_final'])
667 {
668 $a_item_list_gui->disableTitleLink(true);
669 $a_item_list_gui->enableProperties(true);
670 $a_item_list_gui->addCustomProperty(
671 $this->lng->txt('crs_loc_passes_reached'),
672 '',
673 true
674 );
675 }
676 elseif($this->loc_settings->getQualifiedTest() == $a_item['ref_id'])
677 {
678 include_once './Modules/Course/classes/class.ilCourseObjective.php';
679 $poss_pass = ilCourseObjective::lookupMaxPasses($a_item['objective_id']);
680
681 if($poss_pass)
682 {
683 $a_item_list_gui->enableProperties(true);
684 $a_item_list_gui->addCustomProperty(
685 $this->lng->txt('crs_loc_passes_left'),
686 (($poss_pass - $res['tries']) > 0) ? ($poss_pass - $res['tries']) : 1,
687 false
688 );
689 }
690 }
691 }
692 }
693
694 protected function updateResult($a_res,$a_item_ref_id,$a_objective_id,$a_user_id)
695 {
696
697 if($this->loc_settings->getQualifiedTest() == $a_item_ref_id)
698 {
699 // Check for existing test run, and decrease tries, reset final if run exists
700 include_once './Modules/Test/classes/class.ilObjTest.php';
701 include_once './Modules/Course/classes/Objectives/class.ilLOSettings.php';
703 $a_item_ref_id,
704 $a_user_id);
705
706 if($active)
707 {
708 include_once './Modules/Course/classes/Objectives/class.ilLOTestRun.php';
710 ilObject::_lookupObjId($a_item_ref_id),
711 $a_objective_id,
712 $a_user_id))
713 {
714 ($a_res['tries'] > 0) ? --$a_res['tries'] : 0;
715 $a_res['is_final'] = 0;
716 }
717 }
718 }
719 return $a_res;
720
721 }
722
733 protected function renderObjective($a_objective_id, &$a_has_lo_page, ilAccordionGUI $a_accordion = null, array $a_lo_result = null)
734 {
735 global $ilUser,$lng;
736
737 include_once('./Modules/Course/classes/class.ilCourseObjective.php');
738 $objective = new ilCourseObjective($this->getContainerObject(),$a_objective_id);
739
740 include_once('./Services/Container/classes/class.ilContainerSorting.php');
741 include_once('./Services/Object/classes/class.ilObjectActivation.php');
742 $items = ilObjectActivation::getItemsByObjective($a_objective_id);
743
744 // sorting is handled by ilCourseObjectiveMaterials
745 // $items = ilContainerSorting::_getInstance($this->getContainerObject()->getId())->sortSubItems('lobj',$a_objective_id,$items);
746
747 include_once('./Modules/Course/classes/class.ilCourseObjectiveMaterials.php');
748 $objectives_lm_obj = new ilCourseObjectiveMaterials($a_objective_id);
749
750 // #13381 - map material assignment to position
751 $sort_map = array();
752 foreach($objectives_lm_obj->getMaterials() as $item)
753 {
754 $sort_map[$item["lm_ass_id"]] = $item["position"];
755 }
756
757 $is_manage = $this->getContainerGUI()->isActiveAdministrationPanel();
758 $is_order = $this->getContainerGUI()->isActiveOrdering();
759
760 $sort_content = array();
761
762 foreach($items as $item)
763 {
764 if($this->getDetailsLevel($a_objective_id) < self::DETAILS_ALL)
765 {
766 continue;
767 }
768
769 $item_list_gui2 = $this->getItemGUI($item);
770 $item_list_gui2->enableIcon(true);
771
772 if($is_order || $a_accordion)
773 {
774 $item_list_gui2->enableCommands(true, true);
775 $item_list_gui2->enableProperties(false);
776 }
777
778 $chapters = $objectives_lm_obj->getChapters();
779 if(count($chapters))
780 {
781 $has_sections = false;
782 foreach($chapters as $chapter)
783 {
784 if($chapter['ref_id'] != $item['child'])
785 {
786 continue;
787 }
788 $has_sections = true;
789
790 include_once './Modules/LearningModule/classes/class.ilLMObject.php';
791 $title = $item['title'].
792 " &rsaquo; ".ilLMObject::_lookupTitle($chapter['obj_id']).
793 " (".$lng->txt('obj_'.$chapter['type']).")";
794
795 $item_list_gui2->setDefaultCommandParameters(array(
796 "obj_id" => $chapter['obj_id'],
797 "focus_id" => $chapter['obj_id'],
798 "focus_return" => $this->container_obj->getRefId()));
799
800 if($is_order)
801 {
802 $item_list_gui2->setPositionInputField("[lobj][".$a_objective_id."][".$chapter['lm_ass_id']."]",
803 sprintf('%d', $chapter['position']*10));
804 }
805
806 $sub_item_html = $item_list_gui2->getListItemHTML($item['ref_id'],
807 $item['obj_id'], $title, $item['description']);
808
809 // #13381 - use materials order
810 $sort_key = str_pad($chapter['position'], 5, 0, STR_PAD_LEFT)."_".strtolower($title)."_".$chapter['lm_ass_id'];
811 $sort_content[$sort_key] = $sub_item_html;
812 }
813 }
814
815 $this->rendered_items[$item['child']] = true;
816
817 if($lm_ass_id = $objectives_lm_obj->isAssigned($item['ref_id'], true))
818 {
819 if($is_order)
820 {
821 $item_list_gui2->setPositionInputField("[lobj][".$a_objective_id."][".$lm_ass_id."]",
822 sprintf('%d', $sort_map[$lm_ass_id]*10));
823 }
824
825 $sub_item_html = $item_list_gui2->getListItemHTML($item['ref_id'],
826 $item['obj_id'], $item['title'], $item['description']);
827
828 // #13381 - use materials order
829 $sort_key = str_pad($sort_map[$lm_ass_id], 5, 0, STR_PAD_LEFT)."_".strtolower($item['title'])."_".$lm_ass_id;
830 $sort_content[$sort_key] = $sub_item_html;
831 }
832 }
833
834 if($this->getDetailsLevel($a_objective_id) == self::DETAILS_ALL)
835 {
836 $this->objective_list_gui->enableCommands(false);
837 }
838 else
839 {
840 $this->objective_list_gui->enableCommands(true);
841 }
842
843 if($is_order)
844 {
845 $this->objective_list_gui->setPositionInputField("[lobj][".$a_objective_id."][0]",
846 $objective->__getPosition()*10);
847 }
848
849 ksort($sort_content);
850
851 if(!$a_accordion)
852 {
853 foreach($sort_content as $sub_item_html)
854 {
855 $this->objective_list_gui->addSubItemHTML($sub_item_html);
856 }
857
858 return $this->objective_list_gui->getListItemHTML(
859 0,
860 $a_objective_id,
861 $objective->getTitle(),
862 $objective->getDescription(),
863 ($is_manage || $is_order));
864 }
865 else
866 {
867 $acc_content = $sort_content;
868
869 $initial_shown = false;
870 if($this->loc_settings->getInitialTest() &&
871 $this->loc_settings->getType() == ilLOSettings::LOC_INITIAL_SEL &&
872 !$a_lo_result["initial_status"])
873 {
874 $acc_content[] = $this->renderTest($this->loc_settings->getInitialTest(), $a_objective_id, true, false, $a_lo_result);
875 $initial_shown = true;
876 }
877
878 if(!$initial_shown &&
879 $this->loc_settings->getQualifiedTest() &&
880 $this->loc_settings->isQualifiedTestPerObjectiveVisible())
881 {
882 $acc_content[] = $this->renderTest($this->loc_settings->getQualifiedTest(), $a_objective_id, false, false, $a_lo_result);
883 }
884
885 $co_page = null;
886 include_once("./Services/COPage/classes/class.ilPageUtil.php");
887 if(ilPageUtil::_existsAndNotEmpty("lobj", $objective->getObjectiveId()))
888 {
889 $a_has_lo_page = true;
890
891 include_once 'Modules/Course/classes/Objectives/class.ilLOPageGUI.php';
892 $page_gui = new ilLOPageGUI($objective->getObjectiveId());
893
894 include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
895 $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId(0));
896 $page_gui->setPresentationTitle("");
897 $page_gui->setTemplateOutput(false);
898 $page_gui->setHeader("");
899
900 $co_page = "<div class='ilContObjectiveIntro'>".$page_gui->showPage()."</div>";
901 }
902
903 $a_accordion->addItem(
904 $this->buildAccordionTitle($objective, $a_lo_result),
905 $co_page.
906 $this->buildAccordionContent($acc_content)
907 );
908 }
909 }
910
918 protected function initDetails()
919 {
920 global $ilUser;
921
922 // no details
923 return;
924
925 /*
926 if(isset($_GET['details_level']))
927 {
928 $this->details_level = (int) $_GET['details_level'];
929 ilObjUser::_writePref($ilUser->getId(),'crs_objectives_details',$this->details_level);
930 }
931 else
932 {
933 $this->details_level = $ilUser->getPref('crs_objectives_details') ? $ilUser->getPref('crs_objectives_details') : self::DETAILS_TITLE;
934 }
935 if(isset($_GET['objective_details']))
936 {
937 $this->force_details = (int) $_GET['objective_details'];
938 ilObjUser::_writePref($ilUser->getId(),'crs_objectives_force_details_'.$this->getContainerObject()->getId(),$this->force_details);
939 }
940 elseif($details_id = $ilUser->getPref('crs_objectives_force_details_'.$this->getContainerObject()->getId()))
941 {
942 $this->force_details = $details_id;
943 }
944 else
945 {
946 include_once './Modules/Course/classes/class.ilCourseObjective.php';
947 include_once('./Modules/Course/classes/class.ilCourseObjectiveResultCache.php');
948 foreach(ilCourseObjective::_getObjectiveIds($this->getContainerObject()->getId()) as $objective_id)
949 {
950 if(ilCourseObjectiveResultCache::isSuggested($ilUser->getId(),$this->getContainerObject()->getId(),$objective_id))
951 {
952 $this->force_details = $objective_id;
953 break;
954 }
955 }
956 }
957 return true;
958 */
959 }
960
961 protected function parseLOUserResults()
962 {
963 global $ilUser;
964
965 $res = array();
966
967 include_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php";
968 $lur = new ilLOUserResults($this->getContainerObject()->getId(), $ilUser->getId());
969 foreach($lur->getCourseResultsForUserPresentation() as $objective_id => $types)
970 {
971 // show either initial or qualified for objective
972 if(isset($types[ilLOUserResults::TYPE_INITIAL]))
973 {
974 $initial_status = $types[ilLOUserResults::TYPE_INITIAL]["status"];
975 }
976
977 // qualified test has priority
978 if(isset($types[ilLOUserResults::TYPE_QUALIFIED]))
979 {
982 }
983 else
984 {
987 }
988
989 $result["initial_status"] = $initial_status;
990
991 $res[$objective_id] = $result;
992 }
993
994 return $res;
995 }
996
997 public static function buildObjectiveProgressBar($a_has_initial_test, $a_objective_id, array $a_lo_result, $a_list_mode = false)
998 {
999 global $lng;
1000
1001 $tpl = new ilTemplate("tpl.objective_progressbar.html", true, true, "Services/Container");
1002
1003 $tooltip_id = "crsobjtvusr_".$a_objective_id;
1004
1005 $tt_txt = sprintf($lng->txt("crs_loc_tt_info"),
1006 $a_lo_result["result_perc"], $a_lo_result["limit_perc"]);
1007
1008 // #12970
1009 $perc_resize = (int)$a_lo_result["result_perc"];
1010 /*
1011 if($a_lo_result["limit_perc"] && $a_lo_result["result_perc"])
1012 {
1013 $perc_resize = min(round($a_lo_result["result_perc"]*(100/$a_lo_result["limit_perc"])), 100);
1014 }
1015 */
1016
1017 $next_step = $progress_txt = $bar_color = null;
1018
1019 // qualifying test
1020 if($a_lo_result["type"] == ilLOUserResults::TYPE_QUALIFIED)
1021 {
1022 $progress_txt = $lng->txt("crs_loc_progress_result_qtest");
1023 $tt_txt = $lng->txt("crs_loc_tab_qtest").": ".$tt_txt;
1024
1025 if($a_lo_result["status"] == ilLOUserResults::STATUS_COMPLETED)
1026 {
1027 $next_step = $lng->txt("crs_loc_progress_objective_complete");
1028 $bar_color = "#80f080";
1029 }
1030 else
1031 {
1032 $next_step = $lng->txt("crs_loc_progress_do_qualifying_again");
1033 $bar_color = "#f08080";
1034 }
1035 }
1036 // initial test
1037 else
1038 {
1039 if($a_lo_result["status"])
1040 {
1041 $progress_txt = $lng->txt("crs_loc_progress_result_itest");
1042 $tt_txt = $lng->txt("crs_loc_tab_itest").": ".$tt_txt;
1043
1044 $bar_color = "#aaa";
1045
1046 if($a_lo_result["status"] == ilLOUserResults::STATUS_COMPLETED)
1047 {
1048 $next_step = $lng->txt("crs_loc_progress_do_qualifying");
1049 }
1050 else
1051 {
1052 $next_step = $lng->txt("crs_loc_suggested");
1053 }
1054 }
1055 // not attempted: no progress bar
1056 else
1057 {
1058 if((bool)$a_has_initial_test)
1059 {
1060 $next_step = $lng->txt("crs_loc_progress_no_result_do_initial");
1061 }
1062 else
1063 {
1064 $next_step = $lng->txt("crs_loc_progress_no_result_no_initial");
1065 }
1066 }
1067 }
1068
1069 if($progress_txt)
1070 {
1071 $tpl->setCurrentBlock("statustxt_bl");
1072 $tpl->setVariable("TXT_PROGRESS_STATUS", $progress_txt);
1073 $tpl->parseCurrentBlock();
1074 }
1075
1076 if($bar_color)
1077 {
1078 if($a_lo_result["limit_perc"])
1079 {
1080 $limit_pos = (121-ceil(125/100*$a_lo_result["limit_perc"]))*-1;
1081 }
1082 else
1083 {
1084 $limit_pos = -121;
1085 }
1086
1087 $tpl->setCurrentBlock("statusbar_bl");
1088 $tpl->setVariable("PERC_STATUS", $a_lo_result["result_perc"]);
1089 $tpl->setVariable("LIMIT_POS", $limit_pos);
1090 $tpl->setVariable("PERC_WIDTH", $perc_resize);
1091 $tpl->setVariable("PERC_COLOR", $bar_color);
1092 $tpl->setVariable("BG_COLOR", "#fff");
1093 $tpl->setVariable("TT_ID", $tooltip_id);
1094 $tpl->parseCurrentBlock();
1095 }
1096
1097 if($next_step && !$a_list_mode)
1098 {
1099 $tpl->setCurrentBlock("nstep_bl");
1100 $tpl->setVariable("TXT_NEXT_STEP", $next_step);
1101 $tpl->parseCurrentBlock();
1102 }
1103
1104 if($tt_txt)
1105 {
1106 include_once("./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
1107 ilTooltipGUI::addTooltip($tooltip_id, $tt_txt);
1108 }
1109
1110 return $tpl->get();
1111 }
1112
1113 protected function buildAccordionTitle(ilCourseObjective $a_objective, array $a_lo_result = null)
1114 {
1115 $tpl = new ilTemplate("tpl.objective_accordion_title.html", true, true, "Services/Container");
1116
1117 if($a_lo_result)
1118 {
1119 $tpl->setVariable("PROGRESS_BAR", self::buildObjectiveProgressBar(
1120 (bool)$this->loc_settings->getInitialTest(),
1121 $a_objective->getObjectiveId(),
1122 $a_lo_result)
1123 );
1124 }
1125
1126 // $tpl->setVariable("ICON_SRC", ilObject::_getIcon($a_objective->getObjectiveId(), "small", "lobj"));
1127 // $tpl->setVariable("ICON_TXT", $this->lng->txt("icon")." ".$this->lng->txt("crs_objectives"));
1128 $tpl->setVariable("TITLE", $this->lng->txt("crs_loc_learning_objective").": ".trim($a_objective->getTitle()));
1129 $tpl->setVariable("DESCRIPTION", nl2br(trim($a_objective->getDescription())));
1130
1131 return $tpl->get();
1132 }
1133
1134 protected function buildAccordionContent(array $a_items)
1135 {
1136 $tpl = new ilTemplate("tpl.objective_accordion_content.html", true, true, "Services/Container");
1137 foreach($a_items as $item)
1138 {
1139 $tpl->setCurrentBlock("items_bl");
1140 $tpl->setVariable("ITEM", $item);
1141 $tpl->parseCurrentBlock();
1142 }
1143 return $tpl->get();
1144 }
1145
1153 protected function showButton($a_cmd,$a_text,$a_target = '', $a_id = "")
1154 {
1155 global $ilToolbar, $ilCtrl;
1156
1157 // #11842
1158 $ilToolbar->addButton($a_text,
1159 $ilCtrl->getLinkTarget($this->getContainerGUI(),$a_cmd),
1160 $a_target, "", '', $a_id);
1161 }
1162}
1163?>
$result
global $tpl
Definition: ilias.php:8
const IL_OBJECTIVE_STATUS_EMPTY
Accordion user interface class.
_checkAllConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type="", $a_usr_id=0)
checks wether all conditions of a target object are fulfilled
Parent class of all container content GUIs.
initRenderer()
Init container renderer.
getContainerObject()
Get container object.
getContainerGUI()
Get container GUI object.
renderItem($a_item_data, $a_position=0, $a_force_icon=false, $a_pos_prefix="")
Render an item.
insertPageEmbeddedBlocks($a_output_html)
Insert blocks into container page.
getItemGroupsHTML($a_pos=0)
Get item groups HTML.
getItemGUI($item_data, $a_show_path=false)
Get ListGUI object for item.
clearAdminCommandsDetermination()
cleaer administration commands determination
GUI class for course objective view.
renderObjective($a_objective_id, &$a_has_lo_page, ilAccordionGUI $a_accordion=null, array $a_lo_result=null)
render objective
buildAccordionTitle(ilCourseObjective $a_objective, array $a_lo_result=null)
showButton($a_cmd, $a_text, $a_target='', $a_id="")
show action button
addItemDetails(ilObjectListGUI $a_item_list_gui, array $a_item)
__construct($a_container_gui)
Constructor.
getDetailsLevel($a_objective_id)
get details level
updateResult($a_res, $a_item_ref_id, $a_objective_id, $a_user_id)
showMaterials($a_tpl, $a_mode=null, $a_is_manage=false, $a_as_accordion=false)
Show all other (no assigned tests, no assigned materials) materials.
renderTest($a_test_ref_id, $a_objective_id, $a_is_initial=false, $a_add_border=false, $a_lo_result=array())
showObjectives($a_tpl, $a_is_order=false)
show objectives
getMainContent()
Impementation of abstract method getMainContent.
static buildObjectiveProgressBar($a_has_initial_test, $a_objective_id, array $a_lo_result, $a_list_mode=false)
List gui for course objectives.
class ilCourseObjectiveMaterials
static _getAssignedMaterials($a_objective_id)
get assigned materials
static getStatus($a_usr_id, $a_crs_id)
get status of user
class ilcourseobjective
static lookupObjectiveTitle($a_objective_id)
static lookupMaxPasses($a_objective_id)
static _getObjectiveIds($course_id, $a_activated_only=false)
(Course) learning objective page GUI class
static getInstanceByObjId($a_obj_id)
get singleton instance
static lookupRunExistsForObjective($a_test_id, $a_objective_id, $a_user_id)
@global type $ilDB
static hasResults($a_container_id, $a_user_id)
static lookupResult($a_course_obj_id, $a_user_id, $a_objective_id, $a_tst_type)
Lookup user result.
static hasActiveRun($a_container_id, $a_test_ref_id, $a_objective_id)
getContentStylePath($a_style_id)
get content style path
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
getSyntaxStylePath()
get syntax style path
static isParticipantsLastPassActive($testObjId, $userId)
static getItemsByObjective($a_objective_id)
Get objective items.
Class ilObjectListGUI.
setConditionTarget($a_ref_id, $a_obj_id, $a_target_type)
enableCommands($a_status, $a_std_only=false)
En/disable commands.
setDefaultCommandParameters(array $a_params)
enableProperties($a_status)
En/disable properties.
addCustomProperty($a_property="", $a_value="", $a_alert=false, $a_newline=false)
add custom property
enableItemDetailLinks($a_status)
enable item detail links E.g Direct links to chapters or pages
setItemDetailLinks($a_detail_links, $a_intro_txt='')
set items detail links
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
_existsAndNotEmpty($a_parent_type, $a_id, $a_lang="-")
checks whether page exists and is not empty (may return true on some empty pages)
special template class to simplify handling of ITX/PEAR
static addTooltip($a_el_id, $a_text, $a_container="", $a_my="bottom center", $a_at="top center", $a_use_htmlspecialchars=true)
Adds a tooltip to an HTML element.
$txt
Definition: error.php:10
$GLOBALS['ct_recipient']
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40
global $ilUser
Definition: imgupload.php:15