Commit bcc715aed704ca9d4ee6e736e950d9ce5e27114d

Authored by Eriksen Costa Paixão
1 parent 6608f5a7
Exists in master

Atualizado relatório "Resultado final" para usar o service {{{Avaliacao_Service_…

…Boletim}}} como padrão para geração das informações de aluno aprovado/retido. Uma observação interessante: foram removidas 167 linhas de código com múltiplos if e loops aninhados por cerca de 20 linhas com 1 if/elseif/else. Removeu-se o comportamente redundante do cálculo de média e de presença com a aplicação do design pattern [http://martinfowler.com/eaaCatalog/serviceLayer.html service layer].
ieducar/intranet/educar_relatorio_resultado_final_proc.php
@@ -33,6 +33,8 @@ require_once 'include/clsCadastro.inc.php'; @@ -33,6 +33,8 @@ require_once 'include/clsCadastro.inc.php';
33 require_once 'include/clsBanco.inc.php'; 33 require_once 'include/clsBanco.inc.php';
34 require_once 'include/pmieducar/geral.inc.php'; 34 require_once 'include/pmieducar/geral.inc.php';
35 require_once 'include/clsPDF.inc.php'; 35 require_once 'include/clsPDF.inc.php';
  36 +require_once 'Avaliacao/Service/Boletim.php';
  37 +require_once 'App/Model/MatriculaSituacao.php';
36 38
37 /** 39 /**
38 * clsIndexBase class. 40 * clsIndexBase class.
@@ -85,8 +87,6 @@ class indice extends clsCadastro @@ -85,8 +87,6 @@ class indice extends clsCadastro
85 var $nm_serie; 87 var $nm_serie;
86 var $nm_cidade; 88 var $nm_cidade;
87 89
88 - var $array_modulos;  
89 -  
90 var $is_padrao; 90 var $is_padrao;
91 var $semestre; 91 var $semestre;
92 92
@@ -147,36 +147,6 @@ class indice extends clsCadastro @@ -147,36 +147,6 @@ class indice extends clsCadastro
147 $eh_multi_seriado = TRUE; 147 $eh_multi_seriado = TRUE;
148 } 148 }
149 149
150 - $obj_curso = new clsPmieducarCurso($this->ref_cod_curso);  
151 - $det_curso = $obj_curso->detalhe();  
152 -  
153 - $frequencia_minima = $det_curso["frequencia_minima"];  
154 - $hora_falta = $det_curso["hora_falta"];  
155 -  
156 - $obj_tipo_avaliacao = new clsPmieducarTipoAvaliacao($det_curso["ref_cod_tipo_avaliacao"]);  
157 - $det_tipo_avaliacao = $obj_tipo_avaliacao->detalhe();  
158 -  
159 - $eh_conceitual = $det_tipo_avaliacao["conceitual"];  
160 -  
161 - if ($det_curso['padrao_ano_escolar']) {  
162 - $obj_ano_letivo_modulo = new clsPmieducarAnoLetivoModulo();  
163 - $obj_ano_letivo_modulo->setOrderby('data_inicio asc');  
164 -  
165 - $lst_ano_letivo_modulo = $obj_ano_letivo_modulo->lista($this->ano,  
166 - $this->ref_cod_escola, NULL, NULL);  
167 -  
168 - if ($lst_ano_letivo_modulo) {  
169 - foreach ($lst_ano_letivo_modulo as $modulo) {  
170 - $obj_modulo = new clsPmieducarModulo($modulo['ref_cod_modulo']);  
171 - $det_modulo = $obj_modulo->detalhe();  
172 - $this->array_modulos[] = $det_modulo;  
173 - }  
174 - }  
175 - }  
176 -  
177 - $obj_disc_serie = new clsPmieducarEscolaSerieDisciplina();  
178 - $lst_disc_serie = $obj_disc_serie->lista($this->ref_cod_serie, $this->ref_cod_escola, NULL, 1);  
179 -  
180 $this->pdf = new clsPDF('Resultado Final', 'Resultado Final', 'A4', '', FALSE, FALSE); 150 $this->pdf = new clsPDF('Resultado Final', 'Resultado Final', 'A4', '', FALSE, FALSE);
181 151
182 $this->pdf->OpenPage(); 152 $this->pdf->OpenPage();
@@ -211,8 +181,7 @@ class indice extends clsCadastro @@ -211,8 +181,7 @@ class indice extends clsCadastro
211 $obj_matricula = new clsPmieducarMatriculaTurma(); 181 $obj_matricula = new clsPmieducarMatriculaTurma();
212 $obj_matricula->setOrderby('m.ref_ref_cod_serie, nome_ascii'); 182 $obj_matricula->setOrderby('m.ref_ref_cod_serie, nome_ascii');
213 183
214 - // @todo 2007? Que diabo de condição é essa?  
215 - if ($this->is_padrao || $this->ano == 2007) { 184 + if ($this->is_padrao) {
216 $this->semestre = NULL; 185 $this->semestre = NULL;
217 } 186 }
218 187
@@ -238,7 +207,13 @@ class indice extends clsCadastro @@ -238,7 +207,13 @@ class indice extends clsCadastro
238 $obj_matricula = new clsPmieducarMatricula($matricula['ref_cod_matricula']); 207 $obj_matricula = new clsPmieducarMatricula($matricula['ref_cod_matricula']);
239 $det_matricula = $obj_matricula->detalhe(); 208 $det_matricula = $obj_matricula->detalhe();
240 209
241 - if ($det_matricula['aprovado'] == 1 || $det_matricula['aprovado'] == 2) { 210 + // Verifica se o aluno está aprovado ou reprovado
  211 + $situacoes = array(
  212 + App_Model_MatriculaSituacao::APROVADO,
  213 + App_Model_MatriculaSituacao::REPROVADO
  214 + );
  215 +
  216 + if (in_array($det_matricula['aprovado'], $situacoes)) {
242 $ordem_mostra++; 217 $ordem_mostra++;
243 $ordem_mostra = sprintf('%02d', $ordem_mostra); 218 $ordem_mostra = sprintf('%02d', $ordem_mostra);
244 219
@@ -271,172 +246,31 @@ class indice extends clsCadastro @@ -271,172 +246,31 @@ class indice extends clsCadastro
271 250, 15, NULL, 8); 246 250, 15, NULL, 8);
272 } 247 }
273 248
274 - if (!$eh_conceitual) {  
275 - if ($det_matricula['aprovado'] == 1) {  
276 - $this->pdf->escreve_relativo('X', 345, ($base + 3) + ($linha * 15),  
277 - 250, 15, NULL, 8);  
278 - $total_aprovados++;  
279 - }  
280 - else {  
281 - $reprovou_por_falta = FALSE;  
282 - $reprovou_por_nota = FALSE;  
283 -  
284 - if (is_array($lst_disc_serie)) {  
285 - foreach ($lst_disc_serie as $disciplina) {  
286 - if (!$reprovou_por_falta) {  
287 - $obj_falta = new clsPmieducarFaltaAluno();  
288 -  
289 - if ($det_curso['padrao_ano_escolar'] == 1) {  
290 - $lst_falta = $obj_falta->lista(NULL, NULL, NULL,  
291 - $this->ref_cod_serie, $this->ref_cod_escola,  
292 - $disciplina['ref_cod_disciplina'],  
293 - $matricula['ref_cod_matricula'], NULL, NULL, NULL,  
294 - NULL, NULL, 1);  
295 - }  
296 - else {  
297 - $lst_falta = $obj_falta->lista(NULL, NULL, NULL,  
298 - $this->ref_cod_serie, $this->ref_cod_escola, NULL,  
299 - $matricula['ref_cod_matricula'], NULL, NULL, NULL, NULL,  
300 - NULL, 1, NULL, $disciplina['ref_cod_disciplina']);  
301 - }  
302 -  
303 - $total_faltas = 0;  
304 - if (is_array($lst_falta)) {  
305 - foreach ($lst_falta as $key => $value) {  
306 - $total_faltas += $lst_falta[$key]['faltas'];  
307 - }  
308 - }  
309 -  
310 - $obj_disciplina = new clsPmieducarDisciplina($disciplina['ref_cod_disciplina']);  
311 - $det_disciplina = $obj_disciplina->detalhe();  
312 - $carga_horaria_disciplina = $det_disciplina['carga_horaria'];  
313 -  
314 - $max_falta = ($carga_horaria_disciplina * $frequencia_minima) / 100;  
315 - $max_falta = $carga_horaria_disciplina - $max_falta;  
316 -  
317 - $total_faltas *= $hora_falta;  
318 - if ($total_faltas > $max_falta) {  
319 - $this->pdf->escreve_relativo('X', 465, ($base + 3) + ($linha * 15),  
320 - 250, 15, NULL, 8);  
321 -  
322 - $reprovou_por_falta = TRUE;  
323 - $total_reprovados_desempenho++;  
324 - }  
325 - }  
326 -  
327 - if (!$reprovou_por_nota) {  
328 - $obj_nota = new clsPmieducarNotaAluno();  
329 - $obj_nota->setOrderby('modulo asc');  
330 -  
331 - if ($det_curso['padrao_ano_escolar'] == 1) {  
332 - $det_nota = $obj_nota->lista(NULL, NULL, NULL,  
333 - $this->ref_cod_serie, $this->ref_cod_escola,  
334 - $disciplina['ref_cod_disciplina'], $matricula['ref_cod_matricula'],  
335 - NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL);  
336 - }  
337 - else {  
338 - $det_nota = $obj_nota->lista(NULL, NULL, NULL,  
339 - $this->ref_cod_serie, $this->ref_cod_escola, NULL,  
340 - $matricula['ref_cod_matricula'], NULL, NULL, NULL, NULL,  
341 - NULL, NULL, 1, NULL, $disciplina['ref_cod_disciplina']);  
342 - }  
343 -  
344 - if (is_array($det_nota)) {  
345 - $soma_notas = 0;  
346 -  
347 - foreach ($det_nota as $key => $nota) {  
348 - $obj_tipo_av_val = new clsPmieducarTipoAvaliacaoValores(  
349 - $nota['ref_ref_cod_tipo_avaliacao'], $nota['ref_sequencial'],  
350 - NULL, NULL, NULL, NULL  
351 - );  
352 -  
353 - $det_tipo_av_val = $obj_tipo_av_val->detalhe();  
354 -  
355 - if (count($this->array_modulos) == count($det_nota)) {  
356 - $frequencia_minima = $det_curso['frequencia_minima'];  
357 - $hora_falta = $det_curso['hora_falta'];  
358 - $carga_horaria_curso = $det_curso['carga_horaria'];  
359 - }  
360 -  
361 - if (!dbBool($det_serie['ultima_nota_define'])) {  
362 - if ($key < (count($this->array_modulos))) {  
363 - $soma_notas += $det_tipo_av_val['valor'];  
364 - $media_sem_exame = TRUE;  
365 - }  
366 - else {  
367 - $media_sem_exame = FALSE;  
368 - $nota_exame = TRUE;  
369 - $exame_nota = $det_nota[$key]['nota'];  
370 - }  
371 - }  
372 - else {  
373 - $media_sem_exame = TRUE;  
374 - $soma_notas = $det_tipo_av_val['valor'];  
375 - }  
376 - }  
377 - }  
378 -  
379 - if (!dbBool($det_serie['ultima_nota_define'])) {  
380 - if (!$nota_exame) {  
381 - $media = $soma_notas / count($det_nota);  
382 - // soh esta parte eh do codigo original  
383 - // $media_ = $media;  
384 - }  
385 - else {  
386 - $media = ($soma_notas + $exame_nota * 2) / (count($det_nota) + 1);  
387 - }  
388 - }  
389 - else {  
390 - $media = $soma_notas;  
391 - }  
392 -  
393 - $obj_media = new clsPmieducarTipoAvaliacaoValores();  
394 - $det_media = $obj_media->lista($det_curso['ref_cod_tipo_avaliacao'],  
395 - $det_curso['ref_sequencial'], NULL, NULL, $media, $media);  
396 -  
397 - if ($det_media) {  
398 - $det_media = array_shift($det_media);  
399 - $media = $det_media['valor'];  
400 - $media = sprintf('%01.1f',$media);  
401 - $media = str_replace('.', ',', $media);  
402 - }  
403 -  
404 - if ($media_sem_exame) {  
405 - $media_curso_ = $det_curso['media'];  
406 - }  
407 - else {  
408 - $media_curso_ = $det_curso['media_exame'];  
409 - }  
410 -  
411 - if (str_replace(',', '.', $media) < $media_curso_) {  
412 - $this->pdf->escreve_relativo('X', 410, ($base + 3) + ($linha * 15),  
413 - 250, 15, NULL, 8);  
414 - $reprovou_por_nota = TRUE;  
415 - $total_reprovados_nota++;  
416 - }  
417 - }  
418 -  
419 - if ($reprovou_por_falta && $reprovou_por_nota) {  
420 - break;  
421 - }  
422 - }  
423 - }  
424 - } 249 + /**
  250 + * Instancia o service de boletim e requisita os dados da situação
  251 + * do aluno. Graças ao service, são "apenas" 147 linhas de código
  252 + * mal-escrito a menos.
  253 + */
  254 + $boletim = new Avaliacao_Service_Boletim(array(
  255 + 'matricula' => $matricula['ref_cod_matricula']
  256 + ));
  257 +
  258 + $situacao = $boletim->getSituacaoAluno();
  259 +
  260 + if (TRUE == $situacao->aprovado) {
  261 + $this->pdf->escreve_relativo('X', 345, ($base + 3) + ($linha * 15),
  262 + 250, 15, NULL, 8);
  263 + $total_aprovados++;
  264 + }
  265 + elseif (TRUE == $situacao->retidoFalta) {
  266 + $total_reprovados_desempenho++;
  267 + $this->pdf->escreve_relativo('X', 465, ($base + 3) + ($linha * 15),
  268 + 250, 15, NULL, 8);
425 } 269 }
426 else { 270 else {
427 - if ($det_matricula['aprovado'] == 1) {  
428 - $this->pdf->escreve_relativo('X', 345, ($base + 3) + ($linha * 15),  
429 - 250, 15, NULL, 8); // aprovado  
430 -  
431 - $total_aprovados++;  
432 - }  
433 - else {  
434 - $this->pdf->escreve_relativo('X', 410, ($base + 3) + ($linha * 15),  
435 - 250, 15, NULL, 8); // desempenho  
436 -  
437 - $reprovou_por_nota = TRUE;  
438 - $total_reprovados_nota++;  
439 - } 271 + $total_reprovados_nota++;
  272 + $this->pdf->escreve_relativo('X', 410, ($base + 3) + ($linha * 15),
  273 + 250, 15, NULL, 8);
440 } 274 }
441 275
442 // analfabeto 276 // analfabeto