ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilObjLearningSequenceLearnerGUI Class Reference

Class ilObjLearningSequenceLearnerGUI. More...

+ Collaboration diagram for ilObjLearningSequenceLearnerGUI:

Public Member Functions

 __construct (ilObjLearningSequence $ls_object, int $usr_id, array $ls_learner_items, int $current_item, ilCtrl $ctrl, ilLanguage $lng, ilTemplate $tpl, ilToolbarGUI $toolbar, ILIAS\UI\Factory $ui_factory, ILIAS\UI\Renderer $ui_renderer)
 
 executeCommand ()
 

Data Fields

const CMD_STANDARD = 'learnerView'
 
const CMD_EXTRO = 'learnerViewFinished'
 
const CMD_UNSUBSCRIBE = 'unsubscribe'
 
const CMD_VIEW = 'view'
 
const CMD_START = 'start'
 
const PARAM_LSO_NEXT_ITEM = 'lsoni'
 
const LSO_CMD_NEXT = 'lson'
 
const LSO_CMD_PREV = 'lsop'
 

Protected Member Functions

 view (string $cmd)
 
 addMember (int $usr_id)
 
 removeMember (int $usr_id)
 
 initToolbar (string $cmd)
 
 play ()
 

Protected Attributes

 $ls_learner_items
 

Private Member Functions

 getWrappedHTML (array $components)
 
 getCurriculum ()
 
 getMainContent (string $cmd)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjLearningSequenceLearnerGUI::__construct ( ilObjLearningSequence  $ls_object,
int  $usr_id,
array  $ls_learner_items,
int  $current_item,
ilCtrl  $ctrl,
ilLanguage  $lng,
ilTemplate  $tpl,
ilToolbarGUI  $toolbar,
ILIAS\UI\Factory  $ui_factory,
ILIAS\UI\Renderer  $ui_renderer 
)

Definition at line 27 of file class.ilObjLearningSequenceLearnerGUI.php.

References $lng, $ls_learner_items, and $tpl.

38  {
39  $this->ls_object = $ls_object;
40  $this->usr_id = $usr_id;
41  $this->ls_learner_items = $ls_learner_items;
42  $this->current_item = $current_item;
43  $this->ctrl = $ctrl;
44  $this->lng = $lng;
45  $this->tpl = $tpl;
46  $this->toolbar = $toolbar;
47  $this->ui_factory = $ui_factory;
48  $this->renderer = $ui_renderer;
49  }
$tpl
Definition: ilias.php:10
$lng

Member Function Documentation

◆ addMember()

ilObjLearningSequenceLearnerGUI::addMember ( int  $usr_id)
protected

Definition at line 91 of file class.ilObjLearningSequenceLearnerGUI.php.

Referenced by executeCommand().

92  {
93  $admins = $this->ls_object->getLearningSequenceAdminIds();
94  if (!in_array($usr_id, $admins)) {
95  $this->ls_object->join($usr_id);
96  }
97  }
+ Here is the caller graph for this function:

◆ executeCommand()

ilObjLearningSequenceLearnerGUI::executeCommand ( )

Definition at line 51 of file class.ilObjLearningSequenceLearnerGUI.php.

References addMember(), play(), removeMember(), and view().

52  {
53  $cmd = $this->ctrl->getCmd();
54  switch ($cmd) {
55  case self::CMD_STANDARD:
56  case self::CMD_EXTRO:
57  $this->view($cmd);
58  break;
59  case self::CMD_START:
60  $this->addMember($this->usr_id);
61  $this->ctrl->redirect($this, self::CMD_VIEW);
62  break;
63  case self::CMD_UNSUBSCRIBE:
64  if ($this->ls_object->userMayUnparticipate()) {
65  $this->removeMember($this->usr_id);
66  }
67  $this->ctrl->redirect($this, self::CMD_STANDARD);
68  break;
69  case self::CMD_VIEW:
70  $this->play();
71  break;
72 
73  default:
74  throw new ilException(
75  "ilObjLearningSequenceLearnerGUI: " .
76  "Command not supported: $cmd"
77  );
78  }
79  }
+ Here is the call graph for this function:

◆ getCurriculum()

ilObjLearningSequenceLearnerGUI::getCurriculum ( )
private

Definition at line 182 of file class.ilObjLearningSequenceLearnerGUI.php.

References $index.

Referenced by view().

