Proyectos de Subversion LeadersLinked - Services

Rev

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

Rev 586 Rev 587
Línea 1428... Línea 1428...
1428
        $slideMapper = MicrolearningSlideMapper::getInstance($this->adapter);
1428
        $slideMapper = MicrolearningSlideMapper::getInstance($this->adapter);
1429
        $userProgressMapper = MicrolearningUserProgressMapper::getInstance($this->adapter);
1429
        $userProgressMapper = MicrolearningUserProgressMapper::getInstance($this->adapter);
1430
        $quizMapper = MicrolearningQuizMapper::getInstance($this->adapter);
1430
        $quizMapper = MicrolearningQuizMapper::getInstance($this->adapter);
Línea 1431... Línea 1431...
1431
 
1431
 
1432
        $path = $storage->getPathMicrolearningSlide();
1432
        $path = $storage->getPathMicrolearningSlide();
Línea 1433... Línea 1433...
1433
        $slides = $slideMapper->fetchAllByCompanyIdAndTopicIdAndCapsuleId($capsule->company_id, $capsule->topic_id, $capsule->id);
1433
        $slides = $slideMapper->fetchAllByCompanyIdAndCapsuleId($capsule->company_id, $capsule->id);
1434
 
1434
 
1435
        foreach ($slides as $slide) {
1435
        foreach ($slides as $slide) {
Línea 1648... Línea 1648...
1648
    }
1648
    }
Línea 1649... Línea 1649...
1649
    
1649
    
1650
    public function getCapsuleAction()
1650
    public function getCapsuleAction()
1651
    {
1651
    {
1652
        $request = $this->getRequest();
1652
        $request = $this->getRequest();
1653
        
1653
 
1654
        if($request->isGet()) {
1654
        if($request->isGet()) {
1655
            $currentUserPlugin = $this->plugin('currentUserPlugin');
1655
            $currentUserPlugin = $this->plugin('currentUserPlugin');
Línea 1656... Línea 1656...
1656
            $currentUser = $currentUserPlugin->getUser();
1656
            $currentUser = $currentUserPlugin->getUser();
Línea 1673... Línea 1673...
1673
                    'success' => false,
1673
                    'success' => false,
1674
                    'data' => 'ERROR_YOU_DO_NOT_HAVE_ACCESS_TO_THIS_CAPSULE'
1674
                    'data' => 'ERROR_YOU_DO_NOT_HAVE_ACCESS_TO_THIS_CAPSULE'
1675
                ]);
1675
                ]);
1676
            }
1676
            }
Línea 1677... Línea -...
1677
            
-
 
1678
            // Obtener el Tópico asociado
-
 
1679
            $topic = null;
-
 
1680
            $topic_uuid_for_links = null;
-
 
1681
            $topicCapsuleMapper = MicrolearningTopicCapsuleMapper::getInstance($this->adapter);
-
 
1682
            $relation = $topicCapsuleMapper->fetchOneByCapsuleId($capsule->id);
-
 
1683
            
-
 
1684
            if ($relation && in_array($relation->topic_id, $accessGrantedIds->topics)) {
-
 
1685
                $topicMapper = MicrolearningTopicMapper::getInstance($this->adapter);
-
 
1686
                $topic = $topicMapper->fetchOne($relation->topic_id);
-
 
1687
                if ($topic) {
-
 
1688
                    $topic_uuid_for_links = $topic->uuid;
-
 
1689
                }
-
 
1690
            }
-
 
1691
            
1677
            
1692
            $userProgressMapper = MicrolearningUserProgressMapper::getInstance($this->adapter);
1678
            $userProgressMapper = MicrolearningUserProgressMapper::getInstance($this->adapter);
Línea 1693... Línea 1679...
1693
            $capsuleCommentMapper = MicrolearningCapsuleCommentMapper::getInstance($this->adapter);
1679
            $capsuleCommentMapper = MicrolearningCapsuleCommentMapper::getInstance($this->adapter);
1694
            
1680
            
1695
            $userProgress = $userProgressMapper->fetchOneByUseridAndCapsuleId($currentUser->id, $capsule->id);
1681
            $userProgress = $userProgressMapper->fetchOneByUseridAndCapsuleId($currentUser->id, $capsule->id);
Línea 1696... Línea 1682...
1696
            $progress = $userProgress ? $userProgress->progress : 0;
1682
            $progress = $userProgress->progress ?? 0;
Línea -... Línea 1683...
-
 
1683
            $completed = $userProgress->completed ?? 0;
-
 
1684
            
-
 
