ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilLearningProgressBaseGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once 'Services/Tracking/classes/class.ilObjUserTracking.php';
6 
22 {
23  public $tpl = null;
24  public $ctrl = null;
25  public $lng = null;
26  public $ref_id = 0;
27  public $mode = 0;
28 
29  protected $anonymized;
30 
34  protected $logger;
35 
39  protected $tabs_gui;
40 
41 
47 
48  const LP_ACTIVE_SETTINGS = 1;
49  const LP_ACTIVE_OBJECTS = 2;
50  const LP_ACTIVE_PROGRESS = 3;
51  // const LP_ACTIVE_LM_STATISTICS = 4; obsolete
52  const LP_ACTIVE_USERS = 5;
53  const LP_ACTIVE_SUMMARY = 6;
58  const LP_ACTIVE_MATRIX = 11;
59 
60  public function __construct($a_mode, $a_ref_id = 0, $a_usr_id = 0)
61  {
62  global $DIC;
63 
64  $tpl = $DIC['tpl'];
65  $ilCtrl = $DIC['ilCtrl'];
66  $lng = $DIC['lng'];
67  $ilObjDataCache = $DIC['ilObjDataCache'];
68  $ilTabs = $DIC['ilTabs'];
69 
70  $this->tpl = $tpl;
71  $this->ctrl = $ilCtrl;
72  $this->lng = $lng;
73  $this->lng->loadLanguageModule('trac');
74  $this->tabs_gui = $ilTabs;
75 
76  $this->mode = $a_mode;
77  $this->ref_id = $a_ref_id;
78  $this->obj_id = $ilObjDataCache->lookupObjId($this->ref_id);
79  $this->obj_type = $ilObjDataCache->lookupType($this->obj_id);
80  $this->usr_id = $a_usr_id;
81 
82  $this->anonymized = (bool) !ilObjUserTracking::_enabledUserRelatedData();
83  if (!$this->anonymized && $this->obj_id) {
84  include_once "Services/Object/classes/class.ilObjectLP.php";
85  $olp = ilObjectLP::getInstance($this->obj_id);
86  $this->anonymized = $olp->isAnonymized();
87  }
88 
89  $this->logger = $GLOBALS['DIC']->logger()->trac();
90  }
91 
92  public function isAnonymized()
93  {
94  return $this->anonymized;
95  }
96 
97  public function getMode()
98  {
99  return $this->mode;
100  }
101 
102  public function getRefId()
103  {
104  return $this->ref_id;
105  }
106 
107  public function getObjId()
108  {
109  return $this->obj_id;
110  }
111 
112  public function getUserId()
113  {
114  if ($this->usr_id) {
115  return $this->usr_id;
116  }
117  if ((int) $_GET['user_id']) {
118  return (int) $_GET['user_id'];
119  }
120  return 0;
121  }
122 
123  // Protected
124  public function __getDefaultCommand()
125  {
126  if (strlen($cmd = $this->ctrl->getCmd())) {
127  return $cmd;
128  }
129  return 'show';
130  }
131 
132  public function __setSubTabs($a_active)
133  {
134  global $DIC;
135 
136  $rbacsystem = $DIC['rbacsystem'];
137  $ilObjDataCache = $DIC['ilObjDataCache'];
138 
139 
140 
141  switch ($this->getMode()) {
142  case self::LP_CONTEXT_PERSONAL_DESKTOP:
143 
144  include_once("Services/Tracking/classes/class.ilObjUserTracking.php");
147  $this->tabs_gui->addSubTabTarget(
148  'trac_progress',
149  $this->ctrl->getLinkTargetByClass('illplistofprogressgui', ''),
150  "",
151  "",
152  "",
153  $a_active == self::LP_ACTIVE_PROGRESS
154  );
155  }
156 
158  $this->tabs_gui->addSubTabTarget(
159  'trac_objects',
160  $this->ctrl->getLinkTargetByClass("illplistofobjectsgui", ''),
161  "",
162  "",
163  "",
164  $a_active == self::LP_ACTIVE_OBJECTS
165  );
166  }
167  break;
168 
169 
170  case self::LP_CONTEXT_REPOSITORY:
171  // #12771 - do not show status if learning progress is deactivated
172  include_once './Services/Object/classes/class.ilObjectLP.php';
173  $olp = ilObjectLP::getInstance($this->obj_id);
174  if ($olp->isActive()) {
175  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
176  $has_read = ilLearningProgressAccess::checkPermission('read_learning_progress', $this->getRefId());
177 
178  if ($this->isAnonymized() || !$has_read) {
179  $this->ctrl->setParameterByClass('illplistofprogressgui', 'user_id', $this->getUserId());
180  $this->tabs_gui->addSubTabTarget(
181  'trac_progress',
182  $this->ctrl->getLinkTargetByClass('illplistofprogressgui', ''),
183  "",
184  "",
185  "",
186  $a_active == self::LP_ACTIVE_PROGRESS
187  );
188  } else {
189  // Check if it is a course
190  $sub_tab = ($ilObjDataCache->lookupType($ilObjDataCache->lookupObjId($this->getRefId())) == 'crs') ?
191  'trac_crs_objects' :
192  'trac_objects';
193 
194  $this->tabs_gui->addSubTabTarget(
195  $sub_tab,
196  $this->ctrl->getLinkTargetByClass("illplistofobjectsgui", ''),
197  "",
198  "",
199  "",
200  $a_active == self::LP_ACTIVE_OBJECTS
201  );
202  }
203 
204  if ($has_read) {
205  if (!$this->isAnonymized() &&
206  !($olp instanceof ilPluginLP) &&
207  ilObjectLP::supportsMatrixView($this->obj_type)) {
208  $this->tabs_gui->addSubTabTarget(
209  "trac_matrix",
210  $this->ctrl->getLinkTargetByClass("illplistofobjectsgui", 'showUserObjectMatrix'),
211  "",
212  "",
213  "",
214  $a_active == self::LP_ACTIVE_MATRIX
215  );
216  }
217 
218  $this->tabs_gui->addSubTabTarget(
219  "trac_summary",
220  $this->ctrl->getLinkTargetByClass("illplistofobjectsgui", 'showObjectSummary'),
221  "",
222  "",
223  "",
224  $a_active == self::LP_ACTIVE_SUMMARY
225  );
226  }
227  }
228  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
229  if (!($olp instanceof ilPluginLP) &&
230  ilLearningProgressAccess::checkPermission('edit_learning_progress', $this->getRefId())) {
231  $this->tabs_gui->addSubTabTarget(
232  'trac_settings',
233  $this->ctrl->getLinkTargetByClass('illplistofsettingsgui', ''),
234  "",
235  "",
236  "",
237  $a_active == self::LP_ACTIVE_SETTINGS
238  );
239  }
240  break;
241 
242  case self::LP_CONTEXT_ADMINISTRATION:
243  /*
244  $this->tabs_gui->addSubTabTarget('trac_progress',
245  $this->ctrl->getLinkTargetByClass('illplistofprogressgui',''),
246  "","","",$a_active == self::LP_ACTIVE_PROGRESS);
247  */
248  $this->tabs_gui->addSubTabTarget(
249  'trac_objects',
250  $this->ctrl->getLinkTargetByClass("illplistofobjectsgui", ''),
251  "",
252  "",
253  "",
254  $a_active == self::LP_ACTIVE_OBJECTS
255  );
256  break;
257 
258  case self::LP_CONTEXT_USER_FOLDER:
259  case self::LP_CONTEXT_ORG_UNIT:
260  // No tabs default class is lpprogressgui
261  break;
262 
263  default:
264  die('No valid mode given');
265  break;
266  }
267 
268  return true;
269  }
270 
271  public function __buildFooter()
272  {
273  switch ($this->getMode()) {
274  case self::LP_CONTEXT_PERSONAL_DESKTOP:
275 
276  $this->tpl->show(true);
277  }
278  }
279 
280  public function __buildHeader()
281  {
282  if ($this->getMode() == self::LP_CONTEXT_PERSONAL_DESKTOP) {
283  //$this->tpl->setTitle($this->lng->txt("learning_progress"));
284 
285  // set locator
286  /*
287  $this->tpl->setVariable("TXT_LOCATOR", $this->lng->txt("locator"));
288  $this->tpl->touchBlock("locator_separator");
289  $this->tpl->touchBlock("locator_item");
290  //$this->tpl->setCurrentBlock("locator_item");
291  //$this->tpl->setVariable("ITEM", $this->lng->txt("personal_desktop"));
292  //$this->tpl->setVariable("LINK_ITEM",
293  // $this->ctrl->getLinkTargetByClass("ilpersonaldesktopgui"));
294  //$this->tpl->parseCurrentBlock();
295 
296  $this->tpl->setCurrentBlock("locator_item");
297  $this->tpl->setVariable("ITEM", $this->lng->txt("learning_progress"));
298  $this->tpl->setVariable("LINK_ITEM",
299  $this->ctrl->getLinkTargetByClass('illearningprogressgui'));
300  $this->tpl->parseCurrentBlock();
301  */
302 
303  // display infopanel if something happened
305  }
306  }
307 
311  public function __insertPath(&$a_tpl, $a_ref_id)
312  {
313  global $DIC;
314 
315  $tree = $DIC['tree'];
316 
317  $path_arr = $tree->getPathFull($a_ref_id);
318  $counter = 0;
319  foreach ($tree->getPathFull($a_ref_id) as $data) {
320  if ($counter++) {
321  $path .= " -> ";
322  }
323  $path .= $data['title'];
324  }
325  $a_tpl->setCurrentBlock("path_item");
326  $a_tpl->setVariable("PATH_ITEM", $path);
327  $a_tpl->parseCurrentBlock();
328 
329  $a_tpl->setCurrentBlock("path");
330  $a_tpl->parseCurrentBlock();
331 
332  return $path;
333  }
334 
335  public function __showImageByStatus(&$tpl, $a_status, $tpl_prefix = "")
336  {
337  return ilLearningProgressBaseGUI::_showImageByStatus($tpl, $a_status, $tpl_prefix);
338  }
339 
340  // we need this public in table classes
341  public static function _showImageByStatus(&$tpl, $a_status, $tpl_prefix = "")
342  {
343  global $DIC;
344 
345  $lng = $DIC['lng'];
346 
347  $tpl->setVariable(
348  $tpl_prefix . "STATUS_IMG",
350  );
351  $tpl->setVariable($tpl_prefix . "STATUS_ALT", $lng->txt($a_status));
352 
353  return true;
354  }
355 
359  public static function _getImagePathForStatus($a_status)
360  {
361  include_once("./Services/Tracking/classes/class.ilLPStatus.php");
362 
363  // constants are either number or string, so make comparison string-based
364  switch ((string) $a_status) {
368  return ilUtil::getImagePath('scorm/incomplete.svg');
369  break;
370 
374  return ilUtil::getImagePath('scorm/complete.svg');
375  break;
376 
380  return ilUtil::getImagePath('scorm/not_attempted.svg');
381  break;
382 
385  return ilUtil::getImagePath('scorm/failed.svg');
386  break;
387 
388  default:
389  return ilUtil::getImagePath('scorm/not_attempted.svg');
390  break;
391  }
392  }
393 
397  public static function _getStatusText($a_status, $a_lng = null)
398  {
399  global $DIC;
400 
401  $lng = $DIC['lng'];
402 
403  if (!$a_lng) {
404  $a_lng = $lng;
405  }
406 
407  include_once("./Services/Tracking/classes/class.ilLPStatus.php");
408  //echo "#".$a_status."#";
409  switch ($a_status) {
411  return $a_lng->txt(ilLPStatus::LP_STATUS_IN_PROGRESS);
412 
414  return $a_lng->txt(ilLPStatus::LP_STATUS_COMPLETED);
415 
417  return $a_lng->txt(ilLPStatus::LP_STATUS_FAILED);
418 
419  default:
420  if ($a_status === ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM) {
421  return $a_lng->txt(ilLPStatus::LP_STATUS_NOT_ATTEMPTED);
422  }
423  return $a_lng->txt($a_status);
424  }
425  }
426 
427 
428  // Protected Table gui methods
429  public function &__initTableGUI()
430  {
431  include_once "./Services/Table/classes/class.ilTableGUI.php";
432 
433  return new ilTableGUI(0, false);
434  }
435 
436 
440  public function __showObjectDetails(&$info, $item_id = 0, $add_section = true)
441  {
442  global $DIC;
443 
444  $ilObjDataCache = $DIC['ilObjDataCache'];
445 
446  $details_id = $item_id ? $item_id : $this->details_id;
447 
448  include_once 'Services/Object/classes/class.ilObjectLP.php';
449  $olp = ilObjectLP::getInstance($details_id);
450  $mode = $olp->getCurrentMode();
451 
452  include_once './Services/MetaData/classes/class.ilMDEducational.php';
455  // Section object details
456  if ($add_section) {
457  $info->addSection($this->lng->txt('details'));
458  }
459 
461  $info->addProperty($this->lng->txt('trac_required_visits'), ilLPObjSettings::_lookupVisits($details_id));
462  }
463 
464  if ($seconds = ilMDEducational::_getTypicalLearningTimeSeconds($details_id)) {
465  $info->addProperty($this->lng->txt('meta_typical_learning_time'), ilDatePresentation::secondsToString($seconds));
466  }
467 
468  return true;
469  }
470  return false;
471  }
472 
473  public function __appendUserInfo(&$info, $a_user)
474  {
475  global $DIC;
476 
477  $ilUser = $DIC['ilUser'];
478 
479  // #13525 - irrelevant personal data is not to be presented
480  return;
481 
482  if (!is_object($a_user)) {
483  $a_user = ilObjectFactory::getInstanceByObjId($a_user);
484  }
485 
486  if ($a_user->getId() != $ilUser->getId()) {
487  $info->addSection($this->lng->txt("trac_user_data"));
488  // $info->addProperty($this->lng->txt('username'),$a_user->getLogin());
489  // $info->addProperty($this->lng->txt('name'),$a_user->getFullname());
490  $info->addProperty(
491  $this->lng->txt('last_login'),
492  ilDatePresentation::formatDate(new ilDateTime($a_user->getLastLogin(), IL_CAL_DATETIME))
493  );
494  $info->addProperty(
495  $this->lng->txt('trac_total_online'),
496  ilDatePresentation::secondsToString(ilOnlineTracking::getOnlineTime($a_user->getId()))
497  );
498  return true;
499  }
500  }
501 
502  public function __appendLPDetails(&$info, $item_id, $user_id)
503  {
504  global $DIC;
505 
506  $ilObjDataCache = $DIC['ilObjDataCache'];
507 
508  $type = $ilObjDataCache->lookupType($item_id);
509 
510  // Section learning_progress
511  // $info->addSection($this->lng->txt('trac_learning_progress'));
512  // see ilLPTableBaseGUI::parseTitle();
513  $info->addSection($this->lng->txt("trac_progress") . ": " . ilObject::_lookupTitle($item_id));
514 
515  $olp = ilObjectLP::getInstance($item_id);
516  $info->addProperty(
517  $this->lng->txt('trac_mode'),
518  $olp->getModeText($olp->getCurrentMode())
519  );
520 
521  switch ($type) {
522  case 'lm':
523  case 'htlm':
524  include_once 'Services/Tracking/classes/class.ilLearningProgress.php';
525  $progress = ilLearningProgress::_getProgress($user_id, $item_id);
526 
527  if ($progress['access_time']) {
528  $info->addProperty(
529  $this->lng->txt('last_access'),
530  ilDatePresentation::formatDate(new ilDateTime($progress['access_time'], IL_CAL_UNIX))
531  );
532  } else {
533  $info->addProperty($this->lng->txt('last_access'), $this->lng->txt('trac_not_accessed'));
534  }
535  $info->addProperty($this->lng->txt('trac_visits'), (int) $progress['visits']);
537  $info->addProperty($this->lng->txt('trac_spent_time'), ilDatePresentation::secondsToString($progress['spent_seconds']));
538  }
539  // fallthrough
540 
541  // no break
542  case 'exc':
543  case 'tst':
544  case 'file':
545  case 'mcst':
546  case 'svy':
547  case 'crs':
548  case 'sahs':
549  case 'grp':
550  case 'iass':
551  case 'copa':
552  case 'sess':
553  case 'lso':
554  // display status as image
555  include_once("./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
556  $status = $this->__readStatus($item_id, $user_id);
558  $status_text = ilLearningProgressBaseGUI::_getStatusText($status);
559  $info->addProperty(
560  $this->lng->txt('trac_status'),
561  ilUtil::img($status_path, $status_text) . " " . $status_text
562  );
563 
564  // #15334 - see ilLPTableBaseGUI::isPercentageAvailable()
565  $mode = $olp->getCurrentMode();
566  if (in_array($mode, array(ilLPObjSettings::LP_MODE_TLT,
568  // ilLPObjSettings::LP_MODE_OBJECTIVES,
571  include_once 'Services/Tracking/classes/class.ilLPStatus.php';
572  $perc = ilLPStatus::_lookupPercentage($item_id, $user_id);
573  $info->addProperty($this->lng->txt('trac_percentage'), (int) $perc . "%");
574  }
575  break;
576 
577  }
578 
579  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
580 
582  if (strlen($mark = ilLPMarks::_lookupMark($user_id, $item_id))) {
583  $info->addProperty($this->lng->txt('trac_mark'), $mark);
584  }
585  }
586 
587  if (strlen($comment = ilLPMarks::_lookupComment($user_id, $item_id))) {
588  $info->addProperty($this->lng->txt('trac_comment'), $comment);
589  }
590  }
591 
592  public static function __readStatus($a_obj_id, $user_id)
593  {
594  include_once 'Services/Tracking/classes/class.ilLPStatus.php';
595  $status = ilLPStatus::_lookupStatus($a_obj_id, $user_id);
596 
597  include_once("./Services/Tracking/classes/class.ilLPStatus.php");
598  switch ($status) {
601 
604 
607 
610 
611  default:
612  return $status;
613  }
614  }
615 
628  public function __sort($a_ids, $a_table, $a_field, $a_id_name)
629  {
630  global $DIC;
631 
632  $ilDB = $DIC['ilDB'];
633 
634  if (!$a_ids) {
635  return array();
636  }
637 
638  // comment by mjansen: Requesting database in gui classes?
639 
640  // use database to sort user array
641  $where = "WHERE " . $ilDB->in($a_id_name, $a_ids, false, 'integer') . " ";
642 
643  $query = "SELECT " . $a_id_name . " FROM " . $a_table . " " .
644  $where .
645  "ORDER BY " . $a_field;
646 
647  $res = $ilDB->query($query);
648  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
649  $ids[] = $row->$a_id_name;
650  }
651  return $ids ? $ids : array();
652  }
653 
654  public function __getPercent($max, $reached)
655  {
656  if (!$max) {
657  return "0%";
658  }
659 
660  return sprintf("%d%%", $reached / $max * 100);
661  }
662 
663  public function __readItemStatusInfo($a_items)
664  {
665  global $DIC;
666 
667  $ilObjDataCache = $DIC['ilObjDataCache'];
668 
669  include_once 'Services/Object/classes/class.ilObjectLP.php';
670 
671  foreach ($a_items as $item_id) {
672  $olp = ilObjectLP::getInstance($item_id);
673 
674  $this->obj_data[$item_id]['type'] = $ilObjDataCache->lookupType($item_id);
675  $this->obj_data[$item_id]['mode'] = $olp->getCurrentMode();
676  if ($this->obj_data[$item_id]['mode'] == ilLPObjSettings::LP_MODE_TLT) {
677  include_once './Services/MetaData/classes/class.ilMDEducational.php';
678  $this->obj_data[$item_id]['tlt'] = ilMDEducational::_getTypicalLearningTimeSeconds($item_id);
679  }
680  if ($this->obj_data[$item_id]['mode'] == ilLPObjSettings::LP_MODE_VISITS) {
681  $this->obj_data[$item_id]['visits'] = ilLPObjSettings::_lookupVisits($item_id);
682  }
683  if ($this->obj_data[$item_id]['mode'] == ilLPObjSettings::LP_MODE_SCORM) {
684  $collection = $olp->getCollectionInstance();
685  if ($collection) {
686  $this->obj_data[$item_id]['scos'] = count($collection->getItems());
687  }
688  }
689  }
690  }
691 
692  public function __getLegendHTML()
693  {
694  global $DIC;
695 
696  $lng = $DIC['lng'];
697 
698  $tpl = new ilTemplate("tpl.lp_legend.html", true, true, "Services/Tracking");
699  $tpl->setVariable(
700  "IMG_NOT_ATTEMPTED",
701  ilUtil::getImagePath("scorm/not_attempted.svg")
702  );
703  $tpl->setVariable(
704  "IMG_IN_PROGRESS",
705  ilUtil::getImagePath("scorm/incomplete.svg")
706  );
707  $tpl->setVariable(
708  "IMG_COMPLETED",
709  ilUtil::getImagePath("scorm/completed.svg")
710  );
711  $tpl->setVariable(
712  "IMG_FAILED",
713  ilUtil::getImagePath("scorm/failed.svg")
714  );
715  $tpl->setVariable(
716  "TXT_NOT_ATTEMPTED",
717  $lng->txt("trac_not_attempted")
718  );
719  $tpl->setVariable(
720  "TXT_IN_PROGRESS",
721  $lng->txt("trac_in_progress")
722  );
723  $tpl->setVariable(
724  "TXT_COMPLETED",
725  $lng->txt("trac_completed")
726  );
727  $tpl->setVariable(
728  "TXT_FAILED",
729  $lng->txt("trac_failed")
730  );
731 
732  include_once "Services/UIComponent/Panel/classes/class.ilPanelGUI.php";
733  $panel = ilPanelGUI::getInstance();
734  $panel->setPanelStyle(ilPanelGUI::PANEL_STYLE_SECONDARY);
735  $panel->setBody($tpl->get());
736 
737  return $panel->getHTML();
738  }
739 
740  protected function initEditUserForm($a_user_id, $a_obj_id, $a_cancel = null)
741  {
742  global $DIC;
743 
744  $lng = $DIC['lng'];
745  $ilCtrl = $DIC['ilCtrl'];
746 
747  include_once 'Services/Object/classes/class.ilObjectLP.php';
748  $olp = ilObjectLP::getInstance($a_obj_id);
749  $lp_mode = $olp->getCurrentMode();
750 
751  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
752  $form = new ilPropertyFormGUI();
753 
754  $form->setFormAction($ilCtrl->getFormAction($this, "updateUser"));
755 
756  $form->setTitle($lng->txt("edit") . ": " . ilObject::_lookupTitle($a_obj_id));
757  $form->setDescription($lng->txt('trac_mode') . ": " . $olp->getModeText($lp_mode));
758 
759  include_once "Services/User/classes/class.ilUserUtil.php";
760  $user = new ilNonEditableValueGUI($lng->txt("user"), null, true);
761  $user->setValue(ilUserUtil::getNamePresentation($a_user_id, true));
762  $form->addItem($user);
763 
764  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
765  $marks = new ilLPMarks($a_obj_id, $a_user_id);
766 
768  $mark = new ilTextInputGUI($lng->txt("trac_mark"), "mark");
769  $mark->setValue($marks->getMark());
770  $mark->setMaxLength(32);
771  $form->addItem($mark);
772  }
773 
774  $comm = new ilTextInputGUI($lng->txt("trac_comment"), "comment");
775  $comm->setValue($marks->getComment());
776  $form->addItem($comm);
777 
778  if ($lp_mode == ilLPObjSettings::LP_MODE_MANUAL ||
780  include_once("./Services/Tracking/classes/class.ilLPStatus.php");
781  $completed = ilLPStatus::_lookupStatus($a_obj_id, $a_user_id);
782 
783  $status = new ilCheckboxInputGUI($lng->txt('trac_completed'), "completed");
784  $status->setChecked(($completed == ilLPStatus::LP_STATUS_COMPLETED_NUM));
785  $form->addItem($status);
786  }
787 
788  $form->addCommandButton("updateUser", $lng->txt('save'));
789 
790  if ($a_cancel) {
791  $form->addCommandButton($a_cancel, $lng->txt('cancel'));
792  }
793 
794  return $form;
795  }
796 
797  public function __showEditUser($a_user_id, $a_ref_id, $a_cancel, $a_sub_id = false)
798  {
799  global $DIC;
800 
801  $ilCtrl = $DIC['ilCtrl'];
802 
803  if (!$a_sub_id) {
804  $obj_id = ilObject::_lookupObjId($a_ref_id);
805  } else {
806  $ilCtrl->setParameter($this, 'userdetails_id', $a_sub_id);
807  $obj_id = ilObject::_lookupObjId($a_sub_id);
808  }
809 
810  $ilCtrl->setParameter($this, 'user_id', $a_user_id);
811  $ilCtrl->setParameter($this, 'details_id', $a_ref_id);
812 
813  $form = $this->initEditUserForm($a_user_id, $obj_id, $a_cancel);
814 
815  return $form->getHTML();
816  }
817 
818  public function __updateUser($user_id, $obj_id)
819  {
820  $form = $this->initEditUserForm($user_id, $obj_id);
821  if ($form->checkInput()) {
822  include_once 'Services/Tracking/classes/class.ilLPMarks.php';
823 
824  $marks = new ilLPMarks($obj_id, $user_id);
825  $marks->setMark($form->getInput("mark"));
826  $marks->setComment($form->getInput("comment"));
827 
828  $do_lp = false;
829 
830  // status/completed is optional
831  $status = $form->getItemByPostVar("completed");
832  if (is_object($status)) {
833  if ($marks->getCompleted() != $form->getInput("completed")) {
834  $marks->setCompleted($form->getInput("completed"));
835  $do_lp = true;
836  }
837  }
838 
839  $marks->update();
840 
841  // #11600
842  if ($do_lp) {
843  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
844  ilLPStatusWrapper::_updateStatus($obj_id, $user_id);
845  }
846  }
847  }
848 
849  public static function isObjectOffline($a_obj_id, $a_type = null)
850  {
851  global $DIC;
852 
853  $objDefinition = $DIC['objDefinition'];
854  $ilObjDataCache = $DIC['ilObjDataCache'];
855 
856  if (!$a_type) {
857  $a_type = $ilObjDataCache->lookupType($a_obj_id);
858  }
859 
860  if ($objDefinition->isPluginTypeName($a_type)) {
861  return false;
862  }
863 
864  $class = "ilObj" . $objDefinition->getClassName($a_type) . "Access";
865  include_once $objDefinition->getLocation($a_type) . "/class." . $class . ".php";
866  return call_user_func(array($class,'_isOffline'), $a_obj_id);
867 
868  // PHP 5.3 only ?
869  //return $class::_isOffline($obj_id);
870  }
871 }
const LP_STATUS_COMPLETED_NUM
$path
Definition: aliased.php:25
__construct($a_mode, $a_ref_id=0, $a_usr_id=0)
__showEditUser($a_user_id, $a_ref_id, $a_cancel, $a_sub_id=false)
const IL_CAL_DATETIME
static _getTypicalLearningTimeSeconds($a_rbac_id, $a_obj_id=0)
static _getImagePathForStatus($a_status)
Get image path for status.
This class represents a property form user interface.
$type
global $DIC
Definition: saml.php:7
$_GET["client_id"]
const LP_STATUS_PARTICIPATED
const LP_STATUS_NOT_ATTEMPTED
static _getStatusText($a_status, $a_lng=null)
Get status alt text.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _lookupPercentage($a_obj_id, $a_user_id)
Lookup percentage.
const LP_STATUS_IN_PROGRESS_NUM
This class represents a checkbox property in a property form.
static _lookupTitle($a_id)
lookup object title
Class ilTableGUI.
const IL_CAL_UNIX
__appendLPDetails(&$info, $item_id, $user_id)
static checkPermission($a_permission, $a_ref_id, $a_user_id=null)
wrapper for rbac access checks
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
__showObjectDetails(&$info, $item_id=0, $add_section=true)
show details about current object.
const LP_STATUS_IN_PROGRESS
global $ilCtrl
Definition: ilias.php:18
$a_type
Definition: workflow.php:92
setChecked($a_checked)
Set Checked.
static _enabledUserRelatedData()
check wether user related tracking is enabled or not
initEditUserForm($a_user_id, $a_obj_id, $a_cancel=null)
const LP_STATUS_NOT_PARTICIPATED
const LP_STATUS_FAILED
static secondsToString($seconds, $force_with_seconds=false, $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
foreach($_POST as $key=> $value) $res
if(isset($_POST['submit'])) $form
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static isObjectOffline($a_obj_id, $a_type=null)
static _lookupObjId($a_id)
special template class to simplify handling of ITX/PEAR
static _showImageByStatus(&$tpl, $a_status, $tpl_prefix="")
This class represents a text property in a property form.
static infoPanel($a_keep=true)
Date and time handling
$ilUser
Definition: imgupload.php:18
static supportsMatrixView($a_obj_type)
$query
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
$user
Definition: migrateto20.php:57
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
$comment
Definition: buildRTE.php:83
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static _lookupType($a_id, $a_reference=false)
lookup object type
$row
static supportsMark($a_obj_type)
const LP_STATUS_NOT_ATTEMPTED_NUM
static __readStatus($a_obj_id, $user_id)
const LP_STATUS_REGISTERED
static getInstance()
Get instance.
static supportsSpentSeconds($a_obj_type)
__insertPath(&$a_tpl, $a_ref_id)
insert path
__showImageByStatus(&$tpl, $a_status, $tpl_prefix="")
static _lookupVisits($a_obj_id)
This class represents a non editable value in a property form.
__sort($a_ids, $a_table, $a_field, $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,7),&#39;usr_data&#39;,&#39;lastname&#39;,&#39;usr_id&#39;) => sorts by lastname.
global $ilDB
const PANEL_STYLE_SECONDARY
static _lookupMark($a_usr_id, $a_obj_id)
static _lookupComment($a_usr_id, $a_obj_id)
$info
Definition: index.php:5
setValue($a_value)
Set Value.
const LP_STATUS_COMPLETED
static getInstance($a_obj_id)
static _getProgress($a_user_id, $a_obj_id)
const LP_STATUS_NOT_REGISTERED
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
const LP_STATUS_FAILED_NUM
$data
Definition: bench.php:6