182  : array
183  {
184  $current_position = 0;
185  foreach ($this->ls_learner_items as $index => $item) {
186  if ($item->getRefId() === $this->current_item) {
187  $current_position = $index;
188  }
189  }
190 
191  $curriculum = $this->ls_object
192  ->getCurriculumBuilder($this->ls_learner_items)
193  ->getLearnerCurriculum();
194 
195  if (count($this->ls_learner_items) > 0) {
196  $curriculum = $curriculum->withActive($current_position);
197  }
198  return array($curriculum);
199  }
$index
Definition: metadata.php:60
+ Here is the caller graph for this function:

◆ getMainContent()

ilObjLearningSequenceLearnerGUI::getMainContent ( string  $cmd)
private

Definition at line 201 of file class.ilObjLearningSequenceLearnerGUI.php.

References $img, and $txt.

Referenced by view().

201  : array
202  {
203  $settings = $this->ls_object->getLSSettings();
204 
205  if ($cmd === self::CMD_STANDARD) {
206  $txt = $settings->getAbstract();
207  $img = $settings->getAbstractImage();
208  }
209 
210  if ($cmd === self::CMD_EXTRO) {
211  $txt = $settings->getExtro();
212  $img = $settings->getExtroImage();
213  }
214 
215  $contents = [$this->ui_factory->legacy($txt)];
216  if (!is_null($img)) {
217  $contents[] = $this->ui_factory->image()->responsive($img, '');
218  }
219 
220  return $contents;
221  }
$txt
Definition: error.php:11
+ Here is the caller graph for this function:

◆ getWrappedHTML()

ilObjLearningSequenceLearnerGUI::getWrappedHTML ( array  $components)
private

Definition at line 171 of file class.ilObjLearningSequenceLearnerGUI.php.

Referenced by view().

171  : string
172  {
173  array_unshift(
174  $components,
175  $this->ui_factory->legacy('<div class="ilLSOLearnerView">')
176  );
177  $components[] = $this->ui_factory->legacy('</div>');
178 
179  return $this->renderer->render($components);
180  }
+ Here is the caller graph for this function:

◆ initToolbar()

ilObjLearningSequenceLearnerGUI::initToolbar ( string  $cmd)
protected

Definition at line 104 of file class.ilObjLearningSequenceLearnerGUI.php.

Referenced by view().

105  {
106  $is_member = $this->ls_object->isMember($this->usr_id);
107  $completed = $this->ls_object->isCompletedByUser($this->usr_id);
108  $has_items = count($this->ls_learner_items) > 0;
109 
110  if (!$is_member) {
111  if ($has_items) {
112  $may_subscribe = $this->ls_object->userMayJoin();
113  if ($may_subscribe) {
114  $this->toolbar->addButton(
115  $this->lng->txt("lso_player_start"),
116  $this->ctrl->getLinkTarget($this, self::CMD_START)
117  );
118  }
119  }
120  } else {
121  if (!$completed) {
122  if ($has_items) {
123  $state_db = $this->ls_object->getStateDB();
124  $obj_ref_id = (int) $this->ls_object->getRefId();
125  $first_access = $state_db->getFirstAccessFor(
126  $obj_ref_id,
127  array($this->usr_id)
128  )[$this->usr_id];
129 
130  $label = "lso_player_resume";
131  if ($first_access === -1) {
132  $label = "lso_player_start";
133  }
134 
135  $this->toolbar->addButton(
136  $this->lng->txt($label),
137  $this->ctrl->getLinkTarget($this, self::CMD_VIEW)
138  );
139  }
140  } else {
141  if ($has_items) {
142  $this->toolbar->addButton(
143  $this->lng->txt("lso_player_review"),
144  $this->ctrl->getLinkTarget($this, self::CMD_VIEW)
145  );
146  }
147  if ($cmd === self::CMD_STANDARD) {
148  $this->toolbar->addButton(
149  $this->lng->txt("lso_player_extro"),
150  $this->ctrl->getLinkTarget($this, self::CMD_EXTRO)
151  );
152  }
153  if ($cmd === self::CMD_EXTRO) {
154  $this->toolbar->addButton(
155  $this->lng->txt("lso_player_abstract"),
156  $this->ctrl->getLinkTarget($this, self::CMD_STANDARD)
157  );
158  }
159  }
160 
161  $may_unsubscribe = $this->ls_object->userMayUnparticipate();
162  if ($may_unsubscribe) {
163  $this->toolbar->addButton(
164  $this->lng->txt("unparticipate"),
165  $this->ctrl->getLinkTarget($this, self::CMD_UNSUBSCRIBE)
166  );
167  }
168  }
169  }
+ Here is the caller graph for this function:

◆ play()

ilObjLearningSequenceLearnerGUI::play ( )
protected

Definition at line 224 of file class.ilObjLearningSequenceLearnerGUI.php.

