/** * Creates a ModelResponse object for this ModelQuestionModel * * @param type One of 'no preference', 'match' (exact text match), 'selected', 'not selected' * @param target If for a question of type T, then exact text. If type S or M (single or multi-select), * then the promptID * @return ModelResponseModel */ public function createModelResponse($type, $target, $info = '') { $row = self::$modelResponseTable->createRow(); if ($type !== 'no preference' && $type !== 'match' && $type !== 'selected' && $type !== 'not selected' && $type !== 'remediation info' && $type !== 'require attachment') { throw new Exception("Unknown model response type [{$type}]"); } $row->type = $type; $row->target = $target; $row->modelID = $this->modelID; $row->pageID = $this->question->pageID; $row->sectionID = $this->question->sectionID; $row->questionID = $this->question->questionID; $row->info = $info; $row->save(); $modelResponse = new ModelResponseModel(array('modelResponseID' => $row->modelResponseID)); return $modelResponse; }