Example #1
0
 public function toArray($filterVariableContent = false, &$filtered = array())
 {
     $returnValue = parent::toArray($filterVariableContent, $filtered);
     $rpSerialized = QtiSerializer::parseResponseProcessingXml(simplexml_load_string($this->data));
     $protectedData = array('processingType' => 'custom', 'data' => $this->data, 'responseRules' => $rpSerialized['responseRules']);
     if ($filterVariableContent) {
         $filtered[$this->getSerial()] = $protectedData;
     } else {
         $returnValue = array_merge($returnValue, $protectedData);
     }
     return $returnValue;
 }
 /**
  * Short description of method takeOverFrom
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @param  ResponseProcessing responseProcessing
  * @param  Item item
  * @return oat\taoQtiItem\model\qti\response\Composite
  */
 public static function takeOverFrom(ResponseProcessing $responseProcessing, Item $item)
 {
     $returnValue = null;
     if ($responseProcessing instanceof static) {
         // already good
         $returnValue = $responseProcessing;
     } elseif ($responseProcessing instanceof Template) {
         // IMS Template
         $rp = new Summation($item, 'SCORE');
         foreach ($item->getInteractions() as $interaction) {
             $response = $interaction->getResponse();
             try {
                 $irp = IrpTemplate::createByTemplate($responseProcessing->getUri(), $response, $item);
             } catch (Exception $e) {
                 throw new TakeoverFailedException();
             }
             $rp->add($irp, $item);
         }
         $returnValue = $rp;
     } elseif ($responseProcessing instanceof TemplatesDriven) {
         // TemplateDriven
         $rp = new Summation($item, 'SCORE');
         foreach ($item->getInteractions() as $interaction) {
             $response = $interaction->getResponse();
             try {
                 $irp = IrpTemplate::createByTemplate($responseProcessing->getTemplate($response), $response, $item);
             } catch (Exception $e) {
                 throw new TakeoverFailedException();
             }
             $rp->add($irp, $item);
         }
         $returnValue = $rp;
     } else {
         common_Logger::d('Composite ResponseProcessing can not takeover from ' . get_class($responseProcessing) . ' yet');
         throw new TakeoverFailedException();
     }
     common_Logger::i('Converted to Composite', array('TAOITEMS', 'QTI'));
     return $returnValue;
 }
 public function toArray($filterVariableContent = false, &$filtered = array())
 {
     $returnValue = parent::toArray($filterVariableContent, $filtered);
     $rp = null;
     $template = $this->convertToTemplate();
     if (is_null($template)) {
         //cannot be converted into a Template instance, so build the rp from the current instance
         $rp = $this->buildQTI();
     } else {
         //can be converted into a Template instance, so get the Template content
         $rp = $template->getTemplateContent();
     }
     $rpSerialized = QtiSerializer::parseResponseProcessingXml(simplexml_load_string($rp));
     $protectedData = array('processingType' => 'templateDriven', 'responseRules' => $rpSerialized['responseRules']);
     if ($filterVariableContent) {
         $filtered[$this->getSerial()] = $protectedData;
     } else {
         $returnValue = array_merge($returnValue, $protectedData);
     }
     return $returnValue;
 }