Proyectos de Subversion LeadersLinked - Services

Rev

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

Rev 574 Rev 575
Línea 521... Línea 521...
521
                    'success' => true,
521
                    'success' => true,
522
                    'data' => [
522
                    'data' => [
523
                        'uuid'              => $capsule->uuid,
523
                        'uuid'              => $capsule->uuid,
524
                        'name'              => $capsule->name ? $capsule->name : '',
524
                        'name'              => $capsule->name ? $capsule->name : '',
525
                        'description'       => $capsule->description ? $capsule->description : '',
525
                        'description'       => $capsule->description ? $capsule->description : '',
526
                        'image'             => $capsule->image ? $storage->getGenericImage($path,  $capsule->uuid, $capsule->image )  : '',
526
                        'image'             => ($capsule->image && $topic) ? $storage->getGenericImage($path,  $topic->uuid, $capsule->image )  : '',
527
                        'link_comments'     => $this->url()->fromRoute('microlearning/capsules-comments', ['capsule_id' => $capsule->uuid], ['force_canonical' => true]),
-
 
528
                        'link_comment_add'  => $this->url()->fromRoute('microlearning/capsules-comments/add', ['capsule_id' => $capsule->uuid],['force_canonical' => true]),
-
 
529
                        'link_slides'       => $this->url()->fromRoute('microlearning/slides', ['topic_id' => $topic->uuid,  'capsule_id' => $capsule->uuid], ['force_canonical' => true]),
-
 
530
                        'total_comments'    => strval($dataCountAndRatingAverage['total_comments']),
527
                        'total_comments'    => strval($dataCountAndRatingAverage['total_comments']),
531
                        'total_rating'      => strval($dataCountAndRatingAverage['total_rating']),
528
                        'total_rating'      => strval($dataCountAndRatingAverage['total_rating']),
532
                        'completed'         => $userProgress->completed,
529
                        'completed'         => $userProgress->completed,
533
                        'progress'          => $userProgress->progress,
530
                        'progress'          => $userProgress->progress,
534
                        'link_get'          => $this->url()->fromRoute('microlearning/get-capsule', ['id' => $capsule->uuid], ['force_canonical' => true]),
-
 
535
                        'added_on'          => $userProgress->added_on,
531
                        'added_on'          => $userProgress->added_on,
536
                        'updated_on'        => $userProgress->updated_on
532
                        'updated_on'        => $userProgress->updated_on
537
                    ] 
533
                    ] 
538
                ];
534
                ];
Línea 539... Línea 535...
539
                
535
                
540
                
536
                
541
            } else {
537
            } else {
542
                $response = [
538
                $response = [
543
                    'success' => true, 
-
 
544
                    'data' => [
-
 
545
                        
539
                    'success' => true, 
546
                    ]
540
                    'data' => []
Línea 547... Línea 541...
547
                ];
541
                ];
Línea 1360... Línea 1354...
1360
     * @return array An array of formatted capsule data.
1354
     * @return array An array of formatted capsule data.
1361
     */
1355
     */
1362
    private function _getCapsulesByTopic($topic, $storage)
1356
    private function _getCapsulesByTopic($topic, $storage)
1363
    {
1357
    {
1364
        $capsulesData = [];
1358
        $capsulesData = [];
-
 
1359
        
1365
        // Get path for capsule images
1360
        // Get path for capsule images
1366
        $pathCapsule = $storage->getPathMicrolearningCapsule();
1361
        $pathCapsule = $storage->getPathMicrolearningCapsule();
Línea 1367... Línea 1362...
1367
        
1362
        
1368
        // Initialize mappers
1363
        // Initialize mappers
Línea 1387... Línea 1382...
1387
                    $capsuleIdsToFetch[] = $relation->capsule_id;
1382
                    $capsuleIdsToFetch[] = $relation->capsule_id;
1388
                }
1383
                }
1389
            }
1384
            }
1390
        }
1385
        }
Línea 1391... Línea 1386...
1391
        
1386
        
1392
        $capsules = []; // Initialize $capsules as an empty array
1387
        $capsules = []; 
1393
        if (!empty($capsuleIdsToFetch)) {
1388
        if (!empty($capsuleIdsToFetch)) {
1394
            // Fetch capsule details for the accessible and related capsule IDs
1389
            // Fetch capsule details for the accessible and related capsule IDs
1395
            // Remove duplicates just in case, though relations should be unique per topic-capsule pair
1390
            // Removed array_unique to match capsulesAction more closely
1396
            $capsules = $capsuleMapper->fetchAllByIds(array_unique($capsuleIdsToFetch));
1391
            $capsules = $capsuleMapper->fetchAllByIds($capsuleIdsToFetch); 
Línea 1397... Línea 1392...
1397
        }
1392
        }
1398
 
1393
 
1399
        if(count($capsules) > 0) {
1394
        if(count($capsules) > 0) {
Línea 1413... Línea 1408...
1413
                }
1408
                }
Línea 1414... Línea 1409...
1414
 
1409
 
1415
                // Get comment count and average rating for the capsule
1410
                // Get comment count and average rating for the capsule
Línea 1416... Línea 1411...
1416
                $dataCountAndRatingAverage = $capsuleCommentMapper->fetchCountAndRatingAverage($capsule->company_id, $capsule->id);
1411
                $dataCountAndRatingAverage = $capsuleCommentMapper->fetchCountAndRatingAverage($capsule->company_id, $capsule->id);
1417
 
1412
 
1418
                // Add formatted capsule data to the array
1413
                // Add formatted capsule data to the array, ensuring links are present as in capsulesAction
1419
                array_push($capsulesData, [
1414
                array_push($capsulesData, [
1420
                    'uuid'              => $capsule->uuid,
1415
                    'uuid'              => $capsule->uuid,
1421
                    'name'              => $capsule->name ? $capsule->name : '',
1416
                    'name'              => $capsule->name ? $capsule->name : '',
-
 
1417
                    'description'       => $capsule->description ? $capsule->description : '',
-
 
1418
                    'image'             => $capsule->image ? $storage->getGenericImage($pathCapsule, $capsule->uuid, $capsule->image)  : '',
-
 
1419
                    'link_comments'     => $this->url()->fromRoute('microlearning/capsules-comments', ['capsule_id' => $capsule->uuid], ['force_canonical' => true]),
-
 
1420
                    'link_comment_add'  => $this->url()->fromRoute('microlearning/capsules-comments/add', ['capsule_id' => $capsule->uuid],['force_canonical' => true]),
1422
                    'description'       => $capsule->description ? $capsule->description : '',
1421
                    'link_slides'       => $this->url()->fromRoute('microlearning/slides', ['topic_id' => $topic->uuid,  'capsule_id' => $capsule->uuid], ['force_canonical' => true]),
1423
                    'image'             => $capsule->image ? $storage->getGenericImage($pathCapsule, $capsule->uuid, $capsule->image)  : '',
1422
                    'link_get'          => $this->url()->fromRoute('microlearning/get-capsule', ['id' => $capsule->uuid], ['force_canonical' => true]),
1424
                    'total_comments'    => strval($dataCountAndRatingAverage['total_comments']),
1423
                    'total_comments'    => strval($dataCountAndRatingAverage['total_comments']),
1425
                    'total_rating'      => strval($dataCountAndRatingAverage['total_rating']),
1424
                    'total_rating'      => strval($dataCountAndRatingAverage['total_rating']),
1426
                    'progress'          => $capsuleProgress,
1425
                    'progress'          => $capsuleProgress,