/**
  * 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');
     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();
     }
 }