/**
  * Create a new Question from a passed XML File
  * @param string $vFileName
  * @throws Exception
  */
 public function __construct($vFileName)
 {
     Model_Shell_Debug::getInstance()->log("Attempting to create generic question from XML File {$vFileName}");
     $file_contents = Model_XML_Parser::xml2array($vFileName);
     if (!is_array($file_contents) || sizeof($file_contents) == 0) {
         throw new Exception("Could not parse XML File " . $vFileName);
     }
     $this->mFileContents = $file_contents;
     $this->mFileName = $vFileName;
     $this->mSubstitutions = array();
     $this->mAltAnswers = array();
     //print_r($this->mFileContents);
 }
Example #2
0
 static function load($file_name)
 {
     //My_Logger::log(__METHOD__ . " loading:" . $file_name);
     $obj = new self();
     if (!file_exists($file_name)) {
         return $obj;
     }
     $file_contents = Model_XML_Parser::xml2array($file_name);
     if (!is_array($file_contents) || sizeof($file_contents) == 0) {
         return $obj;
     }
     $obj->xml = simplexml_load_file($file_name);
     My_Logger::log(__METHOD__ . " contents:" . print_r($file_contents, true));
     //My_Logger::log(__METHOD__ . " xml:" . print_r($obj->xml, true));
     $obj->file_Contents = $file_contents;
     $obj->file_name = $file_name;
     $obj->substitutions = array();
     $obj->valid = true;
     //print_r($obj->mFileContents);
     My_Logger::log(__METHOD__ . $obj->file_Contents['question']['problem']);
     return $obj;
 }