/**
  * Overrides CqQuestionAbstract::loadXml()
  */
 public function loadXml(DOMElement $dom)
 {
     parent::loadXml($dom);
     module_load_include('inc.php', 'closedquestion', 'lib/XmlLib');
     module_load_include('php', 'closedquestion', 'question/mapping/FactoryHotspot');
     $this->hotspots = array();
     $this->mappings = array();
     $this->hints = array();
     $this->draggables = array();
     foreach ($dom->childNodes as $node) {
         $name = drupal_strtolower($node->nodeName);
         switch ($name) {
             case 'text':
                 $this->text = cq_get_text_content($node, $this);
                 break;
             case 'matchimg':
                 $this->matchImgUrl = $node->getAttribute('src');
                 $this->matchImgHeight = $node->getAttribute('height');
                 $this->matchImgWidth = $node->getAttribute('width');
                 $this->maxChoices = $node->getAttribute('maxChoices');
                 foreach ($node->childNodes as $child) {
                     switch (drupal_strtolower($child->nodeName)) {
                         case 'hotspot':
                             $hotspot = cq_Hotspot_from_xml($child, $this);
                             if (is_object($hotspot)) {
                                 if (isset($this->hotspots[$hotspot->getIdentifier()])) {
                                     drupal_set_message(t('Hotspot identifier %identifier used more than once!', array('%identifier' => $hotspot->getIdentifier())), 'warning');
                                 }
                                 $this->hotspots[$hotspot->getIdentifier()] = $hotspot;
                             }
                             break;
                     }
                 }
                 break;
             case 'mapping':
                 $map = new CqMapping();
                 $map->generateFromNode($node, $this);
                 $this->mappings[] = $map;
                 break;
             case 'hint':
                 $this->hints[] = CqFeedback::newCqFeedback($node, $this);
                 break;
             default:
                 if (!in_array($name, $this->knownElements)) {
                     drupal_set_message(t('Unknown node: @nodename', array('@nodename' => $node->nodeName)));
                 }
                 break;
         }
     }
 }
 /**
  * Overrides CqQuestionAbstract::loadXml()
  */
 public function loadXml(DOMElement $dom)
 {
     parent::loadXml($dom);
     module_load_include('inc.php', 'closedquestion', 'lib/XmlLib');
     foreach ($dom->childNodes as $node) {
         $name = drupal_strtolower($node->nodeName);
         switch ($name) {
             case 'option':
             case 'item':
                 $option = new CqOption($node, $this);
                 if (is_numeric($option->getIdentifier())) {
                     $this->sections[$option->getIdentifier()] = $option;
                     $this->selectedBySection[$option->getIdentifier()] = array();
                 }
                 if (isset($this->items[$option->getIdentifier()])) {
                     drupal_set_message(t('Option identifier %identifier used more than once!', array('%identifier' => $option->getIdentifier())), 'warning');
                 }
                 $this->items[$option->getIdentifier()] = $option;
                 break;
             case 'sequence':
                 // Old style sequence, would stop at first match.
             // Old style sequence, would stop at first match.
             case 'mapping':
                 // New style mapping, continues at match by default.
                 $map = new CqMapping();
                 $map->generateFromNode($node, $this);
                 if ($node->nodeName == 'sequence') {
                     $map->setStopIfMatch(TRUE);
                 }
                 $this->mappings[] = $map;
                 break;
             case 'text':
                 $this->text = cq_get_text_content($node, $this);
                 break;
             case 'hint':
                 $this->hints[] = CqFeedback::newCqFeedback($node, $this);
                 break;
             case 'default':
             case 'startstate':
                 $attribs = $node->attributes;
                 $item = $attribs->getNamedItem('value');
                 if ($item !== NULL) {
                     $this->defaultAnswer = $item->value;
                 }
                 break;
             default:
                 if (!in_array($name, $this->knownElements)) {
                     drupal_set_message(t('Unknown node: @nodename', array('@nodename' => $node->nodeName)));
                 }
                 break;
         }
     }
     $attribs = $dom->attributes;
     $item = $attribs->getNamedItem('duplicates');
     if ($item !== NULL) {
         $this->duplicates = (int) $item->value;
     }
     $item = $attribs->getNamedItem('alignment');
     if ($item !== NULL) {
         $this->alignment = $item->value;
     }
     $item = $attribs->getNamedItem('optionheight');
     if ($item !== NULL) {
         $this->optionHeight = $item->value;
     }
     $answer = $this->userAnswer->getAnswer();
     if (empty($answer)) {
         $this->userAnswer->setAnswer($this->defaultAnswer);
     }
     if (count($this->selectedBySection) == 0) {
         // No sections defined, make one.
         $this->selectedBySection[1] = array();
     }
 }
 /**
  * Overrides CqQuestionAbstract::loadXml()
  */
 public function loadXml(DOMElement $dom)
 {
     parent::loadXml($dom);
     module_load_include('inc.php', 'closedquestion', 'lib/XmlLib');
     foreach ($dom->childNodes as $node) {
         $name = drupal_strtolower($node->nodeName);
         switch ($name) {
             case 'option':
                 $this->options[] = new CqOption($node, $this);
                 break;
             case 'text':
                 $this->text = cq_get_text_content($node, $this);
                 break;
             case 'prompt':
                 $this->prompt = cq_get_text_content($node, $this);
                 break;
             case 'hint':
                 $this->hints[] = CqFeedback::newCqFeedback($node, $this);
                 break;
             case 'correct':
                 $this->correctFeeback = CqFeedback::newCqFeedback($node, $this);
                 break;
             case 'mapping':
                 // New style mapping, continues at match by default.
                 $map = new CqMapping();
                 $map->generateFromNode($node, $this);
                 if ($node->nodeName == 'sequence') {
                     $map->setStopIfMatch(TRUE);
                 }
                 $this->mappings[] = $map;
                 break;
             default:
                 if (!in_array($name, $this->knownElements)) {
                     drupal_set_message(t('Unknown node: @nodename', array('@nodename' => $node->nodeName)));
                 }
                 break;
         }
     }
     $attribs = $dom->attributes;
     $item = $attribs->getNamedItem('inlinefeedback');
     if ($item !== NULL) {
         $this->inlineFeedback = (int) $item->value;
     }
 }
 /**
  * Overrides CqQuestionAbstract::loadXml()
  */
 public function loadXml(DOMElement $dom)
 {
     parent::loadXml($dom);
     module_load_include('inc.php', 'closedquestion', 'lib/XmlLib');
     $textNode = NULL;
     foreach ($dom->childNodes as $node) {
         $name = drupal_strtolower($node->nodeName);
         switch ($name) {
             case 'inlineoption':
                 $option = new CqInlineOption($node, $this);
                 if (isset($this->inlineOptions[$option->getIdentifier()])) {
                     drupal_set_message(t('Inlineoption identifier %identifier used more than once!', array('%identifier' => $option->getIdentifier())), 'warning');
                 }
                 $this->inlineOptions[$option->getIdentifier()] = $option;
                 $this->inlineOptionsByGroup[$option->getGroup()][$option->getIdentifier()] = $option;
                 break;
             case 'mapping':
                 $map = new CqMapping();
                 $map->generateFromNode($node, $this);
                 $this->mappings[] = $map;
                 break;
             case 'text':
                 $textNode = $node;
                 break;
             case 'hint':
                 $this->hints[] = CqFeedback::newCqFeedback($node, $this);
                 break;
             default:
                 if (!in_array($name, $this->knownElements)) {
                     drupal_set_message(t('Unknown node: @nodename', array('@nodename' => $node->nodeName)));
                 }
                 break;
         }
     }
     if ($textNode != NULL) {
         $this->text = cq_get_text_content($textNode, $this);
     }
 }