From ec83fb31210f18f0498f6fa23fcff766065f2497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9munaire?= Date: Wed, 23 May 2012 17:45:12 +0200 Subject: [PATCH] Fix Question getter; search ID --- Question.class.php | 4 ++-- QuestionsFile.class.php | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Question.class.php b/Question.class.php index dfbe638..5bbfb33 100644 --- a/Question.class.php +++ b/Question.class.php @@ -22,7 +22,7 @@ class Question $this->question = $node->getAttribute("question"); $this->course = $node->getAttribute("course"); - $answers = $node->getElementByTagName("answer"); + $answers = $node->getElementsByTagName("answer"); for ($i = 0; $i < $answers->length; $i++) $this->answers[] = $answers->item($i)->getAttribute("answer"); } @@ -80,7 +80,7 @@ class Question { $qnode = $root->createElement("question"); - $qnode->setAttribute("id", $this->id); + $qnode->setAttribute("xml:id", $this->id); $qnode->setAttribute("addedtime", $this->added_time); $qnode->setAttribute("validated", $this->validated); $qnode->setAttribute("validator", $this->validator); diff --git a/QuestionsFile.class.php b/QuestionsFile.class.php index cead304..f4228f3 100644 --- a/QuestionsFile.class.php +++ b/QuestionsFile.class.php @@ -21,7 +21,6 @@ class QuestionsFile private function reload() { $this->treeXML = new DOMDocument('1.0', 'UTF-8'); - $this->treeXML->formatOutput = true; if (@$this->treeXML->load($this->filename)) { @@ -44,7 +43,8 @@ class QuestionsFile */ public function add_question($question) { - $this->root_node->appendChild($question->to_xml($this->treeXML)); + $qnode = $question->to_xml($this->treeXML); + $this->root_node->appendChild($qnode); } /** @@ -63,6 +63,7 @@ class QuestionsFile if (!empty($newfilename)) $this->filename = $newfilename; + $this->treeXML->formatOutput = true; $this->treeXML->save($this->filename); } }