示例#1
0
 /**
  * 
  */
 public function testCadastrar()
 {
     $questaoModel = new QuestaoModel(null, $this->idGuiaTest, 'Questao teste', 1);
     $questaoModel->cadastrar();
     $questao = $questaoModel->toStdClass();
     $this->assertNotNull($questao->questao);
 }
 /**
  * 
  */
 public function atualizarAction()
 {
     $questao = new QuestaoModel($this->getRequest()->getParam('questao'), $this->getRequest()->getParam('guia'), $this->getRequest()->getParam('textoQuestao'), $this->getRequest()->getParam('textoAjudaQuestao'), $this->getRequest()->getParam('tipoResposta'));
     $questao->atualizar();
     $this->view->questao = $questao->toStdClass();
     // Remove as respostas disponiveis para a questao
     $respostaModel = new RespostaModel(null, null, $this->view->questao->questao);
     $respostaModel->deletarPorQuestao();
     // Se for postada a(s) resposta efetua o cadastro
     $this->view->questao->resposta = array();
     $respostas = $this->getRequest()->getParam('respostaNome') ?: array();
     foreach ($respostas as $resposta) {
         $respostaModel = new RespostaModel(null, $this->getRequest()->getParam('tipoResposta'), $this->view->questao->questao, $resposta);
         $respostaModel->cadastrar();
         $this->view->questao->resposta[] = $respostaModel->toStdClass();
     }
 }