/**
  * @depends testVeryBasic
  */
 public function testTemplateConstraintImpossibleWithTemplateVariableOnly()
 {
     $component = $this->createComponentFromXml('
         <templateProcessing>
             <setTemplateValue identifier="TEMPLATE">
                 <baseValue baseType="integer">0</baseValue>
             </setTemplateValue>
             <templateConstraint>
                 <gt>
                     <variable identifier="TEMPLATE"/>
                     <baseValue baseType="integer">0</baseValue>
                 </gt>
             </templateConstraint>
         </templateProcessing>
     ');
     $var = new TemplateVariable('TEMPLATE', Cardinality::SINGLE, BaseType::INTEGER);
     $var->setDefaultValue(new QtiInteger(-1));
     $state = new State(array($var));
     // The <templateConstraint> will never be satisfied.
     // We should then find the default value in TEMPLATE.
     $engine = new TemplateProcessingEngine($component, $state);
     $engine->process();
     $this->assertEquals(-1, $state['TEMPLATE']->getValue());
 }
Exemplo n.º 2
0
 /**
  * Apply templateProcessing on the session if a templateProcessing is described.
  * 
  * @throws \qtism\runtime\rules\RuleProcessingException
  * @return boolean Whether or not the template processing occured.
  */
 protected function templateProcessing()
 {
     $assessmentItem = $this->getAssessmentItem();
     if (($templateProcessing = $assessmentItem->getTemplateProcessing()) !== null) {
         $templateProcessingEngine = new TemplateProcessingEngine($templateProcessing, $this);
         $templateProcessingEngine->process();
         return true;
     } else {
         return false;
     }
 }