1 |
www |
1 |
<?php
|
|
|
2 |
declare(strict_types=1);
|
|
|
3 |
|
|
|
4 |
namespace LeadersLinked\Controller;
|
|
|
5 |
|
|
|
6 |
use Laminas\Db\Adapter\AdapterInterface;
|
|
|
7 |
use Laminas\Cache\Storage\Adapter\AbstractAdapter;
|
|
|
8 |
use Laminas\Mvc\Controller\AbstractActionController;
|
|
|
9 |
use Laminas\Log\LoggerInterface;
|
|
|
10 |
use Laminas\View\Model\ViewModel;
|
|
|
11 |
use Laminas\View\Model\JsonModel;
|
|
|
12 |
use LeadersLinked\Form\ExtendUserMicrolearningForm;
|
|
|
13 |
use LeadersLinked\Mapper\QueryMapper;
|
|
|
14 |
use LeadersLinked\Mapper\UserMapper;
|
|
|
15 |
use Laminas\Db\Sql\Expression;
|
|
|
16 |
use LeadersLinked\Mapper\CompanyMicrolearningCapsuleUserMapper;
|
|
|
17 |
use LeadersLinked\Model\CompanyMicrolearningCapsuleUser;
|
|
|
18 |
use LeadersLinked\Mapper\CompanyMicrolearningCapsuleMapper;
|
|
|
19 |
use LeadersLinked\Mapper\CompanyMicrolearningUserProgressMapper;
|
|
|
20 |
use LeadersLinked\Mapper\CompanyMicrolearningSlideMapper;
|
|
|
21 |
use LeadersLinked\Mapper\CompanyMicrolearningUserLogMapper;
|
|
|
22 |
use Google\Service\Classroom\Student;
|
|
|
23 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserCompanyMapper;
|
|
|
24 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserFunctionMapper;
|
|
|
25 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserGroupMapper;
|
|
|
26 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserInstitutionMapper;
|
|
|
27 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserProgramMapper;
|
|
|
28 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserPartnerMapper;
|
|
|
29 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserSectorMapper;
|
|
|
30 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserStudentTypeMapper;
|
|
|
31 |
use LeadersLinked\Mapper\CompanyMicrolearningExtendUserMapper;
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
class MicrolearningReportsController extends AbstractActionController
|
|
|
35 |
{
|
|
|
36 |
/**
|
|
|
37 |
*
|
|
|
38 |
* @var AdapterInterface
|
|
|
39 |
*/
|
|
|
40 |
private $adapter;
|
|
|
41 |
|
|
|
42 |
|
|
|
43 |
/**
|
|
|
44 |
*
|
|
|
45 |
* @var AbstractAdapter
|
|
|
46 |
*/
|
|
|
47 |
private $cache;
|
|
|
48 |
|
|
|
49 |
/**
|
|
|
50 |
*
|
|
|
51 |
* @var LoggerInterface
|
|
|
52 |
*/
|
|
|
53 |
private $logger;
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
/**
|
|
|
57 |
*
|
|
|
58 |
* @param AdapterInterface $adapter
|
|
|
59 |
* @param AbstractAdapter $cache
|
|
|
60 |
* @param LoggerInterface $logger
|
|
|
61 |
* @param array $config
|
|
|
62 |
*/
|
|
|
63 |
public function __construct($adapter, $cache , $logger, $config)
|
|
|
64 |
{
|
|
|
65 |
$this->adapter = $adapter;
|
|
|
66 |
$this->cache = $cache;
|
|
|
67 |
$this->logger = $logger;
|
|
|
68 |
$this->config = $config;
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
public function overviewAction()
|
|
|
75 |
{
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
79 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
80 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
$request = $this->getRequest();
|
|
|
84 |
if($request->isGet()) {
|
|
|
85 |
$reportsLastWeek = [];
|
|
|
86 |
$reportsCapsuleResume = [];
|
|
|
87 |
$reportsStudentsTotal = [];
|
|
|
88 |
|
|
|
89 |
$companyMicrolearningExtendUserCompanyMapper = CompanyMicrolearningExtendUserCompanyMapper::getInstance($this->adapter);
|
|
|
90 |
$extendCompanies = $companyMicrolearningExtendUserCompanyMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
91 |
|
|
|
92 |
foreach($extendCompanies as $extendCompany)
|
|
|
93 |
{
|
|
|
94 |
$reportsLastWeek['companies'][$extendCompany->id] = [
|
|
|
95 |
'name' => $extendCompany->name,
|
|
|
96 |
'total' => 0,
|
|
|
97 |
'value' => 0
|
|
|
98 |
] ;
|
|
|
99 |
|
|
|
100 |
$reportsCapsuleResume['companies'][$extendCompany->id] = [
|
|
|
101 |
'name' => $extendCompany->name,
|
|
|
102 |
'total' => 0,
|
|
|
103 |
'value' => 0
|
|
|
104 |
] ;
|
|
|
105 |
|
|
|
106 |
$reportsStudentsTotal['companies'][$extendCompany->id] = [
|
|
|
107 |
'name' => $extendCompany->name,
|
|
|
108 |
'total' => 0,
|
|
|
109 |
] ;
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
$companyMicrolearningExtendUserFunctionMapper = CompanyMicrolearningExtendUserFunctionMapper::getInstance($this->adapter);
|
|
|
114 |
$extendFunctions = $companyMicrolearningExtendUserFunctionMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
115 |
|
|
|
116 |
foreach($extendFunctions as $extendFunction)
|
|
|
117 |
{
|
|
|
118 |
$reportsLastWeek['functions'][$extendFunction->id] = [
|
|
|
119 |
'name' => $extendFunction->name,
|
|
|
120 |
'total' => 0,
|
|
|
121 |
'value' => 0
|
|
|
122 |
] ;
|
|
|
123 |
|
|
|
124 |
$reportsCapsuleResume['functions'][$extendFunction->id] = [
|
|
|
125 |
'name' => $extendFunction->name,
|
|
|
126 |
'total' => 0,
|
|
|
127 |
'value' => 0
|
|
|
128 |
] ;
|
|
|
129 |
|
|
|
130 |
$reportsStudentsTotal['functions'][$extendFunction->id] = [
|
|
|
131 |
'name' => $extendFunction->name,
|
|
|
132 |
'total' => 0,
|
|
|
133 |
] ;
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
$companyMicrolearningExtendUserGroupMapper = CompanyMicrolearningExtendUserGroupMapper::getInstance($this->adapter);
|
|
|
137 |
$extendGroups = $companyMicrolearningExtendUserGroupMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
138 |
|
|
|
139 |
foreach($extendGroups as $extendGroup)
|
|
|
140 |
{
|
|
|
141 |
$reportsLastWeek['groups'][$extendGroup->id] = [
|
|
|
142 |
'name' => $extendGroup->name,
|
|
|
143 |
'total' => 0,
|
|
|
144 |
'value' => 0
|
|
|
145 |
];
|
|
|
146 |
|
|
|
147 |
$reportsCapsuleResume['groups'][$extendGroup->id] = [
|
|
|
148 |
'name' => $extendFunction->name,
|
|
|
149 |
'total' => 0,
|
|
|
150 |
'value' => 0
|
|
|
151 |
] ;
|
|
|
152 |
|
|
|
153 |
$reportsStudentsTotal['groups'][$extendGroup->id] = [
|
|
|
154 |
'name' => $extendGroup->name,
|
|
|
155 |
'total' => 0,
|
|
|
156 |
];
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
}
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
$companyMicrolearningExtendUserInstitutionMapper = CompanyMicrolearningExtendUserInstitutionMapper::getInstance($this->adapter);
|
|
|
163 |
$extendInstitutions = $companyMicrolearningExtendUserInstitutionMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
164 |
|
|
|
165 |
foreach($extendInstitutions as $extendInstitution)
|
|
|
166 |
{
|
|
|
167 |
$reportsLastWeek['institutions'][$extendInstitution->id] = [
|
|
|
168 |
'name' => $extendInstitution->name,
|
|
|
169 |
'total' => 0,
|
|
|
170 |
'value' => 0
|
|
|
171 |
] ;
|
|
|
172 |
|
|
|
173 |
$reportsCapsuleResume['institutions'][$extendInstitution->id] = [
|
|
|
174 |
'name' => $extendInstitution->name,
|
|
|
175 |
'total' => 0,
|
|
|
176 |
'value' => 0
|
|
|
177 |
] ;
|
|
|
178 |
|
|
|
179 |
$reportsStudentsTotal['institutions'][$extendInstitution->id] = [
|
|
|
180 |
'name' => $extendInstitution->name,
|
|
|
181 |
'total' => 0,
|
|
|
182 |
] ;
|
|
|
183 |
}
|
|
|
184 |
|
|
|
185 |
|
|
|
186 |
$companyMicrolearningExtendUserProgramMapper = CompanyMicrolearningExtendUserProgramMapper::getInstance($this->adapter);
|
|
|
187 |
$extendPrograms = $companyMicrolearningExtendUserProgramMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
188 |
|
|
|
189 |
foreach($extendPrograms as $extendProgram)
|
|
|
190 |
{
|
|
|
191 |
$reportsLastWeek['programs'][$extendProgram->id] = [
|
|
|
192 |
'name' => $extendProgram->name,
|
|
|
193 |
'total' => 0,
|
|
|
194 |
'value' => 0
|
|
|
195 |
] ;
|
|
|
196 |
|
|
|
197 |
$reportsCapsuleResume['programs'][$extendProgram->id] = [
|
|
|
198 |
'name' => $extendProgram->name,
|
|
|
199 |
'total' => 0,
|
|
|
200 |
'value' => 0
|
|
|
201 |
] ;
|
|
|
202 |
|
|
|
203 |
$reportsStudentsTotal['programs'][$extendProgram->id] = [
|
|
|
204 |
'name' => $extendProgram->name,
|
|
|
205 |
'total' => 0,
|
|
|
206 |
|
|
|
207 |
] ;
|
|
|
208 |
}
|
|
|
209 |
|
|
|
210 |
|
|
|
211 |
$companyMicrolearningExtendUserPartnerMapper = CompanyMicrolearningExtendUserPartnerMapper::getInstance($this->adapter);
|
|
|
212 |
$extendPartners = $companyMicrolearningExtendUserPartnerMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
213 |
|
|
|
214 |
foreach($extendPartners as $extendPartner)
|
|
|
215 |
{
|
|
|
216 |
$reportsLastWeek['partners'][$extendPartner->id] = [
|
|
|
217 |
'name' => $extendPartner->name,
|
|
|
218 |
'total' => 0,
|
|
|
219 |
'value' => 0
|
|
|
220 |
] ;
|
|
|
221 |
|
|
|
222 |
$reportsCapsuleResume['partners'][$extendPartner->id] = [
|
|
|
223 |
'name' => $extendPartner->name,
|
|
|
224 |
'total' => 0,
|
|
|
225 |
'value' => 0
|
|
|
226 |
] ;
|
|
|
227 |
|
|
|
228 |
$reportsStudentsTotal['partners'][$extendPartner->id] = [
|
|
|
229 |
'name' => $extendPartner->name,
|
|
|
230 |
'total' => 0,
|
|
|
231 |
] ;
|
|
|
232 |
}
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
$companyMicrolearningExtendUserSectorMapper = CompanyMicrolearningExtendUserSectorMapper::getInstance($this->adapter);
|
|
|
236 |
$extendSectors = $companyMicrolearningExtendUserSectorMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
237 |
|
|
|
238 |
foreach($extendSectors as $extendSector)
|
|
|
239 |
{
|
|
|
240 |
$reportsLastWeek['sectors'][$extendSector->id] = [
|
|
|
241 |
'name' => $extendSector->name,
|
|
|
242 |
'total' => 0,
|
|
|
243 |
'value' => 0
|
|
|
244 |
] ;
|
|
|
245 |
|
|
|
246 |
$reportsCapsuleResume['sectors'][$extendSector->id] = [
|
|
|
247 |
'name' => $extendSector->name,
|
|
|
248 |
'total' => 0,
|
|
|
249 |
'value' => 0
|
|
|
250 |
] ;
|
|
|
251 |
|
|
|
252 |
$reportsStudentsTotal['sectors'][$extendSector->id] = [
|
|
|
253 |
'name' => $extendSector->name,
|
|
|
254 |
'total' => 0,
|
|
|
255 |
] ;
|
|
|
256 |
}
|
|
|
257 |
|
|
|
258 |
$companyMicrolearningExtendUserStudentTypeMapper = CompanyMicrolearningExtendUserStudentTypeMapper::getInstance($this->adapter);
|
|
|
259 |
$extendStudentTypes = $companyMicrolearningExtendUserStudentTypeMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
260 |
|
|
|
261 |
foreach($extendStudentTypes as $extendStudentType)
|
|
|
262 |
{
|
|
|
263 |
$reportsLastWeek['student_types'][$extendStudentType->id] = [
|
|
|
264 |
'name' => $extendStudentType->name,
|
|
|
265 |
'total' => 0,
|
|
|
266 |
'value' => 0
|
|
|
267 |
] ;
|
|
|
268 |
|
|
|
269 |
$reportsCapsuleResume['student_types'][$extendStudentType->id] = [
|
|
|
270 |
'name' => $extendStudentType->name,
|
|
|
271 |
'total' => 0,
|
|
|
272 |
'value' => 0
|
|
|
273 |
] ;
|
|
|
274 |
|
|
|
275 |
$reportsStudentsTotal['student_types'][$extendStudentType->id] = [
|
|
|
276 |
'name' => $extendStudentType->name,
|
|
|
277 |
'total' => 0,
|
|
|
278 |
] ;
|
|
|
279 |
}
|
|
|
280 |
|
|
|
281 |
$companyMicrolearningUserProgressMapper = CompanyMicrolearningUserProgressMapper::getInstance($this->adapter);
|
|
|
282 |
|
|
|
283 |
$minLastWeek = date('Y-m-d', strtotime(' -180 days'));
|
|
|
284 |
$maxLastWeek = date('Y-m-d');
|
|
|
285 |
$companyMicrolearningUserLogMapper = CompanyMicrolearningUserLogMapper::getInstance($this->adapter);
|
|
|
286 |
$companyUsersLogWithActivityLastWeek = $companyMicrolearningUserLogMapper->fetchAllUserIdsLastWeekByCompanyId($currentCompany->id, $minLastWeek, $maxLastWeek);
|
|
|
287 |
|
|
|
288 |
//header('Content-type: text/plain');
|
|
|
289 |
// print_r($companyUsersLogWithActivityLastWeek);
|
|
|
290 |
|
|
|
291 |
|
|
|
292 |
|
|
|
293 |
|
|
|
294 |
$date = date('Y-m-d');
|
|
|
295 |
|
|
|
296 |
$companyMicrolearningCapsuleUserMapper = CompanyMicrolearningCapsuleUserMapper::getInstance($this->adapter);
|
|
|
297 |
$user_ids = $companyMicrolearningCapsuleUserMapper->fetchAllDistinctUserIdActiveByCompanyIdAndDate($currentCompany->id, $date);
|
|
|
298 |
|
|
|
299 |
$studentsTotal = count($user_ids);
|
|
|
300 |
$studentsStarted = 0;
|
|
|
301 |
|
|
|
302 |
|
|
|
303 |
$userIdsWithAllCapsulesCompleted = [];
|
|
|
304 |
|
|
|
305 |
|
|
|
306 |
foreach($user_ids as $user_id)
|
|
|
307 |
{
|
|
|
308 |
$countSlides = $companyMicrolearningUserProgressMapper->fetchCountAllSlideCompletedByCompanyIdAndUserId($currentCompany->id, $user_id);
|
|
|
309 |
if($countSlides) {
|
|
|
310 |
$studentsStarted++;
|
|
|
311 |
}
|
|
|
312 |
|
|
|
313 |
$incompleted = false;
|
|
|
314 |
|
|
|
315 |
$capsuleUsers = $companyMicrolearningCapsuleUserMapper->fetchAllActiveByUserId($user_id);
|
|
|
316 |
foreach($capsuleUsers as $capsuleUser)
|
|
|
317 |
{
|
|
|
318 |
$userProgress = $companyMicrolearningUserProgressMapper->fetchOneByUseridAndCapsuleId($capsuleUser->user_id, $capsuleUser->capsule_id);
|
|
|
319 |
if($userProgress) {
|
|
|
320 |
if(!$userProgress->completed) {
|
|
|
321 |
$incompleted = true;
|
|
|
322 |
break;
|
|
|
323 |
}
|
|
|
324 |
} else {
|
|
|
325 |
$incompleted = true;
|
|
|
326 |
break;
|
|
|
327 |
}
|
|
|
328 |
|
|
|
329 |
|
|
|
330 |
|
|
|
331 |
}
|
|
|
332 |
|
|
|
333 |
if(!$incompleted) {
|
|
|
334 |
array_push($userIdsWithAllCapsulesCompleted, $user_id);
|
|
|
335 |
}
|
|
|
336 |
}
|
|
|
337 |
|
|
|
338 |
|
|
|
339 |
$studentsWithoutStarting = $studentsTotal - $studentsStarted;
|
|
|
340 |
$reportsLastWeek['general'] = ['total' => $studentsTotal, 'value' => count($companyUsersLogWithActivityLastWeek) ];
|
|
|
341 |
|
|
|
342 |
$reportsCapsuleResume['general'] = ['total' => $studentsTotal, 'value' => count($userIdsWithAllCapsulesCompleted) ];
|
|
|
343 |
|
|
|
344 |
|
|
|
345 |
$companyMicrolearningExtendUserMapper = CompanyMicrolearningExtendUserMapper::getInstance($this->adapter);
|
|
|
346 |
$records = $companyMicrolearningExtendUserMapper->fetchAllByCompanyId($currentCompany->id);
|
|
|
347 |
foreach($records as $record)
|
|
|
348 |
{
|
|
|
349 |
|
|
|
350 |
if($record->extend_company_id) {
|
|
|
351 |
$reportsLastWeek['companies'][$record->extend_company_id]['total'] += 1;
|
|
|
352 |
$reportsStudentsTotal['companies'][$record->extend_company_id]['total'] += 1;
|
|
|
353 |
|
|
|
354 |
if(in_array($record->user_id, $companyUsersLogWithActivityLastWeek )) {
|
|
|
355 |
$reportsLastWeek['companies'][$record->extend_company_id]['value'] += 1;
|
|
|
356 |
}
|
|
|
357 |
|
|
|
358 |
$reportsCapsuleResume['companies'][$record->extend_company_id]['total'] += 1;
|
|
|
359 |
|
|
|
360 |
if(in_array($record->user_id, $userIdsWithAllCapsulesCompleted )) {
|
|
|
361 |
$reportsCapsuleResume['companies'][$record->extend_company_id]['value'] += 1;
|
|
|
362 |
}
|
|
|
363 |
|
|
|
364 |
}
|
|
|
365 |
|
|
|
366 |
if($record->extend_function_id) {
|
|
|
367 |
$reportsLastWeek['functions'][$record->extend_function_id]['total'] += 1;
|
|
|
368 |
$reportsStudentsTotal['functions'][$record->extend_function_id]['total'] += 1;
|
|
|
369 |
|
|
|
370 |
if(in_array($record->user_id, $companyUsersLogWithActivityLastWeek )) {
|
|
|
371 |
$reportsLastWeek['functions'][$record->extend_function_id]['value'] += 1;
|
|
|
372 |
}
|
|
|
373 |
|
|
|
374 |
$reportsCapsuleResume['functions'][$record->extend_function_id]['total'] += 1;
|
|
|
375 |
if(in_array($record->user_id, $userIdsWithAllCapsulesCompleted )) {
|
|
|
376 |
$reportsCapsuleResume['functions'][$record->extend_function_id]['value'] += 1;
|
|
|
377 |
}
|
|
|
378 |
}
|
|
|
379 |
|
|
|
380 |
if($record->extend_group_id) {
|
|
|
381 |
$reportsLastWeek['groups'][$record->extend_group_id]['total'] += 1;
|
|
|
382 |
$reportsStudentsTotal['groups'][$record->extend_group_id]['total'] += 1;
|
|
|
383 |
if(in_array($record->user_id, $companyUsersLogWithActivityLastWeek )) {
|
|
|
384 |
$reportsLastWeek['groups'][$record->extend_group_id]['value'] += 1;
|
|
|
385 |
}
|
|
|
386 |
|
|
|
387 |
$reportsCapsuleResume['groups'][$record->extend_group_id]['total'] += 1;
|
|
|
388 |
if(in_array($record->user_id, $userIdsWithAllCapsulesCompleted )) {
|
|
|
389 |
$reportsCapsuleResume['groups'][$record->extend_group_id]['value'] += 1;
|
|
|
390 |
}
|
|
|
391 |
}
|
|
|
392 |
|
|
|
393 |
if($record->extend_institution_id) {
|
|
|
394 |
$reportsLastWeek['institutions'][$record->extend_institution_id]['total'] += 1;
|
|
|
395 |
$reportsStudentsTotal['institutions'][$record->extend_institution_id]['total'] += 1;
|
|
|
396 |
if(in_array($record->user_id, $companyUsersLogWithActivityLastWeek )) {
|
|
|
397 |
$reportsLastWeek['institutions'][$record->extend_institution_id]['value'] += 1;
|
|
|
398 |
}
|
|
|
399 |
|
|
|
400 |
$reportsCapsuleResume['institutions'][$record->extend_institution_id]['total'] += 1;
|
|
|
401 |
if(in_array($record->user_id, $userIdsWithAllCapsulesCompleted )) {
|
|
|
402 |
$reportsCapsuleResume['institutions'][$record->extend_institution_id]['value'] += 1;
|
|
|
403 |
}
|
|
|
404 |
}
|
|
|
405 |
|
|
|
406 |
if($record->extend_program_id) {
|
|
|
407 |
$reportsLastWeek['programs'][$record->extend_program_id]['total'] += 1;
|
|
|
408 |
$reportsStudentsTotal['programs'][$record->extend_program_id]['total'] += 1;
|
|
|
409 |
if(in_array($record->user_id, $companyUsersLogWithActivityLastWeek )) {
|
|
|
410 |
$reportsLastWeek['programs'][$record->extend_program_id]['value'] += 1;
|
|
|
411 |
}
|
|
|
412 |
|
|
|
413 |
$reportsCapsuleResume['programs'][$record->extend_program_id]['total'] += 1;
|
|
|
414 |
if(in_array($record->user_id, $userIdsWithAllCapsulesCompleted )) {
|
|
|
415 |
$reportsCapsuleResume['programs'][$record->extend_program_id]['value'] += 1;
|
|
|
416 |
}
|
|
|
417 |
}
|
|
|
418 |
|
|
|
419 |
if($record->extend_partner_id) {
|
|
|
420 |
$reportsLastWeek['partners'][$record->extend_partner_id]['total'] += 1;
|
|
|
421 |
$reportsStudentsTotal['partners'][$record->extend_partner_id]['total'] += 1;
|
|
|
422 |
if(in_array($record->user_id, $companyUsersLogWithActivityLastWeek )) {
|
|
|
423 |
$reportsLastWeek['partners'][$record->extend_partner_id]['value'] += 1;
|
|
|
424 |
}
|
|
|
425 |
|
|
|
426 |
$reportsCapsuleResume['partners'][$record->extend_partner_id]['total'] += 1;
|
|
|
427 |
if(in_array($record->user_id, $userIdsWithAllCapsulesCompleted )) {
|
|
|
428 |
$reportsCapsuleResume['partners'][$record->extend_partner_id]['value'] += 1;
|
|
|
429 |
}
|
|
|
430 |
}
|
|
|
431 |
|
|
|
432 |
if($record->extend_sector_id) {
|
|
|
433 |
$reportsLastWeek['sectors'][$record->extend_sector_id]['total'] += 1;
|
|
|
434 |
$reportsStudentsTotal['sectors'][$record->extend_sector_id]['total'] += 1;
|
|
|
435 |
if(in_array($record->user_id, $companyUsersLogWithActivityLastWeek )) {
|
|
|
436 |
$reportsLastWeek['sectors'][$record->extend_sector_id]['value'] += 1;
|
|
|
437 |
}
|
|
|
438 |
|
|
|
439 |
$reportsCapsuleResume['sectors'][$record->extend_sector_id]['total'] += 1;
|
|
|
440 |
if(in_array($record->user_id, $userIdsWithAllCapsulesCompleted )) {
|
|
|
441 |
$reportsCapsuleResume['sectors'][$record->extend_sector_id]['value'] += 1;
|
|
|
442 |
}
|
|
|
443 |
}
|
|
|
444 |
|
|
|
445 |
if($record->extend_student_type_id) {
|
|
|
446 |
$reportsLastWeek['student_types'][$record->extend_student_type_id]['total'] += 1;
|
|
|
447 |
$reportsStudentsTotal['student_types'][$record->extend_student_type_id]['total'] += 1;
|
|
|
448 |
if(in_array($record->user_id, $companyUsersLogWithActivityLastWeek )) {
|
|
|
449 |
$reportsLastWeek['student_types'][$record->extend_student_type_id]['value'] += 1;
|
|
|
450 |
}
|
|
|
451 |
|
|
|
452 |
$reportsCapsuleResume['student_types'][$record->extend_student_type_id]['total'] += 1;
|
|
|
453 |
if(in_array($record->user_id, $userIdsWithAllCapsulesCompleted )) {
|
|
|
454 |
$reportsCapsuleResume['student_types'][$record->extend_student_type_id]['value'] += 1;
|
|
|
455 |
}
|
|
|
456 |
}
|
|
|
457 |
}
|
|
|
458 |
|
|
|
459 |
|
|
|
460 |
/*
|
|
|
461 |
header('Content-type: text/plain');
|
|
|
462 |
print_r($reportsStudentsTotal); exit;
|
|
|
463 |
*/
|
|
|
464 |
|
|
|
465 |
|
|
|
466 |
$this->layout()->setTemplate('layout/layout-backend.phtml');
|
|
|
467 |
$viewModel = new ViewModel();
|
|
|
468 |
$viewModel->setTemplate('leaders-linked/microlearning-reports/overview.phtml');
|
|
|
469 |
$viewModel->setVariables([
|
|
|
470 |
'reportsLastWeek' => $reportsLastWeek,
|
|
|
471 |
'reportsCapsuleResume' => $reportsCapsuleResume,
|
|
|
472 |
'reportsStudentsTotal' => $reportsStudentsTotal,
|
|
|
473 |
'reportStudents' => [
|
|
|
474 |
'total' => $studentsTotal,
|
|
|
475 |
'started' => $studentsStarted,
|
|
|
476 |
'withoutStarting' => $studentsWithoutStarting,
|
|
|
477 |
]
|
|
|
478 |
|
|
|
479 |
]);
|
|
|
480 |
return $viewModel ;
|
|
|
481 |
}
|
|
|
482 |
|
|
|
483 |
return new JsonModel([
|
|
|
484 |
'success' => false,
|
|
|
485 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
486 |
]);
|
|
|
487 |
}
|
|
|
488 |
|
|
|
489 |
public function reportsAction()
|
|
|
490 |
{
|
|
|
491 |
|
|
|
492 |
|
|
|
493 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
494 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
495 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
496 |
|
|
|
497 |
|
|
|
498 |
$request = $this->getRequest();
|
|
|
499 |
if($request->isGet()) {
|
|
|
500 |
|
|
|
501 |
|
|
|
502 |
$headers = $request->getHeaders();
|
|
|
503 |
|
|
|
504 |
$isJson = false;
|
|
|
505 |
if($headers->has('Accept')) {
|
|
|
506 |
$accept = $headers->get('Accept');
|
|
|
507 |
|
|
|
508 |
$prioritized = $accept->getPrioritized();
|
|
|
509 |
|
|
|
510 |
foreach($prioritized as $key => $value) {
|
|
|
511 |
$raw = trim($value->getRaw());
|
|
|
512 |
|
|
|
513 |
if(!$isJson) {
|
|
|
514 |
$isJson = strpos($raw, 'json');
|
|
|
515 |
}
|
|
|
516 |
|
|
|
517 |
}
|
|
|
518 |
}
|
|
|
519 |
|
|
|
520 |
if($isJson) {
|
|
|
521 |
|
|
|
522 |
$date = date('Y-m-d');
|
|
|
523 |
|
|
|
524 |
$companyMicrolearningProgressMapper = CompanyMicrolearningUserProgressMapper::getInstance($this->adapter);
|
|
|
525 |
$companyMicrolearningUserLogMapper = CompanyMicrolearningUserLogMapper::getInstance($this->adapter);
|
|
|
526 |
|
|
|
527 |
$companyMicrolearningCapsuleUserMapper = CompanyMicrolearningCapsuleUserMapper::getInstance($this->adapter);
|
|
|
528 |
|
|
|
529 |
$companyMicrolearningSlideMapper = CompanyMicrolearningSlideMapper::getInstance($this->adapter);
|
|
|
530 |
|
|
|
531 |
|
|
|
532 |
|
|
|
533 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
534 |
|
|
|
535 |
$selectCapsuleUser = $queryMapper->getSql()->select();
|
|
|
536 |
$selectCapsuleUser->columns(['user_id' => new Expression('DISTINCT(user_id)') ]);
|
|
|
537 |
$selectCapsuleUser->from(CompanyMicrolearningCapsuleUserMapper::_TABLE);
|
|
|
538 |
$selectCapsuleUser->where->equalTo('company_id', $currentCompany->id);
|
|
|
539 |
$selectCapsuleUser->where->nest->equalTo('access', CompanyMicrolearningCapsuleUser::ACCESS_UNLIMITED)->or->nest()
|
|
|
540 |
->equalTo('access', CompanyMicrolearningCapsuleUser::ACCESS_PAY_PERIOD)
|
|
|
541 |
->and->lessThanOrEqualTo(new Expression('DATE(paid_from)'), $date)
|
|
|
542 |
->and->greaterThanOrEqualTo(new Expression('DATE(paid_to)'), $date )->unnest()->unnest();
|
|
|
543 |
|
|
|
544 |
//echo $select->getSqlString($this->adapter->platform); exit;
|
|
|
545 |
|
|
|
546 |
$select = $queryMapper->getSql()->select();
|
|
|
547 |
$select->columns(['id' , 'uuid', 'first_name', 'last_name', 'email']);
|
|
|
548 |
$select->from(UserMapper::_TABLE);
|
|
|
549 |
$select->where->in('id', $selectCapsuleUser);
|
|
|
550 |
$select->order(['first_name', 'last_name']);
|
|
|
551 |
|
|
|
552 |
|
|
|
553 |
|
|
|
554 |
$students = [];
|
|
|
555 |
$records = $queryMapper->fetchAll($select);
|
|
|
556 |
foreach($records as $record)
|
|
|
557 |
{
|
|
|
558 |
$capsules = $companyMicrolearningCapsuleUserMapper->fetchAllActiveByUserId($record['id']);
|
|
|
559 |
$totalCapsules = count($capsules);
|
|
|
560 |
$totalCapsulesStarted = 0;
|
|
|
561 |
$totalCapsulesCompleted = 0;
|
|
|
562 |
|
|
|
563 |
$totalSlides = 0;
|
|
|
564 |
$totalSlidesStarted = 0;
|
|
|
565 |
$totalSlidesCompleted = 0;
|
|
|
566 |
|
|
|
567 |
foreach($capsules as $capsule)
|
|
|
568 |
{
|
|
|
569 |
$userProgress = $companyMicrolearningProgressMapper->fetchOneByUseridAndCapsuleId($capsule->user_id, $capsule->capsule_id);
|
|
|
570 |
if($userProgress) {
|
|
|
571 |
$totalCapsulesStarted++;
|
|
|
572 |
if($userProgress->completed) {
|
|
|
573 |
$totalCapsulesCompleted++;
|
|
|
574 |
}
|
|
|
575 |
}
|
|
|
576 |
|
|
|
577 |
$slides = $companyMicrolearningSlideMapper->fetchAllByCompanyIdAndTopicIdAndCapsuleId($capsule->company_id, $capsule->topic_id, $capsule->capsule_id);
|
|
|
578 |
$totalSlides = count($slides);
|
|
|
579 |
foreach($slides as $slide)
|
|
|
580 |
{
|
|
|
581 |
|
|
|
582 |
$userProgress = $companyMicrolearningProgressMapper->fetchOneByUserIdAndSlideId($capsule->user_id, $slide->id);
|
|
|
583 |
if($userProgress) {
|
|
|
584 |
|
|
|
585 |
$totalSlidesStarted++;
|
|
|
586 |
if($userProgress->completed) {
|
|
|
587 |
$totalSlidesCompleted++;
|
|
|
588 |
}
|
|
|
589 |
|
|
|
590 |
}
|
|
|
591 |
}
|
|
|
592 |
|
|
|
593 |
|
|
|
594 |
}
|
|
|
595 |
|
|
|
596 |
|
|
|
597 |
|
|
|
598 |
$student = [
|
|
|
599 |
'uuid' => $record['uuid'],
|
|
|
600 |
'first_name' => $record['first_name'],
|
|
|
601 |
'last_name' => $record['last_name'],
|
|
|
602 |
'email' => $record['email'],
|
|
|
603 |
'total_capsules' => $totalCapsules,
|
|
|
604 |
'total_capsules_incomplete' => ( $totalCapsules - $totalCapsulesCompleted ),
|
|
|
605 |
'total_capsules_started' => $totalCapsulesStarted,
|
|
|
606 |
'total_capsules_completed' => $totalCapsulesCompleted,
|
|
|
607 |
'total_slides' => $totalSlides,
|
|
|
608 |
'total_slides_started' => $totalSlidesStarted,
|
|
|
609 |
'total_slides_completed' => $totalSlidesCompleted,
|
|
|
610 |
'totql_slides_incompleted' => ($totalSlides - $totalSlidesCompleted ) ,
|
|
|
611 |
'first_date' => '',
|
|
|
612 |
'first_time' => '',
|
|
|
613 |
'last_date' => '',
|
|
|
614 |
'last_time' => '',
|
|
|
615 |
];
|
|
|
616 |
|
|
|
617 |
$first_added_on = $companyMicrolearningUserLogMapper->fetchFirstDateByCompanyIdAndUserId($currentCompany->id, $record['id']);
|
|
|
618 |
if($first_added_on) {
|
|
|
619 |
$dt = \DateTime::createFromFormat('Y-m-d H:i:s', $first_added_on);
|
|
|
620 |
if($dt) {
|
|
|
621 |
$student['first_date'] = $dt->format('d/m/Y');
|
|
|
622 |
$student['first_time'] = $dt->format('h:i a');
|
|
|
623 |
}
|
|
|
624 |
}
|
|
|
625 |
|
|
|
626 |
$last_added_on = $companyMicrolearningUserLogMapper->fetchLastDateByCompanyIdAndUserId($currentCompany->id, $record['id']);
|
|
|
627 |
if($last_added_on) {
|
|
|
628 |
$dt = \DateTime::createFromFormat('Y-m-d H:i:s', $last_added_on);
|
|
|
629 |
if($dt) {
|
|
|
630 |
$student['last_date'] = $dt->format('d/m/Y');
|
|
|
631 |
$student['last_time'] = $dt->format('h:i a');
|
|
|
632 |
}
|
|
|
633 |
}
|
|
|
634 |
|
|
|
635 |
array_push($students, $student);
|
|
|
636 |
|
|
|
637 |
|
|
|
638 |
}
|
|
|
639 |
|
|
|
640 |
|
|
|
641 |
|
|
|
642 |
|
|
|
643 |
return new JsonModel([
|
|
|
644 |
'success' => true,
|
|
|
645 |
'data' => $students
|
|
|
646 |
|
|
|
647 |
]);
|
|
|
648 |
|
|
|
649 |
} else {
|
|
|
650 |
|
|
|
651 |
|
|
|
652 |
|
|
|
653 |
$form = new ExtendUserMicrolearningForm($this->adapter, $currentCompany->id);
|
|
|
654 |
|
|
|
655 |
|
|
|
656 |
$this->layout()->setTemplate('layout/layout-backend.phtml');
|
|
|
657 |
$viewModel = new ViewModel();
|
|
|
658 |
$viewModel->setTemplate('leaders-linked/microlearning-reports/reports.phtml');
|
|
|
659 |
$viewModel->setVariables([
|
|
|
660 |
'form' => $form
|
|
|
661 |
]);
|
|
|
662 |
return $viewModel ;
|
|
|
663 |
}
|
|
|
664 |
}
|
|
|
665 |
|
|
|
666 |
return new JsonModel([
|
|
|
667 |
'success' => false,
|
|
|
668 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
669 |
]);
|
|
|
670 |
}
|
|
|
671 |
|
|
|
672 |
}
|