Proyectos de Subversion LeadersLinked - Services

Rev

Rev 1 | Rev 283 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 119
Línea 111... Línea 111...
111
            ]);
111
            ]);
112
        }
112
        }
113
    }
113
    }
Línea 114... Línea -...
114
    
-
 
115
    
-
 
116
    /**
-
 
117
     *
-
 
118
     * Generación del timeline de microaprendizaje para el usuario actual
-
 
119
     * solo con agregar ?page=XX
-
 
120
     * 
-
 
121
     * Para las repuesta afirmativa
-
 
122
     * [ 
-
 
123
     *    'success' => true,
-
 
124
     *    'data' => [
-
 
125
     *      'total' => [
-
 
126
     *          'count' => cantidad de registros totales,
-
 
127
     *          'pages' => cantidad de páginas totales,
-
 
128
     *      ],
-
 
129
     *      'current' => [
-
 
130
     *          'items'    => [
-
 
131
     *              [
-
 
132
     *                  'activity' => actividad realizada,
-
 
133
     *                  'added_on' => fecha en la que fué realizada
-
 
134
     *              ]
-
 
135
     *           ] ,
-
 
136
     *          'page'     => página actual,
-
 
137
     *          'count'    => cantidad de registros de la página actual,
-
 
138
     *       ]
-
 
139
     *    ]
-
 
140
     *    
-
 
141
     *  En caso contrario
-
 
142
     *  [
-
 
143
     *      'success' => false,
-
 
144
     *      'data' => mensaje de error
-
 
145
     *  ]  
-
 
146
     *
-
 
147
     *
-
 
148
     * @return \Laminas\View\Model\JsonModel
-
 
149
     */
-
 
150
    public function timelineAction()
-
 
151
    {
-
 
152
        
-
 
153
        $request = $this->getRequest();
-
 
154
        if($request->isGet()) {
-
 
155
            $currentUserPlugin = $this->plugin('currentUserPlugin');
-
 
156
            $currentUser = $currentUserPlugin->getUser();
-
 
157
        
-
 
158
            
-
 
159
            $page = intval($this->params()->fromQuery('page'), 10); 
-
 
160
            
-
 
161
            $companyMicrolearningUserLogMapper = CompanyMicrolearningUserLogMapper::getInstance($this->adapter);
-
 
162
            $paginator = $companyMicrolearningUserLogMapper->getAllMessagesPaginatorByUserId($currentUser->id, $page);
-
 
163
            
-
 
164
            $items = [];
-
 
165
            foreach($paginator as $record)
-
 
166
            {
-
 
167
                $dt = \DateTime::createFromFormat('Y-m-d H:i:s', $record->added_on);
-
 
168
                
-
 
169
                array_push($items, [
-
 
170
                    'activity' => $record->activity,
-
 
171
                    'added_on' => $dt->format('d/m/Y H:i a')
-
 
172
                ]); 
-
 
173
            }
-
 
174
            
-
 
175
            
-
 
176
            return new JsonModel([
-
 
177
                    'success' => true,
-
 
178
                    'data' => [
-
 
179
                        'total' => [
-
 
180
                            'count' => $paginator->getTotalItemCount(),
-
 
181
                            'pages' => $paginator->getPages()->pageCount,
-
 
182
                        ],
-
 
183
                        'current' => [
-
 
184
                            'items'    => $items,
-
 
185
                            'page'     => $paginator->getCurrentPageNumber(),
-
 
186
                            'count'    => $paginator->getCurrentItemCount(),
-
 
187
                        ]
-
 
188
                    ]
-
 
189
            ]);
-
 
190
            
-
 
191
            
-
 
192
        } else {
-
 
193
            return new JsonModel([
-
 
194
                'success' => false,
-
 
195
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
196
            ]);
-
 
197
        }
-
 
198
    }
-
 
199
    
-
 
