Proyectos de Subversion LeadersLinked - Services

Rev

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

Rev 580 Rev 581
Línea 1362... Línea 1362...
1362
        $currentUser = $currentUserPlugin->getUser();
1362
        $currentUser = $currentUserPlugin->getUser();
Línea 1363... Línea 1363...
1363
 
1363
 
1364
        $topicCapsuleMapper = MicrolearningTopicCapsuleMapper::getInstance($this->adapter);
1364
        $topicCapsuleMapper = MicrolearningTopicCapsuleMapper::getInstance($this->adapter);
Línea -... Línea 1365...
-
 
1365
        $topicCapsuleRelations = $topicCapsuleMapper->fetchAllActiveByTopicId($topic->id);
-
 
1366
 
-
 
1367
        $userProgressMapper = MicrolearningUserProgressMapper::getInstance($this->adapter);
1365
        $topicCapsuleRelations = $topicCapsuleMapper->fetchAllActiveByTopicId($topic->id);
1368
        $capsuleCommentMapper = MicrolearningCapsuleCommentMapper::getInstance($this->adapter);
Línea 1366... Línea 1369...
1366
 
1369
 
1367
        $capsuleIdsToFetch = [];
-
 
1368
 
1370
        $path = $storage->getPathMicrolearningCapsule();
1369
        foreach ($topicCapsuleRelations as $relation) {
1371
 
1370
            $capsuleIdsToFetch[] = $relation->capsule_id;
1372
        foreach ($topicCapsuleRelations as $relation) {
1371
            /* if (in_array($relation->capsule_id, $accessGrantedIds->capsules)) {
-
 
1372
                $capsuleIdsToFetch[] = $relation->capsule_id;
-
 
1373
            } */
-
 
1374
        }
-
 
1375
 
-
 
1376
        if (empty($capsuleIdsToFetch)) {
-
 
1377
            return $data;
-
 
1378
        }
-
 
Línea 1379... Línea -...
1379
 
-
 
1380
        $capsuleMapper = MicrolearningCapsuleMapper::getInstance($this->adapter);
-
 
1381
        $capsules = $capsuleMapper->fetchAllByIds($capsuleIdsToFetch);
-
 
1382
 
-
 
1383
        $userProgressMapper = MicrolearningUserProgressMapper::getInstance($this->adapter);
-
 
1384
        $capsuleCommentMapper = MicrolearningCapsuleCommentMapper::getInstance($this->adapter);
-
 
1385
        
1373
            /* if (in_array($relation->capsule_id, $accessGrantedIds->capsules)) {
1386
        $path = $storage->getPathMicrolearningCapsule();
1374
                $capsuleIdsToFetch[] = $relation->capsule_id;
1387
 
1375
            } */
-
 
1376
 
-
 
1377
            /* if (!in_array($capsule->id, $accessGrantedIds->capsules)) {
-
 
1378
                continue;
-
 
1379
            } */
-
 
1380
            $capsuleMapper = MicrolearningCapsuleMapper::getInstance($this->adapter);
-
 
1381
            $capsule = $capsuleMapper->fetchOne($relation->capsule_id);
-
 
1382
 
-
 
1383
            if(!$capsule) {
-
 
1384
                array_push($data, [
-
 
1385
                    'uuid'              => $relation->capsule_id,
-
 
1386
                    'name'              => 'Cápsula no encontrada',
-
 
1387
                    'description'       => 'Cápsula no encontrada',
-
 
1388
                    'image'             => '',
Línea 1388... Línea 1389...
1388
        foreach ($capsules as $capsule) {
1389
                    'total_comments'    => 0,
1389
            /* if (!in_array($capsule->id, $accessGrantedIds->capsules)) {
1390
                ]);
1390
                continue;
1391
                continue;
1391
            } */
1392
            }
1392
 
1393
 
1393
            $userProgress = $userProgressMapper->fetchOneByUseridAndCapsuleId($currentUser->id, $capsule->id);
1394
            $userProgress = $userProgressMapper->fetchOneByUseridAndCapsuleId($currentUser->id, $capsule->id);
1394
            $progress = $userProgress->progress ?? 0;
1395
            $progress = $userProgress->progress ?? 0;
Línea 1395... Línea 1396...
1395
            $completed = $userProgress->completed ?? 0;
1396
            $completed = $userProgress->completed ?? 0;
1396
            $dataCountAndRatingAverage = $capsuleCommentMapper->fetchCountAndRatingAverage($capsule->company_id, $capsule->id);
1397
            $dataCountAndRatingAverage = $capsuleCommentMapper->fetchCountAndRatingAverage($capsule->company_id, $capsule->id);
1397
            $image = $capsule->image ? $storage->getGenericImage($path, $capsule->uuid, $capsule->image) : '';
1398
            $image = $capsule->image ? $storage->getGenericImage($path, $capsule->uuid, $capsule->image) : '';
1398
            $total_comments = strval($dataCountAndRatingAverage['total_comments']);
1399
            $total_comments = strval($dataCountAndRatingAverage['total_comments']);
1399
            $total_rating = strval($dataCountAndRatingAverage['total_rating']);
1400
            $total_rating = strval($dataCountAndRatingAverage['total_rating']);
1400
 
1401
 
Línea 1408... Línea 1409...
1408
                'progress'          => $progress,
1409
                'progress'          => $progress,
1409
                'completed'         => $completed,
1410
                'completed'         => $completed,
1410
                'order'             => $capsule->order,
1411
                'order'             => $capsule->order,
1411
                'added_on'          => $capsule->added_on,
1412
                'added_on'          => $capsule->added_on,
1412
                'updated_on'        => $capsule->updated_on,
1413
                'updated_on'        => $capsule->updated_on,
1413
            ]); */
1414
            ]);
1414
 
-
 
1415
            
-
 
1416
        }
1415
        }
Línea 1417... Línea -...
1417
 
-
 
1418
        return [
-
 
1419
            'relations' => $topicCapsuleRelations,
-
 
1420
            'capsules' => $capsules,
-
 
1421
            'topic' => $topic,
-
 
1422
        ];
-
 
1423
 
1416
 
1424
        //return $data;
1417
        return $data;
Línea 1425... Línea 1418...
1425
    }
1418
    }
1426
    
1419
    
1427
    public function capsulesAction()
1420
    public function capsulesAction()