public function fromJson($json)
 {
     $doc = new XmlDocument('2.1');
     $converter = new taoQtiTest_models_classes_QtiTestConverter($doc);
     $converter->fromJson($json);
     return $doc;
 }
 /**
  * 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 = array();
         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 (common_Exception $e) {
         throw new common_Exception('Unable to pack test ' . $test->getUri() . ' : ' . $e->getMessage());
     }
     return $testPack;
 }