*/ class QtiTestPacker implements Packable { /** * The test type identifier * @var string */ private static $testType = 'qti'; /** * packTest implementation for QTI * @see {@link Packable} * @throws InvalidArgumentException * @throws common_Exception */ public function packTest(core_kernel_classes_Resource $test) { $testPack = null; try { $qtiTestService = taoQtiTest_models_classes_QtiTestService::singleton(); $doc = $qtiTestService->getDoc($test); $converter = new \taoQtiTest_models_classes_QtiTestConverter($doc); $items = []; foreach ($qtiTestService->getItems($test) as $item) { $items[$item->getUri()] = (new Packer($item, '')) ->setServiceLocator(ServiceManager::getServiceManager()) ->pack(); } $testPack = new TestPack(self::$testType, $converter->toArray(), $items); } catch (Exception $e) { throw new common_Exception('Unable to pack test ' . $test->getUri() . ' : ' . $e->getMessage()); } return $testPack; } }