Ejemplo n.º 1
0
 private function storeResource(array $resources, ResourceNode $node)
 {
     $resource = $this->resourceManager->getResourceFromNode($node);
     if (empty($resources[$node->getId()])) {
         $resources[$node->getId()] = $resource;
     }
     return $resources;
 }
Ejemplo n.º 2
0
 /**
  * Import the content of an archive in a workspace.
  *
  * @param Configuration $configuration
  * @param Workspace $workspace
  * @return Workspace
  */
 public function importInExistingWorkspace(Configuration $configuration, Workspace $workspace)
 {
     $root = $this->resourceManager->getResourceFromNode($this->resourceManager->getWorkspaceRoot($workspace));
     $wsRoles = $this->roleManager->getRolesByWorkspace($workspace);
     $entityRoles = [];
     foreach ($wsRoles as $wsRole) {
         $entityRoles[$this->roleManager->getWorkspaceRoleBaseName($wsRole)] = $wsRole;
     }
     $workspace = $this->container->get('claroline.manager.transfert_manager')->populateWorkspace($workspace, $configuration, $root, $entityRoles);
     $this->importRichText();
     return $workspace;
 }
Ejemplo n.º 3
0
 /**
  * Create a Scorm archive for a ResourceNode.
  *
  * @param ResourceNode $node
  * @param string       $locale
  * @param string       $scormVersion
  *
  * @return \ZipArchive
  *
  * @throws ResourceNotFoundException
  * @throws \Exception
  */
 public function export(ResourceNode $node, $locale = 'en', $scormVersion = '2004')
 {
     if ('2004' !== $scormVersion && '1.2' !== $scormVersion) {
         // Invalid Scorm version
         throw new \Exception('SCORM export : Invalid SCORM version.');
     }
     $resource = $this->resourceManager->getResourceFromNode($node);
     if (!$resource) {
         throw new ResourceNotFoundException('SCORM export : The resource ' . $node->getName() . ' was not found');
     }
     // Export the Resource and all it's sub-resources
     $exportedResources = $this->exportResource($resource, $locale);
     // Create the manifest for the Scorm package
     if ('1.2' === $scormVersion) {
         $manifest = new Scorm12Manifest($node, $exportedResources);
     } else {
         $manifest = new Scorm2004Manifest($node, $exportedResources);
     }
     $package = $this->createPackage($node, $locale, $manifest, $exportedResources);
     return $package;
 }
Ejemplo n.º 4
0
 /**
  * Load activity data from ResourceNode id.
  *
  * @param int $nodeId
  *
  * @return JsonResponse
  *
  * @Route(
  *      "/load_activity/{nodeId}",
  *      name         = "innova_path_load_activity",
  *      requirements = { "id"     = "\d+" },
  *      options      = { "expose" = true }
  * )
  * @Method("GET")
  */
 public function loadActivityAction($nodeId)
 {
     $activity = [];
     $node = $this->om->getRepository('ClarolineCoreBundle:Resource\\ResourceNode')->findOneById($nodeId);
     if (!empty($node)) {
         $resource = $this->resourceManager->getResourceFromNode($node);
         if (!empty($resource)) {
             $activity['id'] = $resource->getId();
             $activity['name'] = $resource->getTitle();
             $activity['description'] = $resource->getDescription();
             // Primary resources
             $activity['primaryResource'] = null;
             $primaryResource = $resource->getPrimaryResource();
             if (!empty($primaryResource)) {
                 $activity['primaryResource'] = ['resourceId' => $primaryResource->getId(), 'name' => $primaryResource->getName(), 'type' => $primaryResource->getResourceType()->getName(), 'mimeType' => $primaryResource->getMimeType()];
             }
             // Process activity parameters
             $parameters = $resource->getParameters();
             if (!empty($parameters)) {
                 // Secondary resources
                 $activity['resources'] = [];
                 $secondaryResources = $parameters->getSecondaryResources();
                 if (!empty($secondaryResources)) {
                     foreach ($secondaryResources as $secondaryResource) {
                         $activity['resources'][] = ['resourceId' => $secondaryResource->getId(), 'name' => $secondaryResource->getName(), 'type' => $secondaryResource->getResourceType()->getName(), 'mimeType' => $secondaryResource->getMimeType(), 'propagateToChildren' => true];
                     }
                 }
                 // Global Parameters
                 $activity['withTutor'] = $parameters->isWithTutor();
                 $activity['who'] = $parameters->getWho();
                 $activity['where'] = $parameters->getWhere();
                 $activity['duration'] = $parameters->getMaxDuration();
                 // Duration in seconds
                 $activity['evaluationType'] = $parameters->getEvaluationType();
                 //manual/automatic
             }
         }
     }
     return new JsonResponse($activity);
 }