/**
  * 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();
         $itemService = taoItems_models_classes_ItemsService::singleton();
         $doc = $qtiTestService->getDoc($test);
         $converter = new \taoQtiTest_models_classes_QtiTestConverter($doc);
         $itemPacker = new QtiItemPacker();
         $items = array();
         foreach ($qtiTestService->getItems($test) as $item) {
             $items[$item->getUri()] = $itemPacker->packItem($item, $itemService->getItemFolder($item));
         }
         $testPack = new TestPack(self::$testType, $converter->toArray(), $items);
     } catch (common_Exception $e) {
         throw new common_Exception('Unable to pack test ' . $test->getUri() . ' : ' . $e->getMessage());
     }
     return $testPack;
 }
 /**
  * packTest implementation for QTI
  * @see {@link Packable}
  * @throws InvalidArgumentException
  * @throws common_Exception
  */
 public function packTest(core_kernel_classes_Resource $test)
 {
     $testPack = null;
     try {
         //load resquired services
         $qtiTestService = taoQtiTest_models_classes_QtiTestService::singleton();
         $itemService = taoItems_models_classes_ItemsService::singleton();
         //load the test data
         $testFilePath = $qtiTestService->getDocPath($test);
         $testData = $this->getRoute($testFilePath);
         $testData['uri'] = $test->getUri();
         //pack each test's item
         $itemPacker = new QtiItemPacker();
         $items = array();
         foreach ($qtiTestService->getItems($test) as $item) {
             $items[$item->getUri()] = $itemPacker->packItem($item, $itemService->getItemFolder($item));
         }
         //create the pack
         $testPack = new TestPack(self::$testType, $testData, $items);
     } catch (common_Exception $e) {
         throw new common_Exception('Unable to pack test ' . $test->getUri() . ' : ' . $e->getMessage());
     }
     return $testPack;
 }
 /**
  * Test the exception when a wrong content is given to the parser
  *
  * @expectedException \common_Exception
  */
 public function testWrongContentToPack()
 {
     $itemPacker = new QtiItemPacker();
     $itemPacker->packItem(new core_kernel_classes_Resource('foo'), 'en-US');
 }
 /**
  * Test the exception when a wrong content is given to the parser
  *
  * @expectedException \common_Exception
  */
 public function testWrongContentToPack()
 {
     $itemPacker = new QtiItemPacker();
     $itemPacker->packItem(new core_kernel_classes_Resource('foo'), 'en-US', $this->getDirectoryStorage());
 }