Merge branch 'master' of ssh://p0m.fr:6224/git/nemubot_askweb
This commit is contained in:
commit
7ab305ef62
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,7 +52,11 @@ class QuestionsFile
|
||||
*/
|
||||
public function get_question($id)
|
||||
{
|
||||
return new Question($this->treeXML->getElementById($id));
|
||||
$q = $this->treeXML->getElementById($id);
|
||||
if (isset($q))
|
||||
return new Question($q);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -63,6 +67,7 @@ class QuestionsFile
|
||||
if (!empty($newfilename))
|
||||
$this->filename = $newfilename;
|
||||
|
||||
$this->treeXML->formatOutput = true;
|
||||
$this->treeXML->save($this->filename);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user