/**
  * packItem implementation for QTI
  * @see {@link Packable}
  * @throws InvalidArgumentException
  * @throws common_Exception
  */
 public function packItem(core_kernel_classes_Resource $item, $path)
 {
     $itemPack = null;
     $content = $this->getItemContent($path);
     //use the QtiParser to transform the QTI XML into an assoc array representation
     try {
         //load content
         $qtiParser = new QtiParser($content);
         //validate it
         $qtiParser->validate();
         if (!$qtiParser->isValid()) {
             throw new common_Exception('Invalid QTI content : ' . $qtiParser->displayErrors(false));
         }
         //parse
         $qtiItem = $qtiParser->load();
         //then build the ItemPack from the parsed data
         if (!is_null($qtiItem)) {
             $itemPack = new ItemPack(self::$itemType, $qtiItem->toArray());
             $assetParser = new AssetParser($qtiItem, $path);
             foreach ($assetParser->extract() as $type => $assets) {
                 $itemPack->setAssets($type, $assets);
             }
         }
     } catch (common_Exception $e) {
         throw new common_Exception('Unable to pack item ' . $item->getUri() . ' : ' . $e->getMessage());
     }
     return $itemPack;
 }
 /**
  * Provides data to test the bundle
  * @return array() the data
  */
 public function jsonSerializableProvider()
 {
     $data = array();
     $pack1 = new ItemPack('qti', array('foo' => 'bar'));
     $json1 = '{"type":"qti","data":{"foo":"bar"},"assets":[]}';
     $data[0] = array($pack1, $json1);
     $pack2 = new ItemPack('owi', array('foo' => 'bar'));
     $pack2->setAssets('js', array('lodash.js', 'jquery.js'));
     $json2 = '{"type":"owi","data":{"foo":"bar"},"assets":{"js":["lodash.js","jquery.js"]}}';
     $data[1] = array($pack2, $json2);
     return $data;
 }