Esempio n. 1
0
 public function testModelSectionModelSavesModelResponses()
 {
     $this->auth();
     $section = new ModelSectionModel(array('modelID' => 1, 'sectionID' => 5, 'depth' => 'response'));
     $question = $section->nextModelQuestion();
     $response = $question->createModelResponse('match', 'test');
     $modelResponseID = $response->modelResponseID;
     $section->save();
     $testResponse = new ModelResponseModel(array('modelResponseID' => $modelResponseID));
     $this->assertEquals($modelResponseID, $testResponse->modelResponseID);
 }
Esempio n. 2
0
 /**
  * Instantiate a new ModelSectionModel object
  *
  * @param array
  */
 public function __construct($args = array())
 {
     $args = array_merge(array('depth' => 'section', '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::$questionTable)) {
         self::$questionTable = QFrame_Db_Table::getTable('question');
     }
     if (isset($args['modelID']) && isset($args['sectionID'])) {
         $this->modelID = $args['modelID'];
         $this->section = new SectionModel(array('sectionID' => $args['sectionID'], 'depth' => $args['depth']));
     } else {
         throw new InvalidArgumentException('Missing arguments to ModelSectionModel constructor');
     }
     if ($this->depth !== 'section') {
         $this->_loadModelQuestions();
     }
 }