1685
            $dataCountAndRatingAverage = $capsuleCommentMapper->fetchCountAndRatingAverage($capsule->company_id, $capsule->id);
-
 
1686
            
-
 
1687
            // Get comments data
-
 
1688
            $userMapper = UserMapper::getInstance($this->adapter);
-
 
1689
            $storage = Storage::getInstance($this->config, $this->adapter);
-
 
1690
            $serviceDatetimeFormat = $this->config['leaderslinked.services.datetime'];
-
 
1691
            
-
 
1692
            $comments = [];
-
 
1693
            $records = $capsuleCommentMapper->fetchAllByCapsuleId($capsule->id);
-
 
1694
            foreach($records as $record) {
-
 
1695
                $user = $userMapper->fetchOne($record->user_id);
-
 
1696
                if(!$user) {
-
 
1697
                    continue;
-
 
1698
                }
-
 
1699
                
-
 
1700
                $dt = \DateTime::createFromFormat('Y-m-d H:i:s', $record->added_on);
-
 
1701
                
-
 
1702
                array_push($comments, [
-
 
1703
                    'date' => $dt->format($serviceDatetimeFormat),
-
 
1704
                    'image' => $storage->getUserImage($user),
-
 
1705
                    'fullname' => trim(trim($user->first_name) . ' ' . trim($user->last_name)),
-
 
1706
                    'rating' => strval($record->rating),
-
 
1707
                    'comment' => $record->comment,
1697
            $completed = $userProgress ? $userProgress->completed : 0;
1708
                    'link_delete' => $record->user_id == $currentUser->id ? $this->url()->fromRoute('microlearning/capsules-comments/delete', ['capsule_id' => $capsule->uuid, 'comment_id' => $record->uuid], ['force_canonical' => true]) : '',
1698
            
1709
                ]);
Línea 1699... Línea -...
1699
            $dataCountAndRatingAverage = $capsuleCommentMapper->fetchCountAndRatingAverage($capsule->company_id, $capsule->id);
-
 
1700
            
1710
            }
Línea 1701... Línea -...
1701
            $storage = Storage::getInstance($this->config, $this->adapter);
-
 
1702
            $path = $storage->getPathMicrolearningCapsule();
-
 
1703
            
-
 
1704
            // Obtener slides usando el método _getSlidesByCapsule
1711
            
1705
            $slides = $this->_getSlidesByCapsule($capsule, $storage);
1712
            $storage = Storage::getInstance($this->config, $this->adapter);
1706
            
1713
            $path = $storage->getPathMicrolearningCapsule();
1707
            // Construir enlaces usando $topic_uuid_for_links si está disponible
1714
            
1708
            $link_slides = $topic_uuid_for_links ? $this->url()->fromRoute('microlearning/slides', ['topic_id' => $topic_uuid_for_links, 'capsule_id' => $capsule->uuid], ['force_canonical' => true]) : '';
1715
            $slides = $this->_getSlidesByCapsule($capsule, $storage);
1709
            
-
 
1710
            $data = [
1716
            
1711
                'uuid'              => $capsule->uuid,
-
 
1712
                'name'              => $capsule->name ? $capsule->name : '',
1717
            $data = [
1713
                'description'       => $capsule->description ? $capsule->description : '',
1718
                'uuid'              => $capsule->uuid,
-
 
1719
                'name'              => $capsule->name ? $capsule->name : '',
1714
                'image'             => $capsule->image ? $storage->getGenericImage($path, $capsule->uuid, $capsule->image) : '',
1720
                'description'       => $capsule->description ? $capsule->description : '',
1715
                'link_comments'     => $this->url()->fromRoute('microlearning/capsules-comments', ['capsule_id' => $capsule->uuid], ['force_canonical' => true]),
1721
                'image'             => $capsule->image ? $storage->getGenericImage($path, $capsule->uuid, $capsule->image) : '',
1716
                'link_comment_add'  => $this->url()->fromRoute('microlearning/capsules-comments/add', ['capsule_id' => $capsule->uuid], ['force_canonical' => true]),
1722
                'link_comment_add'  => $this->url()->fromRoute('microlearning/capsules-comments/add', ['capsule_id' => $capsule->uuid], ['force_canonical' => true]),
1717
                'link_slides'       => $link_slides,
1723
                'total_comments'    => strval($dataCountAndRatingAverage['total_comments']),
1718
                'total_comments'    => strval($dataCountAndRatingAverage['total_comments']),
1724
                'total_rating'      => strval($dataCountAndRatingAverage['total_rating']),