* @package taoQTI */ class taoQtiTest_models_classes_import_TestImport implements tao_models_classes_import_ImportHandler, PhpSerializable, ServiceLocatorAwareInterface, TaskParameterProviderInterface { use PhpSerializeStateless; use EventManagerAwareTrait; use ImportHandlerHelperTrait; /** * (non-PHPdoc) * @see tao_models_classes_import_ImportHandler::getLabel() */ public function getLabel() { return __('QTI/APIP Test Content Package'); } /** * (non-PHPdoc) * @see tao_models_classes_import_ImportHandler::getForm() */ public function getForm() { $form = new taoQtiTest_models_classes_import_TestImportForm(); return $form->getForm(); } /** * @param core_kernel_classes_Class $class * @param tao_helpers_form_Form|array $form * @param string|null $userId owner of the resource * @return common_report_Report */ public function import($class, $form, $userId = null) { try { $uploadedFile = $this->fetchUploadedFile($form); // The zip extraction is a long process that can exceed the 30s timeout helpers_TimeOutHelper::setTimeOutLimit(helpers_TimeOutHelper::LONG); $report = taoQtiTest_models_classes_QtiTestService::singleton()->importMultipleTests($class, $uploadedFile); helpers_TimeOutHelper::reset(); $this->getUploadService()->remove($uploadedFile); if (common_report_Report::TYPE_SUCCESS == $report->getType()) { $this->getEventManager()->trigger(new QtiTestImportEvent($report)); } return $report; } catch (Exception $e) { return common_report_Report::createFailure($e->getMessage()); } } }