public function setPergunta(Pergunta $p)
 {
     if ($this->id != '') {
         $p->setIdCategoria($this->id);
         $this->perguntas->inserir($p);
     }
 }
Example #2
0
function Main()
{
    $classe = isset($_GET['cls']) ? $_GET['cls'] : null;
    $tipo = isset($_GET['tip']) ? $_GET['tip'] : null;
    $termo = $_GET['term'];
    $u = unserialize($_SESSION['usu']);
    $perg_atual = unserialize($_SESSION['perg']);
    if ($classe == 0) {
        $classe = null;
    }
    if ($tipo == 0) {
        $tipo = null;
    }
    $p = new Pergunta();
    $retorno = $p->ListaPerguntasAtivas($classe, $tipo, $termo, $perg_atual->getCodigo(), $u->getCodigo());
    $registros = count($retorno);
    if ($registros > 0) {
        $dados = "<strong>" . $registros . "</strong> @lng[perguntas encontradas]<br /><br />";
    } else {
        $dados = "@lng[Nenhuma pergunta encontrada]<br /><br />";
    }
    foreach ($retorno as $pergunta) {
        $dados .= '<img src="img/use-this.png" alt="@lng[Apontar para esta pergunta]" title="@lng[Apontar para esta pergunta]" onclick="javascript:fntAddPerguntaCombo(\'' . base64_encode($pergunta->Codigo) . '\', \'' . $pergunta->Texto . '\');">' . $pergunta->Texto . "<br /><hr />";
    }
    header('Content-Type: text/html; charset=iso-8859-1');
    echo $dados;
}
Example #3
0
function Main()
{
    $tpl = file_get_contents("tpl/cad-perg-agrup.html");
    $ag = new GrupoPergunta();
    $p = new Pergunta();
    $u = unserialize($_SESSION['usu']);
    $codigo = base64_decode($_GET['c']);
    if ($ag->Carrega($codigo)) {
        $_SESSION['agruperg'] = $ag->getCodgrupo();
        $perguntas = $p->ListaPerguntasAtivas(null, null, "", 0, $u->getCodigo());
        if (count($perguntas) > 0) {
            $retorno = "<h4>@lng[As perguntas marcadas são as já vinculadas a este agrupamento]</h4>";
            $cont = 0;
            foreach ($perguntas as $perg) {
                $cont++;
                if (!is_null($ag->getPerguntas()) && in_array($perg->Codigo, $ag->getPerguntas())) {
                    $retorno .= '<input type="checkbox" name="chkPerguntas[]" id="chkRelPergCaso_' . $cont . '" value="' . base64_encode($perg->Codigo) . '" class="campo" checked="checked" />' . $perg->Texto . '<br />';
                } else {
                    $retorno .= '<input type="checkbox" name="chkPerguntas[]" id="chkRelPergCaso_' . $cont . '" value="' . base64_encode($perg->Codigo) . '" class="campo" />' . $perg->Texto . '<br />';
                }
            }
        } else {
            $retorno = "@lng[Nenhum pergunta cadastrada no sistema]";
        }
        $botoes = Botao::BotaoSalvar("fntSalvaAgrupamento();", "@lng[Salvar as alterações do agrupamento]");
        $botoes .= Botao::BotaoVoltar("fntVoltar();", "@lng[Voltar para a listagem de agrupadores de pergunta]");
        $tpl = str_replace("<!--textoagrupador-->", $ag->getTexto(), $tpl);
        $tpl = str_replace("<!--listaexercicios-->", $retorno, $tpl);
        $tpl = str_replace("<!--telatopo-->", Comuns::GeraTopoPagina($u), $tpl);
        $tpl = str_replace("<!--itens-toolbar-->", $botoes, $tpl);
        echo $tpl;
    } else {
        echo "ERRO inesperado! " . $ag->getErro();
    }
}
Example #4
0
function Main()
{
    // Leitura do template
    $tpl = file_get_contents("tpl/perguntas.html");
    // Número de registros a exibir por página
    $limite = 10;
    $pagina = isset($_GET['pag']) ? $_GET['pag'] : 1;
    // Instancia a classe Pergunta
    $p = new Pergunta();
    // Se vier a instrução de inserir uma pergunta, faz isso
    $inserir = isset($_POST['txtDescricao']) ? $_POST['txtDescricao'] : null;
    if ($inserir) {
        $p->setDescricao($inserir);
        $p->adicionar();
    }
    //  Começa a listagem das perguntas já cadastradas
    // Retorna uma lista das perguntas cadastradas
    $lista = $p->listarperguntas($pagina, $limite);
    if ($lista != 0 && mysql_num_rows($lista) > 0) {
        // Se tem perguntas cadastradas, começa a montar a lista
        $html = '<ul>';
        while ($linha = mysql_fetch_array($lista)) {
            $html .= '<li>' . $linha["Descricao"] . ' ( <a href="javascript:void(0);">X</a> )</li>';
        }
        $html .= '</ul><br /><br />';
        // Verifica quantas perguntas tem cadastradas ao todo
        $registros = $p->contaperguntas();
        // Se for necessário, adiciona ao fim da página os links para navegação (da paginação)
        if ($pagina > 1) {
            $html .= '<a href="perguntas.php?pag=' . ($pagina - 1) . '">Anterior</a> | ';
        }
        if ($registros > $limite * $pagina) {
            $html .= '<a href="perguntas.php?pag=' . ($pagina + 1) . '">Proximo</a>';
        }
    } else {
        // Se não tem perguntas cadastradas, informa que não tem nenhuma
        $html = "@lng[Nenhuma pergunta cadastrada]";
    }
    $tpl = str_replace("<!--ListaPerguntas-->", $html, $tpl);
    header('Content-Type: text/html; charset=iso-8859-1');
    echo comuns::Idioma($tpl);
}
Example #5
0
 public function listar($ordem = "ASC", $campo = self::ID)
 {
     $info = parent::listar($ordem, $campo);
     if (!empty($info)) {
         $temp = new Pergunta($info[self::ID]);
         parent::resgatarObjetos($info);
         $temp->titulo = $info[self::TITULO];
         $temp->texto = $info[self::TEXTO];
         $temp->ordem = $info[self::ORDEM];
         if (!empty($info[self::IMAGEM])) {
             $lI = new ListaImagens();
             $lI->caminhoEscrita = Sistema::$caminhoDiretorio . Sistema::$caminhoDataFAQ;
             $lI->caminhoLeitura = Sistema::$caminhoURL . Sistema::$caminhoDataFAQ;
             $lI->condicoes('', $info[self::IMAGEM], ListaImagens::ID);
             if ($lI->getTotal() > 0) {
                 $temp->setImagem($lI->listar());
             }
         }
         $temp->setURL($info[parent::URL]);
         $temp->setIdCategoria($info[self::CATEGORIA]);
         return $temp;
     }
 }