200
    /**
-
 
201
     * Valores para la generación de los gráficos de progreso
-
 
202
     * Para las repuesta afirmativa
-
 
203
     * [
-
 
204
     *  'success' => true,
-
 
205
     *      'data' => [
-
 
206
     *          'topicTotal' => cantidad total de tópicos,
-
 
207
     *          'topicStarted' => cantidad de tópicos iniciados,
-
 
208
     *          'topicIncompleted' => cantidad de tópicos incompletos,
-
 
209
     *          'topicCompleted' => cantidad de tópicos completos,
-
 
210
     *          'percentCompleted' => % de diapositivas completados ,
-
 
211
     *          'percentIncompleted' => % de diapositivas incompletos ,
-
 
212
     *          'percentWithoutReturning' => % de cápsulas sin retorno después de completada,
-
 
213
     *          'percentWithReturning' => % de cápsulas con retorno después de completada,  
-
 
214
     *       ],
-
 
215
     * ]
-
 
216
     *
-
 
217
     *    
-
 
218
     *  En caso contrario
-
 
219
     *  [
-
 
220
     *      'success' => false,
-
 
221
     *      'data' => mensaje de error
-
 
222
     *  ]  
-
 
223
     *
-
 
224
     *
-
 
225
     * @return \Laminas\View\Model\JsonModel
-
 
226
     */
-
 
227
    public function progressAction()
-
 
