ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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...
 
 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 25 of file class.ilCourseLPBadgeGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilCourseLPBadgeGUI::__construct ( )

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

34 {
35 global $DIC;
36
37 $this->tree = $DIC->repositoryTree();
38 $this->ctrl = $DIC->ctrl();
39 $this->lng = $DIC->language();
40 $this->lng->loadLanguageModule('trac');
41 }
global $DIC
Definition: shib_login.php:26

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

+ 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 101 of file class.ilCourseLPBadgeGUI.php.

101 : array
102 {
103 return ["subitems" => $a_form->getInput("subitems")];
104 }
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-...

References ilPropertyFormGUI\getInput().

+ Here is the call graph for this function:

◆ getInvalidLPModes()

static ilCourseLPBadgeGUI::getInvalidLPModes ( )
static

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

106 : array
107 {
108 /* supported modes
109 LP_MODE_TLT
110 LP_MODE_OBJECTIVES
111 LP_MODE_TEST_FINISHED
112 LP_MODE_TEST_PASSED
113 LP_MODE_EXERCISE_RETURNED
114 LP_MODE_EVENT
115 LP_MODE_SCORM_PACKAGE
116 LP_MODE_PLUGIN
117 LP_MODE_QUESTIONS
118 LP_MODE_SURVEY_FINISHED
119 LP_MODE_VISITED_PAGES
120 LP_MODE_DOWNLOADED
121 LP_MODE_STUDY_PROGRAMME ?!
122 */
123
124 $invalid_modes = array(ilLPObjSettings::LP_MODE_DEACTIVATED,
126 );
127
128 // without active LP the following modes cannot be supported
130 // status cannot be set without active LP
131 //$invalid_modes[] = ilLPObjSettings::LP_MODE_MANUAL;
134
135 // mode cannot be configured without active LP
136 $invalid_modes[] = ilLPObjSettings::LP_MODE_COLLECTION;
139 $invalid_modes[] = ilLPObjSettings::LP_MODE_SCORM;
140 $invalid_modes[] = ilLPObjSettings::LP_MODE_VISITS; // ?
141 }
142 return $invalid_modes;
143 }

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_BY_TUTOR, ilLPObjSettings\LP_MODE_SCORM, ilLPObjSettings\LP_MODE_UNDEFINED, and ilLPObjSettings\LP_MODE_VISITS.

Referenced by initConfigForm(), and validateForm().

+ 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

@noinspection PhpUndefinedMethodInspection

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

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

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

Referenced by initConfigForm().

+ 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 93 of file class.ilCourseLPBadgeGUI.php.

93 : void
94 {
95 if (is_array($a_config["subitems"])) {
96 $items = $a_form->getItemByPostVar("subitems");
97 $items->setValue($a_config["subitems"]);
98 }
99 }
getItemByPostVar(string $a_post_var)

References ilPropertyFormGUI\getItemByPostVar().

+ 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 43 of file class.ilCourseLPBadgeGUI.php.

43 : void
44 {
45 $this->parent_ref_id = $a_parent_ref_id;
46
47 $subitems = new ilRepositorySelector2InputGUI($this->lng->txt("objects"), "subitems", true);
48
49 $exp = $subitems->getExplorerGUI();
50 $exp->setSkipRootNode(true);
51 $exp->setRootId($this->parent_ref_id);
52 $white = $this->getLPTypes($this->parent_ref_id);
53 $exp->setSelectableTypes($white);
54 if (!in_array("fold", $white)) {
55 $white[] = "fold";
56 }
57 $exp->setTypeWhiteList($white);
58 $subitems->setTitleModifier(function ($a_id): string {
59 $obj_id = ilObject::_lookupObjId((int) $a_id);
60 $olp = ilObjectLP::getInstance((int) $obj_id);
62 $mode = $olp->getModeText($olp->getCurrentMode());
63 if (in_array($olp->getCurrentMode(), $invalid_modes)) {
64 $mode = "<strong>$mode</strong>";
65 }
66 return ilObject::_lookupTitle(ilObject::_lookupObjId((int) $a_id)) . " (" . $mode . ")";
67 });
68
69 $subitems->setRequired(true);
70 $a_form->addItem($subitems);
71 }
getLPTypes(int $a_parent_ref_id)
static getInstance(int $obj_id)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)

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

+ Here is the call graph for this function:

◆ validateForm()

ilCourseLPBadgeGUI::validateForm ( ilPropertyFormGUI  $a_form)

Custom form validation.

Implements ilBadgeTypeGUI.

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

145 : bool
146 {
147 $invalid = array();
148 $invalid_modes = self::getInvalidLPModes();
149 foreach ($a_form->getInput("subitems") as $ref_id) {
150 $obj_id = ilObject::_lookupObjId((int) $ref_id);
151 $olp = ilObjectLP::getInstance((int) $obj_id);
152 if (in_array($olp->getCurrentMode(), $invalid_modes)) {
153 $invalid[] = ilObject::_lookupTitle((int) $obj_id);
154 }
155 }
156 if ($invalid !== []) {
157 $mess = sprintf($this->lng->txt("badge_course_lp_invalid"), implode(", ", $invalid));
158 $a_form->getItemByPostVar("subitems")->setAlert($mess);
159 return false;
160 }
161 return true;
162 }
$ref_id
Definition: ltiauth.php:66

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

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrlInterface ilCourseLPBadgeGUI::$ctrl
protected

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

◆ $lng

ilLanguage ilCourseLPBadgeGUI::$lng
protected

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

◆ $parent_ref_id

int ilCourseLPBadgeGUI::$parent_ref_id = 0
protected

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

◆ $tree

ilTree ilCourseLPBadgeGUI::$tree
protected

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


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