getTestModel($instance); if ($model->getUri() != \taoQtiTest_models_classes_QtiTestService::INSTANCE_TEST_MODEL_QTI) { return Report::createFailure(__('Metadata export is not available for test "%s."', $instance->getLabel())); } $fileName = $formValues['filename'] . '_' . time() . '.csv'; if (!\tao_helpers_File::securityCheck($fileName, true)) { throw new \Exception('Unauthorized file name'); } /** @var TestExporter $exporterService */ $exporterService = $this->getServiceManager()->get(TestMetadataExporter::SERVICE_ID); $exporterService->setOption(TestExporter::OPTION_FILE_NAME, $fileName); $filePath = $exporterService->export($formValues['uri']); $report->setData($filePath); $report->setMessage(__('Test metadata successfully exported.')); $this->getEventManager()->trigger(new QtiTestMetadataExportEvent($instance)); return $report; } }