228
    {
-
 
229
        
-
 
230
        $request = $this->getRequest();
-
 
231
        if($request->isGet()) {
-
 
232
            $currentUserPlugin = $this->plugin('currentUserPlugin');
-
 
233
            $currentUser = $currentUserPlugin->getUser();
-
 
234
            
-
 
235
            $topicIdsUsers = [];
-
 
236
            $capsuleIdsUser = [];
-
 
237
            
-
 
238
            $topicTotal = 0;
-
 
239
            $topicStarted = 0;
-
 
240
            $topicIncompleted = 0;
-
 
241
            $topicCompleted =  0;
-
 
242
            $totalSlides = 0;
-
 
243
            $totalSlidesCompleted = 0;
-
 
244
            //$totalSlideWithReturning = 0;
-
 
245
            
-
 
246
            $totalCapsules = 0;
-
 
247
            $totalCapsulesCompleted = 0;
-
 
248
            $totalCapsulesCompletedWithReturn = 0;
-
 
249
            $totalCapsulesCompletedWithoutReturn = 0;
-
 
250
            
-
 
251
            //$companyMicrolearningTopicMapper = CompanyMicrolearningTopicMapper::getInstance($this->adapter);
-
 
252
            $companyMicrolearningSlideMapper = CompanyMicrolearningSlideMapper::getInstance($this->adapter);
-
 
253
            
-
 
254
            $companyMicrolearningUserProgressMapper = CompanyMicrolearningUserProgressMapper::getInstance($this->adapter);
-
 
255
            
-
 
256
            
-
 
257
            $companyMicrolearningCapsuleUserMapper = CompanyMicrolearningCapsuleUserMapper::getInstance($this->adapter);
-
 
258
            $capsulesUser = $companyMicrolearningCapsuleUserMapper->fetchAllActiveByUserId($currentUser->id);
-
 
259
            
-
 
260
            foreach($capsulesUser as $capsuleUser)
-
 
261
            {
-
 
262
                $company_id = $capsuleUser->company_id;
-
 
263
                $topic_id   = $capsuleUser->topic_id;
114
    
264
                $capsule_id = $capsuleUser->capsule_id;
-
 
265
                
-
 
266
                if(!in_array($topic_id, $topicIdsUsers)) {
-
 
267
                    $topicTotal++;
-
 
268
                    array_push($topicIdsUsers, $topic_id);
-
 
269
                    
-
 
270
                    $progress = $companyMicrolearningUserProgressMapper->fetchOneByUserIdAndTopicId($currentUser->id, $topic_id);
-
 
271
                    if($progress) {
-
 
272
                        $topicStarted++;
-
 
273
                        if(100 > $progress->progress) {
-
 
274
                            $topicIncompleted++;
-
 
275
                        } else {
-
 
276
                            $topicCompleted++;
-
 
277
                        }
-
 
278
                        
-
 
279
                    }
-
 
280
                }
-
 
281
                
-
 
282
                if(!in_array($capsule_id, $capsuleIdsUser)) {
-
 
283
                    
-
 
284
                    $totalSlides += $companyMicrolearningSlideMapper->fetchTotalCountByCompanyIdAndTopicIdAndCapsuleId($company_id, $topic_id, $capsule_id);
-
 
285
                    $totalSlidesCompleted += $companyMicrolearningUserProgressMapper->fetchCountAllSlideCompletedByUserIdAndCapsuleId($currentUser->id, $capsule_id);
-
 
286
                    
-
 
287
                    array_push($capsuleIdsUser, $capsule_id);
-
 
288
                    
-
 
289
                    $totalCapsules++;
-
 
290
                    $progress = $companyMicrolearningUserProgressMapper->fetchOneByUseridAndCapsuleId($currentUser->id, $capsule_id);
-
 
291
                    if($progress && $progress->completed) {
-
 
292
                        
-
 
293
                        $totalCapsulesCompleted++;
-
 
294
                        if($progress->returning_after_completed) {
-
 
295
                            $totalCapsulesCompletedWithReturn++;
-
 
296
                        } else {
-
 
297
                            $totalCapsulesCompletedWithoutReturn++;
-
 
298
                        }
-
 
299
                        
-
 
300
                    }
-
 
301
                    
-
 
302
                    
-
 
303
                }
-
 
304
                
-
 
305
                
-
 
306
            }
-
 
307
            
-
 
308
            $percentCompleted = 0;
-
 
309
            $percentIncompleted = 100;
-
 
310
            
-
 
311
            if( $totalSlides > 0) {
-
 
312
                $percentCompleted = ($totalSlidesCompleted  * 100) /  $totalSlides;
-
 
313
                $percentIncompleted = 100 - $percentCompleted;
-
 
314
            }
-
 
315
            
-
 
316
            
-
 
317
            $percentWithoutReturning  = 0;
-
 
318
            $percentWithReturning = 0;
-
 
319
            
-
 
320
            if($totalCapsulesCompleted > 0) {
-
 
321
                $percentWithReturning = ($totalCapsulesCompletedWithReturn  * 100) / $totalCapsulesCompleted;
-
 
322
                $percentWithoutReturning = ($totalCapsulesCompletedWithoutReturn  * 100) / $totalCapsulesCompleted;
-
 
323
            }
-
 
324
 
-
 
325
            
-
 
326
            
-
 
327
            return new JsonModel([
-
 
328
                'success' => true,
-
 
329
                'data' => [
-
 
330
                    'topicTotal' => $topicTotal,
-
 
331
                    'topicStarted' => $topicStarted,
-
 
332
                    'topicIncompleted' => $topicIncompleted,
-
 
333
                    'topicCompleted' => $topicCompleted,
-
 
334
                    'percentCompleted' => number_format($percentCompleted, 2, '.', ','),
-
 
335
                    'percentIncompleted' => number_format($percentIncompleted, 2, '.', ','),
-
 
336
                    'percentWithoutReturning' => number_format($percentWithoutReturning, 2, '.', ','),
-
 
337
                    'percentWithReturning' => number_format($percentWithReturning, 2, '.', ','),
-
 
338
                ],
-
 
339
            ]);
-
 
340
            
-
 
341
            
-
 
342
        } else {
-
 
343
            return new JsonModel([
-
 
344
                'success' => false,
-
 
345
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
346
            ]);
-
 
Línea 347... Línea 115...
347
        }
115