/**
  * 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);
 }
 /**
  * Export to the Excel template using the PHPExcel library
  *
  * @param \GIB\GradingTool\Domain\Model\Project $project
  */
 public function exportExcelGradingAction(\GIB\GradingTool\Domain\Model\Project $project)
 {
     // Write Grading results
     $grading = $this->submissionService->getProcessedSubmission($project);
     if ($grading['hasError']) {
         // Don't export the Grading if is has errors
         $message = new \TYPO3\Flow\Error\Message('The Grading has errors and therefore it cannot be exported. Review and correct the Grading.', \TYPO3\Flow\Error\Message::SEVERITY_ERROR);
         $this->flashMessageContainer->addMessage($message);
         $this->redirect('index', 'Standard');
     }
     // the uploaded export template
     $templateFilePathAndFileName = \TYPO3\Flow\Utility\Files::concatenatePaths(array($this->settings['export']['excel']['templatePath'], $this->settings['export']['excel']['templateFileName']));
     $excelReader = new \PHPExcel_Reader_Excel2007();
     $excelReader->setLoadSheetsOnly($this->settings['export']['excel']['worksheetLabel']);
     $phpExcel = $excelReader->load($templateFilePathAndFileName);
     $worksheet = $phpExcel->getSheetByName($this->settings['export']['excel']['worksheetLabel']);
     $firstSectionColumn = $this->settings['export']['excel']['firstSectionColumn'];
     // we need to subtract 1 because of https://github.com/PHPOffice/PHPExcel/issues/307
     $columnNumber = \PHPExcel_Cell::columnIndexFromString($firstSectionColumn) - 1;
     foreach ($grading['sections'] as $section) {
         $row = $this->settings['export']['excel']['sectionLabelFirstRow'];
         $column = \PHPExcel_Cell::stringFromColumnIndex($columnNumber);
         $worksheet->getCell($column . $row)->setValue($section['label']);
         foreach ($section['questions'] as $question) {
             $row++;
             if (isset($question['score'])) {
                 if ($question['score'] === 'N/A') {
                     // N/A is value 5 in Excel tool
                     $worksheet->getCell($column . $row)->setValue('5');
                 } else {
                     $worksheet->getCell($column . $row)->setValue($question['score']);
                 }
             }
         }
         $columnNumber++;
     }
     // Write project title
     $worksheet->getCell($this->settings['export']['excel']['projectTitleCell'])->setValue($project->getProjectTitle());
     header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
     header('Content-Disposition: attachment;filename="grading.xlsx"');
     header('Cache-Control: max-age=0');
     /** @var \PHPExcel_Writer_Excel2007 $excelWriter */
     $excelWriter = \PHPExcel_IOFactory::createWriter($phpExcel, 'Excel2007');
     $excelWriter->save('php://output');
 }