/**
  * Create a new TestCategoryRulesService instance.
  * 
  * This constructor allows you to instantiate a new TestCategoryRulesService object with the following options available:
  * 
  * * 'score-variable-identifier' (string) : The identifier of the item session outcome variable to be used when generating <testVariables> based rules.
  * * 'weight-identifier' (string) : The identifier of the item reference weight to be used when generating <testVariables> based rules.
  * * 'category-exclusions' (array) : An array of PCREs describing what are the categories to be excluded from the rule generation process.
  * * 'flags' (integer) : A binary flags configuration of the rule generation process composed by values described by the TestCategoryRulesGenerator class constants.
  * 
  * @param array $options (optional) An optional array of options.
  */
 public function __construct(array $options = array())
 {
     parent::__construct($options);
     \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');
     $generator = new TestCategoryRulesGenerator();
     $generator->setScoreVariableIdentifier(empty($options['score-variable-identifier']) ? 'SCORE' : (string) $options['score-variable-identifier']);
     $generator->setWeightIdentifier(array_key_exists('weight-identifier', $options) ? (string) $options['weight-identifier'] : '');
     $generator->setCategoryExclusions(empty($options['category-exclusions']) ? array() : $options['category-exclusions']);
     $this->setGenerator($generator);
 }
 /**
  * @depends testApplyScoreOnlyWithCustomScoreVariableIdentifier
  */
 public function testApplyScoreOnlyWithCustomScoreVariableIdentifierAndCustomWeightIdentifier()
 {
     $generator = new TestCategoryRulesGenerator();
     $generator->setScoreVariableIdentifier('MY_SCORE');
     $generator->setWeightIdentifier('MY_WEIGHT');
     $doc = new XmlDocument();
     $doc->load(self::samplesDir() . 'categories.xml');
     $generator->apply($doc->getDocumentComponent(), TestCategoryRulesGenerator::SCORE);
     $outcomes = $doc->getDocumentComponent()->getOutcomeDeclarations();
     $this->assertCount(2, $outcomes);
     $this->assertTrue(isset($outcomes['MATH' . TestCategoryRulesUtils::TOTAL_SCORE_SUFFIX]));
     $this->assertTrue(isset($outcomes['ENGLISH' . TestCategoryRulesUtils::TOTAL_SCORE_SUFFIX]));
     $setOutcomeValues = $doc->getDocumentComponent()->getComponentsByClassName('setOutcomeValue');
     $this->assertCount(2, $setOutcomeValues);
     $this->assertEquals('MY_SCORE', $setOutcomeValues[0]->getExpression()->getExpressions()[0]->getVariableIdentifier());
     $this->assertEquals('MY_WEIGHT', $setOutcomeValues[0]->getExpression()->getExpressions()[0]->getWeightIdentifier());
     $this->assertEquals('MY_SCORE', $setOutcomeValues[1]->getExpression()->getExpressions()[0]->getVariableIdentifier());
     $this->assertEquals('MY_WEIGHT', $setOutcomeValues[1]->getExpression()->getExpressions()[0]->getWeightIdentifier());
 }