Ejemplo n.º 1
0
 public function processar_turmas_medias()
 {
     $msg = null;
     $data = $this->getParametroVisao();
     $data['page'] = 'home';
     $data['tema'] != '' ? $this->load->setTheme($data['tema']) : '';
     $data['msg'] = $msg;
     $data['abaAtiva'] = 9;
     $data['abaPage'] = 'processar_turmas_medias';
     $data['alias'] = 'processar_turmas_medias';
     // Pega o total de turmas a serem processadas
     $total = count($_SESSION['dadosEnvio']);
     $result = $_SESSION['dadosEnvio'];
     $data['total'] = $total;
     $data['status'] = '';
     // Se já tiver ocorrido algum redirecionamento, faz um incremento. Caso contrário, inicia a contagem
     if (isset($_GET['counter'])) {
         $counter = $_GET['counter'] + 1;
     } else {
         $counter = 0;
     }
     // carrega a library e envia as variáveis a função "loop_refresh"
     $this->load->library('util');
     $data['redirect_delay'] = $this->util->loop_refresh('1', $this->uri->segment(3), $counter, $total);
     // Se o contador for menor que o total de registros da array, efetua o processamento com base no registro da vez
     if ($counter < $total) {
         $dadosEnvio = $result[$counter];
         $data['status'] = 'Processando ' . $dadosEnvio['turma_nome'];
         // CONCEITO DEFICIENTE
         $sqlAfa = new SqlAfa();
         $result = $sqlAfa->get_turmas_conceitos_n($dadosEnvio['pk_turma'], $data['ano_letivo'], 'Deficiente');
         $n_deficiente = (int) $result[0]['total'];
         $sqlAfa = new SqlAfa();
         $result = $sqlAfa->get_turmas_conceitos($dadosEnvio['pk_turma'], $data['ano_letivo'], 'Deficiente');
         if ($n_deficiente == 0) {
             $conceito_deficiente = NULL;
         } else {
             if ($result[0]['score'] >= 5) {
                 $conceito_deficiente = 4.9;
             } else {
                 $conceito_deficiente = $result[0]['score'];
             }
         }
         // CONCEITO INSUFICINETE
         $sqlAfa = new SqlAfa();
         $result = $sqlAfa->get_turmas_conceitos_n($dadosEnvio['pk_turma'], $data['ano_letivo'], 'Insuficiente');
         $n_insuficiente = (int) $result[0]['total'];
         $sqlAfa = new SqlAfa();
         $result = $sqlAfa->get_turmas_conceitos($dadosEnvio['pk_turma'], $data['ano_letivo'], 'Insuficiente');
         $conceito_insuficiente = $result[0]['score'];
         if ($n_insuficiente == 0) {
             $conceito_insuficiente = NULL;
         } else {
             if ($result[0]['score'] < 5) {
                 $conceito_insuficiente = 5;
             } else {
                 if ($result[0]['score'] >= 7) {
                     $conceito_insuficiente = 6.9;
                 } else {
                     $conceito_insuficiente = $result[0]['score'];
                 }
             }
         }
         // CONCEITO REGULAR
         $sqlAfa = new SqlAfa();
         $result = $sqlAfa->get_turmas_conceitos_n($dadosEnvio['pk_turma'], $data['ano_letivo'], 'Regular');
         $n_regular = (int) $result[0]['total'];
         $sqlAfa = new SqlAfa();
         $result = $sqlAfa->get_turmas_conceitos($dadosEnvio['pk_turma'], $data['ano_letivo'], 'Regular');
         if ($n_regular == 0) {
             $conceito_regular = NULL;
         } else {
             if ($result[0]['score'] < 7) {
                 $conceito_regular = 7;
             } else {
                 if ($result[0]['score'] >= 8) {
                     $conceito_regular = 7.9;
                 } else {
                     $conceito_regular = $result[0]['score'];
                 }
             }
         }
         // CONCEITO BOM
         $sqlAfa = new SqlAfa();
         $result = $sqlAfa->get_turmas_conceitos_n($dadosEnvio['pk_turma'], $data['ano_letivo'], 'Bom');
         $n_bom = (int) $result[0]['total'];
         $sqlAfa = new SqlAfa();
         $result = $sqlAfa->get_turmas_conceitos($dadosEnvio['pk_turma'], $data['ano_letivo'], 'Bom');
         if ($n_bom == 0) {
             $conceito_bom = NULL;
         } else {
             if ($result[0]['score'] < 8) {
                 $conceito_bom = 8;
             } else {
                 if ($result[0]['score'] >= 9) {
                     $conceito_bom = 8.9;
                 } else {
                     $conceito_bom = doubleval($result[0]['score']);
                 }
             }
         }
         // CONCEITO LOUVOR
         $sqlAfa = new SqlAfa();
         $result = $sqlAfa->get_turmas_conceitos_n($dadosEnvio['pk_turma'], $data['ano_letivo'], 'Louvor');
         $n_louvor = (int) $result[0]['total'];
         $sqlAfa = new SqlAfa();
         $result = $sqlAfa->get_turmas_conceitos($dadosEnvio['pk_turma'], $data['ano_letivo'], 'Louvor');
         if ($n_louvor == 0) {
             $conceito_louvor = NULL;
         } else {
             if ($result[0]['score'] < 9) {
                 $conceito_louvor = 9;
             } else {
                 $conceito_louvor = doubleval($result[0]['score']);
             }
         }
         // CONCEITO GERAL DA TURMA
         $sqlAfa = new SqlAfa();
         $result = $sqlAfa->get_conceito_geral_turma($dadosEnvio['pk_turma'], $data['ano_letivo']);
         $conceito_geral = doubleval($result[0]['score']);
         $sqlAfa = new SqlAfa();
         $sqlAfa->insert_conceito_turma($dadosEnvio['pk_turma'], $_SESSION['pk_afa_data_process'], $conceito_geral, $conceito_deficiente, $n_deficiente, $conceito_insuficiente, $n_insuficiente, $conceito_regular, $n_regular, $conceito_bom, $n_bom, $conceito_louvor, $n_louvor);
     } else {
         $this->load->library('util');
         $data['redirect_delay'] = $this->util->redirect_delay(1, 'afa/aluno/processar_series');
     }
     $this->load->view($this->load->getUrlTema(), $data);
 }