ILIAS  release_7 Revision v7.30-3-g800a261c036
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 $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}
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)
global $DIC
Definition: goto.php:24
Manual Badge Auto.
Badge type interface.
$lng