public function testFromInvalidObject()
 {
     $this->setExpectedException('\\InvalidArgumentException');
     $component = new stdClass();
     $factory = new MarshallerFactory();
     $marshaller = $factory->createMarshaller($component);
 }
 public function __invoke($params)
 {
     // load constants...
     \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->load();
     if (empty($params[0]) === true) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'Test URI not provided as parameter 1.');
     }
     if (empty($params[1]) === true) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'AssessmentItemRefIdentifier not provided as parameter 2.');
     }
     $testResource = new \core_kernel_classes_Resource($params[0]);
     if ($testResource->exists() === false) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'No RDFS Resource found for URI ' . $params[0] . '.');
     }
     $qtiService = \taoQtiTest_models_classes_QtiTestService::singleton();
     $testDoc = $qtiService->getDoc($testResource);
     $test = $testDoc->getDocumentComponent();
     $assessmentItemRef = $test->getComponentByIdentifier($params[1]);
     if (!$assessmentItemRef) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'No QTI assessmentItemRef with identifier ' . $params[1] . ' found in the QTI Test definition.');
     }
     $input = file_get_contents('php://stdin');
     if (empty($input) === true) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'No QTI-XML input provided in stdin.');
     } else {
         $dom = new \DOMDocument('1.0', 'UTF-8');
         if (@$dom->loadXML($input)) {
             $element = $dom->documentElement;
             $marshallerFactory = new MarshallerFactory();
             $marshaller = $marshallerFactory->createMarshaller($element);
             $component = $marshaller->unmarshall($element);
             if (!$component instanceof BranchRule) {
                 return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'No QTI branchRule component found in stdin.');
             }
             $assessmentItemRef->setBranchRules(new BranchRuleCollection(array($component)));
             $qtiService->getQtiTestFile($testResource)->update($testDoc->saveToString());
         } else {
             return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'Invalid QTI-XML input provided in stdin.');
         }
     }
     return new \common_report_Report(\common_report_Report::TYPE_SUCCESS, "BranchRule found in stdin successfully appended to assessmentItemRef '" . $params[1] . "' part of QTI Test with URI '" . $params[0] . "'.");
 }
 /**
  * Create a new Qti20MarshallerFactory object.
  */
 public function __construct()
 {
     parent::__construct();
     $this->removeMappingEntry('mediaInteraction');
     $this->removeMappingEntry('infoControl');
     $this->removeMappingEntry('interpolationTable');
     $this->removeMappingEntry('interpolationTableEntry');
     $this->removeMappingEntry('matchTable');
     $this->removeMappingEntry('matchTableEntry');
     $this->removeMappingEntry('assessmentTest');
     $this->removeMappingEntry('testPart');
     $this->removeMappingEntry('assessmentSection');
     $this->removeMappingEntry('assessmentSectionRef');
     $this->removeMappingEntry('assessmentItemRef');
     $this->removeMappingEntry('sectionPart');
     $this->removeMappingEntry('selection');
     $this->removeMappingEntry('ordering');
     $this->removeMappingEntry('weight');
     $this->removeMappingEntry('variableMapping');
     $this->removeMappingEntry('templateDefault');
     $this->removeMappingEntry('timeLimits');
     $this->removeMappingEntry('testFeedback');
     $this->removeMappingEntry('branchRule');
     $this->removeMappingEntry('preCondition');
     $this->removeMappingEntry('outcomeProcessing');
     $this->removeMappingEntry('outcomeCondition');
     $this->removeMappingEntry('outcomeIf');
     $this->removeMappingEntry('outcomeElseIf');
     $this->removeMappingEntry('outcomeElse');
     $this->removeMappingEntry('exitTest');
     $this->removeMappingEntry('itemSubset');
     $this->removeMappingEntry('testVariables');
     $this->removeMappingEntry('outcomeMaximum');
     $this->removeMappingEntry('outcomeMinimum');
     $this->removeMappingEntry('numberCorrect');
     $this->removeMappingEntry('numberIncorrect');
     $this->removeMappingEntry('numberResponded');
     $this->removeMappingEntry('numberPresented');
     $this->removeMappingEntry('numberSelected');
     $this->removeMappingEntry('repeat');
     $this->removeMappingEntry('roundTo');
     $this->removeMappingEntry('mathOperator');
     $this->removeMappingEntry('mathConstant');
     $this->removeMappingEntry('min');
     $this->removeMappingEntry('max');
     $this->removeMappingEntry('statsOperator');
     $this->removeMappingEntry('gcd');
     $this->removeMappingEntry('lcd');
     $this->removeMappingEntry('templateConstraint');
 }
 public function __construct()
 {
     parent::__construct();
     $this->addMappingEntry('assessmentItemRef', 'qtism\\data\\storage\\xml\\marshalling\\ExtendedAssessmentItemRefMarshaller');
     $this->addMappingEntry('assessmentSection', 'qtism\\data\\storage\\xml\\marshalling\\ExtendedAssessmentSectionMarshaller');
 }
 /**
  * Create a new Qti22MarshallerFactory object.
  */
 public function __construct()
 {
     parent::__construct();
     $this->addMappingEntry('bdo', 'qtism\\data\\storage\\xml\\marshalling\\SimpleInlineMarshaller');
 }