/**
  * @param \GIB\GradingTool\Domain\Model\Project $project
  * @return array
  */
 public function getProcessedProjectData(\GIB\GradingTool\Domain\Model\Project $project)
 {
     /** @var \TYPO3\Form\Core\Model\FormDefinition $formDefinition */
     $formDefinition = $this->formPersistenceManager->load($this->settings['forms']['projectData']);
     $fieldArray = $this->buildFieldArray($formDefinition['renderables'], $project->getProjectDataArray());
     return $fieldArray;
 }
Beispiel #2
0
 /**
  * @param string $persistenceIdentifier the persistence identifier for the form.
  * @param string $factoryClass The fully qualified class name of the factory (which has to implement \TYPO3\Form\Factory\FormFactoryInterface)
  * @param string $presetName name of the preset to use
  * @param array $overrideConfiguration factory specific configuration
  * @return string the rendered form
  */
 public function render($persistenceIdentifier = NULL, $factoryClass = 'TYPO3\\Form\\Factory\\ArrayFormFactory', $presetName = 'default', array $overrideConfiguration = array())
 {
     if (isset($persistenceIdentifier)) {
         $overrideConfiguration = Arrays::arrayMergeRecursiveOverrule($this->formPersistenceManager->load($persistenceIdentifier), $overrideConfiguration);
     }
     $factory = $this->objectManager->get($factoryClass);
     $formDefinition = $factory->build($overrideConfiguration, $presetName);
     $response = new Response($this->controllerContext->getResponse());
     $form = $formDefinition->bind($this->controllerContext->getRequest(), $response);
     return $form->render();
 }
 /**
  * @param JobConfigurationInterface $jobConfiguration
  * @param string $persistenceIdentifier the persistence identifier for the form.
  * @param string $factoryClass The fully qualified class name of the factory (which has to implement \TYPO3\Form\Factory\FormFactoryInterface)
  * @param string $presetName name of the preset to use
  * @param array $overrideConfiguration factory specific configuration
  * @return string the rendered form
  */
 public function render(JobConfigurationInterface $jobConfiguration, $persistenceIdentifier = null, $factoryClass = 'TYPO3\\Form\\Factory\\ArrayFormFactory', $presetName = 'default', array $overrideConfiguration = [])
 {
     if (isset($persistenceIdentifier)) {
         $overrideConfiguration = Arrays::arrayMergeRecursiveOverrule($this->formPersistenceManager->load($persistenceIdentifier), $overrideConfiguration);
     }
     $factory = $this->objectManager->get($factoryClass);
     /** @var FormDefinition $formDefinition */
     $formDefinition = $factory->build($overrideConfiguration, $presetName);
     ObjectAccess::setProperty($formDefinition, 'identifier', 'options', true);
     $this->postProcessFormDefinition($jobConfiguration, $formDefinition);
     $response = new Response($this->controllerContext->getResponse());
     $form = $formDefinition->bind($this->controllerContext->getRequest(), $response);
     $form->getRequest()->setArgumentNamespace('--options');
     return $form->render();
 }
 /**
  * Check if a form has a localized version and deliver it if available
  *
  * @param $formName
  * @param $localeOverride
  * @return string
  */
 public function getFormNameRespectingLocale($formName, $localeOverride = '')
 {
     // if we override the locale anyway (and it isn't english), we return early
     if (!empty($localeOverride) && $localeOverride !== 'en') {
         return $formName . ucfirst($localeOverride);
     }
     $currentLanguage = $this->i18nService->getConfiguration()->getCurrentLocale()->getLanguage();
     /*
      * a localized version has the language iso code as uppercased suffix, e.g. dataSheetFormFr
      * english is the default language and has no suffix, therefore we return the unchanged name if
      * no translation was found
      */
     if ($this->formPersistenceManager->exists($formName . ucfirst($currentLanguage))) {
         $formName = $formName . ucfirst($currentLanguage);
     }
     return $formName;
 }
 /**
  * This takes a form identifier and returns a unique persistence identifier for it.
  * By default this is just similar to the identifier. But if a form with the same persistence identifier already
  * exists a suffix is appended until the persistence identifier is unique.
  *
  * @param string $formIdentifier lowerCamelCased form identifier
  * @return string unique form persistence identifier
  */
 protected function findUniquePersistenceIdentifier($formIdentifier)
 {
     if (!$this->formPersistenceManager->exists($formIdentifier)) {
         return $formIdentifier;
     }
     for ($attempts = 1; $attempts < 100; $attempts++) {
         $formPersistenceIdentifier = sprintf('%s_%d', $formIdentifier, $attempts);
         if (!$this->formPersistenceManager->exists($formPersistenceIdentifier)) {
             return $formPersistenceIdentifier;
         }
     }
     throw new \TYPO3\Flow\Exception(sprintf('Could not find a unique persistence identifier for form identifier "%s" after %d attempts', $formIdentifier, $attempts), 1329842768);
 }
 /**
  * Get score basis data
  *
  * @param Project $project
  * @return array
  */
 public function getScoreData(Project $project = NULL)
 {
     $form = $project instanceof Project ? $project->getSubmissionFormIdentifier() : $this->settings['forms']['submission']['default'];
     $submissionFormDefinition = $this->formPersistenceManager->load($form);
     $scoreData = array();
     foreach ($submissionFormDefinition['renderables'] as $key => $page) {
         // a form page
         foreach ($page['renderables'] as $section) {
             $scoreData[$key]['categoryName'] = $section['label'];
             $scoreData[$key]['goodScore'] = $section['properties']['goodPerformanceReferenceScore'];
             $scoreData[$key]['modestScore'] = $section['properties']['modestPerformanceReferenceScore'];
             $scoreData[$key]['modestScore'] = $section['properties']['modestPerformanceReferenceScore'];
             // todo average score
             $scoreData[$key]['currentAverageScore'] = 0;
         }
     }
     return $scoreData;
 }
 /**
  * @param \GIB\GradingTool\Domain\Model\Project $project
  * @param bool $languageOverlay
  * @return array
  */
 public function getFlatProcessedDataSheet(\GIB\GradingTool\Domain\Model\Project $project, $languageOverlay = FALSE)
 {
     /** @var \TYPO3\Form\Factory\ArrayFormFactory $factory */
     $factory = new \TYPO3\Form\Factory\ArrayFormFactory();
     // todo overlay if needed
     $overrideConfiguration = $this->formPersistenceManager->load($project->getDataSheetFormIdentifier());
     /** @var \TYPO3\Form\Core\Model\FormDefinition $formDefinition */
     $formDefinition = $factory->build($overrideConfiguration);
     $flatDataSheetArray = array();
     foreach ($project->getDataSheetContentArray() as $key => $value) {
         $formElement = $formDefinition->getElementByIdentifier($key);
         if ($formElement instanceof \TYPO3\Form\Core\Model\FormElementInterface) {
             $flatDataSheetArray[$key]['label'] = $formDefinition->getElementByIdentifier($key)->getLabel();
             $flatDataSheetArray[$key]['type'] = $formDefinition->getElementByIdentifier($key)->getType();
             $flatDataSheetArray[$key]['value'] = $value;
         }
     }
     return $flatDataSheetArray;
 }
Beispiel #8
0
 /**
  * @param string $formPersistenceIdentifier
  * @param array $formDefinition
  * @return string
  */
 public function saveformAction($formPersistenceIdentifier, array $formDefinition)
 {
     $this->formPersistenceManager->save($formPersistenceIdentifier, $formDefinition);
     return 'success';
 }