Esempio n. 1
0
 /**
  * @param \_OurBrand_\Quiz\Domain\Model\Quiz $quiz
  *
  * @return array
  */
 private function makeExportArrayFromQuiz($quiz)
 {
     $thumbnailMaxWidth = 200;
     $thumbnailMaxHeight = 200;
     $previewImage = $quiz->getBannerImage() ? $quiz->getBannerImage()->getThumbNail($thumbnailMaxWidth, $thumbnailMaxHeight)->getOriginalResource() : null;
     $outQuiz = array('__identifier' => $this->persistenceManager->getIdentifierByObject($quiz), 'title' => $quiz->getTitle(), 'bannerImage' => $this->resourcePublisher->getPersistentResourceWebUri($previewImage), 'subject' => $quiz->getSubject(), 'numberOfExercises' => $quiz->getExercises()->count());
     return $outQuiz;
 }
 /**
  * Review a submission
  *
  * The create action is missing because the project is added in the
  * SubmissionFinisher (see Form/Finishers)
  *
  * @param \GIB\GradingTool\Domain\Model\Project $project
  */
 public function reviewSubmissionAction(\GIB\GradingTool\Domain\Model\Project $project)
 {
     // access check
     $this->checkOwnerOrAdministratorAndDenyIfNeeded($project);
     $submission = $this->submissionService->getProcessedSubmission($project);
     $radarChartImagePathAndFilename = $this->submissionService->getRadarImage($project);
     $radarChartImageResource = $this->resourceManager->importResource($radarChartImagePathAndFilename);
     $radarChartUri = $this->resourcePublisher->getPersistentResourceWebUri($radarChartImageResource);
     // this is necessary because we're in a safe request, but generate a resource
     $this->persistenceManager->persistAll();
     $this->view->assignMultiple(array('submission' => $submission, 'project' => $project, 'radarChartUri' => $radarChartUri));
 }
 /**
  * Send a mail to the project manager with the spider graph as attachement
  *
  * @param Project $project
  */
 public function sendGradingToProjectManager($project)
 {
     // send mail to project manager
     $radarChartImagePathAndFilename = $this->getRadarImage($project);
     $radarChartImageResource = $this->resourceManager->importResource($radarChartImagePathAndFilename);
     $radarChartUri = $this->resourcePublisher->getPersistentResourceWebUri($radarChartImageResource);
     // this is necessary because we're in a safe request, but generate a resource
     $this->persistenceManager->persistAll();
     $attachements = array(array('source' => $radarChartUri, 'fileName' => 'gib-grading.png'));
     $templateIdentifierOverlay = $this->templateService->getTemplateIdentifierOverlay('newSubmissionProjectManagerNotification', $project);
     $this->notificationMailService->sendNotificationMail($templateIdentifierOverlay, $project, $project->getProjectManager(), $project->getProjectManager()->getName()->getFirstName() . ' ' . $project->getProjectManager()->getName()->getLastName(), $project->getProjectManager()->getPrimaryElectronicAddress()->getIdentifier(), '', $attachements);
     // CC to GIB
     $this->notificationMailService->sendNotificationMail($templateIdentifierOverlay, $project, $project->getProjectManager(), $project->getProjectManager()->getName()->getFirstName() . ' ' . $project->getProjectManager()->getName()->getLastName(), '*****@*****.**', '', $attachements);
 }
 /**
  * Init tracker if in exam mode
  *
  * @param \_OurBrand_\Quiz\Domain\Model\Exercise $exercise
  *
  * @return json
  */
 public function getDictationAudioAction($exercise)
 {
     $audioFiles = array();
     foreach ($exercise->getSnippets() as $snippet) {
         if ($snippet->getAudio() && $snippet->getAudio()->getOriginalResource()) {
             $audioFiles[] = array('src' => base64_encode($this->resourcePublisher->getPersistentResourceWebUri($snippet->getAudio()->getOriginalResource())));
         }
     }
     if ($this->studentQuizSession) {
         $tracker = $this->trackStudentAudioPlaybackRepository->findBySessionAndExercise($this->studentQuizSession, $exercise)->getFirst();
         if (!is_a($tracker, '\\_OurBrand_\\Quiz\\Domain\\Model\\TrackStudentAudioPlayback')) {
             $tracker = new TrackStudentAudioPlayback();
             $tracker->setExercise($exercise);
             $tracker->setStudentQuizSession($this->studentQuizSession);
             $tracker->setTimeElapsed(0);
             $tracker->setStatus(0);
             $this->trackStudentAudioPlaybackRepository->add($tracker);
             $this->persistenceManager->persistAll();
         }
         return json_encode(array('elapsedTime' => $tracker->getTimeElapsed(), 'status' => $tracker->getStatus(), 'trackerId' => $this->persistenceManager->getIdentifierByObject($tracker), 'audioFiles' => $audioFiles));
     }
     return json_encode(array('status' => 0, 'audioFiles' => $audioFiles));
 }
 /**
  * Render the URI to the resource. The filename is used from child content.
  *
  * @param string $path The location of the resource, can be either a path relative to the Public resource directory of the package or a resource://... URI
  * @param string $package Target package key. If not set, the current package key will be used
  * @param Resource $resource If specified, this resource object is used instead of the path and package information
  * @param boolean $localize Whether resource localization should be attempted or not
  * @return string The absolute URI to the resource
  * @throws InvalidVariableException
  * @api
  */
 public function render($path = NULL, $package = NULL, Resource $resource = NULL, $localize = TRUE)
 {
     if ($resource !== NULL) {
         $uri = $this->resourcePublisher->getPersistentResourceWebUri($resource);
         if ($uri === FALSE) {
             $uri = $this->resourcePublisher->getStaticResourcesWebBaseUri() . 'BrokenResource';
         }
     } else {
         if ($path === NULL) {
             throw new InvalidVariableException('The ResourceViewHelper did neither contain a valuable "resource" nor "path" argument.', 1353512742);
         }
         if ($package === NULL) {
             $package = $this->controllerContext->getRequest()->getControllerPackageKey();
         }
         if (strpos($path, 'resource://') === 0) {
             $matches = array();
             if (preg_match('#^resource://([^/]+)/Public/(.*)#', $path, $matches) === 1) {
                 $package = $matches[1];
                 $path = $matches[2];
             } else {
                 throw new InvalidVariableException(sprintf('The path "%s" which was given to the ResourceViewHelper must point to a public resource.', $path), 1353512639);
             }
         }
         if ($localize === TRUE) {
             $resourcePath = 'resource://' . $package . '/Public/' . $path;
             $localizedResourcePathData = $this->i18nService->getLocalizedFilename($resourcePath);
             $matches = array();
             if (preg_match('#resource://([^/]+)/Public/(.*)#', current($localizedResourcePathData), $matches) === 1) {
                 $package = $matches[1];
                 $path = $matches[2];
             }
         }
         $uri = $this->resourcePublisher->getStaticResourcesWebBaseUri() . 'Packages/' . $package . '/' . $path;
     }
     return $uri;
 }