ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilCourseLPBadge.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once "./Services/Badge/interfaces/interface.ilBadgeType.php";
5 require_once "./Services/Badge/interfaces/interface.ilBadgeAuto.php";
6 
16 {
17  public function getId()
18  {
19  return "course_lp";
20  }
21 
22  public function getCaption()
23  {
24  global $DIC;
25 
26  $lng = $DIC['lng'];
27  return $lng->txt("badge_course_lp");
28  }
29 
30  public function isSingleton()
31  {
32  return false;
33  }
34 
35  public function getValidObjectTypes()
36  {
37  return array("crs");
38  }
39 
40  public function getConfigGUIInstance()
41  {
42  include_once "Modules/Course/classes/Badges/class.ilCourseLPBadgeGUI.php";
43  return new ilCourseLPBadgeGUI();
44  }
45 
46  public function evaluate($a_user_id, array $a_params, array $a_config)
47  {
48  $subitem_obj_ids = array();
49  foreach ($a_config["subitems"] as $ref_id) {
50  $subitem_obj_ids[$ref_id] = ilObject::_lookupObjId($ref_id);
51  }
52 
53  $trigger_subitem_id = $a_params["obj_id"];
54 
55  // relevant for current badge instance?
56  if (in_array($trigger_subitem_id, $subitem_obj_ids)) {
57  $completed = true;
58 
59  // check if all subitems are completed now
60  foreach ($a_config["subitems"] as $subitem_id) {
61  $subitem_obj_id = $subitem_obj_ids[$subitem_id];
62  if (ilLPStatus::_lookupStatus($subitem_obj_id, $a_user_id) != ilLPStatus::LP_STATUS_COMPLETED_NUM) {
63  $completed = false;
64  break;
65  }
66  }
67 
68  return $completed;
69  }
70 
71  return false;
72  }
73 }
const LP_STATUS_COMPLETED_NUM
getCaption()
Get caption.
Course LP badge gui.
getConfigGUIInstance()
Get GUI config instance.
global $DIC
Definition: saml.php:7
Badge type interface.
isSingleton()
Can only be created once?
Manual Badge Auto.
$lng
static _lookupObjId($a_id)
getValidObjectTypes()
Get valid (repository) "parent" object types.
getId()
Get typ id (unique for component)
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.
evaluate($a_user_id, array $a_params, array $a_config)
Evaluate if given user has earned badge.