ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilAchievementsGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
26  protected ilCtrl $ctrl;
28  protected ilLanguage $lng;
29  protected ilTabsGUI $tabs;
31 
32  public function __construct()
33  {
34  global $DIC;
35  $this->ctrl = $DIC->ctrl();
36  $this->achievements = new ilAchievements();
37  $this->lng = $DIC->language();
38  $this->tabs = $DIC->tabs();
39  $this->main_tpl = $DIC->ui()->mainTemplate();
40  }
41 
42  public function executeCommand(): void
43  {
44  $ctrl = $this->ctrl;
45  $main_tpl = $this->main_tpl;
46  $lng = $this->lng;
47 
48  $lng->loadLanguageModule('lhist');
49 
50  $next_class = $ctrl->getNextClass($this);
51  $cmd = $ctrl->getCmd('show');
52 
53 
54  switch ($next_class) {
55  case strtolower(ilLearningHistoryGUI::class):
56  $main_tpl->setTitle($lng->txt('lhist_learning_history'));
57  $main_tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_lhist.svg'));
58  $lhistgui = new ilLearningHistoryGUI();
59  $ctrl->forwardCommand($lhistgui);
60  $this->main_tpl->printToStdout();
61  break;
62 
63  case strtolower(ilLPPersonalGUI::class):
64  $lng->loadLanguageModule("trac");
65  $main_tpl->setTitle($lng->txt("personal_learning_progress_view_title"));
66  $main_tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_trac.svg'));
67  $main_tpl->setDescription($lng->txt("personal_learning_progress_view_description"));
68  $plp_gui = new ilLPPersonalGUI();
69  $ctrl->forwardCommand($plp_gui);
70  $this->main_tpl->printToStdout();
71  break;
72 
73  case strtolower(ilPersonalSkillsGUI::class):
74  $main_tpl->setTitle($lng->txt('skills'));
75  $main_tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_skmg.svg'));
76  $skgui = new ilPersonalSkillsGUI();
77  $ctrl->forwardCommand($skgui);
78  $this->main_tpl->printToStdout();
79  break;
80 
81  case strtolower(ilBadgeProfileGUI::class):
82  $main_tpl->setTitle($lng->txt('obj_bdga'));
83  $main_tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_bdga.svg'));
84  $bgui = new ilBadgeProfileGUI();
85  $ctrl->forwardCommand($bgui);
86  $this->main_tpl->printToStdout();
87  break;
88 
89  case strtolower(ilUserCertificateGUI::class):
90  $main_tpl->setTitle($lng->txt('obj_cert'));
91  $main_tpl->setTitleIcon(ilUtil::getImagePath('standard/icon_cert.svg'));
92  $cgui = new ilUserCertificateGUI();
93  $ctrl->forwardCommand($cgui);
94  $this->main_tpl->printToStdout();
95  break;
96 
97  default:
98  if ($cmd == 'show') {
99  $this->$cmd();
100  }
101  $this->main_tpl->printToStdout();
102  break;
103  }
104  }
105 
106  protected function show(): void
107  {
108  $ctrl = $this->ctrl;
109 
110  $gui_classes = $this->getGUIClasses();
111  $first_service = current($this->achievements->getActiveServices());
112  if ($first_service) {
113  $ctrl->redirectByClass([ilDashboardGUI::class, ilAchievementsGUI::class, $gui_classes[$first_service]]);
114  }
115  }
116 
117  protected function setTabs(string $activate): void
118  {
119  $tabs = $this->tabs;
120  $links = $this->getLinks();
121 
122  foreach ($this->achievements->getActiveServices() as $s) {
123  $tabs->addTab('achieve_' . $s, $links[$s]['txt'], $links[$s]['link']);
124  }
125  $tabs->activateTab('achieve_' . $activate);
126  }
127 
131  protected function getLinks(): array
132  {
133  $ctrl = $this->ctrl;
134  $lng = $this->lng;
135 
136  $lng->loadLanguageModule('lhist');
137  $gui_classes = $this->getGUIClasses();
138 
139  $links = [
141  'txt' => $lng->txt('lhist_learning_history')
142  ],
144  'txt' => $lng->txt('skills')
145  ],
147  'txt' => $lng->txt('learning_progress')
148  ],
150  'txt' => $lng->txt('obj_bdga')
151  ],
153  'txt' => $lng->txt('obj_cert')
154  ]
155  ];
156 
157  foreach ($links as $k => $v) {
158  $links[$k]['link'] = $ctrl->getLinkTargetByClass([ilDashboardGUI::class, ilAchievementsGUI::class, $gui_classes[$k]]);
159  }
160 
161  return $links;
162  }
163 
167  protected function getGUIClasses(): array
168  {
169  return [
170  ilAchievements::SERV_LEARNING_HISTORY => strtolower(ilLearningHistoryGUI::class),
171  ilAchievements::SERV_COMPETENCES => strtolower(ilPersonalSkillsGUI::class),
172  ilAchievements::SERV_LEARNING_PROGRESS => strtolower(ilLearningProgressGUI::class),
173  ilAchievements::SERV_BADGES => strtolower(ilBadgeProfileGUI::class),
174  ilAchievements::SERV_CERTIFICATES => strtolower(ilUserCertificateGUI::class)
175  ];
176  }
177 }
ilUserCertificateGUI: ilAchievementsGUI
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getCmd(?string $fallback_command=null)
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
loadLanguageModule(string $a_module)
Load language module.
redirectByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
forwardCommand(object $a_gui_object)
Personal skills GUI class.
ilGlobalTemplateInterface $main_tpl
getNextClass($a_gui_class=null)
global $DIC
Definition: shib_login.php:22
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
setTitleIcon(string $a_icon_path, string $a_icon_desc="")
set title icon
activateTab(string $a_id)
setDescription(string $a_descr)
Sets description below title in standard template.
addTab(string $a_id, string $a_text, string $a_link, string $a_frame="")
Add a Tab.
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)