/** * Import a Collecticiel into the platform. * * @param array $data * @param array $created * * @return Dropzone */ public function import(array $data, array $created, $archivePath) { $dropData = $data['data']; $dropzone = new Dropzone(); $dropzone->setInstruction(file_get_contents($archivePath . DIRECTORY_SEPARATOR . $dropData['instruction'])); $dropzone->setAllowWorkspaceResource($dropData['allow_workspace_resource']); $dropzone->setAllowUpload($dropData['allow_upload']); $dropzone->setAllowUrl($dropData['allow_url']); $dropzone->setAllowRichText($dropData['allow_rich_text']); $dropzone->setManualPlanning($dropData['manual_planning']); $dropzone->setManualState($dropData['manual_state']); if (!empty($dropData['start_allow_drop'])) { $dropzone->setStartAllowDrop(\DateTime::createFromFormat('Y-m-d H:i:s', $dropData['start_allow_drop'])); } if (!empty($dropData['end_allow_drop'])) { $dropzone->setEndAllowDrop(\DateTime::createFromFormat('Y-m-d H:i:s', $dropData['end_allow_drop'])); } return $dropzone; }
/** * @DI\Observe("copy_innova_collecticiel") * * @param CopyResourceEvent $event */ public function onCopy(CopyResourceEvent $event) { $em = $this->container->get('doctrine.orm.entity_manager'); /** @var Dropzone $resource */ $resource = $event->getResource(); $newDropzone = new Dropzone(); $newDropzone->setName($resource->getName()); $newDropzone->setAllowCommentInCorrection($resource->getAllowCommentInCorrection()); $newDropzone->setAllowRichText($resource->getAllowRichText()); $newDropzone->setAllowUpload($resource->getAllowUpload()); $newDropzone->setAllowUrl($resource->getAllowUrl()); $newDropzone->setAllowWorkspaceResource($resource->getAllowWorkspaceResource()); $newDropzone->setDisplayNotationMessageToLearners($resource->getDisplayNotationMessageToLearners()); $newDropzone->setDisplayNotationToLearners($resource->getDisplayNotationToLearners()); $newDropzone->setEditionState($resource->getEditionState()); $newDropzone->setEndAllowDrop($resource->getEndAllowDrop()); $newDropzone->setEndReview($resource->getEndReview()); $newDropzone->setExpectedTotalCorrection($resource->getExpectedTotalCorrection()); $newDropzone->setInstruction($resource->getInstruction()); $newDropzone->setManualPlanning($resource->getManualPlanning()); $newDropzone->setManualState($resource->getManualState()); $newDropzone->setMinimumScoreToPass($resource->getMinimumScoreToPass()); $newDropzone->setPeerReview($resource->getPeerReview()); $newDropzone->setStartAllowDrop($resource->getStartAllowDrop()); $newDropzone->setStartReview($resource->getStartReview()); $newDropzone->setTotalCriteriaColumn($resource->getTotalCriteriaColumn()); $oldCriteria = $resource->getPeerReviewCriteria(); foreach ($oldCriteria as $oldCriterion) { $newCriterion = new Criterion(); $newCriterion->setInstruction($oldCriterion->getInstruction()); $newDropzone->addCriterion($newCriterion); } $em->persist($newDropzone); $event->setCopy($newDropzone); $event->stopPropagation(); }