public function recuperarProvaResposta($id_prova_resposta){

		$query ="SELECT tbl_prova_resposta.prova_resposta       AS prova_resposta,
						tbl_prova_resposta.prova_pergunta       AS prova_pergunta,
						tbl_prova_resposta.resposta_texto       AS resposta_texto,
						tbl_prova_resposta.resposta_correta     AS resposta_correta,
						tbl_prova_resposta.resposta_filho       AS resposta_filho,
						tbl_prova_resposta.ordem                AS ordem
				FROM tbl_prova_resposta
				WHERE tbl_prova_resposta.prova_resposta = $id_prova_resposta ";

		$banco = $this->getBancoDados(); 
		$prova_resposta = NULL; 
		$retorno = $banco->executaSQL($query); 
		if($retorno != NULL) {

			if ($banco->numRows($retorno) == 0){
				#throw new Exception("Nenhuma resposta da prova encontrada. (QUERY: $query )",0);
			}

			while($linha = $banco->fetchArray($retorno)) { 

				if (strlen(trim($linha["resposta_filho"]))>0){
					$sessionFacade   = new SessionFacade($banco); 
					$obj_prova_resposta_filho = $sessionFacade->recuperarProvaResposta($linha["resposta_filho"]);
				}else{
					$obj_prova_resposta_filho = NULL;
				}

				$prova_resposta = new Resposta(); 
				$prova_resposta->setId($linha['prova_resposta']);
				$prova_resposta->setPergunta($linha["prova_pergunta"]);
				$prova_resposta->setRespostaCorreta($linha["resposta_correta"]);
				$prova_resposta->setRespostaTexto($linha["resposta_texto"]);
				$prova_resposta->setRespostaFilho($obj_prova_resposta_filho);
				$prova_resposta->setOrdem($linha["ordem"]);
			}
			return $prova_resposta; 
		} else {
			throw new Exception("Erro ao recuperar Resposta Prova (SQL: $query )"); 
		}
	}
示例#2
0
| Amb aquest fitxer carregar el framework podrà ser ussat per el
| desenvolupador.
|
*/
require directori('sys') . 'nucli.php';
/*
|--------------------------------------------------------------------------
| Reportem tots els errors
|--------------------------------------------------------------------------
|
| @todo: Si està en producció no es mostren
|
*/
error_reporting(-1);
$peticio = new Peticio();
$resposta = Resposta::fer($peticio->peticio);
$resposta->enviar();
function __autoload($nomClase)
{
    if (strstr($nomClase, 'Controlador')) {
        $nomControlador = str_replace('controlador', '', strtolower($nomClase));
        $fitxerControlador = directori('app') . 'controladors' . DS . $nomControlador . '.php';
        if (file_exists($fitxerControlador)) {
            require $fitxerControlador;
        }
        // @todo: else
    } else {
        // Ruta del model a incloure
        $fitxerModel = directori('app') . 'models' . DS . $nomClase . '.php';
        if (file_exists($fitxerModel)) {
            require $fitxerModel;
示例#3
0
				$resposta_filho = new Resposta();
				$resposta_filho->setId($resposta);
				#$resposta_filho->setPergunta($perg);
				$resposta_filho->setRespostaTexto($resposta_texto_filho);
				$resposta_filho->setRespostaCorreta($resposta_correta);
				$resposta_filho->setRespostaFilho($resposta_correta);

				$perg->addResposta($resposta_filho);
			}

			if (strlen($resposta_texto)==0){
				continue;
			}

			$resItem = new Resposta();
			$resItem->setId($resposta);
			#$resItem->setPergunta($perg);
			$resItem->setRespostaTexto($resposta_texto);
			$resItem->setRespostaCorreta($resposta_correta);
			$resItem->setRespostaFilho($resposta_filho);

			$perg->addResposta($resItem);
		}
		$sessionFacade->gravarPergunta($perg);

		/* ---------- UPLOAD DAS IMAGENS ---------- */
		$files = array();
		if (isset($_FILES['imagens'])){
			foreach ($_FILES['imagens'] as $k => $l) {
				foreach ($l as $i => $v) {
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     // Capiturar todos os campos
     $input = Input::all();
     // informar o id para o metodo unique
     $input['id'] = $id;
     // Busca validação no model
     $validator = Resposta::validate($input);
     // trata os erros
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator)->with('error', Util::message('MSG004'));
     } else {
         $inputs = array('pergunta_id' => Input::get('pergunta_id'), 'resposta' => Input::get('resposta'), 'data_hora' => Input::get('data_hora'), 'correta' => Input::get('correta'), 'nota' => Input::get('nota'));
         $this->resposta->find($id)->update($inputs);
         $this->resposta->find($id)->pergunta()->sync(Input::get('pergunta_id'));
         return Redirect::to('resposta')->with('success', Util::message('MSG005'));
     }
 }
示例#5
0
	function gravarProvaResposta(Resposta $resposta){

		if (strlen($resposta->getPergunta())==0){
			throw new Exception('Informe a pergunta!');
		}else{
			$resposta->Xpergunta = $resposta->getPergunta();
		}
		
		if (strlen($resposta->getRespostaCorreta())==0){
			$resposta->Xresposta_correta = " NULL ";
		}else{
			$resposta->Xresposta_correta = "'".$resposta->getRespostaCorreta()."'";
		}		

		if (strlen($resposta->getRespostaTexto())==0){
			$resposta->Xresposta_texto = " NULL ";
		}else{
			$resposta->Xresposta_texto = "'".$resposta->getRespostaTexto()."'";
		}

		if (!is_object($resposta->getRespostaFilho())){
			$resposta->Xresposta_filho = " NULL ";
		}else{
			$resposta->Xresposta_filho = $resposta->getRespostaFilho()->getId();
		}

		$provaRespostaDAO = new ProvaRespostaDAO(); 
		$provaRespostaDAO->setBancoDados($this->banco); 
		return $provaRespostaDAO->gravaDadosProvaResposta($resposta); 
	}