1<?php 2 3declare(strict_types=1); 4 5/** 6 * Class ilObjLearningSequenceGUI 7 * 8 * @ilCtrl_isCalledBy ilObjLearningSequenceGUI: ilRepositoryGUI 9 * @ilCtrl_isCalledBy ilObjLearningSequenceGUI: ilAdministrationGUI 10 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilPermissionGUI 11 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilInfoScreenGUI 12 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilCommonActionDispatcherGUI 13 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilColumnGUI 14 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilObjectCopyGUI 15 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilExportGUI 16 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilContainerLinkListGUI 17 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilObjLearningSequenceSettingsGUI 18 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilObjLearningSequenceContentGUI 19 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilObjLearningSequenceLearnerGUI 20 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilLearningSequenceMembershipGUI 21 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilLearningProgressGUI 22 * 23 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilObjLearningModuleGUI 24 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilObjFileBasedLMGUI 25 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilObjSAHSLearningModuleGUI 26 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilObjContentPageGUI 27 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilObjExerciseGUI 28 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilObjFileGUI 29 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilObjIndividualAssessmentGUI 30 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilIndividualAssessmentSettingsGUI 31 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilObjTestGUI 32 * @ilCtrl_Calls ilObjLearningSequenceGUI: ilObjSurveyGUI 33 34 */ 35class ilObjLearningSequenceGUI extends ilContainerGUI 36{ 37 const CMD_VIEW = "view"; 38 const CMD_LEARNER_VIEW = "learnerView"; 39 const CMD_CONTENT = "manageContent"; 40 41 const CMD_MEMBERS = "members"; 42 const CMD_MANAGE_MEMBERS = "participants"; 43 const CMD_MEMBERS_GALLERY = "jump2UsersGallery"; 44 45 const CMD_INFO = "showSummary"; 46 const CMD_INFO_SCREEN = "infoScreen"; 47 const CMD_SETTINGS = "settings"; 48 const CMD_PERMISSIONS = "perm"; 49 const CMD_LP = "learningProgress"; 50 const CMD_EXPORT = "export"; 51 const CMD_IMPORT = "importFile"; 52 const CMD_CREATE = "create"; 53 const CMD_SAVE = "save"; 54 const CMD_CANCEL = "cancel"; 55 const CMD_UNPARTICIPATE = "unparticipate"; 56 const CMD_ADD_TO_DESK = "addToDesk"; 57 const CMD_REMOVE_FROM_DESK = "removeFromDesk"; 58 const CMD_LINK = "link"; 59 const CMD_CANCEL_LINK = "cancelMoveLink"; 60 const CMD_CUT = "cut"; 61 const CMD_CANCEL_CUT = "cancelCut"; 62 const CMD_CUT_SHOWTREE = "showPasteTree"; 63 const CMD_CUT_CLIPBOARD = "keepObjectsInClipboard"; 64 const CMD_DELETE = "delete"; 65 const CMD_CANCEL_DELETE = "cancelDelete"; 66 const CMD_DELETE_CONFIRMED = "confirmedDelete"; 67 const CMD_PERFORM_PASTE = 'performPasteIntoMultipleObjects'; 68 const CMD_SHOW_TRASH = 'trash'; 69 const CMD_UNDELETE = 'undelete'; 70 71 const TAB_VIEW_CONTENT = "view_content"; 72 const TAB_MANAGE = "manage"; 73 const TAB_CONTENT_MAIN = "manage_content_maintab"; 74 const TAB_INFO = "show_summary"; 75 const TAB_SETTINGS = "settings"; 76 const TAB_PERMISSIONS = "perm_settings"; 77 const TAB_MEMBERS = "members"; 78 const TAB_LP = "learning_progress"; 79 const TAB_EXPORT = "export"; 80 81 const MAIL_ALLOWED_ALL = 1; 82 const MAIL_ALLOWED_TUTORS = 2; 83 84 public $object; 85 86 public static function _goto(string $target) 87 { 88 global $DIC; 89 90 $ctrl = $DIC->ctrl(); 91 $id = explode("_", $target); 92 $ctrl->setTargetScript("ilias.php"); 93 $ctrl->initBaseClass("ilRepositoryGUI"); 94 $ctrl->setParameterByClass("ilobjlearningsequencegui", "ref_id", $id[0]); 95 $ctrl->redirectByClass(array( "ilRepositoryGUI", "ilobjlearningsequencegui" ), self::CMD_VIEW); 96 } 97 98 public function __construct() 99 { 100 $this->ref_id = (int) $_GET['ref_id']; 101 parent::__construct([], $this->ref_id, true, false); 102 103 $this->obj_type = ilObjLearningSequence::OBJ_TYPE; 104 105 global $DIC; 106 $this->ctrl = $DIC['ilCtrl']; 107 $this->lng = $DIC['lng']; 108 $this->user = $DIC['ilUser']; 109 $this->tabs = $DIC['ilTabs']; 110 $this->toolbar = $DIC['ilToolbar']; 111 $this->help = $DIC['ilHelp']; 112 $this->settings = $DIC['ilSetting']; 113 $this->access = $DIC['ilAccess']; 114 $this->rbac_review = $DIC['rbacreview']; 115 $this->ui_factory = $DIC['ui.factory']; 116 $this->ui_renderer = $DIC['ui.renderer']; 117 $this->log = $DIC["ilLoggerFactory"]->getRootLogger(); 118 $this->app_event_handler = $DIC['ilAppEventHandler']; 119 $this->navigation_history = $DIC['ilNavigationHistory']; 120 $this->obj_definition = $DIC['objDefinition']; 121 $this->obj_service = $DIC->object(); 122 $this->toolbar = $DIC['ilToolbar']; 123 124 $this->help->setScreenIdComponent($this->obj_type); 125 $this->lng->loadLanguageModule($this->obj_type); 126 127 $this->object = $this->getObject(); 128 } 129 130 protected function getCurrentItemLearningProgress() 131 { 132 $usr_id = (int) $this->user->getId(); 133 $items = $this->getLearnerItems($usr_id); 134 $current_item_ref_id = $this->getCurrentItemForLearner($usr_id); 135 foreach ($items as $index => $item) { 136 if ($item->getRefId() === $current_item_ref_id) { 137 return $item->getLearningProgressStatus(); 138 } 139 } 140 } 141 142 protected function recordLearningSequenceRead() 143 { 144 ilChangeEvent::_recordReadEvent( 145 $this->object->getType(), 146 $this->object->getRefId(), 147 $this->object->getId(), 148 $this->user->getId() 149 ); 150 } 151 152 public function executeCommand() 153 { 154 $next_class = $this->ctrl->getNextClass($this); 155 $cmd = $this->ctrl->getCmd(); 156 157 //exit real early for LP-checking. 158 if ($cmd === LSControlBuilder::CMD_CHECK_CURRENT_ITEM_LP) { 159 if (isset($_GET[LSControlBuilder::PARAM_LP_CURRENT_ITEM_OBJID])) { 160 $current_obj_obj_id = (int) $_GET[LSControlBuilder::PARAM_LP_CURRENT_ITEM_OBJID]; 161 162 print (int) ilLPStatus::_lookupStatus( 163 $current_obj_obj_id, 164 $this->user->getId(), 165 true 166 ); 167 exit; 168 } 169 170 //this is the previous way (before #28840) 171 //with iteration over learner items. 172 print $this->getCurrentItemLearningProgress(); 173 exit; 174 } 175 176 $tpl = $this->tpl; 177 parent::prepareOutput(); 178 $this->addToNavigationHistory(); 179 //showRepTree is from containerGUI; 180 //LSO will attach allowed subitems to whitelist 181 //see: $this::getAdditionalWhitelistTypes 182 $this->showRepTree(); 183 184 $in_player = ( 185 $next_class === 'ilobjlearningsequencelearnergui' 186 && $cmd === 'view' 187 ); 188 189 $tpl->setPermanentLink("lso", $this->ref_id); 190 191 switch ($next_class) { 192 case "ilcommonactiondispatchergui": 193 $gui = ilCommonActionDispatcherGUI::getInstanceFromAjaxCall(); 194 $this->ctrl->forwardCommand($gui); 195 break; 196 case "ilinfoscreengui": 197 $this->info($cmd); 198 break; 199 case "ilpermissiongui": 200 $this->permissions($cmd); 201 break; 202 case "ilobjlearningsequencesettingsgui": 203 $this->settings($cmd); 204 break; 205 case "ilobjlearningsequencecontentgui": 206 $this->manageContent($cmd); 207 break; 208 case "ilobjlearningsequencelearnergui": 209 $this->learnerView($cmd); 210 break; 211 case "illearningsequencemembershipgui": 212 $this->manage_members($cmd); 213 break; 214 case 'ilmailmembersearchgui': 215 $this->mail(); 216 break; 217 case 'illearningprogressgui': 218 $this->learningProgress($cmd); 219 break; 220 case 'ilexportgui': 221 $this->export(); 222 break; 223 case 'ilobjectcopygui': 224 $cp = new ilObjectCopyGUI($this); 225 $cp->setType('lso'); 226 $this->ctrl->forwardCommand($cp); 227 break; 228 case 'ilobjindividualassessmentgui': 229 $struct = ['ilrepositorygui','ilobjindividualassessmentgui']; 230 if ($cmd === 'edit') { 231 $struct[] = 'ilindividualassessmentsettingsgui'; 232 } 233 $this->ctrl->redirectByClass($struct, $cmd); 234 235 break; 236 237 case false: 238 if ($cmd === '') { 239 $cmd = self::CMD_VIEW; 240 } 241 242 switch ($cmd) { 243 case self::CMD_IMPORT: 244 $this->importFileObject(); 245 break; 246 case self::CMD_INFO: 247 case self::CMD_INFO_SCREEN: 248 $this->info(); 249 break; 250 case self::CMD_VIEW: 251 case self::CMD_LEARNER_VIEW: 252 case self::CMD_CONTENT: 253 case self::CMD_MEMBERS: 254 case self::CMD_SETTINGS: 255 case self::CMD_SAVE: 256 case self::CMD_CREATE: 257 case self::CMD_LP: 258 case self::CMD_UNPARTICIPATE: 259 $this->$cmd(); 260 break; 261 case self::CMD_CANCEL: 262 if ($this->getCreationMode()) { 263 $this->cancelCreation(); 264 } 265 break; 266 case self::CMD_REMOVE_FROM_DESK: 267 $this->removeFromDeskObject(); 268 $this->view(); 269 break; 270 case self::CMD_ADD_TO_DESK: 271 $this->addToDeskObject(); 272 $this->view(); 273 break; 274 case self::CMD_CUT: 275 $this->cutObject(); 276 break; 277 case self::CMD_CUT_SHOWTREE: 278 $this->showPasteTreeObject(); 279 break; 280 case self::CMD_CUT_CLIPBOARD: 281 $this->keepObjectsInClipboardObject(); 282 break; 283 case self::CMD_LINK: 284 $this->linkObject(); 285 break; 286 case self::CMD_DELETE: 287 $this->deleteObject(); 288 break; 289 case self::CMD_DELETE_CONFIRMED: 290 $this->confirmedDeleteObject(); 291 break; 292 case self::CMD_PERFORM_PASTE: 293 $this->performPasteIntoMultipleObjectsObject(); 294 break; 295 case self::CMD_SHOW_TRASH: 296 $this->trashObject(); 297 break; 298 case self::CMD_UNDELETE: 299 $this->undeleteObject(); 300 break; 301 302 case self::CMD_CANCEL_CUT: 303 case self::CMD_CANCEL_DELETE: 304 case self::CMD_CANCEL_LINK: 305 $cmd = self::CMD_CONTENT; 306 $this->$cmd(); 307 break; 308 309 default: 310 throw new ilException("ilObjLearningSequenceGUI: Invalid command '$cmd'"); 311 } 312 break; 313 default: 314 throw new ilException("ilObjLearningSequenceGUI: Can't forward to next class $next_class"); 315 } 316 317 if (!$in_player) { 318 $this->addHeaderAction(); 319 } 320 } 321 322 public function addToNavigationHistory() 323 { 324 if ( 325 !$this->getCreationMode() && 326 $this->access->checkAccess('read', '', $this->ref_id) 327 ) { 328 $link = ilLink::_getLink($this->ref_id, $this->obj_type); 329 $this->navigation_history->addItem($this->ref_id, $link, $this->obj_type); 330 } 331 } 332 333 protected function info(string $cmd = self::CMD_INFO) 334 { 335 $this->tabs->setTabActive(self::TAB_INFO); 336 $this->ctrl->setCmdClass('ilinfoscreengui'); 337 $this->ctrl->setCmd($cmd); 338 $info = new ilInfoScreenGUI($this); 339 $this->ctrl->forwardCommand($info); 340 } 341 342 protected function permissions(string $cmd = self::CMD_PERMISSIONS) 343 { 344 $this->tabs->setTabActive(self::TAB_PERMISSIONS); 345 $perm_gui = new ilPermissionGUI($this); 346 $this->ctrl->setCmd($cmd); 347 $this->ctrl->forwardCommand($perm_gui); 348 } 349 350 protected function settings(string $cmd = self::CMD_SETTINGS) 351 { 352 $this->tabs->activateTab(self::TAB_SETTINGS); 353 $gui = new ilObjLearningSequenceSettingsGUI( 354 $this->getObject(), 355 $this->ctrl, 356 $this->lng, 357 $this->tpl, 358 $this->obj_service 359 ); 360 $this->ctrl->setCmd($cmd); 361 $this->ctrl->forwardCommand($gui); 362 } 363 364 protected function view() 365 { 366 $this->tabs->clearSubTabs(); 367 if ($this->checkAccess("write")) { 368 $this->manageContent(self::CMD_CONTENT); 369 return; 370 } 371 if ($this->checkAccess("read")) { 372 $this->learnerView(self::CMD_LEARNER_VIEW); 373 $this->recordLearningSequenceRead(); 374 return; 375 } 376 $this->info(self::CMD_INFO); 377 $this->recordLearningSequenceRead(); 378 } 379 380 protected function manageContent(string $cmd = self::CMD_CONTENT) 381 { 382 $this->tabs->activateTab(self::TAB_CONTENT_MAIN); 383 $this->addSubTabsForContent($cmd); 384 $this->tabs->activateSubTab(self::TAB_MANAGE); 385 386 $gui = new ilObjLearningSequenceContentGUI( 387 $this, 388 $this->ctrl, 389 $this->tpl, 390 $this->lng, 391 $this->access, 392 new ilConfirmationGUI(), 393 new LSItemOnlineStatus() 394 ); 395 $this->ctrl->setCmd($cmd); 396 $this->ctrl->forwardCommand($gui); 397 } 398 399 protected function learnerView(string $cmd = self::CMD_LEARNER_VIEW) 400 { 401 $this->tabs->activateTab(self::TAB_CONTENT_MAIN); 402 $this->addSubTabsForContent($cmd); 403 $this->tabs->activateSubTab(self::TAB_VIEW_CONTENT); 404 405 $usr_id = (int) $this->user->getId(); 406 $items = $this->getLearnerItems($usr_id); 407 $current_item_ref_id = $this->getCurrentItemForLearner($usr_id); 408 409 $gui = new ilObjLearningSequenceLearnerGUI( 410 $this->getObject(), 411 $usr_id, 412 $items, 413 $current_item_ref_id, 414 $this->ctrl, 415 $this->lng, 416 $this->tpl, 417 $this->toolbar, 418 $this->ui_factory, 419 $this->ui_renderer 420 ); 421 422 $this->ctrl->setCmd($cmd); 423 $this->ctrl->forwardCommand($gui); 424 } 425 426 protected function members() 427 { 428 $may_manage_members = $this->checkAccess("edit_members"); 429 $this->ctrl->setCmdClass('ilLearningSequenceMembershipGUI'); 430 if ($may_manage_members) { 431 $this->manage_members(self::CMD_MANAGE_MEMBERS); 432 } else { 433 $this->manage_members(self::CMD_MEMBERS_GALLERY); 434 } 435 } 436 437 protected function manage_members(string $cmd = self::CMD_MANAGE_MEMBERS) 438 { 439 $this->tabs->setTabActive(self::TAB_MEMBERS); 440 441 $ms_gui = new ilLearningSequenceMembershipGUI( 442 $this, 443 $this->getObject(), 444 $this->getTrackingObject(), 445 ilPrivacySettings::_getInstance(), 446 $this->lng, 447 $this->ctrl, 448 $this->access, 449 $this->rbac_review, 450 $this->settings, 451 $this->toolbar 452 ); 453 454 $this->ctrl->setCmd($cmd); 455 $this->ctrl->forwardCommand($ms_gui); 456 } 457 458 protected function learningProgress(string $cmd = self::CMD_LP) 459 { 460 $this->tabs->setTabActive(self::TAB_LP); 461 462 $for_user = $this->user->getId(); 463 464 if ($_GET['user_id']) { 465 $for_user = $_GET['user_id']; 466 } 467 468 $lp_gui = new ilLearningProgressGUI( 469 ilLearningProgressGUI::LP_CONTEXT_REPOSITORY, 470 $this->getObject()->getRefId(), 471 $for_user 472 ); 473 474 if ($cmd === self::CMD_LP) { 475 $cmd = ''; 476 } 477 478 $this->ctrl->setCmd($cmd); 479 $this->ctrl->forwardCommand($lp_gui); 480 } 481 482 protected function export() 483 { 484 $this->tabs->setTabActive(self::TAB_EXPORT); 485 $gui = new ilExportGUI($this); 486 $gui->addFormat("xml"); 487 488 $this->ctrl->forwardCommand($gui); 489 } 490 491 protected function initDidacticTemplate(ilPropertyFormGUI $form) 492 { 493 return $form; 494 } 495 496 protected function create() 497 { 498 parent::createObject(); 499 } 500 501 protected function save() 502 { 503 parent::saveObject(); 504 } 505 506 protected function afterSave(ilObject $new_object) 507 { 508 $participant = new ilLearningSequenceParticipants( 509 (int) $new_object->getId(), 510 $this->log, 511 $this->app_event_handler, 512 $this->settings 513 ); 514 515 $participant->add($this->user->getId(), IL_LSO_ADMIN); 516 $participant->updateNotification($this->user->getId(), $this->settings->get('mail_lso_admin_notification', true)); 517 518 519 $settings = new \ilContainerSortingSettings($new_object->getId()); 520 $settings->setSortMode(\ilContainer::SORT_MANUAL); 521 $settings->setSortDirection(\ilContainer::SORT_DIRECTION_ASC); 522 $settings->setSortNewItemsOrder(\ilContainer::SORT_NEW_ITEMS_ORDER_CREATION); 523 $settings->setSortNewItemsPosition(\ilContainer::SORT_NEW_ITEMS_POSITION_BOTTOM); 524 $settings->save(); 525 526 ilUtil::sendSuccess($this->lng->txt('object_added'), true); 527 $this->ctrl->setParameter($this, "ref_id", $new_object->getRefId()); 528 ilUtil::redirect( 529 $this->getReturnLocation( 530 "save", 531 $this->ctrl->getLinkTarget($this, self::CMD_SETTINGS, "", false, false) 532 ) 533 ); 534 } 535 536 public function unparticipate() 537 { 538 if ($this->checkAccess('unparticipate')) { 539 $usr_id = (int) $this->user->getId(); 540 $this->getObject()->leave($usr_id); 541 $this->learnerView(); 542 } 543 } 544 545 protected function removeMember(int $usr_id) 546 { 547 $this->ls_object->leave($usr_id); 548 } 549 550 public function getTabs() 551 { 552 if ($this->checkAccess("read")) { 553 $this->tabs->addTab( 554 self::TAB_CONTENT_MAIN, 555 $this->lng->txt(self::TAB_CONTENT_MAIN), 556 $this->ctrl->getLinkTarget($this, self::CMD_VIEW, "", false, false) 557 ); 558 } 559 560 if ($this->checkAccess("read") || $this->checkAccess("visible")) { 561 $this->tabs->addTab( 562 self::TAB_INFO, 563 $this->lng->txt(self::TAB_INFO), 564 $this->getLinkTarget(self::CMD_INFO) 565 ); 566 } 567 568 if ($this->checkAccess("write")) { 569 $this->tabs->addTab( 570 self::TAB_SETTINGS, 571 $this->lng->txt(self::TAB_SETTINGS), 572 $this->getLinkTarget(self::CMD_SETTINGS) 573 ); 574 } 575 576 if ($this->checkAccess("read")) { 577 if ($this->checkAccess("manage_members") 578 || ( 579 $this->getObject()->getLSSettings()->getMembersGallery() 580 && 581 $this->object->isMember((int) $this->user->getId()) 582 ) 583 ) { 584 $this->tabs->addTab( 585 self::TAB_MEMBERS, 586 $this->lng->txt(self::TAB_MEMBERS), 587 $this->ctrl->getLinkTarget($this, self::CMD_MEMBERS, "", false, false) 588 ); 589 } 590 } 591 592 if (ilObjUserTracking::_enabledLearningProgress() && $this->checkLPAccess()) { 593 $this->tabs->addTab( 594 self::TAB_LP, 595 $this->lng->txt(self::TAB_LP), 596 $this->getLinkTarget(self::CMD_LP) 597 ); 598 } 599 600 if ($this->checkAccess("write")) { 601 $this->tabs->addTab( 602 self::TAB_EXPORT, 603 $this->lng->txt(self::TAB_EXPORT), 604 $this->ctrl->getLinkTargetByClass("ilexportgui", "") 605 ); 606 } 607 608 if ($this->checkAccess("edit_permission")) { 609 $this->tabs->addTab( 610 self::TAB_PERMISSIONS, 611 $this->lng->txt(self::TAB_PERMISSIONS), 612 $this->getLinkTarget(self::CMD_PERMISSIONS) 613 ); 614 } 615 } 616 617 public function renderObject() 618 { 619 // disables this method in ilContainerGUI 620 } 621 622 protected function addSubTabsForContent() 623 { 624 $this->tabs->addSubTab( 625 self::TAB_VIEW_CONTENT, 626 $this->lng->txt(self::TAB_VIEW_CONTENT), 627 $this->getLinkTarget(self::CMD_LEARNER_VIEW) 628 ); 629 630 if ($this->checkAccess("write")) { 631 $this->tabs->addSubTab( 632 self::TAB_MANAGE, 633 $this->lng->txt(self::TAB_MANAGE), 634 $this->getLinkTarget(self::CMD_CONTENT) 635 ); 636 } 637 } 638 639 protected function checkAccess($which) : bool 640 { 641 return $this->access->checkAccess($which, "", $this->ref_id); 642 } 643 644 protected function checkLPAccess() 645 { 646 $ref_id = $this->getObject()->getRefId(); 647 $is_participant = ilLearningSequenceParticipants::_isParticipant($ref_id, $this->user->getId()); 648 649 $lp_access = ilLearningProgressAccess::checkAccess($ref_id, $is_participant); 650 $may_edit_lp_settings = $this->checkAccess('edit_learning_progress'); 651 652 return ($lp_access || $may_edit_lp_settings); 653 } 654 655 protected function getLinkTarget(string $cmd) : string 656 { 657 $class = $this->getClassForTabs($cmd); 658 $class_path = [ 659 strtolower('ilObjLearningSequenceGUI'), 660 $class 661 ]; 662 return $this->ctrl->getLinkTargetByClass($class_path, $cmd); 663 } 664 665 protected function getClassForTabs(string $cmd) : string 666 { 667 switch ($cmd) { 668 case self::CMD_CONTENT: 669 return 'ilObjLearningSequenceContentGUI'; 670 case self::CMD_LEARNER_VIEW: 671 return 'ilObjLearningSequenceLearnerGUI'; 672 case self::CMD_SETTINGS: 673 return 'ilObjLearningSequenceSettingsGUI'; 674 case self::CMD_INFO: 675 return 'ilInfoScreenGUI'; 676 case self::CMD_PERMISSIONS: 677 return 'ilPermissionGUI'; 678 case self::CMD_LP: 679 return 'ilLearningProgressGUI'; 680 } 681 682 throw new InvalidArgumentException('cannot resolve class for command: ' . $cmd); 683 } 684 685 public function createMailSignature() 686 { 687 $link = chr(13) . chr(10) . chr(13) . chr(10); 688 $link .= $this->lng->txt('lso_mail_permanent_link'); 689 $link .= chr(13) . chr(10) . chr(13) . chr(10); 690 $link .= ilLink::_getLink($this->object->getRefId()); 691 692 return rawurlencode(base64_encode($link)); 693 } 694 695 protected function getLearnerItems(int $usr_id) : array 696 { 697 return $this->getObject()->getLSLearnerItems($usr_id); 698 } 699 700 protected function getCurrentItemForLearner(int $usr_id) : int 701 { 702 return $this->getObject()->getCurrentItemForLearner($usr_id); 703 } 704 705 public function getObject() 706 { 707 if ($this->object === null) { 708 $this->object = ilObjLearningSequence::getInstanceByRefId($this->ref_id); 709 } 710 711 return $this->object; 712 } 713 714 protected function getTrackingObject() : ilObjUserTracking 715 { 716 return new ilObjUserTracking(); 717 } 718 719 /** 720 * @return [role_id] => title 721 */ 722 public function getLocalRoles() : array 723 { 724 $local_roles = $this->object->getLocalLearningSequenceRoles(false); 725 $lso_member = $this->object->getDefaultMemberRole(); 726 $lso_roles = array(); 727 728 if (in_array($lso_member, $local_roles)) { 729 $lso_roles[$lso_member] = ilObjRole::_getTranslation(array_search($lso_member, $local_roles)); 730 unset($local_roles[$lso_roles[$lso_member]]); 731 } 732 733 foreach ($local_roles as $title => $role_id) { 734 $lso_roles[$role_id] = ilObjRole::_getTranslation($title); 735 } 736 737 return $lso_roles; 738 } 739 740 /** 741 * append additional types to ilRepositoryExplorerGUI's whitelist 742 */ 743 protected function getAdditionalWhitelistTypes() : array 744 { 745 $types = array_filter( 746 array_keys($this->obj_definition->getSubObjects('lso', false)), 747 function ($type) { 748 return $type !== 'rolf'; 749 } 750 ); 751 752 return $types; 753 } 754 755 public function addCustomData($a_data) 756 { 757 $res_data = array(); 758 foreach ($a_data as $usr_id => $user_data) { 759 $res_data[$usr_id] = $user_data; 760 $udf_data = new ilUserDefinedData($usr_id); 761 762 foreach ($udf_data->getAll() as $field => $value) { 763 list($f, $field_id) = explode('_', $field); 764 $res_data[$usr_id]['udf_' . $field_id] = (string) $value; 765 } 766 } 767 768 return $res_data; 769 } 770} 771