ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
4require_once "./Services/Badge/interfaces/interface.ilBadgeType.php";
5require_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 {
49 $subitem_obj_ids[$ref_id] = ilObject::_lookupObjId($ref_id);
50 }
51
52 $trigger_subitem_id = $a_params["obj_id"];
53
54 // relevant for current badge instance?
55 if(in_array($trigger_subitem_id, $subitem_obj_ids))
56 {
57 $completed = true;
58
59 // check if all subitems are completed now
60 foreach($a_config["subitems"] as $subitem_id)
61 {
62 $subitem_obj_id = $subitem_obj_ids[$subitem_id];
63 if(ilLPStatus::_lookupStatus($subitem_obj_id, $a_user_id) != ilLPStatus::LP_STATUS_COMPLETED_NUM)
64 {
65 $completed = false;
66 break;
67 }
68 }
69
70 return $completed;
71 }
72
73 return false;
74 }
75}
An exception for terminatinating execution or to throw for unit testing.
getConfigGUIInstance()
Get GUI config instance.
getCaption()
Get caption.
evaluate($a_user_id, array $a_params, array $a_config)
Evaluate if given user has earned badge.
getId()
Get typ id (unique for component)
getValidObjectTypes()
Get valid (repository) "parent" object types.
isSingleton()
Can only be created once?
const LP_STATUS_COMPLETED_NUM
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.
static _lookupObjId($a_id)
Manual Badge Auto.
Badge type interface.
global $lng
Definition: privfeed.php:17
$ref_id
Definition: sahs_server.php:39