/** * Renders alias * * @param \GIB\GradingTool\Domain\Model\Project $subject * @return string Rendered string * @api */ public function render(\GIB\GradingTool\Domain\Model\Project $subject) { $grading = $this->submissionService->getProcessedSubmission($subject); $this->templateVariableContainer->add('grading', $grading); $output = $this->renderChildren(); $this->templateVariableContainer->remove('grading'); return $output; }
/** * @param \GIB\GradingTool\Domain\Model\Project $project */ public function showAction($project) { $radarChartFileName = $this->submissionService->getRadarImage($project); $radarChartResource = $this->resourceManager->importResource($radarChartFileName); $radarChartResource->setFilename('radarChart.jpg'); $radarChartImage = new \TYPO3\Media\Domain\Model\Image($radarChartResource); $this->persistenceManager->persistAll(); $this->view->assignMultiple(array('project' => $project, 'submission' => $this->submissionService->getProcessedSubmission($project), 'radarChartImage' => $radarChartImage)); }
/** * @test */ public function assertSectionScore() { /** @var \GIB\GradingTool\Domain\Model\Project $mockProject */ $mockProject = $this->getAccessibleMock('GIB\\GradingTool\\Domain\\Model\\Project', array('dummy'), array(), '', FALSE); // naAcceptanceLevel = 0.7, therefore 3 questions must be answered // 2 questions have N/A, but one has optOutAccepted = 1, so the threshold is reached $submissionContent = array('accountability1' => 4, 'transparency1' => 4, 'customerFocus1' => 5, 'customerFocus2' => 4, 'customerFocus3' => 4, 'customerFocus4' => 5, 'customerFocusOptOutAccepted4' => 1); $mockProject->_set('submissionContent', serialize($submissionContent)); $submission = $this->submissionService->getProcessedSubmission($mockProject); $this->assertEquals($submission['hasError'], FALSE); }
/** * Send the grading of a project to its project manager if the submission is complete * * @param string $submissionFormIdentifier * @param boolean $testMode */ public function sendGradingToProjectManagerAction($submissionFormIdentifier, $testMode = TRUE) { $this->checkAdministratorAndDenyIfNeeded(); $projects = $this->projectRepository->findBySubmissionFormIdentifier($submissionFormIdentifier); foreach ($projects as $project) { /** @var \GIB\GradingTool\Domain\Model\Project $project */ if (!is_null($project->getSubmissionLastUpdated()) && !empty($project->getSubmissionContent())) { $message = 'Send Grading for Project ' . $project->getProjectTitle() . ' to ' . $project->getProjectManager()->getPrimaryElectronicAddress()->getIdentifier() . '.'; if (!$testMode) { $this->submissionService->sendGradingToProjectManager($project); print '[!!!] ' . $message . PHP_EOL; } else { print '[TEST] ' . $message . PHP_EOL; } } } die; }
/** * Executes this finisher * @see AbstractFinisher::execute() * * @return void * @throws \TYPO3\Flow\Mvc\Exception\StopActionException(); */ protected function executeInternal() { /** @var \TYPO3\Form\Core\Runtime\FormRuntime $formRuntime */ $formRuntime = $this->finisherContext->getFormRuntime(); // The corresponding project $projectIdentifier = $formRuntime->getRequest()->getParentRequest()->getArgument('project'); /** @var \GIB\GradingTool\Domain\Model\Project $project */ $project = $this->projectRepository->findByIdentifier($projectIdentifier); $sendGradingToProjectManager = FALSE; if (is_null($project->getSubmissionLastUpdated())) { $sendGradingToProjectManager = TRUE; } // update the project with the data from the form $formValueArray = $formRuntime->getFormState()->getFormValues(); $project->setSubmissionContent(serialize($formValueArray)); $project->setSubmissionLastUpdated(new \TYPO3\Flow\Utility\Now()); $this->projectRepository->update($project); $this->persistenceManager->persistAll(); // add a flash message $message = new \TYPO3\Flow\Error\Message('Thank you for submitting the data for your project "%s".', \TYPO3\Flow\Error\Message::SEVERITY_OK, array($project->getProjectTitle())); $this->flashMessageContainer->addMessage($message); // send notification mail $templateIdentifierOverlay = $this->templateService->getTemplateIdentifierOverlay('newSubmissionNotification', $project); $this->notificationMailService->sendNotificationMail($templateIdentifierOverlay, $project, $project->getProjectManager()); if ($sendGradingToProjectManager) { // The grading was completed for the first time, so we send the grading to the project manager $this->submissionService->sendGradingToProjectManager($project); } // redirect to dashboard $formRuntime = $this->finisherContext->getFormRuntime(); $request = $formRuntime->getRequest()->getMainRequest(); $uriBuilder = new \TYPO3\Flow\Mvc\Routing\UriBuilder(); $uriBuilder->setRequest($request); $uriBuilder->reset(); $uri = $uriBuilder->uriFor('index', NULL, 'Standard'); $response = $formRuntime->getResponse(); $mainResponse = $response; while ($response = $response->getParentResponse()) { $mainResponse = $response; } $mainResponse->setStatus(303); $mainResponse->setHeader('Location', (string) $uri); throw new \TYPO3\Flow\Mvc\Exception\StopActionException(); }