/** * Instantiate a new ModelResponseModel object * * @param array */ public function __construct($args = array()) { $args = array_merge(array('depth' => 'response', 'instance' => null), $args); $this->depth = $args['depth']; $this->compareInstance = $args['instance']; if (!isset(self::$modelTable)) { self::$modelTable = QFrame_Db_Table::getTable('model'); } if (!isset(self::$modelResponseTable)) { self::$modelResponseTable = QFrame_Db_Table::getTable('model_response'); } if (!isset(self::$questionPromptTable)) { self::$questionPromptTable = QFrame_Db_Table::getTable('question_prompt'); } if (isset($args['modelResponseID'])) { $rows = self::$modelResponseTable->fetchRows('modelResponseID', $args['modelResponseID']); $this->modelResponseRow = $rows[0]; } else { throw new InvalidArgumentException('Missing arguments to ModelResponseModel constructor'); } // model response row assertion if ($this->modelResponseRow === NULL) { throw new Exception('Model response not found'); } }
/** * Loads Model Responses */ private function _loadModelResponses() { $rows = self::$modelResponseTable->fetchRows('questionID', $this->question->questionID, 'modelResponseID', $this->modelID); foreach ($rows as $row) { $this->modelResponses[] = new ModelResponseModel(array('modelResponseID' => $row->modelResponseID, 'instance' => $this->compareInstance)); } }
/** * Instantiate a new ModelPageModel object * * @param array */ public function __construct($args = array()) { $args = array_merge(array('depth' => 'page', 'instance' => null), $args); $this->depth = $args['depth']; $this->compareInstance = $args['instance']; if (!isset(self::$modelTable)) { self::$modelTable = QFrame_Db_Table::getTable('model'); } if (!isset(self::$modelResponseTable)) { self::$modelResponseTable = QFrame_Db_Table::getTable('model_response'); } if (!isset(self::$sectionTable)) { self::$sectionTable = QFrame_Db_Table::getTable('section'); } if (isset($args['modelID']) && isset($args['pageID'])) { $this->modelID = $args['modelID']; $this->page = new PageModel(array('pageID' => $args['pageID'], 'depth' => $args['depth'])); } else { throw new InvalidArgumentException('Missing arguments to ModelPageModel constructor'); } // To populate cache self::$modelResponseTable->fetchRows('modelID', $this->modelID, 'modelResponseID', $this->modelID); if ($this->depth !== 'page') { $this->_loadModelSections(); } }