ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $lng;
25  return $lng->txt("badge_course_lp");
26  }
27 
28  public function isSingleton()
29  {
30  return false;
31  }
32 
33  public function getValidObjectTypes()
34  {
35  return array("crs");
36  }
37 
38  public function getConfigGUIInstance()
39  {
40  include_once "Modules/Course/classes/Badges/class.ilCourseLPBadgeGUI.php";
41  return new ilCourseLPBadgeGUI();
42  }
43 
44  public function evaluate($a_user_id, array $a_params, array $a_config)
45  {
46  $subitem_obj_ids = array();
47  foreach ($a_config["subitems"] as $ref_id) {
48  $subitem_obj_ids[$ref_id] = ilObject::_lookupObjId($ref_id);
49  }
50 
51  $trigger_subitem_id = $a_params["obj_id"];
52 
53  // relevant for current badge instance?
54  if (in_array($trigger_subitem_id, $subitem_obj_ids)) {
55  $completed = true;
56 
57  // check if all subitems are completed now
58  foreach ($a_config["subitems"] as $subitem_id) {
59  $subitem_obj_id = $subitem_obj_ids[$subitem_id];
60  if (ilLPStatus::_lookupStatus($subitem_obj_id, $a_user_id) != ilLPStatus::LP_STATUS_COMPLETED_NUM) {
61  $completed = false;
62  break;
63  }
64  }
65 
66  return $completed;
67  }
68 
69  return false;
70  }
71 }
const LP_STATUS_COMPLETED_NUM
getCaption()
Get caption.
Course LP badge gui.
getConfigGUIInstance()
Get GUI config instance.
Badge type interface.
isSingleton()
Can only be created once?
Manual Badge Auto.
static _lookupObjId($a_id)
getValidObjectTypes()
Get valid (repository) "parent" object types.
Create styles array
The data for the language used.
getId()
Get typ id (unique for component)
global $lng
Definition: privfeed.php:17
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.