Example #6
0
function Main()
{
    $p = $_SESSION['perg'];
    $codalt = isset($_GET['a']) && !is_null($_GET['a']) ? base64_decode($_GET['a']) : null;
    if (is_numeric($codalt)) {
        //$codperg = $p->getCodigo();
        $pergunta = new Pergunta();
        $pergunta->setCodigo($p);
        $alt = new Alternativa();
        $alt->Carrega($codalt);
        if ($pergunta->DeletaAlternativa($alt)) {
            //$pergunta->RecarregarAlternativas();
            //$_SESSION['perg'] = serialize($p);
            header("Location:vwalternativas.php?p=" . base64_encode($p));
        } else {
            $erros = "Erros ocorreram.";
            foreach ($p->msg_erro as $err) {
                $erros .= "<br />" . $err;
            }
            echo $erros;
        }
    }
}
Example #7
0
function Main()
{
    $codigo = isset($_POST['txtCodigo']) ? base64_decode($_POST['txtCodigo']) : null;
    $txt = urldecode($_POST['txtDescricao']);
    $clsAtual = $_POST['selClasse'];
    $nivAtual = $_POST['selNivel'];
    $tipAtual = $_POST['selTipo'];
    $ativo = $_POST['selAtivo'];
    $act = isset($_POST['act']) ? base64_decode($_POST['act']) : null;
    $expGeral = $_POST['txtExplicacaoGeral'];
    $u = unserialize($_SESSION['usu']);
    // Ação veio vazio. Sendo assim monta o formulário.
    if (!$act) {
        // Busca o template
        $tpl = file_get_contents('tpl/perguntas-E1.html');
        $tpl = str_replace("<!--telatopo-->", Comuns::GeraTopoPagina($u), $tpl);
        $botoes = Botao::BotaoSalvar("fntGravaE1();", "@lng[Salvar pergunta e cadastrar/editar alternativas]");
        $botoes .= Botao::BotaoCancelar("fntNavega('listagem.php?t=8');", "@lng[Cancelar edição]");
        $tpl = str_replace("<!--itens-toolbar-->", $botoes, $tpl);
        $tpl = str_replace("<!--Mensagem-->", isset($mensagem) && $mensagem != "" ? base64_decode($mensagem) : "", $tpl);
        // Verifica se veio um registro informado via GET
        if (is_null($codigo)) {
            $codigo = isset($_GET['r']) ? base64_decode($_GET['r']) : null;
        }
        // Instancia classe
        $p = new Pergunta();
        // Se veio um código via GET, entende-se que o mesmo deva ser editado.
        if (!is_null($codigo)) {
            $p->Carregar($codigo);
        }
        $tipos = $p->tipos->ListaRecordSet();
        $classes = $p->classes->ListaRecordSet();
        $niveis = $p->niveis->ListaRecordSet();
        $strtipos = "";
        $strclasses = "";
        $strniveis = "";
        foreach ($tipos as $linhat) {
            $strtipos .= '<option ' . ($linhat->Codigo == ($p->getTipo() != null ? $p->getTipo()->getCodigo() : 0) ? 'selected="selected"' : '') . ' value="' . $linhat->Codigo . '">' . $linhat->Descricao . '</option>';
        }
        foreach ($classes as $linhac) {
            $strclasses .= '<option ' . ($linhac->Codigo == $p->getClasse() ? 'selected="selected"' : '') . ' value="' . $linhac->Codigo . '">' . $linhac->Descricao . '</option>';
        }
        foreach ($niveis as $linhan) {
            $strniveis .= '<option ' . ($linhan->Codigo == $p->getNivel() ? 'selected="selected"' : '') . ' value="' . $linhan->Codigo . '">' . $linhan->Descricao . '</option>';
        }
        $strAtivo = '<option ' . ($p->getAtivo() == 1 ? 'selected="selected"' : "") . ' value="1">@lng[Sim]</option><option ' . ($p->getAtivo() == 0 ? 'selected="selected"' : "") . ' value="0">@lng[Não]</option>';
        $tpl = str_replace("<!--txtCodigo-->", $p->getCodigo() == 0 ? "" : base64_encode($p->getCodigo()), $tpl);
        $tpl = str_replace("<!--TextoPergunta-->", $p->getTexto(), $tpl);
        $tpl = str_replace("<!--txtExplicacaoGeral-->", is_null($p->getTextoExplicacaoGeral()) ? "" : $p->getTextoExplicacaoGeral(), $tpl);
        $tpl = str_replace("<!--ListaClasses-->", $strclasses, $tpl);
        $tpl = str_replace("<!--ListaNiveis-->", $strniveis, $tpl);
        $tpl = str_replace("<!--ListaAtivo-->", $strAtivo, $tpl);
        $tpl = str_replace("<!--ListaTipos-->", $strtipos, $tpl);
    } else {
        if ($act == "ins") {
            $p = new Pergunta();
            if (!is_null($codigo)) {
                $p->setCodigo($codigo);
            }
            $p->setTexto($txt);
            $p->setClasse($clsAtual);
            $p->setNivel($nivAtual);
            $p->setTipo($tipAtual);
            $p->setAtivo($ativo);
            if ($expGeral != "") {
                $p->setTextoExplicacaoGeral($expGeral);
            }
            if ($p->getCodigo() === 0) {
                if ($p->AdicionaPergunta() === true) {
                    $_SESSION['perg'] = serialize($p);
                    header("Location:alternativas.php");
                } else {
                    $_SESSION['perg'] = "";
                    echo "@lng[Erro ao adicionar a pergunta:]";
                }
            } else {
                if ($p->AtualizaPergunta() === true) {
                    $_SESSION['perg'] = serialize($p);
                }
            }
        }
    }
    echo Comuns::Idioma($tpl);
}
Example #8
0
function fntRetornaExercicios()
{
    if (isset($_SESSION['caso']) && $_SESSION['caso'] > 0) {
        $per = new Pergunta();
        $lista = $per->ListaPerguntasCaso($_SESSION['caso']);
        if ($lista != false && count($lista) > 0) {
            $html = Comuns::TopoTabelaListagem("", "tabExercicios", array('&nbsp;', 'Exercício', 'Classe', 'Núm. Alternativas'));
            foreach ($lista as $perg) {
                $html .= '<tr title="Tipo: ' . $perg->Tipo . '">';
                $html .= '<td><input type="checkbox" id="chk_perg_' . $perg->CodPergunta . '" class="item_arvore"></td>';
                $html .= '<td><span id="spn_perg_' . $perg->CodPergunta . '">' . $perg->Texto . '</span></td>';
                $html .= '<td>' . $perg->Classe . '</td>';
                $html .= '<td>' . $perg->Alternativas . '</td>';
                $html .= '</tr>';
            }
            $html .= "</tbody></table>";
            return $html;
        } else {
            return "@lg[Nenhum exercício cadastrado ou nenhum exercício vinculado ao caso clínico]";
        }
    } else {
        return "@lng[Caso não encontrado]";
    }
}
Example #9
0
function Main()
{
    header('Content-Type: text/html; charset=iso-8859-1');
    if (isset($_SESSION['caso']) && $_SESSION['caso'] > 0) {
        if ($_POST['tip'] == "tree") {
            $mon = new Montagem();
            $mon->setCodCaso($_SESSION['caso']);
            $html = $mon->RetornaArvoreLista();
            if ($html) {
                $html = str_replace('<div id="tree">', '<div id="' . $_POST['id'] . '">', $html);
            } else {
                $html = "ERRO: " . $mon->getErro();
            }
            echo $html;
        } else {
            if ($_POST['tip'] == "opts") {
                if (!$_POST['perg']) {
                    $res = new Resolucao();
                    $res->setCodcaso($_SESSION['caso']);
                    $hash = $res->BuscaConteudoPelaChave($_POST['nodo'], true);
                    if ($hash != false) {
                        echo $hash->ToXML();
                    } else {
                        echo "ERRO. Hash voltou false";
                    }
                } else {
                    $pergunta = new Pergunta();
                    $pergunta->Carregar($_POST['perg']);
                    if ($pergunta->getTipo()->getCodigo() == 1) {
                        $cont = 1;
                        foreach ($pergunta->getAlternativas() as $alternativa) {
                            $html .= '<div class="alt-img">';
                            $html .= '<input type="checkbox" name="rdoAlternativa_' . $pergunta->getCodigo() . '[]" id="rdoAlt_' . $pergunta->getCodigo() . '_' . $cont . '" value="' . $alternativa->getCodBinario() . '" class="opcao-resposta" />' . $alternativa->getTexto();
                            $html .= '<div id="img"><img src="' . $alt->getImagem() . '" alt="' . $alt->getTexto() . '" title="' . $alt->getTexto() . '" class="img-preview" /></div>';
                            $html .= '</div>';
                            $cont++;
                        }
                    } else {
                        $cont = 1;
                        foreach ($pergunta->getAlternativas() as $alternativa) {
                            $html .= '<div class="alt-txt">';
                            $html .= '<input type="checkbox" name="rdoAlternativa_' . $pergunta->getCodigo() . '[]" id="rdoAlt_' . $pergunta->getCodigo() . '_' . $cont . '" value="' . $alternativa->getCodBinario() . '" class="opcao-resposta" />' . $alternativa->getTexto();
                            $html .= '</div>';
                            $cont++;
                        }
                    }
                    echo '<conteudo>' . $html . '</conteudo>';
                }
            } else {
                if ($_POST['tip'] == 'pergs') {
                    //$arrNodo = split("_", $_POST['nodo']);
                    Log::RegistraLog("Vai consultas as perguntas vinculadas ao nodo: " . $arrNodo[3]);
                    $mon = new Montagem();
                    $mon->setCodCaso($_SESSION['caso']);
                    $lista = $mon->ListaPerguntasNodo($_POST['nodo']);
                    if ($lista) {
                        $html .= '<option value="-1">@lng[Selecione]</option>';
                        foreach ($lista as $perg) {
                            $html .= '<option value="' . $perg->Codigo . '">' . substr($perg->Texto, 0, 100) . '</option>';
                        }
                    } else {
                        $html .= '<option>' . $mon->getErro() . '</option>';
                    }
                    echo $html;
                } else {
                    if ($_POST['tip'] == 'salvacond') {
                        $arrNodoAtual = split("_", $_POST['nodoatual']);
                        $arrNodoDestino = split("_", $_POST['nododes']);
                        if ($_POST['nodocond']) {
                            $arrNodoCond = split("_", $_POST['nodocond']);
                            $strChaveCond = $arrNodoCond[3];
                            if ($_POST['perg']) {
                                $intPerg = $_POST['perg'];
                            } else {
                                $intPerg = null;
                            }
                            $intResp = $_POST['resp'];
                        } else {
                            $strChaveCond = null;
                            $intResp = null;
                            $intPerg = null;
                        }
                        $strChaveAtual = $arrNodoAtual[3];
                        $strChaveDestino = $arrNodoDestino[3];
                        $mon = new Montagem();
                        $mon->setCodCaso($_SESSION['caso']);
                        $desvio = $mon->InsereSalto($strChaveAtual, $strChaveDestino, $strChaveCond, $intPerg, $intResp);
                        if ($desvio) {
                            $html = $mon->RetornaListaConfSaltos($strChaveAtual);
                            if ($html) {
                                echo $html;
                            } else {
                                echo "ERRO: " . $mon->getErro();
                            }
                        } else {
                            echo "ERRO: " . $mon->getErro();
                        }
                    } else {
                        if ($_POST['tip'] == 'mudaprior') {
                            $mon = new Montagem();
                            $mon->setCodCaso($_SESSION['caso']);
                            if ($mon->AlteraPrioridadeSalto($_POST['mm'], base64_decode($_POST['chaveOri']), base64_decode($_POST['chaveDest']))) {
                                echo $mon->RetornaListaConfSaltos(base64_decode($_POST['chaveOri']));
                            } else {
                                echo "ERRO: " . $mon->getErro();
                            }
                        } else {
                            if ($_POST['tip'] == 'delsalto') {
                                $mon = new Montagem();
                                $mon->setCodCaso($_SESSION['caso']);
                                if ($mon->DeletaSalto(base64_decode($_POST['chaveOri']), base64_decode($_POST['chaveDest']))) {
                                    echo $mon->RetornaListaConfSaltos(base64_decode($_POST['chaveOri']));
                                } else {
                                    echo "ERRO: " . $mon->getErro();
                                }
                            } else {
                                if ($_POST['tip'] == 'vincanexo') {
                                    $mon = new Montagem();
                                    $mon->setCodCaso($_SESSION['caso']);
                                    $nodo = $_POST['item'];
                                    $cont = $_POST['cont'];
                                    $strTipoCont = substr($cont, 0, 1);
                                    $arr = split("_", $nodo);
                                    $u = unserialize($_SESSION['usu']);
                                    if ($mon->InsereAnexo($arr[3], base64_decode(substr($cont, 1)), $strTipoCont, $u->getCodigo())) {
                                        echo $mon->RetornaListaConfAnexos($arr[3]);
                                    } else {
                                        echo 'ERRO: ' . $mon->getErro();
                                    }
                                } else {
                                    if ($_POST['tip'] == 'delanexo') {
                                        $mon = new Montagem();
                                        $mon->setCodCaso($_SESSION['caso']);
                                        $nodo = base64_decode($_POST['item']);
                                        $cont = $_POST['cont'];
                                        $strTipoCont = substr($cont, 0, 1);
                                        //$arr = split("_", $nodo);
                                        //die("ERRO: " . $nodo . ' ' . base64_decode(substr($cont, 1)));
                                        if ($mon->DeletaAnexo($nodo, base64_decode(substr($cont, 1)), $strTipoCont)) {
                                            $listagem = $mon->RetornaListaConfAnexos($nodo);
                                            if ($listagem !== false) {
                                                echo $listagem;
                                            } else {
                                                echo "ERRO: " . $mon->getErro();
                                            }
                                        } else {
                                            echo 'ERRO: ' . $mon->getErro();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    } else {
        echo "ERRO: @lng[Caso não informado]";
    }
}
Example #10
0
	public function recuperarPergunta($id_pergunta){

		$query ="SELECT tbl_pergunta.pergunta           AS pergunta,
						tbl_pergunta.topico             AS topico,
						tbl_pergunta.tipo_pergunta      AS tipo_pergunta,
						tbl_pergunta.titulo             AS titulo,
						tbl_pergunta.dificuldade        AS dificuldade,
						tbl_pergunta.fonte              AS fonte,
						tbl_pergunta.ativa              AS ativa
				FROM tbl_pergunta
				WHERE tbl_pergunta.pergunta = $id_pergunta ";

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

			if ($banco->numRows($retorno) == 0){
				throw new Exception("Nenhuma pergunta encontrado.",0);
			}

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

				$sessionFacade		= new SessionFacade($banco); 
				$obj_topico			= $sessionFacade->recuperarTopico($linha["topico"]);
				$obj_tipo_pergunta	= $sessionFacade->recuperarTipoPergunta($linha["tipo_pergunta"]);

				$pergunta = new Pergunta(); 
				$pergunta->setId($linha['pergunta']);
				$pergunta->setTopico($obj_topico);
				$pergunta->setTipoPergunta($obj_tipo_pergunta);
				$pergunta->setTitulo($linha["titulo"]);
				$pergunta->setDificuldade($linha["dificuldade"]);
				$pergunta->setFonte($linha["fonte"]);
				$pergunta->setAtiva($linha["ativa"]);

				$query ="SELECT tbl_resposta.resposta            AS resposta,
								tbl_resposta.pergunta            AS pergunta,
								tbl_resposta.resposta_texto      AS resposta_texto,
								tbl_resposta.resposta_correta    AS resposta_correta,
								tbl_resposta.resposta_filho      AS resposta_filho
						FROM tbl_resposta
						JOIN tbl_pergunta      USING(pergunta)
						WHERE tbl_pergunta.pergunta = $id_pergunta";

				if ($obj_tipo_pergunta->getId()=="4" or $obj_tipo_pergunta->getId()=="5"){
					$query .= " AND tbl_resposta.resposta_filho IS NOT NULL ";
				}
				$resposta_item = NULL; 

				$retorno_item = $banco->executaSQL($query); 
				if($retorno_item != NULL) {
					while($linha_item = $banco->fetchArray($retorno_item)) { 

/*	COMENTADO - ACHO que esta parte toda nao precisa, e sim somente da parte de baizo...testar e se der algum problema voltar a tras.
						if (strlen(trim($linha_item["resposta_filho"]))>0){
							$obj_resposta_filho = $sessionFacade->recuperarResposta($linha_item["resposta_filho"]);
						}else{
							$obj_resposta_filho = NULL;
						}

						$resposta_item = new Resposta(); 
						$resposta_item->setId($linha_item['resposta']);
						$resposta_item->setPergunta($linha_item['pergunta']);
						$resposta_item->setRespostaTexto($linha_item['resposta_texto']);
						$resposta_item->setRespostaCorreta($linha_item['resposta_correta']);
						$resposta_item->setRespostaFilho($obj_resposta_filho);
						$pergunta->addResposta($resposta_item);
*/

						$resposta_item = $sessionFacade->recuperarResposta($linha_item["resposta"]); 
						$pergunta->addResposta($resposta_item);
					}
				}
			}
			return $pergunta; 
		} else {
			throw new Exception("Erro ao recuperar Pergunta ($query)"); 
		}
	}
<?php

importar("Utilidades.FAQ.Lista.ListaPerguntaCategorias");
$tituloPagina = 'Utilidades > FAQ > Perguntas > Cadastrar';
$iTP = new IFAdmin(new Arquivos(Sistema::$adminLayoutCaminhoDiretorio . "/SistemaUtilidades/pergunta.html"));
$lI = new ListaIdiomas();
if (!empty($_POST)) {
    $erro = '';
    if (empty($_POST['titulo'])) {
        $erro = "<b>Titulo</b> não preenchido!<br><br>";
    }
    if (empty($erro)) {
        $p = new Pergunta();
        $p->titulo = $_POST['titulo'];
        $p->ordem = $_POST['ordem'];
        $p->texto = $_POST['texto'];
        if (!empty($_FILES['imagem']['name'])) {
            $p->getImagem()->setImage(new Image(Arquivos::__OpenArquivoByTEMP($_FILES['imagem'])));
        }
        $lPC = new ListaPerguntaCategorias();
        $pC = $lPC->condicoes('', $_POST['categoria'], ListaPerguntaCategorias::ID)->listar();
        $pC->setPergunta($p);
        $p->getURL()->setURL($_POST['url'] ? $_POST['url'] : $p->getId() . "-" . strtolower(Strings::__RemoveAcentos(str_replace("\"", "", str_replace("'", "", str_replace(" ", "-", $_POST['titulo']))))));
        $lP = new ListaPerguntas();
        $lP->alterar($p);
        while ($i = $lI->listar()) {
            $t = new Traducao();
            $t->setIdConteudo($p->getId());
            $t->setCampoConteudo(ListaPerguntas::TITULO);
            $t->setTabelaConteudo($pC->getPerguntas()->getTabela());
            $t->conteudo = $p->titulo;
Example #12
0
//Cria objeto "questionário" e busca suas informações no banco.
$questionario = new Questionario();
$questionario->consultaQuest($_POST["quest_codigo"]);
//Cria vetores que armazenam as perguntas, alternativas e ordem de apresentação desse questionário
$ordemPerguntas = array();
$todasPerguntas = array();
$todasAlternativas = array();
//Recupera lista de perguntas e a ordem das mesmas do banco de dados.
$query = "SELECT * FROM ordem_perguntas WHERE quest_codigo = " . $questionario->getCodigo() . ";";
$resultado = $conexao->executaComando($query);
while ($linha = mysqli_fetch_array($resultado)) {
    array_push($ordemPerguntas, array("perg_codigo" => $linha["perg_codigo"], "perg_ordem" => $linha["perg_ordem"]));
}
//Busca as perguntas no banco e as armazena nos vetores.
for ($i = 0; $i < $questionario->getNumPerguntas(); $i++) {
    $pergunta = new Pergunta();
    $pergunta->consultaPergunta($ordemPerguntas[$i]["perg_codigo"]);
    $pergunta->setNumPergunta($ordemPerguntas[$i]["perg_ordem"]);
    array_push($todasPerguntas, $pergunta);
    if ($pergunta->getTipo() != "D") {
        $alternativas = new Pergunta_alternativa();
        $alternativas->consultaAlternativas($pergunta->getCodigo());
        $todasAlternativas[$ordemPerguntas[$i]["perg_ordem"]] = $alternativas;
        unset($alternativas);
    }
    unset($pergunta);
}
//Insere informações na sessão
$_SESSION["questionario"] = serialize($questionario);
$_SESSION["todasPerguntas"] = serialize($todasPerguntas);
$_SESSION["todasAlternativas"] = serialize($todasAlternativas);
Example #13
0
	function gravarPergunta(Pergunta $pergunta){

		if (strlen($pergunta->getTitulo())==0){
			throw new Exception('Informe o título da pergunta!');
		}else{
			$pergunta->Xtitulo = "'".$pergunta->getTitulo()."'";
		}

		if (!is_object($pergunta->getTipoPergunta())){
			throw new Exception('Informe o tipo da pergunta!');
		}else{
			$pergunta->Xtipo_pergunta = $pergunta->getTipoPergunta()->getId();
		}

		if (!is_object($pergunta->getTopico())){
			throw new Exception('Informe o tópico da pergunta!');
		}else{
			$pergunta->Xtopico = $pergunta->getTopico()->getId();
		}

		if (strlen($pergunta->getDificuldade())==0){
			throw new Exception('Selecione a dificuldade da perguta!');
		}else{
			$pergunta->Xdificuldade = $pergunta->getDificuldade();
		}

		if (strlen($pergunta->getFonte())==0){
			$pergunta->Xfonte = " NULL ";
		}else{
			$pergunta->Xfonte = "'".$pergunta->getFonte()."'";
		}

		if (strlen($pergunta->getAtiva())==0){
			$pergunta->Xativa = 0;
		}else{
			$pergunta->Xativa = $pergunta->getAtiva();
		}

		$perguntaDAO = new PerguntaDAO(); 
		$perguntaDAO->setBancoDados($this->banco); 
		$perguntaDAO->gravaDadosPergunta($pergunta); 
		$perguntaDAO->apagarRespostas($pergunta); 
#echo nl2br($pergunta->getQtdeResposta());
#echo "<br>";
		for ($i=0;$i<$pergunta->getQtdeResposta();$i++){
			$pergunta->getResposta($i)->setPergunta($pergunta->getId());
			$this->gravarResposta($pergunta->getResposta($i)); 
		}
	}
Example #14
0
if ($_SESSION["user_tipo"] != "P") {
    header('location: permission_denied.php');
}
//Verifica se usuário está logado, caso contrário vai para o login
if (!isset($_SESSION['user_nome']) && empty($_SESSION['user_nome'])) {
    header('location: logout.php');
}
//Instância objeto Questionário e recebe seus valores da Sessão
$questionario = new Questionario();
$questionario = unserialize($_SESSION["questionario"]);
//Recebe número de perguntas que o questinoário já tem e adiciona +1, salva esse valor em "numDaPergunta"
$numDaPergunta = $_SESSION["numPerguntas"] + 1;
//Cria um vetor com os objetos do tipo "Pergunta" e recebe seu valor da sessão
$perguntas = unserialize($_SESSION["perguntas"]);
//Instância objeto do tipo "Pergunta" para armazenar valores da pergunta atual
$perguntaAtual = new Pergunta();
//Cria um vetor com os objetos do tipo "Pergunta_alternativa" e recebe seu valor da sessão
$perguntas_alternativas = unserialize($_SESSION["perguntas_alternativas"]);
//Instância objeto do tipo "Pergunta_alternativa" para armazenar alternativas da pergunta atual
$alternativas = new Pergunta_alternativa();
$conexao = new Conexao();
//Bloco de código que vai ser executado após o "POST" ser enviado pelo formulário
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    //Testa se a pergunta é de Alternativas, para poder criá-las
    if ($_POST["tipo_pergunta"] == "Alternativa" || $_POST["tipo_pergunta"] == "Verdadeiro/Falso") {
        //Cria vetor onde vai ficar armazenado se cada alternativa é correta ou não
        $altCorretas = array();
        //Percorre as alternativas para verificar se elas são corretas ou não, e salva essas informações no vetor
        if ($_POST["tipo_pergunta"] == "Alternativa") {
            for ($i = 1; $i <= $_POST["num_alternativas"]; $i++) {
                if ($_POST["alt_correta"] == $i) {
Example #15
0
 private function MontaConteudoPerguntas($codpergunta, $dica = true, $agrupar = false)
 {
     $perg = new Pergunta();
     $perg->Carregar($codpergunta);
     $conteudo .= '<div class="pergunta">';
     $conteudo .= '  <div id="pergunta-texto">';
     $conteudo .= '    <img id="img_perg_' . $codpergunta . '" src="img/question.png" alt="@lng[Pergunta]" title="@lng[Pergunta]" class="img-pergunta atualizar-resp">' . $perg->getTexto();
     $conteudo .= '  </div>';
     if ($dica) {
         switch ($perg->getTipo()->getCodigo()) {
             case 1:
             case 3:
                 $conteudo .= '<div id="pergunta-instr">@lng[Escolha uma das alternativas]</div>';
                 break;
             case 2:
                 $conteudo .= '<div id="pergunta-instr">@lng[Você pode escolher mais de uma alternativa se achar necessário]</div>';
                 break;
         }
     }
     $alternativas = $perg->getAlternativas();
     $cont = 1;
     $letra = 65;
     foreach ($alternativas as $alt) {
         switch ($perg->getTipo()->getCodigo()) {
             case 1:
                 $conteudo .= '<div class="alt-img">';
                 $conteudo .= '  <div class="alt-img-radio">';
                 $conteudo .= '    ' . chr($letra) . ') <input type="radio" name="rdoAlternativa' . ($agrupar ? '_' . $perg->getCodigo() : '') . '[]" id="rdoAlt_' . $cont . '" value="' . $alt->getCodUnico() . '" class="opcao-resposta" />';
                 $conteudo .= '  </div>';
                 $conteudo .= '  <div id="img"><img src="' . $alt->getImagem() . '" alt="' . $alt->getTexto() . '" title="' . $alt->getTexto() . '" /></div>';
                 $conteudo .= '</div>';
                 break;
             case 2:
                 $conteudo .= '<div class="alt-txt">';
                 $conteudo .= '  ' . chr($letra) . ') <input type="checkbox" name="rdoAlternativa' . ($agrupar ? '_' . $perg->getCodigo() : '') . '[]" id="rdoAlt_' . $cont . '" value="' . $alt->getCodUnico() . '" class="opcao-resposta" />' . $alt->getTexto();
                 $conteudo .= '</div>';
                 break;
             case 3:
                 $conteudo .= '<div class="alt-txt">';
                 $conteudo .= '  ' . chr($letra) . ') <input type="radio" name="rdoAlternativa' . ($agrupar ? '_' . $perg->getCodigo() : '') . '[]" id="rdoAlt_' . $cont . '" value="' . $alt->getCodUnico() . '" class="opcao-resposta" />' . $alt->getTexto();
                 $conteudo .= '</div>';
                 break;
         }
         $cont++;
         $letra++;
     }
     $conteudo .= '</div>';
     return $conteudo;
 }
Example #16
0
function Main()
{
    if (isset($_SESSION['casores']) && $_SESSION['casores'] > 0) {
        $u = unserialize($_SESSION['usu']);
        $intCodCaso = $_SESSION['casores'];
        $intResolucao = Resolucao::BuscaUltimaResolucaoCaso($intCodCaso, $u->getCodigo(), 3);
        $_SESSION['codresolucao'] = $intResolucao;
        $tpl = file_get_contents("tpl/aluno/resumo.html");
        $fe = new Fechamento();
        $fe->setCodcaso($intCodCaso);
        $fe->setCodresolucao($intResolucao);
        $basicos = $fe->RetornaDadosBasicos();
        if ($basicos !== false) {
            $strNome = split(' ', $basicos->NomeCompleto);
            $tpl = str_replace('<!--titulocaso-->', $basicos->Caso, $tpl);
            $tpl = str_replace('<!--NomeUsuario-->', $strNome[0], $tpl);
            $tpl = str_replace('<!--DataInicial-->', date("d/m/Y H:i:s", strtotime($basicos->DataInicio)), $tpl);
            $tpl = str_replace('<!--DataFinal-->', date("d/m/Y H:i:s", strtotime($basicos->DataFim)), $tpl);
            $tpl = str_replace('<!--NumAcessos-->', $basicos->NumAcessos, $tpl);
            $tpl = str_replace('<!--ConteudosVistos-->', $basicos->ConteudosVistos, $tpl);
            $trajetoria = $fe->RetornaTrajetoria();
            if ($trajetoria) {
                $caminho = '<table><tr><td class="dado">@lng[Item]</td><td class="dado">@lng[Data/Hora]</td></tr>';
                foreach ($trajetoria as $etapa) {
                    $caminho .= '<tr>';
                    $caminho .= '<td><img src="img/' . $etapa->TipoConteudo . '_mini.png" />' . $etapa->Conteudo . '</td><td>' . date("d/m/Y H:i:s", strtotime($etapa->DataHora)) . '</td>';
                    $caminho .= '</tr>';
                }
                $caminho .= '</table>';
                $tpl = str_replace('<!--ListaTrajeto-->', $caminho, $tpl);
                $interativas = $fe->RetornaEtapasInterativas();
                if ($interativas) {
                    $intNumCertas = 0;
                    $intNumErradas = 0;
                    $intNumTotalAlt = 0;
                    $tpl = str_replace('<!--NumEtapasInterativas-->', count($interativas), $tpl);
                    $contInt = 1;
                    $contUnico = 1;
                    $res = new Resolucao();
                    foreach ($interativas as $item) {
                        //$res = new Resolucao();
                        //$respostas = $res->BuscaRespostas($item->ChaveItem);
                        if ($item->TipoConteudo != 'perg' && $item->TipoConteudo != 'grupo-perg') {
                            $htmlInterativas .= '<div class="item-interativo">@lng[Etapa:] <strong>' . $item->Conteudo . '</strong></div>';
                            $htmlInterativas .= '<div class="det-etapa-int">@lng[Número de tentivas de resposta:] <span class="dado">' . $item->Tentativas . '</span></div>';
                            $respostas = $res->BuscaRespostas($item->ChaveItem);
                            $alternativas = $fe->RetornaConteudosDoItemDaMontagem($item->ChaveItem, $item->TipoConteudo);
                            if ($alternativas) {
                                $htmlInterativas .= '<div class="det-etapa-int">';
                                $htmlInterativas .= '<table class="listadados">';
                                $htmlInterativas .= '<tr class="head">';
                                $htmlInterativas .= '<td class="td-col-alt">@lng[Alternativa]</td>';
                                $htmlInterativas .= '<td class="td-col-correto">@lng[Gabarito]</td>';
                                $htmlInterativas .= '<td class="td-col-escolha">@lng[Você marcou]</td>';
                                $htmlInterativas .= '<td class="td-col-jus">&nbsp;</td>';
                                $htmlInterativas .= '<td class="td-col-compl">&nbsp;</td>';
                                $htmlInterativas .= '</tr>';
                                $contAlt = 1;
                                foreach ($alternativas as $alternativa) {
                                    $htmlInterativas .= '<tr class="norm">';
                                    $htmlInterativas .= '<td class="dado td-col-alt">' . $alternativa->Titulo . '</td>';
                                    $htmlInterativas .= '<td class="td-col-correto">' . ($alternativa->Correto == 1 ? Comuns::IMG_STATUS_CERTO : Comuns::IMG_STATUS_ERRADO) . '</td>';
                                    $htmlInterativas .= '<td class="td-col-escolha">' . ((intval($respostas) & intval($alternativa->ValorOpt)) > 0 ? Comuns::IMG_ITEM_PINO : '') . '</td>';
                                    $htmlInterativas .= '<td class="td-col-jus">' . (strip_tags($alternativa->Justificativa) != '' ? '<a href="javascript:void(0);" onclick="javascript:fntDetItem(\'j\', \'' . $contInt . '\', \'' . $contAlt . '\');">@lng[Ver detalhes]</a>' : '') . '</td>';
                                    $htmlInterativas .= '<td class="td-col-compl">' . (strip_tags($alternativa->ConteudoAdicional) != '' ? '<a href="javascript:void(0);" onclick="javascript:fntDetItem(\'c\', \'' . $contInt . '\', \'' . $contAlt . '\');">@lng[Ver complemento]</a>' : '') . '</td>';
                                    $htmlInterativas .= '</tr>';
                                    if (strip_tags($alternativa->Justificativa) != '') {
                                        $htmlInterativas .= '<tr style="display:none;" id="jus-' . $contInt . '-' . $contAlt . '">';
                                        $htmlInterativas .= '<td colspan="5" class="apre-just"><div class="cont-just">' . $alternativa->Justificativa . '</div></td>';
                                        $htmlInterativas .= '</tr>';
                                    }
                                    if (strip_tags($alternativa->ConteudoAdicional) != '') {
                                        $htmlInterativas .= '<tr style="display:none;" id="contadi-' . $contInt . '-' . $contAlt . '">';
                                        $htmlInterativas .= '<td colspan="5" class="apre-compl"><div class="cont-compl">' . $alternativa->ConteudoAdicional . '</div></td>';
                                        $htmlInterativas .= '</tr>';
                                    }
                                    // Contabilização das respostas certas ou erradas
                                    if ($alternativa->Correto == 1) {
                                        if ((intval($respostas) & intval($alternativa->ValorOpt)) > 0) {
                                            $intNumCertas++;
                                        } else {
                                            $intNumErradas++;
                                        }
                                    } else {
                                        if ((intval($respostas) & intval($alternativa->ValorOpt)) > 0) {
                                            $intNumErradas++;
                                        } else {
                                            $intNumCertas++;
                                        }
                                    }
                                    $contAlt++;
                                    $contUnico++;
                                }
                                $intNumTotalAlt += $contAlt;
                                $htmlInterativas .= '</table>';
                                $htmlInterativas .= '</div>';
                            } else {
                                die($fe->getErro() . ' Alternativas');
                            }
                            $htmlInterativas .= '<div class="espacador"></div>';
                        } else {
                            if ($item->TipoConteudo == 'perg') {
                                $perg = new Pergunta();
                                $perg->Carregar($item->CodPergunta);
                                if (!is_null($perg->getTextoExplicacaoGeral()) && $perg->getTextoExplicacaoGeral() != '') {
                                    $boolExplicacao = true;
                                } else {
                                    $boolExplicacao = false;
                                }
                                $htmlInterativas .= '<div class="item-interativo">@lng[Etapa:] <strong>' . $item->Conteudo . '</strong>' . ($boolExplicacao ? '<span style="float:right;"><a href="javascript:void(0);" onclick="javascript:fntMostraOculta(\'exp-' . $perg->getCodigo() . '\');"><img src="img/info.gif" alt="@lng[Mais informações]" title="@lng[Mais informações]" /></a></span>' : '') . '</div>';
                                if ($boolExplicacao) {
                                    $htmlInterativas .= '<div class="explicacao-item" id="exp-' . $perg->getCodigo() . '" style="display:none;">' . $perg->getTextoExplicacaoGeral() . '</div>';
                                }
                                $htmlInterativas .= '<div class="det-etapa-int">@lng[Número de tentivas de resposta:] <span class="dado">' . $item->Tentativas . '</span></div>';
                                $respostas = $res->BuscaRespostas($item->ChaveItem, $item->CodPergunta);
                                $alternativas = $fe->RetornaAlternativasDaPergunta($item->CodPergunta);
                                if ($alternativas) {
                                    $htmlInterativas .= '<div class="det-etapa-int">';
                                    $htmlInterativas .= '<table class="listadados">';
                                    $htmlInterativas .= '<tr class="head">';
                                    $htmlInterativas .= '<td class="td-col-alt">@lng[Alternativa]</td>';
                                    $htmlInterativas .= '<td class="td-col-correto">@lng[Gabarito]</td>';
                                    $htmlInterativas .= '<td class="td-col-escolha">@lng[Você marcou]</td>';
                                    $htmlInterativas .= '<td class="td-col-jus">&nbsp;</td>';
                                    $htmlInterativas .= '<td class="td-col-compl">&nbsp;</td>';
                                    $htmlInterativas .= '</tr>';
                                    $contAlt = 1;
                                    foreach ($alternativas as $alternativa) {
                                        $htmlInterativas .= '<tr class="norm">';
                                        $htmlInterativas .= '<td class="dado td-col-alt">' . $alternativa->Alternativa . '</td>';
                                        $htmlInterativas .= '<td class="td-col-correto">' . ($alternativa->Correto == 1 ? Comuns::IMG_STATUS_CERTO : Comuns::IMG_STATUS_ERRADO) . '</td>';
                                        $htmlInterativas .= '<td class="td-col-escolha">' . ((intval($respostas) & intval($alternativa->ValorOpt)) > 0 ? Comuns::IMG_ITEM_PINO : '') . '</td>';
                                        $htmlInterativas .= '<td class="td-col-jus">' . (strip_tags($alternativa->Explicacao) != '' ? '<a href="javascript:void(0);" onclick="javascript:fntDetItem(\'j\', \'' . $contInt . '\', \'' . $contAlt . '\');">@lng[Ver detalhes]</a>' : '') . '</td>';
                                        $htmlInterativas .= '<td class="td-col-compl">&nbsp;</td>';
                                        $htmlInterativas .= '</tr>';
                                        if (strip_tags($alternativa->Explicacao) != '') {
                                            $htmlInterativas .= '<tr style="display:none;" id="jus-' . $contInt . '-' . $contAlt . '">';
                                            $htmlInterativas .= '<td colspan="5" class="apre-just"><div class="cont-just">' . $alternativa->Explicacao . '</div></td>';
                                            $htmlInterativas .= '</tr>';
                                        }
                                        // Contabilização das respostas certas ou erradas
                                        if ($alternativa->Correto == 1) {
                                            if ((intval($respostas) & intval($alternativa->ValorOpt)) > 0) {
                                                $intNumCertas++;
                                            } else {
                                                $intNumErradas++;
                                            }
                                        } else {
                                            if ((intval($respostas) & intval($alternativa->ValorOpt)) > 0) {
                                                $intNumErradas++;
                                            } else {
                                                $intNumCertas++;
                                            }
                                        }
                                        $contAlt++;
                                        $contUnico++;
                                    }
                                    $intNumTotalAlt == $contAlt;
                                    $htmlInterativas .= '</table>';
                                    $htmlInterativas .= '</div>';
                                } else {
                                    die($fe->getErro() . ' Alternativas pergunta');
                                }
                                $htmlInterativas .= '<div class="espacador"></div>';
                            } else {
                                if ($item->TipoConteudo == 'grupo-perg') {
                                    $res->setCodcaso($intCodCaso);
                                    $agrupadores = $res->BuscaConteudosAgrupador($item->ChaveItem);
                                    if ($agrupadores) {
                                        foreach ($agrupadores as $agrup) {
                                            $grupo = new GrupoPergunta();
                                            if ($grupo->Carrega($agrup->ContReferencia)) {
                                                $perguntas = $grupo->getPerguntas();
                                                if (!is_null($grupo->getExplicacao()) && strip_tags($grupo->getExplicacao()) != '') {
                                                    $boolExplicacao = true;
                                                } else {
                                                    $boolExplicacao = false;
                                                }
                                            } else {
                                                die($grupo->getErro());
                                            }
                                            $htmlInterativas .= '<div class="item-interativo">Etapa: <strong>' . $grupo->getTexto() . '</strong>' . ($boolExplicacao ? '<span style="float:right"><a href="javascript:void(0);" onclick="javascript:fntMostraOculta(\'exp-' . $grupo->getCodgrupo() . '\');"><img src="img/info.gif" alt="@lng[Mais informações]" title="@lng[Mais informações]" /></a></span>' : '') . '</div>';
                                            if ($boolExplicacao) {
                                                $htmlInterativas .= '<div class="explicacao-item" id="exp-' . $grupo->getCodgrupo() . '" style="display:none;">' . $grupo->getExplicacao() . '</div>';
                                            }
                                            $htmlInterativas .= '<div class="det-etapa-int">@lng[Número de tentivas de resposta:] <span class="dado">' . $item->Tentativas . '</span></div>';
                                            foreach ($perguntas as $perg) {
                                                $p = new Pergunta();
                                                $p->Carregar($perg);
                                                $respostas = $res->BuscaRespostas($item->ChaveItem, $perg);
                                                $alternativas = $fe->RetornaAlternativasDaPergunta($perg);
                                                if ($alternativas) {
                                                    $htmlInterativas .= '<div class="sub-etapa">' . $p->getTexto() . '</div>';
                                                    $htmlInterativas .= '<div class="det-etapa-int">';
                                                    $htmlInterativas .= '<table class="listadados">';
                                                    $htmlInterativas .= '<tr class="head">';
                                                    $htmlInterativas .= '<td class="td-col-alt">@lng[Alternativa]</td>';
                                                    $htmlInterativas .= '<td class="td-col-correto">@lng[Gabarito]</td>';
                                                    $htmlInterativas .= '<td class="td-col-escolha">@lng[Você marcou]</td>';
                                                    $htmlInterativas .= '<td class="td-col-jus">&nbsp;</td>';
                                                    $htmlInterativas .= '<td class="td-col-compl">&nbsp;</td>';
                                                    $htmlInterativas .= '</tr>';
                                                    $contAlt = 1;
                                                    foreach ($alternativas as $alternativa) {
                                                        $htmlInterativas .= '<tr class="norm">';
                                                        $htmlInterativas .= '<td class="dado td-col-alt">' . $alternativa->Alternativa . '</td>';
                                                        $htmlInterativas .= '<td class="td-col-correto">' . ($alternativa->Correto == 1 ? Comuns::IMG_STATUS_CERTO : Comuns::IMG_STATUS_ERRADO) . '</td>';
                                                        $htmlInterativas .= '<td class="td-col-escolha">' . ((intval($respostas) & intval($alternativa->ValorOpt)) > 0 ? Comuns::IMG_ITEM_PINO : '') . '</td>';
                                                        $htmlInterativas .= '<td class="td-col-jus">' . (strip_tags($alternativa->Explicacao) != '' ? '<a href="javascript:void(0);" onclick="javascript:fntDetItem(\'j\', \'' . $contUnico . '\', \'' . $contAlt . '\');">@lng[Ver detalhes]</a>' : '') . '</td>';
                                                        $htmlInterativas .= '<td class="td-col-compl">&nbsp;</td>';
                                                        $htmlInterativas .= '</tr>';
                                                        if (strip_tags($alternativa->Explicacao) != '') {
                                                            $htmlInterativas .= '<tr style="display:none;" id="jus-' . $contUnico . '-' . $contAlt . '">';
                                                            $htmlInterativas .= '<td colspan="5" class="apre-just"><div class="cont-just">' . $alternativa->Explicacao . '</div></td>';
                                                            $htmlInterativas .= '</tr>';
                                                        }
                                                        // Contabilização das respostas certas ou erradas
                                                        if ($alternativa->Correto == 1) {
                                                            if ((intval($respostas) & intval($alternativa->ValorOpt)) > 0) {
                                                                $intNumCertas++;
                                                            } else {
                                                                $intNumErradas++;
                                                            }
                                                        } else {
                                                            if ((intval($respostas) & intval($alternativa->ValorOpt)) > 0) {
                                                                $intNumErradas++;
                                                            } else {
                                                                $intNumCertas++;
                                                            }
                                                        }
                                                        $contAlt++;
                                                        $contUnico++;
                                                    }
                                                    $htmlInterativas .= '</table>';
                                                    $htmlInterativas .= '</div>';
                                                } else {
                                                    die($fe->getErro() . ' alternativas grupo pergunta');
                                                }
                                                $htmlInterativas .= '<div class="espacador"></div>';
                                            }
                                        }
                                    } else {
                                        die($res->getErro() . " agrupadores");
                                    }
                                }
                            }
                        }
                        $contInt++;
                    }
                    $dblNota = round($intNumCertas / $intNumTotalAlt * 10, 2);
                    $tpl = str_replace('<!--DescricaoInterativas-->', $htmlInterativas, $tpl);
                    $tpl = str_replace('<!--DescricaoNota-->', $dblNota, $tpl);
                } else {
                    die($fe->getErro() . ' Interativas');
                }
            } else {
                die($fe->getErro() . ' Trajetórias');
            }
        } else {
            die($fe->getErro() . ' Basicos');
        }
        echo $tpl;
    } else {
        $msg = base64_encode("@lng[Caso não informado]");
        header("Location:aluno.php?msg=" . $msg);
    }
}
Example #17
0
function Main()
{
    if (isset($_SESSION['perg'])) {
        $p = new Pergunta();
        $p->Carregar($_SESSION['perg']);
        $a = new Alternativa();
        $acao = isset($_GET['act']) && !is_null($_GET['act']) ? $_GET['act'] : "";
        if ($acao == "novaordem") {
            if ($p->ReordenaAlternativa($_POST['ids'])) {
                echo "OK";
            } else {
                $erros = "@lng[Erros ocorreram.]";
                foreach ($p->msg_erro as $err) {
                    $erros .= "<br />" . $err;
                }
                echo $erros;
            }
        } else {
            // Nao recebe o codigo da pergunta pois este ja esta informado na session 'perg'
            // O recebimento da sequencia eh só pra decidir se insere ou atualiza a alternativa
            if ($p->getTipo()->getCodigo() == 1) {
                $seq = isset($_POST['hidSeq']) && $_POST['hidSeq'] != "" ? $_POST['hidSeq'] : null;
                $txt = urldecode($_POST['txtTextoAdicional']);
                $car = $_POST['selCorreta'];
                $m_explicacao = isset($_POST['chkMostra']) ? $_POST['chkMostra'] : 0;
                $explicacao = $_POST['txtExplicacao'];
                $origem = isset($_POST['hdnOrigem']) && $_POST['hdnOrigem'] != "" ? $_POST['hdnOrigem'] : "";
                $acao = $_POST['selConsequencia'];
                $qual_acao = $_POST['selValorConsequencia'];
            } else {
                $seq = isset($_POST['hidSeq']) && $_POST['hidSeq'] != "" ? $_POST['hidSeq'] : null;
                $txt = urldecode($_POST['txtAlternativa']);
                $car = $_POST['selCorretoTxt'];
                $explicacao = $_POST['txtJustTxt'];
                $origem = isset($_POST['hdnOrigem']) && $_POST['hdnOrigem'] != "" ? $_POST['hdnOrigem'] : "";
            }
            if ($acao == 1) {
                $qual_acao = 0;
            }
            if (!is_integer($qual_acao)) {
                if (!is_null($qual_acao)) {
                    $qual_acao = base64_decode($qual_acao);
                }
            }
            if (!is_null($seq)) {
                $a->setSequencia($seq);
            }
            $a->setTexto($txt);
            $a->setCorreto($car);
            $a->setExplicacao($explicacao);
            $a->setExibirExplicacao($m_explicacao);
            $a->setTipoConsequencia($acao);
            $a->setValorConsequencia($qual_acao);
            $a->setOrigem($origem);
            if (is_null($seq)) {
                if ($p->AdicionaAlternativa($a) === true) {
                    $_SESSION['perg'] = $p->getCodigo();
                    header("Location:vwalternativas.php?p=" . base64_encode($p->getCodigo()));
                } else {
                    $erros = "@lng[Erros ocorreram.]";
                    foreach ($p->msg_erro as $erro) {
                        $erros .= "<br />" . $erro;
                    }
                    header("Location:vwalternativas.php?p=" . base64_encode($p->getCodigo()) . "&m=" . base64_encode($erros));
                }
            } else {
                if ($p->AtualizaAlternativa($a) === true) {
                    $_SESSION['perg'] = $p->getCodigo();
                    header("Location:vwalternativas.php?p=" . base64_encode($p->getCodigo()));
                } else {
                    $erros = "@lng[Erros ocorreram.]";
                    foreach ($p->msg_erro as $err) {
                        $erros .= "<br />" . $err;
                    }
                    header("Location:vwalternativas.php?p=" . base64_encode($p->getCodigo()) . "&m=" . base64_encode($erros));
                }
            }
        }
    } else {
        echo "@lng[Pergunta não definida]";
    }
}
Example #18
0
function Main()
{
    $codigo = base64_decode($_POST['txtCodigo']);
    $txt = urldecode($_POST['txtDescricao']);
    $clsAtual = $_POST['selClasse'];
    $nivAtual = $_POST['selNivel'];
    $tipAtual = $_POST['selTipo'];
    $ativo = $_POST['selAtivo'];
    $expGeral = urldecode($_POST['txtExplicacaoGeral']);
    if (trim($codigo) == "") {
        $codigo = null;
    } else {
        if (!is_numeric($codigo)) {
            echo Comuns::Idioma("@lng[Código informado não é válido]");
        }
    }
    $p = new Pergunta();
    if (!is_null($codigo)) {
        $p->setCodigo($codigo);
    }
    $p->setTexto($txt);
    $p->setClasse($clsAtual);
    $p->setNivel($nivAtual);
    $p->setTipo(TipoPergunta::RetornaTipo($tipAtual));
    $p->setAtivo($ativo);
    if ($expGeral != "") {
        $p->setTextoExplicacaoGeral($expGeral);
    }
    if ($p->getCodigo() === 0) {
        if ($p->AdicionaPergunta() === true) {
            $_SESSION['perg'] = $p->getCodigo();
            echo "OK";
        } else {
            $_SESSION['perg'] = 0;
            echo Comuns::Idioma("@lng[Erro ao adicionar a pergunta:]");
        }
    } else {
        if ($p->AtualizaPergunta() === true) {
            $_SESSION['perg'] = $p->getCodigo();
            echo "OK";
        } else {
            $erros = "@lng[Erros ocorreram.]";
            foreach ($p->msg_erro as $err) {
                $erros .= "<br />" . $err;
            }
            echo Comuns::Idioma($erros);
        }
    }
}
Example #19
0
	try {
		$banco->iniciarTransacao();

		$obj_tipo_pergunta = $sessionFacade->recuperarTipoPergunta($tipo_pergunta);
		$obj_topico        = $sessionFacade->recuperarTopico($topico);
		$obj_curso         = $sessionFacade->recuperarCurso($curso);
		$obj_disciplina    = $sessionFacade->recuperarDisciplina($disciplina);

		if (strlen($topico_descricao)>0){
			$obj_topico = new Topico();
			$obj_topico->setDisciplina($obj_disciplina);
			$obj_topico->setDescricao($topico_descricao);
			$sessionFacade->gravarTopico($obj_topico);
		}

		$perg = new Pergunta();
		$perg->setId($pergunta);
		$perg->setTopico($obj_topico);
		$perg->setTitulo($titulo_pergunta);
		$perg->setTipoPergunta($obj_tipo_pergunta);
		$perg->setDificuldade($dificuldade);
		$perg->setFonte($fonte);
		$perg->setAtiva($ativa);

		$qtde_respostas = 0;

		if (is_object($obj_tipo_pergunta)){
			$qtde_respostas = $obj_tipo_pergunta->getQtdeRespostas();
		}

		for ($i=0; $i<$qtde_respostas; $i++){
Example #20
0
function TrataDadosExercicios($template)
{
    if (isset($_SESSION['caso']) && $_SESSION['caso'] != 0) {
        $p = new Pergunta();
        $gp = new GrupoPergunta();
        $u = unserialize($_SESSION['usu']);
        // Perguntas
        $perguntas = $p->ListaPerguntasAtivas(null, null, "", 0, $u->getCodigo());
        if (count($perguntas) > 0) {
            $retorno = "<h4>@lng[Marque abaixo quais perguntas cadastradas no sistema você deseja vincular a este caso de estudos]</h4>";
            $cont = 0;
            $pergcaso = Caso::RetornaArrayExercicios($_SESSION['caso']);
            foreach ($perguntas as $perg) {
                $cont++;
                if (!is_null($pergcaso) && in_array($perg->Codigo, $pergcaso)) {
                    $retorno .= '<input type="checkbox" name="chkRelPergCaso[]" id="chkRelPergCaso_' . $cont . '" value="' . base64_encode($perg->Codigo) . '" class="campo" checked="checked" />' . $perg->Texto . '<br />';
                } else {
                    $retorno .= '<input type="checkbox" name="chkRelPergCaso[]" id="chkRelPergCaso_' . $cont . '" value="' . base64_encode($perg->Codigo) . '" class="campo" />' . $perg->Texto . '<br />';
                }
            }
        } else {
            $debug .= "perguntas <= 0\r\n";
            $retorno = "@lng[Nenhum pergunta cadastrada no sistema]";
        }
        // Agrupamentos de perguntas
        $agrupamentos = $gp->ListaRecordSet();
        if (count($agrupamentos) > 0) {
            $retorno .= '<h4>@lng[Marque abaixo quais agrupamentos de perguntas você deseja vincular ao caso. As perguntas dos agrupamentos não precisam ser marcadas na lista acima]</h4>';
            $cont = 0;
            $agrupscaso = Caso::RetornaArrayAgrupadores($_SESSION['caso']);
            foreach ($agrupamentos as $agrup) {
                $cont++;
                if (!is_null($agrupscaso) && in_array($agrup->Codigo, $agrupscaso)) {
                    $retorno .= '<input type="checkbox" name="chkRelAgrupCaso[]" id="chkRelAgrupCaso_' . $cont . '" value="' . base64_encode($agrup->Codigo) . '" class="campo" checked="checked" />' . $agrup->Texto . '<br />';
                } else {
                    $retorno .= '<input type="checkbox" name="chkRelAgrupCaso[]" id="chkRelAgrupCaso_' . $cont . '" value="' . base64_encode($agrup->Codigo) . '" class="campo" />' . $agrup->Texto . '<br />';
                }
            }
        }
        $template = str_replace("<!--listaexercicios-->", $retorno, $template);
        return $template;
    } else {
        return "@lng[Erro ao localizar o caso de estudo]";
    }
}
Example #21
0
function Main()
{
    $u = unserialize($_SESSION['usu']);
    if (isset($_SESSION['perg']) && !is_null($_SESSION['perg']) && $_SESSION['perg'] != "") {
        // Verifica se já tem uma sessão iniciada para uma pergunta. Se tiver...
        if (isset($_GET['p'])) {
            // Se tiver mas vier via GET algum código, limpa a sessão e recarrega os dados
            unset($_SESSION['perg']);
            $cod = base64_decode($_GET['p']);
            $p = new Pergunta();
            $p->Carregar($cod);
        } else {
            $p = new Pergunta();
            $p->Carregar($_SESSION['perg']);
        }
    } else {
        // Se não tiver sessão iniciada...
        if (isset($_GET['p'])) {
            // Deve vir obrigatoriamente um código informado via GET. Caso veio, instancia a pergunta
            $cod = base64_decode($_GET['p']);
            $p = new Pergunta();
            $p->Carregar($cod);
        } else {
            // Se não veio código é porque alguma coisa saiu errado ou o usuário não deveria estar acessando a página
            $msg = base64_encode("Algo saiu errado.");
            header("Location:listagem.php?t=8&m=" . $msg);
        }
    }
    $tpl = file_get_contents('tpl/alternativas.html');
    $tpl = str_replace("<!--telatopo-->", Comuns::GeraTopoPagina($u), $tpl);
    $botoes = Botao::BotaoSalvar("fntGravaAlternativa();", "@lng[Salvar a alternativa]");
    $botoes .= Botao::BotaoCancelar("fntNavega('listagem.php?t=8');", "@lng[Cancelar edição]");
    $botoes .= Botao::BotaoVoltar("fntNavega('vwpergunta.php?r=" . base64_encode($p->getCodigo()) . "');");
    $tpl = str_replace("<!--itens-toolbar-->", $botoes, $tpl);
    $tpl = str_replace("<!--Mensagem-->", isset($mensagem) && $mensagem != "" ? base64_decode($mensagem) : "", $tpl);
    $tipconsatual = 1;
    $valconsatual = -1;
    if (count($p->getAlternativas()) > 0) {
        $arquivotpl = 'tpl/alternativas-comp' . $p->getTipo()->getCodigo() . '.html';
        //$item_padrao = file_get_contents('tpl/alternativas-comp1.html');
        $item_padrao = file_get_contents($arquivotpl);
        $itens = '';
        foreach ($p->getAlternativas() as $alt) {
            $copia = $item_padrao;
            $copia = str_replace("<!--perg-->", base64_encode($p->getCodigo()), $copia);
            $copia = str_replace("<!--seq-->", base64_encode($alt->getSequencia()), $copia);
            $copia = str_replace("<!--correta-->", $alt->getCorreto() == 1 ? "SIM" : "NÃO", $copia);
            $copia = str_replace("<!--ordem-->", $alt->getSequencia(), $copia);
            $copia = str_replace("<!--ordem-ex-->", base64_encode($alt->getSequencia()), $copia);
            $copia = str_replace("<!--codunico-->", base64_encode($alt->getCodUnico()), $copia);
            $copia = str_replace("<!--excluir-->", "", $copia);
            if ($p->getTipo()->getCodigo() == 1) {
                $copia = str_replace("<!--img-preview-->", $alt->getImagem(), $copia);
            } else {
                $copia = str_replace("<!--textoalternativa-->", strlen($alt->getTexto()) > 100 ? substr($alt->getTexto(), 0, 97) . "..." : $alt->getTexto(), $copia);
            }
            $itens .= $copia;
            if (isset($_GET['s']) && $_GET['s'] != "") {
                // Se foi informado um segundo parâmetro, contendo a sequência da alternativa,
                // quer dizer que deve ser carregada a alternativa para edição.
                if (base64_decode($_GET['s']) == $alt->getCodUnico()) {
                    if ($p->getTipo()->getCodigo() == 1) {
                        $tpl = str_replace("<!--hidSeq-->", $alt->getSequencia(), $tpl);
                        //$tpl = str_replace("<!--nomeimg-->", $alt->getImagem(), $tpl);
                        $tpl = str_replace("<!--nomeimg-->", "", $tpl);
                        $tpl = str_replace("<!--txtTextoAdicional-->", $alt->getTexto(), $tpl);
                        $tpl = str_replace("<!--opcoescorreto-->", SimNao::SelectSimNao($alt->getCorreto()), $tpl);
                        $tpl = str_replace("<!--txtExplicacao-->", $alt->getExplicacao(), $tpl);
                        $tpl = str_replace("<!--hidocultar-->", "N", $tpl);
                    } else {
                        if ($p->getTipo()->getCodigo() == 2 || $p->getTipo()->getCodigo() == 3) {
                            $tpl = str_replace("<!--hidSeq-->", $alt->getSequencia(), $tpl);
                            $tpl = str_replace("<!--txtAlternativa-->", $alt->getTexto(), $tpl);
                            $tpl = str_replace("<!--selcorretotxt-->", SimNao::SelectSimNao($alt->getCorreto()), $tpl);
                            $tpl = str_replace("<!--txtJustTxt-->", $alt->getExplicacao(), $tpl);
                            $tpl = str_replace("<!--hidocultar-->", "N", $tpl);
                        }
                    }
                } else {
                    $tpl = str_replace("<!--hidocultar-->", "S", $tpl);
                }
            } else {
                $tpl = str_replace("<!--hidocultar-->", "S", $tpl);
            }
        }
        $itens .= '<div id="addAlt" class="box-alternativa box-zero-alternativa">';
        $itens .= '    <span style="line-height:43px;">@lng[Adiciona alternativa]</span>';
        $itens .= '</div>';
    } else {
        $itens = '<div id="addAlt" class="box-alternativa box-zero-alternativa">';
        $itens .= '    @lng[Nenhuma alternativa cadastrada]<br />';
        $itens .= '    @lng[Adiciona alternativa]';
        $itens .= '</div>';
    }
    // Se não foi informado nenhum registro, limpa o que ficou pra traz
    $tpl = str_replace("<!--hidSeq-->", "", $tpl);
    $tpl = str_replace("<!--nomeimg-->", "", $tpl);
    $tpl = str_replace("<!--txtTextoAdicional-->", "", $tpl);
    $tpl = str_replace("<!--txtExplicacao-->", "", $tpl);
    $tpl = str_replace("<!--opcoescorreto-->", SimNao::SelectSimNao(), $tpl);
    $tpl = str_replace("<!--txtAlternativa-->", "", $tpl);
    $tpl = str_replace("<!--selcorretotxt-->", SimNao::SelectSimNao(), $tpl);
    $tips = '<option value="0">@lng[Todos]</option>';
    foreach ($p->tipos->ListaRecordSet() as $tipo) {
        $tips .= '<option value="' . $tipo->Codigo . '">' . $tipo->Descricao . '</option>';
    }
    $cls = '<option value="0">@lng[Todos]</option>';
    foreach ($p->classes->ListaRecordSet() as $classe) {
        $cls .= '<option value="' . $classe->Codigo . '">' . $classe->Descricao . '</option>';
    }
    $tpl = str_replace('<!--descricao-->', $p->getTexto(), $tpl);
    $tpl = str_replace('<!--alternativas-->', $itens, $tpl);
    $tpl = str_replace('<!--tipo-->', $p->getTipo()->getDescricao(), $tpl);
    $tpl = str_replace('<!--hidtipo-->', $p->getTipo()->getCodigo(), $tpl);
    $tpl = str_replace("<!--classespergunta-->", $cls, $tpl);
    $tpl = str_replace("<!--tipospergunta-->", $tips, $tpl);
    $_SESSION['perg'] = $p->getCodigo();
    echo Comuns::Idioma($tpl);
}
Example #22
0
 public function BuscaSaltosConteudo($strChaveAtual)
 {
     $sql = "select ";
     $sql .= "\t concat(dest.Organizador, '_', dest.TipoConteudo, '_', dest.ContReferencia, '_', salt.ChaveDestino) as ChaveDestino ";
     $sql .= "\t,salt.ChaveCond ";
     $sql .= "\t,cond.TipoConteudo as TipoContCond ";
     $sql .= "\t,salt.CodPergunta ";
     $sql .= "\t,salt.RespostaCond ";
     $sql .= "from mescasomontagemsaltos salt ";
     $sql .= "inner join mescasomontagem mont ";
     $sql .= "\t\ton mont.CodCaso = salt.CodCaso ";
     $sql .= "\t   and mont.CodMontagem = salt.CodMontagem ";
     $sql .= "\t   and mont.Chave = salt.ChaveAtual ";
     $sql .= "inner join mescasomontagem dest ";
     $sql .= "\t\ton dest.CodCaso = salt.CodCaso ";
     $sql .= "\t   and dest.CodMontagem = salt.CodMontagem ";
     $sql .= "\t   and dest.Chave = salt.ChaveDestino ";
     $sql .= "left outer join mescasomontagem cond ";
     $sql .= "\t\t\t on cond.CodCaso = salt.CodCaso ";
     $sql .= "\t\t\tand cond.CodMontagem = salt.CodMontagem ";
     $sql .= "\t\t\tand cond.Chave = salt.ChaveCond ";
     $sql .= "where salt.CodCaso = :pCodCaso ";
     $sql .= "  and salt.CodMontagem = 1 ";
     $sql .= "  and salt.ChaveAtual = :pChaveAtual;";
     $cnn = Conexao2::getInstance();
     $cmd = $cnn->prepare($sql);
     $cmd->bindParam(":pCodCaso", $this->codcaso, PDO::PARAM_INT);
     $cmd->bindParam(":pChaveAtual", $strChaveAtual, PDO::PARAM_STR);
     $cmd->execute();
     if ($cmd->errorCode() == Comuns::QUERY_OK) {
         if ($cmd->rowCount() > 0) {
             $strProximoItem = "";
             $sair = false;
             while ($salto = $cmd->fetch(PDO::FETCH_OBJ)) {
                 if (is_null($salto->ChaveCond)) {
                     $strProximoItem = $salto->ChaveDestino;
                     break;
                 } else {
                     if ($salto->TipoContCond != 'perg' && $salto->TipoContCond != 'grupo-perg') {
                         $respostas = $this->BuscaRespostas($salto->ChaveCond);
                         $itens = $this->BuscaConteudosAgrupador($salto->ChaveCond, $salto->RespostaCond);
                         foreach ($itens as $opcao) {
                             if ((intval($opcao->ValorOpt, 10) & intval($respostas, 10)) > 0) {
                                 $strProximoItem = $salto->ChaveDestino;
                                 $sair = true;
                                 break;
                             }
                         }
                     } else {
                         $respostas = $this->BuscaRespostas($salto->ChaveCond, $salto->CodPergunta);
                         $p = new Pergunta();
                         $p->setCodigo($salto->CodPergunta);
                         $itens = $p->BuscaAlternativasFiltradas($salto->RespostaCond);
                         if (count($itens) > 0) {
                             foreach ($itens as $opcao) {
                                 if ((intval($opcao->getCodBinario(), 10) & intval($respostas, 10)) > 0) {
                                     $strProximoItem = $salto->ChaveDestino;
                                     $sair = true;
                                     break;
                                 }
                             }
                         } else {
                             return 0;
                         }
                     }
                     if ($sair) {
                         break;
                     }
                 }
             }
             if ($strProximoItem != "") {
                 return $strProximoItem;
             } else {
                 return 0;
             }
         } else {
             return 0;
         }
     } else {
         $msg = $cmd->errorInfo();
         $this->msg_erro = $msg[2];
         return false;
     }
 }
 /**
  * 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 = Pergunta::validate($input);
     // trata os erros
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator)->with('error', Util::message('MSG004'));
     } else {
         $this->pergunta->find($id)->update($input);
         return Redirect::to('pergunta')->with('success', Util::message('MSG005'));
     }
 }
Example #24
0
function Main()
{
    header('Content-Type: text/html; charset=iso-8859-1');
    $arrInfos = split('_', $_POST['chave']);
    $fe = new Fechamento();
    $fe->setCodcaso($_SESSION['casores']);
    $contUnico = 1;
    if ($arrInfos[1] != 'perg' && $arrInfos[1] != 'grupo-perg') {
        $res = new Resolucao();
        $res->setCodcaso($_SESSION['casores']);
        $respostas = $res->BuscaRespostas($arrInfos[3]);
        $alternativas = $fe->RetornaConteudosDoItemDaMontagem($arrInfos[3], $arrInfos[1]);
        if ($alternativas) {
            $htmlInterativas .= '<div><strong>' . Montagem::RetornaDescricaoItem($_SESSION['casores'], 1, $arrInfos[3]) . '</strong></div>';
            $htmlInterativas .= '<div class="det-etapa-int">';
            $htmlInterativas .= '<table class="listadados">';
            $htmlInterativas .= '<tr class="head">';
            $htmlInterativas .= '<td class="td-col-alt">@lng[Alternativa]</td>';
            $htmlInterativas .= '<td class="td-col-correto">@lng[Gabarito]</td>';
            $htmlInterativas .= '<td class="td-col-escolha">@lng[Você marcou]</td>';
            $htmlInterativas .= '<td class="td-col-jus">&nbsp;</td>';
            $htmlInterativas .= '<td class="td-col-compl">&nbsp;</td>';
            $htmlInterativas .= '</tr>';
            $contAlt = 1;
            foreach ($alternativas as $alternativa) {
                $htmlInterativas .= '<tr class="norm">';
                $htmlInterativas .= '<td class="dado td-col-alt">' . $alternativa->Titulo . '</td>';
                $htmlInterativas .= '<td class="td-col-correto">' . ($alternativa->Correto == 1 ? Comuns::IMG_STATUS_CERTO : Comuns::IMG_STATUS_ERRADO) . '</td>';
                $htmlInterativas .= '<td class="td-col-escolha">' . ((intval($respostas) & intval($alternativa->ValorOpt)) > 0 ? Comuns::IMG_ITEM_PINO : '') . '</td>';
                $htmlInterativas .= '<td class="td-col-jus">' . trim(strip_tags(nl2br($alternativa->Justificativa)) != '' ? '<a href="javascript:void(0);" onclick="javascript:fntDetItem(\'j\', \'' . $contUnico . '\', \'' . $contAlt . '\');">@lng[Ver detalhes]</a>' : '') . '</td>';
                $htmlInterativas .= '<td class="td-col-compl">' . trim(strip_tags(nl2br($alternativa->ConteudoAdicional)) != '' ? '<a href="javascript:void(0);" onclick="javascript:fntDetItem(\'c\', \'' . $contUnico . '\', \'' . $contAlt . '\');">@lng[Ver complemento]</a>' : '') . '</td>';
                $htmlInterativas .= '</tr>';
                if (trim(strip_tags($alternativa->Justificativa)) != '') {
                    $htmlInterativas .= '<tr style="display:none;" id="jus-' . $contUnico . '-' . $contAlt . '">';
                    $htmlInterativas .= '<td colspan="5" class="apre-just"><div class="cont-just">' . $alternativa->Justificativa . '</div></td>';
                    $htmlInterativas .= '</tr>';
                }
                if (trim(strip_tags($alternativa->ConteudoAdicional)) != '') {
                    $htmlInterativas .= '<tr style="display:none;" id="contadi-' . $contUnico . '-' . $contAlt . '">';
                    $htmlInterativas .= '<td colspan="5" class="apre-compl"><div class="cont-compl">' . $alternativa->ConteudoAdicional . '</div></td>';
                    $htmlInterativas .= '</tr>';
                }
                $contAlt++;
                $contUnico++;
            }
            $htmlInterativas .= '</table>';
            $htmlInterativas .= '</div>';
        } else {
            die($fe->getErro() . ' Alternativas');
        }
        $htmlInterativas .= '<div class="espacador"></div>';
    } else {
        if ($arrInfos[1] == 'perg') {
            $res = new Resolucao();
            $res->setCodcaso($_SESSION['casores']);
            $itens = $res->BuscaConteudosAgrupador($arrInfos[3]);
            if ($itens) {
                foreach ($itens as $p) {
                    // Chave, TipoConteudo, ChavePai, Organizador, ContReferencia, ValorOpt, Ordem
                    $perg = new Pergunta();
                    $perg->Carregar($p->ContReferencia);
                    if (!is_null($perg->getTextoExplicacaoGeral()) && $perg->getTextoExplicacaoGeral() != '') {
                        $boolExplicacao = true;
                    } else {
                        $boolExplicacao = false;
                    }
                    $htmlInterativas .= '<div>@lng[Etapa:] <strong>' . $perg->getTexto() . '</strong>' . ($boolExplicacao ? '<span style="float:right;"><a href="javascript:void(0);" onclick="javascript:fntMostraOculta(\'exp-' . $perg->getCodigo() . '\');"><img src="img/info.gif" alt="@lng[Mais informações]" title="@lng[Mais informações]" /></a></span>' : '') . '</div>';
                    if ($boolExplicacao) {
                        $htmlInterativas .= '<div class="explicacao-item" id="exp-' . $perg->getCodigo() . '" style="display:none;">' . $perg->getTextoExplicacaoGeral() . '</div>';
                    }
                    $respostas = $res->BuscaRespostas($arrInfos[3], $perg->getCodigo());
                    $alternativas = $fe->RetornaAlternativasDaPergunta($perg->getCodigo());
                    if ($alternativas) {
                        $htmlInterativas .= '<div class="det-etapa-int">';
                        $htmlInterativas .= '<table class="listadados">';
                        $htmlInterativas .= '<tr class="head">';
                        $htmlInterativas .= '<td class="td-col-alt">@lng[Alternativa]</td>';
                        $htmlInterativas .= '<td class="td-col-correto">@lng[Gabarito]</td>';
                        $htmlInterativas .= '<td class="td-col-escolha">@lng[Você marcou]</td>';
                        $htmlInterativas .= '<td class="td-col-jus">&nbsp;</td>';
                        $htmlInterativas .= '<td class="td-col-compl">&nbsp;</td>';
                        $htmlInterativas .= '</tr>';
                        $contAlt = 1;
                        foreach ($alternativas as $alternativa) {
                            $htmlInterativas .= '<tr class="norm">';
                            $htmlInterativas .= '<td class="dado td-col-alt">' . $alternativa->Alternativa . '</td>';
                            $htmlInterativas .= '<td class="td-col-correto">' . ($alternativa->Correto == 1 ? Comuns::IMG_STATUS_CERTO : Comuns::IMG_STATUS_ERRADO) . '</td>';
                            $htmlInterativas .= '<td class="td-col-escolha">' . ((intval($respostas) & intval($alternativa->ValorOpt)) > 0 ? Comuns::IMG_ITEM_PINO : '') . '</td>';
                            $htmlInterativas .= '<td class="td-col-jus">' . (!is_null($alternativa->Explicacao) && strip_tags(trim(nl2br($alternativa->Explicacao))) != '' ? '<a href="javascript:void(0);" onclick="javascript:fntDetItem(\'j\', \'' . $contUnico . '\', \'' . $contAlt . '\');">@lng[Ver detalhes]</a>' : '') . '</td>';
                            $htmlInterativas .= '<td class="td-col-compl">&nbsp;</td>';
                            $htmlInterativas .= '</tr>';
                            if (trim(strip_tags($alternativa->Explicacao)) != '') {
                                $htmlInterativas .= '<tr style="display:none;" id="jus-' . $contUnico . '-' . $contAlt . '">';
                                $htmlInterativas .= '<td colspan="5" class="apre-just"><div class="cont-just">' . $alternativa->Explicacao . '</div></td>';
                                $htmlInterativas .= '</tr>';
                            }
                            $contAlt++;
                            $contUnico++;
                        }
                        $htmlInterativas .= '</table>';
                        $htmlInterativas .= '</div>';
                    } else {
                        die($fe->getErro() . ' Alternativas pergunta');
                    }
                    $htmlInterativas .= '<div class="espacador"></div>';
                }
            } else {
                $htmlInterativas = "Erro linha 34";
            }
        } else {
            if ($arrInfos[1] == 'grupo-perg') {
                $res = new Resolucao();
                $res->setCodcaso($_SESSION['casores']);
                $agrupadores = $res->BuscaConteudosAgrupador($arrInfos[3]);
                if ($agrupadores) {
                    foreach ($agrupadores as $agrup) {
                        $grupo = new GrupoPergunta();
                        if ($grupo->Carrega($agrup->ContReferencia)) {
                            $perguntas = $grupo->getPerguntas();
                            if (!is_null($grupo->getExplicacao()) && trim(strip_tags($grupo->getExplicacao())) != '') {
                                $boolExplicacao = true;
                            } else {
                                $boolExplicacao = false;
                            }
                        } else {
                            die($grupo->getErro());
                        }
                        $htmlInterativas .= '<div class="item-interativo">@lng[Etapa:] <strong>' . $grupo->getTexto() . '</strong>' . ($boolExplicacao ? '<span style="float:right"><a href="javascript:void(0);" onclick="javascript:fntMostraOculta(\'exp-' . $grupo->getCodgrupo() . '\');"><img src="img/info.gif" alt="@lng[Mais informações]" title="@lng[Mais informações]" /></a></span>' : '') . '</div>';
                        if ($boolExplicacao) {
                            $htmlInterativas .= '<div class="explicacao-item" id="exp-' . $grupo->getCodgrupo() . '" style="display:none;">' . $grupo->getExplicacao() . '</div>';
                        }
                        foreach ($perguntas as $perg) {
                            $p = new Pergunta();
                            $p->Carregar($perg);
                            $respostas = $res->BuscaRespostas($arrInfos[3], $perg);
                            $alternativas = $fe->RetornaAlternativasDaPergunta($perg);
                            if ($alternativas) {
                                $htmlInterativas .= '<div class="sub-etapa">' . $p->getTexto() . '</div>';
                                $htmlInterativas .= '<div class="det-etapa-int">';
                                $htmlInterativas .= '<table class="listadados">';
                                $htmlInterativas .= '<tr class="head">';
                                $htmlInterativas .= '<td class="td-col-alt">@lng[Alternativa]</td>';
                                $htmlInterativas .= '<td class="td-col-correto">@lng[Gabarito]</td>';
                                $htmlInterativas .= '<td class="td-col-escolha">@lng[Você marcou]</td>';
                                $htmlInterativas .= '<td class="td-col-jus">&nbsp;</td>';
                                $htmlInterativas .= '<td class="td-col-compl">&nbsp;</td>';
                                $htmlInterativas .= '</tr>';
                                $contAlt = 1;
                                foreach ($alternativas as $alternativa) {
                                    $htmlInterativas .= '<tr class="norm">';
                                    $htmlInterativas .= '<td class="dado td-col-alt">' . $alternativa->Alternativa . '</td>';
                                    $htmlInterativas .= '<td class="td-col-correto">' . ($alternativa->Correto == 1 ? Comuns::IMG_STATUS_CERTO : Comuns::IMG_STATUS_ERRADO) . '</td>';
                                    $htmlInterativas .= '<td class="td-col-escolha">' . ((intval($respostas) & intval($alternativa->ValorOpt)) > 0 ? Comuns::IMG_ITEM_PINO : '') . '</td>';
                                    $htmlInterativas .= '<td class="td-col-jus">' . (trim(strip_tags(nl2br($alternativa->Explicacao))) != '' ? '<a href="javascript:void(0);" onclick="javascript:fntDetItem(\'j\', \'' . $contUnico . '\', \'' . $contAlt . '\');">@lng[Ver detalhes]</a>' : '') . '</td>';
                                    $htmlInterativas .= '<td class="td-col-compl">&nbsp;</td>';
                                    $htmlInterativas .= '</tr>';
                                    if (trim(strip_tags($alternativa->Explicacao)) != '') {
                                        if (!is_null($alternativa->Explicacao)) {
                                            $htmlInterativas .= '<tr style="display:none;" id="jus-' . $contUnico . '-' . $contAlt . '">';
                                            $htmlInterativas .= '<td colspan="5" class="apre-just"><div class="cont-just">' . $alternativa->Explicacao . '</div></td>';
                                            $htmlInterativas .= '</tr>';
                                        }
                                    }
                                    $contAlt++;
                                    $contUnico++;
                                }
                                $htmlInterativas .= '</table>';
                                $htmlInterativas .= '</div>';
                            } else {
                                die($fe->getErro() . ' alternativas grupo pergunta');
                            }
                            $htmlInterativas .= '<div class="espacador"></div>';
                        }
                    }
                } else {
                    $htmlInterativas = "Erro linha 122";
                }
            }
        }
    }
    echo Comuns::Idioma($htmlInterativas);
}
Example #25
0
function BuscaRespostaAgrupadores($codcaso, $chave)
{
    $hash = new HashTable();
    $explicacoes = "";
    foreach ($_POST as $campo => $valor) {
        if (substr($campo, 0, 3) == "rdo") {
            $detalhes = split("_", $campo);
            $pergunta = $detalhes[1];
            $p = new Pergunta();
            $acertou = VerificaAcerto($pergunta, $_POST[$campo]);
            $hash->AddItem($pergunta, $acertou === true ? 's' : 'n');
            $p->Carregar($pergunta);
            $alternativas = $p->getAlternativas();
            foreach ($alternativas as $alt) {
                if (!is_null($alt->getExplicacao()) && strip_tags($alt->getExplicacao()) != "") {
                    $explicacoes .= '<div class="explicacao">' . $alt->getExplicacao() . '</div>';
                }
            }
            if (!is_null($p->getTextoExplicacaoGeral())) {
                $explicacoes = '<div class="explicacao">' . $p->getTextoExplicacaoGeral() . '</div>' . $explicacoes;
            }
        }
    }
    $retornos = $hash->ToArray();
    $certas = 0;
    $erradas = 0;
    foreach ($retornos as $chave => $item) {
        if ($item == 's') {
            $certas++;
        } else {
            $erradas++;
        }
        $imgs .= ($imgs != "" ? "," : "") . $chave . '_' . $item;
    }
    $conteudo = "<p>@lng[Você] ";
    if ($certas > 0 && $erradas > 0) {
        $conteudo .= "@lng[acertou] " . $certas;
    } else {
        if ($certas > 0 && $erradas == 0) {
            $conteudo .= "@lng[acertou todas as questões]";
        }
    }
    if ($certas > 0 && $erradas > 0) {
        $conteudo .= " @lng[e errou] " . $erradas;
    } else {
        if ($certas == 0 && $erradas > 0) {
            $conteudo .= " @lng[errou as] " . $erradas . " @lng[questões.]";
        }
    }
    return '<texto>' . $conteudo . '</p><p>' . $explicacoes . '</p></texto><imgs>' . $imgs . '</imgs>';
}