/** * Return the service for Qti Result * * @return QtiResultsService */ protected function getQtiResultService() { if (!$this->service) { $this->service = QtiResultsService::singleton(); $this->service->setServiceLocator($this->getServiceManager()); } return $this->service; }
/** * Download delivery execution XML * * @author Gyula Szucs, <*****@*****.**> * @throws \common_exception_MissingParameter * @throws \common_exception_NotFound * @throws \common_exception_ValidationFailed */ public function downloadXML() { try { if (!$this->hasRequestParameter('deliveryExecution')) { throw new \common_exception_MissingParameter('deliveryExecution is missing from the request.', $this->getRequestURI()); } if (empty($this->getRequestParameter('deliveryExecution'))) { throw new \common_exception_ValidationFailed('deliveryExecution cannot be empty'); } $qtiResultService = QtiResultsService::singleton(); $qtiResultService->setServiceLocator($this->getServiceManager()); $deliveryExecution = $qtiResultService->getDeliveryExecutionById($this->getRequestParameter('deliveryExecution')); if (empty($deliveryExecution)) { throw new \common_exception_NotFound('Delivery execution not found.'); } $xml = $qtiResultService->getDeliveryExecutionXml($deliveryExecution); header('Set-Cookie: fileDownload=true'); //used by jquery file download to find out the download has been triggered ... setcookie("fileDownload", "true", 0, "/"); header('Content-Disposition: attachment; filename="delivery_execution_' . date('YmdHis') . '.xml"'); header('Content-Type: application/xml'); echo $xml; } catch (\common_exception_Error $e) { $this->returnJson(array('error' => $e->getMessage())); } }