/**
  * render an item as a Qti zip package
  * @author christophe GARCIA <*****@*****.**>
  */
 public function export()
 {
     try {
         if ($this->getRequestMethod() != Request::HTTP_GET) {
             throw new \common_exception_NotImplemented('Only GET method is accepted to export QIT Item.');
         }
         if (!$this->hasRequestParameter('id')) {
             $this->returnFailure(new \common_exception_MissingParameter('required parameter `id` is missing'));
         }
         $id = $this->getRequestParameter('id');
         $item = new \core_kernel_classes_Resource($id);
         $itemService = \taoItems_models_classes_ItemsService::singleton();
         if ($itemService->hasItemModel($item, array(ItemModel::MODEL_URI))) {
             $path = \tao_helpers_Export::getExportFile();
             $tmpZip = new \ZipArchive();
             $tmpZip->open($path, \ZipArchive::CREATE);
             $exporter = new QTIPackedItemExporter($item, $tmpZip);
             $exporter->export(array('apip' => false));
             $exporter->getZip()->close();
             header('Content-Type: application/zip');
             \tao_helpers_Http::returnFile($path, false);
             return;
         } else {
             $this->returnFailure(new \common_exception_NotFound('item can\'t be found'));
         }
     } catch (\Exception $e) {
         $this->returnFailure($e);
     }
 }