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

Course LP badge gui. More...

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

Public Member Functions

 initConfigForm (ilPropertyFormGUI $a_form, $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 ()
 Get invalid lp modes. More...
 

Protected Member Functions

 getLPTypes ($a_parent_ref_id)
 

Protected Attributes

 $parent_ref_id
 

Detailed Description

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

Member Function Documentation

◆ getConfigFromForm()

ilCourseLPBadgeGUI::getConfigFromForm ( ilPropertyFormGUI  $a_form)

Export values to DB.

Parameters
ilPropertyFormGUI$a_form
Returns
array

Implements ilBadgeTypeGUI.

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

References ilPropertyFormGUI\getInput().

127  {
128  return array("subitems" => $a_form->getInput("subitems"));
129  }
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
+ Here is the call graph for this function:

◆ getInvalidLPModes()

static ilCourseLPBadgeGUI::getInvalidLPModes ( )
static

Get invalid lp modes.

Parameters

Definition at line 137 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().

138  {
139  include_once "Services/Object/classes/class.ilObjectLP.php";
140  include_once "Services/Tracking/classes/class.ilLPObjSettings.php";
141  include_once "Services/Tracking/classes/class.ilObjUserTracking.php";
142 
143  /* supported modes
144  LP_MODE_TLT
145  LP_MODE_OBJECTIVES
146  LP_MODE_TEST_FINISHED
147  LP_MODE_TEST_PASSED
148  LP_MODE_EXERCISE_RETURNED
149  LP_MODE_EVENT
150  LP_MODE_SCORM_PACKAGE
151  LP_MODE_PLUGIN
152  LP_MODE_QUESTIONS
153  LP_MODE_SURVEY_FINISHED
154  LP_MODE_VISITED_PAGES
155  LP_MODE_DOWNLOADED
156  LP_MODE_STUDY_PROGRAMME ?!
157  */
158 
159  $invalid_modes = array(ilLPObjSettings::LP_MODE_DEACTIVATED,
161 
162  // without active LP the following modes cannot be supported
164  // status cannot be set without active LP
165  $invalid_modes[] = ilLPObjSettings::LP_MODE_MANUAL;
166  $invalid_modes[] = ilLPObjSettings::LP_MODE_MANUAL_BY_TUTOR;
168 
169  // mode cannot be configured without active LP
170  $invalid_modes[] = ilLPObjSettings::LP_MODE_COLLECTION;
171  $invalid_modes[] = ilLPObjSettings::LP_MODE_COLLECTION_MOBS;
172  $invalid_modes[] = ilLPObjSettings::LP_MODE_COLLECTION_TLT;
173  $invalid_modes[] = ilLPObjSettings::LP_MODE_SCORM;
174  $invalid_modes[] = ilLPObjSettings::LP_MODE_VISITS; // ?
175  }
176  return $invalid_modes;
177  }
static _enabledLearningProgress()
check wether learing progress is enabled or not
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLPTypes()

ilCourseLPBadgeGUI::getLPTypes (   $a_parent_ref_id)
protected

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

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

Referenced by initConfigForm().

56  {
57  global $DIC;
58 
59  $tree = $DIC['tree'];
60 
61  $res = array();
62 
63  $root = $tree->getNodeData($a_parent_ref_id);
64  $sub_items = $tree->getSubTree($root);
65  array_shift($sub_items); // remove root
66 
67  include_once "Services/Object/classes/class.ilObjectLP.php";
68  foreach ($sub_items as $node) {
69  if (ilObjectLP::isSupportedObjectType($node["type"])) {
70  $class = ilObjectLP::getTypeClass($node["type"]);
71  $modes = $class::getDefaultModes(ilObjUserTracking::_enabledLearningProgress());
72  if (sizeof($modes) > 1) {
73  $res[] = $node["type"];
74  }
75  }
76  }
77 
78  return $res;
79  }
static getTypeClass($a_type)
global $DIC
Definition: saml.php:7
static isSupportedObjectType($a_type)
static _enabledLearningProgress()
check wether learing progress is enabled or not
foreach($_POST as $key=> $value) $res
$root
Definition: sabredav.php:45
+ 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.

Parameters
ilPropertyFormGUI$a_form
array$a_config

Implements ilBadgeTypeGUI.

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

References $DIC, $ilCtrl, $lng, and ilPropertyFormGUI\getItemByPostVar().

82  {
83  global $DIC;
84 
85  $ilCtrl = $DIC['ilCtrl'];
86  $lng = $DIC['lng'];
87 
88  if (is_array($a_config["subitems"])) {
89  $items = $a_form->getItemByPostVar("subitems");
90  $items->setValue($a_config["subitems"]);
91 
92  /*
93  include_once "Services/Tracking/classes/class.ilObjUserTracking.php";
94  if(!ilObjUserTracking::_enabledLearningProgress())
95  {
96  $lng->loadLanguageModule("trac");
97  $lp = new ilNonEditableValueGUI($lng->txt("tracking_settings"), "", true);
98  $a_form->addItem($lp);
99 
100  include_once "Services/Object/classes/class.ilObjectLP.php";
101 
102  $links = array();
103  foreach($a_config["subitems"] as $ref_id)
104  {
105  $obj_id = ilObject::_lookupObjId($ref_id);
106 
107  $olp = ilObjectLP::getInstance($obj_id);
108  $mode = $olp->getCurrentMode();
109 
110  $ilCtrl->setParameterByClass("ilLPListOfSettingsGUI", "lpid", $ref_id);
111  $url = $ilCtrl->getLinkTargetByClass("ilLPListOfSettingsGUI", "");
112  $ilCtrl->setParameterByClass("ilLPListOfSettingsGUI", "lpid", "");
113 
114  $links[] = '<p><a href="'.$url.'">'.
115  '<img src="'.ilObject::_getIcon("", "tiny", ilObject::_lookupType($obj_id)).'" /> ' .
116  ilObject::_lookupTitle($obj_id).
117  '</a><div class="help-block">'.$olp->getModeText($mode).'</div>'.
118  '</p>';
119  }
120  $lp->setValue(implode("\n", $links));
121  }
122  */
123  }
124  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
$lng
+ Here is the call graph for this function:

◆ initConfigForm()

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

Add custom fields to form.

Parameters
ilPropertyFormGUI$a_form
int$a_parent_ref_id

Implements ilBadgeTypeGUI.

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

References $DIC, $lng, $white, ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilPropertyFormGUI\addItem(), ilRepositorySelector2InputGUI\getExplorerGUI(), ilObjectLP\getInstance(), getInvalidLPModes(), getLPTypes(), and ilRepositorySelector2InputGUI\setTitleModifier().

19  {
20  global $DIC;
21 
22  $lng = $DIC['lng'];
23 
24  $this->parent_ref_id = (int) $a_parent_ref_id;
25 
26  $lng->loadLanguageModule("trac");
27 
28  include_once "Services/Form/classes/class.ilRepositorySelector2InputGUI.php";
29  $subitems = new ilRepositorySelector2InputGUI($lng->txt("objects"), "subitems", true);
30 
31  $exp = $subitems->getExplorerGUI();
32  $exp->setSkipRootNode(true);
33  $exp->setRootId($this->parent_ref_id);
34  $white = $this->getLPTypes($this->parent_ref_id);
35  $exp->setSelectableTypes($white);
36  if (!in_array("fold", $white)) {
37  $white[] = "fold";
38  }
39  $exp->setTypeWhiteList($white);
40  $subitems->setTitleModifier(function ($a_id) {
41  $obj_id = ilObject::_lookupObjId($a_id);
42  $olp = ilObjectLP::getInstance($obj_id);
43  $invalid_modes = ilCourseLPBadgeGUI::getInvalidLPModes();
44  $mode = $olp->getModeText($olp->getCurrentMode());
45  if (in_array($olp->getCurrentMode(), $invalid_modes)) {
46  $mode = "<strong>$mode</strong>";
47  }
48  return ilObject::_lookupTitle(ilObject::_lookupObjId($a_id)) . " (" . $mode . ")";
49  });
50 
51  $subitems->setRequired(true);
52  $a_form->addItem($subitems);
53  }
getLPTypes($a_parent_ref_id)
setTitleModifier(callable $a_val)
Set title modifier.
global $DIC
Definition: saml.php:7
static _lookupTitle($a_id)
lookup object title
addItem($a_item)
Add Item (Property, SectionHeader).
static getInvalidLPModes()
Get invalid lp modes.
$lng
static _lookupObjId($a_id)
$white
Definition: example_030.php:84
static getInstance($a_obj_id)
+ Here is the call graph for this function:

◆ validateForm()

ilCourseLPBadgeGUI::validateForm ( ilPropertyFormGUI  $a_form)

Custom form validation.

Parameters
ilPropertyFormGUI$a_form
Returns
bool

Implements ilBadgeTypeGUI.

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

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

181  {
182  global $DIC;
183 
184  $lng = $DIC['lng'];
185  $invalid = array();
186 
187  include_once "Services/Object/classes/class.ilObjectLP.php";
188  include_once "Services/Tracking/classes/class.ilLPObjSettings.php";
189  include_once "Services/Tracking/classes/class.ilObjUserTracking.php";
190 
191  $invalid_modes = self::getInvalidLPModes();
192 
193  foreach ($a_form->getInput("subitems") as $ref_id) {
194  $obj_id = ilObject::_lookupObjId($ref_id);
195  $olp = ilObjectLP::getInstance($obj_id);
196  if (in_array($olp->getCurrentMode(), $invalid_modes)) {
197  $invalid[] = ilObject::_lookupTitle($obj_id);
198  }
199  }
200 
201  if (sizeof($invalid)) {
202  $mess = sprintf($lng->txt("badge_course_lp_invalid"), implode(", ", $invalid));
203  $a_form->getItemByPostVar("subitems")->setAlert($mess);
204  return false;
205  }
206 
207  return true;
208  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
global $DIC
Definition: saml.php:7
static _lookupTitle($a_id)
lookup object title
$lng
static _lookupObjId($a_id)
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
static getInstance($a_obj_id)
+ Here is the call graph for this function:

Field Documentation

◆ $parent_ref_id

ilCourseLPBadgeGUI::$parent_ref_id
protected

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


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