public function salvar(\Aluno $u) { $cpf = $u->getCpf(); $rg = $u->getRg(); $data_nascimento = $u->getData_nascimento(); $nome = $u->getNome(); $telefone = $u->getTelefone(); if ($u->getCod_aluno()) { $id = $u->getCod_aluno(); $sql = "update aluno set cpf=:cpf, rg=:rg, data_nascimento=:data_nascimento, nome=:nome, telefone=:telefone where cod_aluno = :id"; } else { $id = $this->generateID(); $u->setCod_aluno($id); $sql = "insert into aluno (cod_aluno, cpf, rg, data_nascimento, nome, telefone) values (:id, :cpf, :rg, :data_nascimento, :nome, :telefone)"; } $cnx = Conexao::getConexao(); $sth = $cnx->prepare($sql); $sth->bindParam("id", $id); $sth->bindParam("cpf", $cpf); $sth->bindParam("rg", $rg); $sth->bindParam("data_nascimento", $data_nascimento); $sth->bindParam("nome", $nome); $sth->bindParam("telefone", $telefone); try { $sth->execute(); return $u; } catch (Exception $exc) { echo $exc->getMessage(); } }
exit; } $aluno = new Aluno($_REQUEST['id']); $TURMA = new Turma($aluno->getTurma()); // override o padrao ?> <h2>Cadastro de alunos</h2> <p>Para alterar detalhes do aluno, edite o formulário abaixo.</p> <p>Para recadastrar a senha do aluno, digite uma nova senha.</p> <form action='alunos.php' method='POST'> <input type='hidden' name='id' value='<?php echo $aluno->getId(); ?> '> <p>Login: <input type='text' name='nome' value='<?php echo $aluno->getNome(); ?> '> <br>Senha: <input type='text' name='senha' value=''> <br>Turma: <?php echo SelectTurma(false); ?> <br><label><input type="checkbox" name="admin" value="1" <?php if ($aluno->admin()) { echo "checked"; } ?> /> Admin</label> <br> <button type='submit' name='submit' value='altera'>Alterar</button>
function RelPlagio() { global $mysqli; $plagio = $mysqli->prepare("select x.i1, x.i2, count(*) from (select distinct n1.id_aluno i1, n2.id_aluno i2, n1.id_exercicio from nota n1 join nota n2 on (n1.texto=n2.texto and n1.id_aluno != n2.id_aluno and n1.id_nota != n2.id_nota and n1.id_exercicio = n2.id_exercicio)) x group by x.i1, x.i2 having count(*) >= 4 order by 1"); $plagio->execute(); $plagio->bind_result($id1, $id2, $count); $ids1 = array(); $ids2 = array(); $counts = array(); while ($plagio->fetch()) { array_push($ids1, $id1); array_push($ids2, $id2); array_push($counts, $count); } if (count($ids2) > 0) { $T = "<table><tr><td>Aluno 1</td><td>Aluno 2</td><td>Exercícios iguais</td></tr>"; for ($i = 0; $i < sizeof($ids2) / 2; $i++) { $a1 = new Aluno($ids1[$i]); $a2 = new Aluno($ids2[$i]); $T .= "<tr><td>" . $a1->getNome() . "</td><td>" . $a2->getNome() . "</td><td>" . $counts[$i] . "</td></tr>"; } $T .= "</table>"; } else { $T = "Nenhum registro de plágio localizado"; } return $T; }
<form action='alunos.php' method='POST'> <?php echo SelectTurma(); ?> <p>Alunos cadastrados:</p> <table><tr><td>Admin</td><td>Login</td><td>Notas</td><td>Editar</td> <?php foreach (ListAlunos($TURMA) as $aluno) { echo "<tr><td>"; if ($aluno->admin()) { echo "<img src='img/check.png'>"; } else { echo " "; } echo "</td><td>" . $aluno->getNome() . "</td><td>" . $aluno->numNotas() . "</td><td>"; echo "<a href='aluno.php?id=" . $aluno->getId() . "'><img src='img/pen.png'></a></td></tr>"; } ?> </table> <p>Para cadastrar novos alunos nesta turma, preencha os logins na caixa de texto abaixo, um por linha:</p> <textarea name="novos" rows=5 cols=70> </textarea> <p>Senha: <input type="text" name="senha"> <br><button type='submit' name='submit' value='insere'>Inserir</button></p> </form> </div> </body> </html>
public function excluirAlunoDAO(Aluno $aluno){ $banco = $this->getBancoDados(); $sql = "SELECT count(*) AS qtde FROM tbl_prova_aluno WHERE aluno = ".$aluno->getId(); $retorno = $banco->executaSQL($sql); if($retorno != NULL) { $linha = mysql_fetch_array($retorno); if ($linha['qtde'] > 0){ throw new Exception("Já foi aplicado uma prova para ".$aluno->getNome().". Exclusão não concluída!"); } } else { throw new Exception("Erro ao excluir o aluno. ($sql)"); } $query = " DELETE FROM tbl_aluno WHERE aluno = ".$aluno->getId(); if(!$banco->updateSQL($query)) { $erro = $banco->mysql_error(); if (strpos($erro,"foreign key constraint fails")) { throw new Exception("Erro ao excluir. Aluno já foi relacionado para prova."); }else{ throw new Exception("Erro ao excluir Aluno. (".$banco->mysql_error().")"); } } }
$aluno->recebeAlunoId($host, $db, $usuario, $senhaBD); $indicador = new Aluno(""); $indicador->setNumeroInscricao($aluno->getIdIndicador()); $indicador->recebeAlunoId($host, $db, $usuario, $senhaBD); $indicador->atualizaDesconto($host, $db, $usuario, $senhaBD); $sucessoNotificacao = false; if ($aluno->getIdIndicador()) { //faremos 10 tentativas para notificar o aluno , se todas falharem //mostramos que não foi possível notificar o aluno for ($i = 0; $i < 10 && !$sucessoNotificacao; $i++) { //gera notificação para o indicador que ele recebeu 10% de desconto //nas próximas parcelas $conexao->beginTransaction(); $titulo = "Desconto por indicação"; $texto = "Você recebeu 10% de desconto por ter indicado "; $texto .= "o(a) aluno(a) : " . $aluno->getNome(); $textoQuery = "INSERT INTO Notificacao(titulo,texto,chaveAluno)\n VALUES (:titulo, :texto,:idIndicador)"; $query = $conexao->prepare($textoQuery); $query->bindParam(":titulo", $titulo, PDO::PARAM_STR); $query->bindParam(":texto", $texto, PDO::PARAM_STR); $query->bindParam(":idIndicador", $indicador->getNumeroInscricao(), PDO::PARAM_INT); $sucessoNotificacao = $query->execute(); if (!$sucessoNotificacao) { $conexao->rollback(); } } //se conseguiu notificar, confirma transação if ($sucessoNotificacao) { $conexao->commit(); } else { //se não, mostra mensagem na tela
<?php $id = filter_input(INPUT_GET, "id") ? filter_input(INPUT_GET, "id") : NULL; $acao = filter_input(INPUT_GET, "acao") ? filter_input(INPUT_GET, "acao") : NULL; $nome = filter_input(INPUT_POST, "nome") ? filter_input(INPUT_POST, "nome") : NULL; $nota = filter_input(INPUT_POST, "nota") ? filter_input(INPUT_POST, "nota") : NULL; require_once 'interface/Entidade.interface.php'; require_once 'classes/ServiceDb.class.php'; require_once 'classes/Aluno.class.php'; require_once "conexao.php"; $pdo = Conectar(); $aluno = new Aluno(); $aluno->setId($id); $aluno->setTable("alunos"); $aluno->setNome($nome); $aluno->setNota($nota); $dds = ["nome" => $aluno->getNome(), "nota" => $aluno->getNota()]; $aluno->setDados($dds); $aluno->setTermos("WHERE id = {$id}"); $exec = new ServiceDb($pdo, $aluno); switch ($acao) { case "cadastrar": $exec->Inserir(); break; case "editar": $exec->Alterar(); break; } header("location:index.php"); ?> </body> </html>
Dados principais do aluno --> <div id="foto"> <img src=<?php if (file_exists("fotos/" . $aluno->getId() . ".png")) { echo "\"fotos/" . $aluno->getId() . ".png\""; } else { echo "\"fotos/Padrao.png\""; } ?> width="150px" height="200px"> </div> <div class="row"> <p style="display:inline" class="col-sm-3"> <b>Aluno:</b> <?php echo htmlspecialchars($aluno->getNome()); ?> </p> <p style="display:inline" class="col-sm-3"> <b>Número de inscrição:</b> <?php echo htmlspecialchars($aluno->getNumeroInscricao()); ?> </p> <?php $status = ""; if ($aluno->getStatus() === "inscrito") { $status = "Inscrito"; } else { if ($aluno->getStatus() === "preinscrito") { $status = "Pré-inscrito";
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author ronald */ interface IAluno { function getNome(); function setNome($nome); function setResponsavel(Pessoa $responsavel); } class Aluno implements IAluno { private $nome; function setNome($nome) { $this->nome = $nome; } function getNome() { return $this->nome; } } $joaninha = new Aluno(); $joaninha->setNome('Joana Maranhã'); echo $joaninha->getNome();
$this->nome = $nome; $this->acertos = $acertos; } public function getNome() { return $this->nome; } public function setNome($nome) { $this->nome = $nome; } public function NotaFinal() { if (!$this->acertos) { return "Qutde de acertos não informados"; } else { return $this->acertos * $this->peso; } } public function setAcertos($acertos) { $this->acertos = $acertos; } public function getAcertos() { return $this->acertos; } } $a = new Aluno("José Carlos", 5); echo "Aluno " . $a->getNome() . " obteve nota: " . $a->NotaFinal() . "\n";
if ($aceito == 0 || $aceito == 1) { $textoQuery = "UPDATE Frequencia SET aprovacaoPendente = 0, presenca = ?\n WHERE chaveAula = ? AND chaveAluno = ?"; $query = $conexao->prepare($textoQuery); $query->bindParam(1, $aceito); $query->bindParam(2, $idAula); $query->bindParam(3, $idAluno); $sucesso = $query->execute(); if (!$sucesso) { $mensagem = "Não foi possível avaliar essa justificativa"; } else { $aluno = new Aluno(""); $aluno->setId($idAluno); $aluno->recebeAlunoId($host, "homeopatias", $usuario, $senhaBD); // enviamos um email avisando o aluno do status de sua justificativa $emailAluno = $aluno->getEmail(); $nomeAluno = $aluno->getNome(); $numInscricao = $idAluno; $assunto = "Homeopatias.com - Justificativa de ausência " . ($aceito ? "aceita" : "negada"); $msg = "<b>Essa é uma mensagem automática do sistema Homeopatias.com, favor não respondê-la</b>"; $msg .= "<br><br>A justificativa de ausência do(a) aluno(a) " . $nomeAluno . " foi " . ($aceito ? "aceita" : "negada") . "."; if (!$aceito) { $msg .= "<br>Caso você acredite que houve algum erro de julgamento"; $msg .= " por parte do avaliador da sua justificativa, favor"; $msg .= " entrar em contato conosco."; } $msg .= "<br><br>Obrigado,<br>Equipe Homeobrás."; $headers = "Content-type: text/html; charset=utf-8 " . "From: Sistema Homeopatias.com <*****@*****.**>" . "\r\n" . "Reply-To: noreply@homeopatias.com" . "\r\n" . "X-Mailer: PHP/" . phpversion(); mail($emailAluno, $assunto, $msg, $headers); // agora registramos no sistema uma notificação para o aluno $textoNotificacao = "Sua justificativa de ausência foi " . ($aceito ? "aceita" : "negada") . "."; if (!$aceito) {
} else { $novo->setCurso(null); } $novo->setStatus("preinscrito"); $novo->setIdIndicador($idIndicador); $sucesso = $novo->cadastrar($host, "homeopatias", $usuario, $senhaBD, $senha); $sucessoMoodle = false; if ($sucesso) { // criamos o aluno no Moodle $usuarioMoodle = $dados["usuario_moodle"]; $senhaMoodle = $dados["senha_moodle"]; $conMoodle = null; try { $conMoodle = new PDO("mysql:host={$host};dbname=moodle;charset=utf8", $usuarioMoodle, $senhaMoodle); $queryMoodle = "INSERT INTO mdl_user\n (firstname,lastname,email,username,password,\n confirmed,mnethostid) VALUES\n (?,?,?,?,MD5(?),1,1)"; $arrayNome = split(" ", $novo->getNome()); $dadosMoodle = array($arrayNome[0], array_pop($arrayNome), $novo->getEmail(), $novo->getLogin(), $senha); $query = $conMoodle->prepare($queryMoodle); $sucessoMoodle = $query->execute($dadosMoodle); } catch (PDOException $e) { // echo $e->getMessage(); } } $mensagem = "Usuário cadastrado com sucesso"; if (!$sucesso) { $mensagem = "Já existe um usuário com esse nome \n de usuário no sistema"; } else { if (!$sucessoMoodle) { $mensagem = "O registro foi efetuado, porém não foi possível registrar no Moodle"; } }
$valorValido = false; } } else { // redirecionamos o aluno de volta com uma mensagem de erro header('Location: ../visualizar_informacoes_curso.php?' . 'mensagem=Erro com o banco de dados', true, "302"); die; } } else { // redirecionamos o aluno de volta com uma mensagem de erro header('Location: ../visualizar_informacoes_curso.php?' . 'mensagem=Valor enviado inválido', true, "302"); die; } // agora enviamos o usuário para a tela de pagamento require '../PagSeguroLibrary/PagSeguroLibrary.php'; $reqPagamento = new PagSeguroPaymentRequest(); $reqPagamento->addItem('0001', 'Parcela do curso de Homeopatia', 1, number_format($valorRecebido, 2)); $reqPagamento->setCurrency("BRL"); $reqPagamento->setSender($aluno->getNome(), $aluno->getEmail(), mb_substr($aluno->getTelefone(), 0, 2), mb_substr($aluno->getTelefone(), 2)); $reqPagamento->setShippingAddress($aluno->getCep(), $aluno->getRua(), $aluno->getNumero(), $aluno->getComplemento(), $aluno->getBairro(), $aluno->getCidade(), $aluno->getEstado(), $aluno->getPais()); $reqPagamento->setShippingType(3); // a referência desse pagamente será a letra "M" de mensalidade, // seguida do número de inscrição desse aluno $reqPagamento->setReference("M" . $aluno->getNumeroInscricao()); $credenciais = PagSeguroConfig::getAccountCredentials(); $url = $reqPagamento->register($credenciais); header('Location: ' . $url, true, "302"); die; } // caso não tenha caído no caso anterior, redirecionamos o usuário // para o index header('Location: ../index.php', true, "302");
<?php include_once '../Classes/Aluno-class.php'; $objAluno = new Aluno(); $objAluno->setNome('Bill'); echo $objAluno->getNome();
$tabela .= "</table>"; echo $tabela; } echo "<a href='" . $_POST["url-send"] . "'>Continuar</a>"; } else { if ($admin->getNivelAdmin() === "administrador" && $admin->getPermissoes() & 1) { // Se o tipo do email e´ para selecionados, buscamos cada aluno selecionado e enviamos o e-mail if (isset($_POST['selecionados']) && mb_strlen($_POST['selecionados']) > 0 && $_POST['sendType'] === "selecionados") { $ids = split(",", $_POST['selecionados']); $tabela = "<table>"; foreach ($ids as $id) { if (!is_nan((double) $id) && $id != "") { $aluno = new Aluno(""); $aluno->setNumeroInscricao($id); $aluno->recebeAlunoId($host, $db, $usuario, $senhaBD); $tabela .= "<tr><td>" . $aluno->getNome() . "</td>"; if (mail($aluno->getEmail(), $titulo, $mensagem, $headers)) { $tabela .= "<td class = 'sucesso'>Enviado</td>"; } else { $tabela .= "<td class = 'warning'>Erro no Envio</td>"; } $tabela .= "</tr>"; } } $tabela .= "</table>"; echo $tabela; } if (isset($_POST['sendType']) && $_POST['sendType'] === "todos") { $filtroCidade = null; $queryAnoCidade = null; if (isset($get["filtro-cidade"])) {
function gravarAluno(Aluno $aluno){ #if (!is_object($aluno->getInstituicao())){ # throw new Exception('Informe a instituição!'); #}else{ # $aluno->Xinstituicao = $aluno->getInstituicao()->getId(); #} if (strlen($aluno->getNome())==0){ throw new Exception('Informe o nome do aluno!'); }else{ $aluno->Xnome = "'".$aluno->getNome()."'"; } if (strlen($aluno->getRa())==0){ throw new Exception('Informe o RA do aluno!'); }else{ $aluno->Xra = "'".$aluno->getRa()."'"; } if (strlen($aluno->getEmail())==0){ throw new Exception('Informe o email do aluno!'); }else{ $aluno->Xemail = "'".$aluno->getEmail()."'"; } if (strlen($aluno->getSenha())==0){ throw new Exception('Informe a senha do aluno!'); }else{ $aluno->Xsenha = "'".$aluno->getSenha()."'"; } if (strlen($aluno->getAtivo())==0){ $aluno->Xativo = " 0 "; }else{ $aluno->Xativo = $aluno->getAtivo(); } if (strlen($aluno->getEndereco())==0){ $aluno->Xendereco = " NULL "; }else{ $aluno->Xendereco = "'".$aluno->getEndereco()."'"; } if (strlen($aluno->getNumero())==0){ $aluno->Xnumero = " NULL "; }else{ $aluno->Xnumero = "'".$aluno->getNumero()."'"; } if (strlen($aluno->getComplemento())==0){ $aluno->Xcomplemento = " NULL "; }else{ $aluno->Xcomplemento = "'".$aluno->getComplemento()."'"; } if (strlen($aluno->getBairro())==0){ $aluno->Xbairro = " NULL "; }else{ $aluno->Xbairro = "'".$aluno->getBairro()."'"; } if (strlen($aluno->getCidade())==0){ $aluno->Xcidade = " NULL "; }else{ $aluno->Xcidade = "'".$aluno->getCidade()."'"; } if (strlen($aluno->getEstado())==0){ $aluno->Xestado = " NULL "; }else{ $aluno->Xestado = "'".$aluno->getEstado()."'"; } if (strlen($aluno->getCep())==0){ $aluno->Xcep = " NULL "; }else{ $aluno->Xcep = "'".$aluno->getCep()."'"; } if (strlen($aluno->getPais())==0){ $aluno->Xpais = "'BR'"; }else{ $aluno->Xpais = "'".$aluno->getPais()."'"; } $alunoDAO = new AlunoDAO(); $alunoDAO->setBancoDados($this->banco); $alunoDAO->gravaDadosAluno($aluno); }