function __construct($args = array()) { if (!isset(self::$responseTable)) { self::$responseTable = QFrame_Db_Table::getTable('response'); } if (!isset(self::$questionPromptTable)) { self::$questionPromptTable = QFrame_Db_Table::getTable('question_prompt'); } $args = array_merge(array('questionID' => null, 'instanceID' => null, 'responseText' => null, 'additionalInfo' => null, 'privateNote' => null, 'externalReference' => null, 'state' => null, 'dbUserID' => -1), $args); if (isset($args['responseID'])) { $responseRows = self::$responseTable->fetchRows('responseID', intval($args['responseID'])); foreach ($responseRows as $r) { if (!$r->responseEndDate) { $this->responseRow = $r; } } // response row assertion if ($this->responseRow === NULL) { throw new Exception('Response not found'); } $this->dirty = 0; } else { $this->responseRow = self::$responseTable->createRow(); $this->responseRow->questionID = intval($args['questionID']); $this->responseRow->instanceID = intval($args['instanceID']); $this->responseRow->pageID = intval($args['pageID']); $this->responseRow->sectionID = intval($args['sectionID']); $this->responseRow->responseText = $args['responseText']; $this->responseRow->additionalInfo = $args['additionalInfo']; $this->responseRow->privateNote = $args['privateNote']; $this->responseRow->externalReference = $args['externalReference']; $this->responseRow->state = $args['state']; $this->responseRow->dbUserID = $args['dbUserID']; $this->dirty = 1; } }