References $_GET, $_POST, $_SESSION, $html, exit, and ilUtil\redirect().

Referenced by executeCommand().

225  {
226  //enforce tree is visible/active for ToC
227  //(this does not work for first item, since there is no page-change)
228  //how is this done?
229 
230  if (!$_SESSION["lso_old_il_rep_mode"]) {
231  $_SESSION["lso_old_il_rep_mode"] = $_SESSION["il_rep_mode"];
232  }
233  $_SESSION["il_rep_mode"] = 'tree';
234 
235 
236  $player = $this->ls_object->getSequencePlayer(
237  $this,
238  self::CMD_VIEW,
239  $this->usr_id
240  );
241  $html = $player->render($_GET, $_POST);
242 
243  if ($html === 'EXIT::' . $player::LSO_CMD_SUSPEND) {
244  $cmd = self::CMD_STANDARD;
245  }
246  if ($html === 'EXIT::' . $player::LSO_CMD_FINISH) {
247  $cmd = self::CMD_EXTRO;
248  }
249  if (is_null($html)) {
250  $cmd = self::CMD_STANDARD;
251  }
252 
253  if (is_null($cmd)) {
254  print $html;
255  exit();
256  } else {
257  $_SESSION["il_rep_mode"] = $_SESSION["lso_old_il_rep_mode"];
258 
259  $href = $this->ctrl->getLinkTarget($this, $cmd, '', false, false);
260  \ilUtil::redirect($href);
261  }
262  }
$_SESSION["AccountId"]
$_GET["client_id"]
exit
Definition: backend.php:16
static redirect($a_script)
$_POST["username"]
$html
Definition: example_001.php:87
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeMember()

ilObjLearningSequenceLearnerGUI::removeMember ( int  $usr_id)
protected

Definition at line 99 of file class.ilObjLearningSequenceLearnerGUI.php.

Referenced by executeCommand().

100  {
101  $this->ls_object->leave($usr_id);
102  }
+ Here is the caller graph for this function:

◆ view()

ilObjLearningSequenceLearnerGUI::view ( string  $cmd)
protected

Definition at line 81 of file class.ilObjLearningSequenceLearnerGUI.php.

References getCurriculum(), getMainContent(), getWrappedHTML(), and initToolbar().

Referenced by executeCommand().

82  {
83  $content = $this->getWrappedHTML($this->getMainContent($cmd));
84  $curriculum = $this->getWrappedHTML($this->getCurriculum());
85 
86  $this->initToolbar($cmd);
87  $this->tpl->setContent($content);
88  $this->tpl->setRightContent($curriculum);
89  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ls_learner_items

ilObjLearningSequenceLearnerGUI::$ls_learner_items
protected

Definition at line 25 of file class.ilObjLearningSequenceLearnerGUI.php.

Referenced by __construct().

◆ CMD_EXTRO

const ilObjLearningSequenceLearnerGUI::CMD_EXTRO = 'learnerViewFinished'

Definition at line 14 of file class.ilObjLearningSequenceLearnerGUI.php.

◆ CMD_STANDARD

const ilObjLearningSequenceLearnerGUI::CMD_STANDARD = 'learnerView'

Definition at line 13 of file class.ilObjLearningSequenceLearnerGUI.php.

◆ CMD_START

const ilObjLearningSequenceLearnerGUI::CMD_START = 'start'

Definition at line 17 of file class.ilObjLearningSequenceLearnerGUI.php.

◆ CMD_UNSUBSCRIBE

const ilObjLearningSequenceLearnerGUI::CMD_UNSUBSCRIBE = 'unsubscribe'

Definition at line 15 of file class.ilObjLearningSequenceLearnerGUI.php.

◆ CMD_VIEW

const ilObjLearningSequenceLearnerGUI::CMD_VIEW = 'view'

Definition at line 16 of file class.ilObjLearningSequenceLearnerGUI.php.

◆ LSO_CMD_NEXT

const ilObjLearningSequenceLearnerGUI::LSO_CMD_NEXT = 'lson'

Definition at line 19 of file class.ilObjLearningSequenceLearnerGUI.php.

◆ LSO_CMD_PREV

const ilObjLearningSequenceLearnerGUI::LSO_CMD_PREV = 'lsop'

Definition at line 20 of file class.ilObjLearningSequenceLearnerGUI.php.

◆ PARAM_LSO_NEXT_ITEM

const ilObjLearningSequenceLearnerGUI::PARAM_LSO_NEXT_ITEM = 'lsoni'

Definition at line 18 of file class.ilObjLearningSequenceLearnerGUI.php.


The documentation for this class was generated from the following file: