ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCourseLPBadgeGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilCourseLPBadgeGUI:
+ Collaboration diagram for ilCourseLPBadgeGUI:

Public Member Functions

 __construct ()
 
 initConfigForm (ilPropertyFormGUI $a_form, int $a_parent_ref_id)
 Add custom fields to form. More...
 
 importConfigToForm (ilPropertyFormGUI $a_form, array $a_config)
 Set form values. More...
 
 getConfigFromForm (ilPropertyFormGUI $a_form)
 Export values to DB. More...
 
 validateForm (ilPropertyFormGUI $a_form)
 Custom form validation. More...
 

Static Public Member Functions

static getInvalidLPModes ()
 

Protected Member Functions

 getLPTypes (int $a_parent_ref_id)
 

Protected Attributes

int $parent_ref_id = 0
 
ilTree $tree
 
ilCtrlInterface $ctrl
 
ilLanguage $lng
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Course LP badge gui

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id:$

Definition at line 24 of file class.ilCourseLPBadgeGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilCourseLPBadgeGUI::__construct ( )

Definition at line 32 of file class.ilCourseLPBadgeGUI.php.

References $DIC, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

33  {
34  global $DIC;
35 
36  $this->tree = $DIC->repositoryTree();
37  $this->ctrl = $DIC->ctrl();
38  $this->lng = $DIC->language();
39  $this->lng->loadLanguageModule('trac');
40  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ getConfigFromForm()

ilCourseLPBadgeGUI::getConfigFromForm ( ilPropertyFormGUI  $a_form)

Export values to DB.

Implements ilBadgeTypeGUI.

Definition at line 102 of file class.ilCourseLPBadgeGUI.php.

References ilPropertyFormGUI\getInput().

102  : array
103  {
104  return ["subitems" => $a_form->getInput("subitems")];
105  }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
+ Here is the call graph for this function:

◆ getInvalidLPModes()

static ilCourseLPBadgeGUI::getInvalidLPModes ( )
static

Definition at line 107 of file class.ilCourseLPBadgeGUI.php.

References ilObjUserTracking\_enabledLearningProgress(), ilLPObjSettings\LP_MODE_COLLECTION, ilLPObjSettings\LP_MODE_COLLECTION_MANUAL, ilLPObjSettings\LP_MODE_COLLECTION_MOBS, ilLPObjSettings\LP_MODE_COLLECTION_TLT, ilLPObjSettings\LP_MODE_DEACTIVATED, ilLPObjSettings\LP_MODE_MANUAL, ilLPObjSettings\LP_MODE_MANUAL_BY_TUTOR, ilLPObjSettings\LP_MODE_SCORM, ilLPObjSettings\LP_MODE_UNDEFINED, and ilLPObjSettings\LP_MODE_VISITS.

Referenced by initConfigForm().

107  : array
108  {
109 
110  /* supported modes
111  LP_MODE_TLT
112  LP_MODE_OBJECTIVES
113  LP_MODE_TEST_FINISHED
114  LP_MODE_TEST_PASSED
115  LP_MODE_EXERCISE_RETURNED
116  LP_MODE_EVENT
117  LP_MODE_SCORM_PACKAGE
118  LP_MODE_PLUGIN
119  LP_MODE_QUESTIONS
120  LP_MODE_SURVEY_FINISHED
121  LP_MODE_VISITED_PAGES
122  LP_MODE_DOWNLOADED
123  LP_MODE_STUDY_PROGRAMME ?!
124  */
125 
126  $invalid_modes = array(ilLPObjSettings::LP_MODE_DEACTIVATED,
128  );
129 
130  // without active LP the following modes cannot be supported
132  // status cannot be set without active LP
133  $invalid_modes[] = ilLPObjSettings::LP_MODE_MANUAL;
134  $invalid_modes[] = ilLPObjSettings::LP_MODE_MANUAL_BY_TUTOR;
136 
137  // mode cannot be configured without active LP
138  $invalid_modes[] = ilLPObjSettings::LP_MODE_COLLECTION;
139  $invalid_modes[] = ilLPObjSettings::LP_MODE_COLLECTION_MOBS;
140  $invalid_modes[] = ilLPObjSettings::LP_MODE_COLLECTION_TLT;
141  $invalid_modes[] = ilLPObjSettings::LP_MODE_SCORM;
142  $invalid_modes[] = ilLPObjSettings::LP_MODE_VISITS; // ?
143  }
144  return $invalid_modes;
145  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLPTypes()

ilCourseLPBadgeGUI::getLPTypes ( int  $a_parent_ref_id)
protected

PhpUndefinedMethodInspection

Definition at line 74 of file class.ilCourseLPBadgeGUI.php.

References $res, ilObjUserTracking\_enabledLearningProgress(), ilObjectLP\getTypeClass(), and ilObjectLP\isSupportedObjectType().

Referenced by initConfigForm().

74  : array
75  {
76  $res = [];
77  $root = $this->tree->getNodeData($a_parent_ref_id);
78  $sub_items = $this->tree->getSubTree($root);
79  array_shift($sub_items); // remove root
80 
81  foreach ($sub_items as $node) {
82  if (ilObjectLP::isSupportedObjectType($node["type"])) {
83  $class = ilObjectLP::getTypeClass($node["type"]);
85  $modes = $class::getDefaultModes(ilObjUserTracking::_enabledLearningProgress());
86  if (count($modes) > 1) {
87  $res[] = $node["type"];
88  }
89  }
90  }
91  return $res;
92  }
$res
Definition: ltiservices.php:69
static isSupportedObjectType(string $type)
static getTypeClass(string $type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importConfigToForm()

ilCourseLPBadgeGUI::importConfigToForm ( ilPropertyFormGUI  $a_form,
array  $a_config 
)

Set form values.

Implements ilBadgeTypeGUI.

Definition at line 94 of file class.ilCourseLPBadgeGUI.php.

References ilPropertyFormGUI\getItemByPostVar().

94  : void
95  {
96  if (is_array($a_config["subitems"])) {
97  $items = $a_form->getItemByPostVar("subitems");
98  $items->setValue($a_config["subitems"]);
99  }
100  }
getItemByPostVar(string $a_post_var)
+ Here is the call graph for this function:

◆ initConfigForm()

ilCourseLPBadgeGUI::initConfigForm ( ilPropertyFormGUI  $a_form,
int  $a_parent_ref_id 
)

Add custom fields to form.

Implements ilBadgeTypeGUI.

Definition at line 42 of file class.ilCourseLPBadgeGUI.php.

References ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilPropertyFormGUI\addItem(), ilRepositorySelector2InputGUI\getExplorerGUI(), ilObjectLP\getInstance(), getInvalidLPModes(), getLPTypes(), ILIAS\Repository\int(), ILIAS\Repository\lng(), and ilRepositorySelector2InputGUI\setTitleModifier().

42  : void
43  {
44  $this->parent_ref_id = $a_parent_ref_id;
45 
46  $subitems = new ilRepositorySelector2InputGUI($this->lng->txt("objects"), "subitems", true);
47 
48  $exp = $subitems->getExplorerGUI();
49  $exp->setSkipRootNode(true);
50  $exp->setRootId($this->parent_ref_id);
51  $white = $this->getLPTypes($this->parent_ref_id);
52  $exp->setSelectableTypes($white);
53  if (!in_array("fold", $white)) {
54  $white[] = "fold";
55  }
56  $exp->setTypeWhiteList($white);
57  $subitems->setTitleModifier(function ($a_id): string {
58  $a_id = (int) $a_id;
59 
60  $obj_id = ilObject::_lookupObjId($a_id);
61  $olp = ilObjectLP::getInstance($obj_id);
62  $invalid_modes = ilCourseLPBadgeGUI::getInvalidLPModes();
63  $mode = $olp->getModeText($olp->getCurrentMode());
64  if (in_array($olp->getCurrentMode(), $invalid_modes)) {
65  $mode = "<strong>$mode</strong>";
66  }
67  return ilObject::_lookupTitle(ilObject::_lookupObjId($a_id)) . " (" . $mode . ")";
68  });
69 
70  $subitems->setRequired(true);
71  $a_form->addItem($subitems);
72  }
getLPTypes(int $a_parent_ref_id)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(int $obj_id)
+ Here is the call graph for this function:

◆ validateForm()

ilCourseLPBadgeGUI::validateForm ( ilPropertyFormGUI  $a_form)

Custom form validation.

Implements ilBadgeTypeGUI.

Definition at line 147 of file class.ilCourseLPBadgeGUI.php.

References $ref_id, ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilPropertyFormGUI\getInput(), ilObjectLP\getInstance(), ilPropertyFormGUI\getItemByPostVar(), and ILIAS\Repository\lng().

147  : bool
148  {
149  $invalid = array();
150  $invalid_modes = self::getInvalidLPModes();
151  foreach ($a_form->getInput("subitems") as $ref_id) {
152  $obj_id = ilObject::_lookupObjId((int) $ref_id);
153  $olp = ilObjectLP::getInstance($obj_id);
154  if (in_array($olp->getCurrentMode(), $invalid_modes)) {
155  $invalid[] = ilObject::_lookupTitle($obj_id);
156  }
157  }
158  if ($invalid !== []) {
159  $mess = sprintf($this->lng->txt("badge_course_lp_invalid"), implode(", ", $invalid));
160  $a_form->getItemByPostVar("subitems")->setAlert($mess);
161  return false;
162  }
163  return true;
164  }
getItemByPostVar(string $a_post_var)
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:67
static _lookupTitle(int $obj_id)
static getInstance(int $obj_id)
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrlInterface ilCourseLPBadgeGUI::$ctrl
protected

Definition at line 29 of file class.ilCourseLPBadgeGUI.php.

◆ $lng

ilLanguage ilCourseLPBadgeGUI::$lng
protected

Definition at line 30 of file class.ilCourseLPBadgeGUI.php.

◆ $parent_ref_id

int ilCourseLPBadgeGUI::$parent_ref_id = 0
protected

Definition at line 26 of file class.ilCourseLPBadgeGUI.php.

◆ $tree

ilTree ilCourseLPBadgeGUI::$tree
protected

Definition at line 28 of file class.ilCourseLPBadgeGUI.php.


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