ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilCertificateCourseLearningProgressEvaluation.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
8{
13
17 private $setting;
18
23
28
33
40 public function __construct(
42 ilSetting $setting = null,
46 ) {
47 $this->templateRepository = $templateRepository;
48
49 if (null === $setting) {
50 $setting = new ilSetting('crs');
51 }
52 $this->setting = $setting;
53
54 if (null === $objectHelper) {
56 }
57 $this->objectHelper = $objectHelper;
58
59 if (null === $statusHelper) {
61 }
62 $this->statusHelper = $statusHelper;
63 if (null === $trackingHelper) {
65 }
66 $this->trackingHelper = $trackingHelper;
67 }
68
74 public function evaluate(int $refId, int $userId) : array
75 {
76 $courseTemplates = $this->templateRepository->fetchActiveTemplatesByType('crs');
77
78 $enabledGlobalLearningProgress = $this->trackingHelper->enabledLearningProgress();
79
80 $templatesOfCompletedCourses = array();
81 foreach ($courseTemplates as $courseTemplate) {
82 $courseObjectId = $courseTemplate->getObjId();
83
84 if ($enabledGlobalLearningProgress) {
85 $objectLearningProgressSettings = new ilLPObjSettings($courseObjectId);
86 $mode = $objectLearningProgressSettings->getMode();
87
89 continue;
90 }
91 }
92
93 $subItems = $this->setting->get('cert_subitems_' . $courseObjectId, false);
94
95 if (false === $subItems || $subItems === null) {
96 continue;
97 }
98
99 $subItems = json_decode($subItems);
100
101 if (!is_array($subItems)) {
102 continue;
103 }
104
105 $subitem_obj_ids = array();
106 foreach ($subItems as $subItemRefId) {
107 $subitem_obj_ids[$subItemRefId] = $this->objectHelper->lookupObjId((int) $subItemRefId);
108 }
109
110 if (in_array($refId, $subItems)) {
111 $completed = true;
112
113 // check if all subitems are completed now
114 foreach ($subitem_obj_ids as $subitem_ref_id => $subitem_id) {
115 $status = $this->statusHelper->lookUpStatus($subitem_id, $userId);
116
118 $completed = false;
119 break;
120 }
121 }
122
123 if (true === $completed) {
124 $templatesOfCompletedCourses[] = $courseTemplate;
125 }
126 }
127 }
128
129 return $templatesOfCompletedCourses;
130 }
131}
An exception for terminatinating execution or to throw for unit testing.
__construct(ilCertificateTemplateRepository $templateRepository, ilSetting $setting=null, ilCertificateObjectHelper $objectHelper=null, ilCertificateLPStatusHelper $statusHelper=null, ilCertificateObjUserTrackingHelper $trackingHelper=null)
const LP_STATUS_COMPLETED_NUM
ILIAS Setting Class.
$refId
Definition: xapitoken.php:42