Commit 5602008e7c516cc513d1ecc0310dd1ebd7e3d7f8

Authored by Eriksen Costa Paixão
1 parent 728f42c6
Exists in master

Atualizado relatório '''Espelho de Nota Anual''' para usar {{{Avaliacao_Service_…

…Boletim}}} e classes dos módulos ComponenteCurricular e RegraAvaliacao. Refactoring de {{{App_Model_IedFinder}}} e testes relacionados
ieducar/intranet/educar_relatorio_alunos_nota_semestre_proc.php
... ... @@ -34,6 +34,8 @@ require_once 'include/clsBanco.inc.php';
34 34 require_once 'include/pmieducar/geral.inc.php';
35 35 require_once 'include/relatorio.inc.php';
36 36  
  37 +require_once 'Avaliacao/Service/Boletim.php';
  38 +
37 39 /**
38 40 * clsIndexBase class.
39 41 *
... ... @@ -69,6 +71,16 @@ class indice extends clsCadastro
69 71 {
70 72 var $pessoa_logada;
71 73  
  74 + /**
  75 + * @var RegraAvaliacao_Model_Regra
  76 + */
  77 + var $regra = NULL;
  78 +
  79 + /**
  80 + * @var array
  81 + */
  82 + static $boletim = array();
  83 +
72 84 var $ref_cod_instituicao;
73 85 var $ref_cod_escola;
74 86 var $ref_cod_serie;
... ... @@ -105,9 +117,9 @@ class indice extends clsCadastro
105 117  
106 118 if (empty($this->ref_cod_turma)) {
107 119 echo '<script>
108   - alert("Erro ao gerar relatório!\nNenhuma turma selecionada!");
109   - window.parent.fechaExpansivel(\'div_dinamico_\'+(window.parent.DOM_divs.length-1));
110   - </script>';
  120 + alert("Erro ao gerar relatório!\nNenhuma turma selecionada!");
  121 + window.parent.fechaExpansivel(\'div_dinamico_\'+(window.parent.DOM_divs.length-1));
  122 + </script>';
111 123  
112 124 return TRUE;
113 125 }
... ... @@ -134,6 +146,10 @@ class indice extends clsCadastro
134 146 $det_serie = $obj_serie->detalhe();
135 147 $this->nm_serie = $det_serie['nm_serie'];
136 148  
  149 + // Regra da série
  150 + $regraMapper = new RegraAvaliacao_Model_RegraDataMapper();
  151 + $this->regra = $regraMapper->find($det_serie['regra_avaliacao_id']);
  152 +
137 153 $obj_pessoa = new clsPessoa_($det_turma['ref_cod_regente']);
138 154 $det = $obj_pessoa->detalhe();
139 155 $this->nm_professor = $det['nome'];
... ... @@ -147,11 +163,6 @@ class indice extends clsCadastro
147 163 return TRUE;
148 164 }
149 165  
150   - $obj = new clsPmieducarSerie();
151   - $obj->setOrderby('cod_serie,etapa_curso');
152   - $lista_serie_curso = $obj->lista(null, null, null, $this->ref_cod_curso,
153   - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao);
154   -
155 166 $obj_curso = new clsPmieducarCurso($this->ref_cod_curso);
156 167 $det_curso = $obj_curso->detalhe();
157 168 $this->nm_curso = $det_curso['nm_curso'];
... ... @@ -163,57 +174,21 @@ class indice extends clsCadastro
163 174 $obj_matricula_turma = new clsPmieducarMatriculaTurma();
164 175 $obj_matricula_turma->setOrderby('nome_ascii');
165 176  
166   - if (!$this->is_padrao && is_numeric($this->semestre) && $this->ano != 2007) {
167   - $lst_matricula_turma = $obj_matricula_turma->lista($this->ref_cod_matricula,
168   - $this->ref_cod_turma, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_serie,
169   - $this->ref_cod_curso, $this->ref_cod_escola, $this->ref_cod_instituicao,
170   - NULL, NULL, array(1,2,3), NULL, NULL, $this->ano, NULL, NULL, NULL, NULL,
171   - TRUE, NULL, NULL, NULL, NULL, $this->semestre);
172   - }
173   - else {
174   - $lst_matricula_turma = $obj_matricula_turma->lista($this->ref_cod_matricula,
175   - $this->ref_cod_turma, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_serie,
176   - $this->ref_cod_curso, $this->ref_cod_escola, $this->ref_cod_instituicao,
177   - NULL, NULL, array(1,2,3), NULL, NULL, $this->ano, NULL, NULL, NULL, NULL, TRUE);
178   - }
  177 + $lst_matricula_turma = $obj_matricula_turma->lista($this->ref_cod_matricula,
  178 + $this->ref_cod_turma, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_serie,
  179 + $this->ref_cod_curso, $this->ref_cod_escola, $this->ref_cod_instituicao,
  180 + NULL, NULL, array(1,2,3), NULL, NULL, $this->ano, NULL, NULL, NULL, NULL, TRUE);
179 181  
180 182 $obj_disciplinas = new clsPmieducarEscolaSerieDisciplina();
181 183 $lst_disciplinas = $obj_disciplinas->lista($this->ref_cod_serie,
182 184 $this->ref_cod_escola, NULL, 1);
183 185  
184   - // Caso o curso siga o padrão da escola
185   - if ($det_curso["padrao_ano_escolar"]) {
186   - $obj_ano_letivo_modulo = new clsPmieducarAnoLetivoModulo();
187   - $lst_ano_letivo_modulo = $obj_ano_letivo_modulo->lista($this->ano, $this->ref_cod_escola);
  186 + // Recupera a quantidade de módulos e o nome do módulo da escola/turma
  187 + $modulo = App_Model_IedFinder::getModulo($this->ref_cod_escola,
  188 + $this->ref_cod_curso, $this->ref_cod_turma, $this->ano);
188 189  
189   - if (is_array($lst_ano_letivo_modulo)) {
190   - // Guarda a qtd de módulos a serem cursados
191   - $qtd_modulos = count($lst_ano_letivo_modulo);
192   - $segue_padrão = TRUE;
193   - }
194   - }
195   - // Caso o curso não siga o padrão da escola
196   - else {
197   - $obj_turma_modulo = new clsPmieducarTurmaModulo();
198   - $lst_turma_modulo = $obj_turma_modulo->lista($this->ref_cod_turma);
199   -
200   - if (is_array($lst_turma_modulo)) {
201   - // Guarda a qtd de módulos a serem cursados
202   - $qtd_modulos = count($lst_turma_modulo);
203   -
204   - $aux_turma_modulo = array_shift($lst_turma_modulo);
205   - $obj_modulo = new clsPmieducarModulo($aux_turma_modulo['ref_cod_modulo']);
206   - $det_modulo = $obj_modulo->detalhe();
207   - $nm_modulo = $det_modulo['nm_tipo'];
208   - $segue_padrão = FALSE;
209   - $mostra_cabecalho = array();
210   - $nm_modulo = substr(strtoupper($nm_modulo), 0, 1);
211   -
212   - for ($i = 0; $i < $qtd_modulos; $i++) {
213   - $mostra_cabecalho[$i] = ($i + 1) . 'º' . $nm_modulo;
214   - }
215   - }
216   - }
  190 + $nomeModulo = $modulo['nome'][0];
  191 + $modulos = $modulo['total'];
217 192  
218 193 if ($lst_matricula_turma) {
219 194 $relatorio = new relatorios('Espelho de Notas Ano - ' . $this->ano, 210,
... ... @@ -223,229 +198,115 @@ class indice extends clsCadastro
223 198 $relatorio->setMargem(20, 20, 20, 20);
224 199 $relatorio->exibe_produzido_por = FALSE;
225 200  
226   - $db = new clsBanco();
  201 + // Mapper para o componente
  202 + $componenteMapper = new ComponenteCurricular_Model_ComponenteDataMapper();
227 203  
228   - if (!$conceitual) {
229   - $campo_nota = 'COALESCE(nota,valor) ';
230   - }
231   - else {
232   - $campo_nota = 'nome ';
233   - }
  204 + $array_val = array(
  205 + array(40, 'Cód.'),
  206 + array(160, 'Nome do Aluno')
  207 + );
234 208  
235   - foreach ($lst_disciplinas as $disciplina) {
236   - $obj_disciplina = new clsPmieducarDisciplina($disciplina['ref_cod_disciplina']);
237   - $det_disciplina = $obj_disciplina->detalhe();
  209 + foreach (range(1, $modulos) as $num) {
  210 + $array_val[] = array(30, $num . $nomeModulo);
  211 + }
238 212  
239   - $relatorio->novalinha(array($det_disciplina['nm_disciplina']), 0, 16,
240   - TRUE, 'arial', array(400), '#515151', '#D3D3D3', '#FFFFFF', FALSE, TRUE);
  213 + $array_val[] = array(55, 'M.Parcial');
  214 + $array_val[] = array(50, 'Exame');
  215 + $array_val[] = array(50, 'M.Final');
  216 + $array_val[] = array(38, 'Faltas');
241 217  
242   - if ($segue_padrão) {
243   - if (!$conceitual) {
244   - $array_val = array('Cód. Aluno', 'Nome do Aluno', '1ºB', '2ºB', '3ºB',
245   - '4ºB', 'M.Parcial', 'Exame', 'M.Final', 'Faltas');
246   - }
247   - else {
248   - $array_val = array('Cód. Aluno', 'Nome do Aluno', '1ºB', '2ºB', '3ºB',
249   - '4ºB', '', '', '', 'Faltas');
250   - }
251   - }
252   - else {
253   - if (!$conceitual) {
254   - $array_val = array('Cód. Aluno', 'Nome do Aluno', $mostra_cabecalho[0],
255   - $mostra_cabecalho[1], $mostra_cabecalho[2], $mostra_cabecalho[3],
256   - 'M.Parcial', 'Exame', 'M.Final', 'Faltas');
257   - }
258   - else {
259   - $array_val = array('Cód. Aluno', 'Nome do Aluno', $mostra_cabecalho[0],
260   - $mostra_cabecalho[1], $mostra_cabecalho[2], $mostra_cabecalho[3],
261   - '', '', '', 'Faltas');
262   - }
  218 + $arrFuncBody = '
  219 + $values = array();
  220 + foreach ($data as $d) {
  221 + $values[] = $d[$index];
263 222 }
  223 + return $values;
  224 + ';
264 225  
265   - $relatorio->novalinha($array_val, 0, 13, TRUE, 'arial',
266   - array(40, 160, 30, 30, 30, 30, 55, 50, 50, 38), '#515151', '#D3D3D3',
267   - '#FFFFFF', FALSE, TRUE);
  226 + $arrFunc = create_function('$data, $index', $arrFuncBody);
268 227  
269   - foreach ($lst_matricula_turma as $matricula) {
270   - $consulta = "
271   - SELECT
272   - ref_cod_disciplina,
273   - $campo_nota AS nota,
274   - modulo
275   - FROM
276   - pmieducar.nota_aluno
277   - LEFT OUTER JOIN
278   - pmieducar.tipo_avaliacao_valores
279   - ON
280   - (
281   - ref_ref_cod_tipo_avaliacao = ref_cod_tipo_avaliacao
282   - AND ref_sequencial = sequencial
283   - )
284   - WHERE
285   - ref_cod_matricula = {$matricula['ref_cod_matricula']}
286   - AND ref_cod_escola = {$this->ref_cod_escola}
287   - AND ref_cod_serie = {$this->ref_cod_serie}
288   - AND ref_cod_disciplina = {$disciplina['ref_cod_disciplina']}
289   - AND nota_aluno.ativo = 1
290   - GROUP BY
291   - ref_cod_disciplina,
292   - modulo,
293   - $campo_nota
294   - ORDER BY
295   - modulo ASC";
296   -
297   - $db->Consulta($consulta);
298   -
299   - $media_parcial = 0;
300   - $registro = NULL;
301   - $nota1 = '';
302   - $nota2 = '';
303   - $nota3 = '';
304   - $nota4 = '';
305   - $faltas = '';
306   - $nota_exame = '';
307   - $media_final = '';
308   -
309   - while ($db->ProximoRegistro()) {
310   - $registro = $db->Tupla();
311   - $variavel = "nota{$registro['modulo']}";
312   - $$variavel = $conceitual ? $registro['nota'] : number_format( $registro['nota'] ,2,'.','');
313   - $ultimo_modulo = $registro['modulo'];
314   -
315   - if (!$conceitual) {
316   - $media_parcial = $media_parcial + $registro['nota'];
317   - /**
318   - * nota do exame
319   - */
320   - if ($registro['modulo'] > $qtd_modulos) {
321   - $nota_exame = $conceitual ? '' : number_format($registro['nota'] ,2, '.', '');
322   - }
323   - else {
324   - $nota_exame = '';
325   - }
326   - }
327   - else {
328   - $media_parcial = '';
329   - }
330   - }
  228 + foreach ($lst_disciplinas as $k => $disciplina) {
  229 + $componenteId = $disciplina['ref_cod_disciplina'];
  230 + $componente = $componenteMapper->find($componenteId);
331 231  
332   - if (!$conceitual) {
333   - $media_parcial = number_format($media_parcial / $ultimo_modulo, 2, '.', '');
334   - }
  232 + $relatorio->novalinha(array($componente->nome), 0, 16,
  233 + TRUE, 'arial', array(400), '#515151', '#D3D3D3', '#FFFFFF', FALSE, TRUE);
335 234  
336   - //exame ou total modulos
337   - if (($ultimo_modulo == $qtd_modulos || $ultimo_modulo - 1 == $qtd_modulos) && !$conceitual) {
338   - $objNotaAluno = new clsPmieducarNotaAluno();
339   -
340   - if ($qtd_modulos == $ultimo_modulo) {
341   - if (!dbBool($det_serie['ultima_nota_define'])) {
342   - $media_final = $objNotaAluno->getMediaAluno(
343   - $matricula['ref_cod_matricula'], $disciplina['ref_cod_disciplina'],
344   - $this->ref_cod_serie, $ultimo_modulo, $det_curso['media']
345   - );
346   - }
347   - else {
348   - $media_final = $objNotaAluno->getUltimaNotaModulo(
349   - $matricula['ref_cod_matricula'], $disciplina['ref_cod_disciplina'],
350   - $this->ref_cod_serie, $ultimo_modulo
351   - );
352   - }
353   - }
354   - else {
355   - $media_final = $objNotaAluno->getMediaAlunoExame(
356   - $matricula['ref_cod_matricula'], $disciplina['ref_cod_disciplina'],
357   - $this->ref_cod_serie, $ultimo_modulo - 1
358   - );
359   - }
  235 + $relatorio->novalinha($arrFunc($array_val, 1), 0, 16, TRUE, 'arial',
  236 + $arrFunc($array_val, 0), '#515151', '#D3D3D3',
  237 + '#FFFFFF', FALSE, TRUE);
360 238  
361   - $media_final = number_format($media_final, 2, '.', '');
  239 + foreach ($lst_matricula_turma as $matricula) {
  240 + $codMatricula = $matricula['ref_cod_matricula'];
  241 +
  242 + if (!isset($this->boletim[$codMatricula])) {
  243 + $boletim = new Avaliacao_Service_Boletim(array(
  244 + 'matricula' => $codMatricula,
  245 + 'ComponenteDataMapper' => $componenteMapper,
  246 + 'RegraDataMapper' => $regraMapper
  247 + ));
362 248 }
363 249 else {
364   - $media_final = $conceitual ? '' : '-';
  250 + $boletim = $this->boletim[$codMatricula];
365 251 }
366 252  
367   - $total_faltas = 0;
  253 + $media_final = $media_parcial = $nota_exame = '';
  254 + $medias = $boletim->getMediasComponentes();
  255 + $notas = $boletim->getNotasComponentes();
368 256  
369   - if ($det_curso['falta_ch_globalizada']) {
370   - $obj_falta = new clsPmieducarFaltas();
371   - $obj_falta->setOrderby('sequencial ASC');
372   - $det_falta = $obj_falta->lista($matricula['ref_cod_matricula'], NULL,
373   - NULL, NULL, NULL, NULL);
374   -
375   - if (is_array($det_falta)) {
376   - foreach ($det_falta as $key => $value) {
377   - $total_faltas += $det_falta[$key]['faltas'] = $value['falta'];
378   - }
379   - }
  257 + if ($boletim->getRegra()->get('tipoPresenca') == RegraAvaliacao_Model_TipoPresenca::GERAL) {
  258 + $faltas = array_sum(CoreExt_Entity::entityFilterAttr(
  259 + $boletim->getFaltasGerais(), 'id', 'quantidade'
  260 + ));
380 261 }
381 262 else {
382   - $obj_falta = new clsPmieducarFaltaAluno();
383   - $obj_falta->setOrderby("cod_falta_aluno asc");
  263 + $faltas = $boletim->getFaltasComponentes();
384 264  
385   - if ($det_curso['padrao_ano_escolar'] == 1) {
386   - $det_falta = $obj_falta->lista(NULL, NULL, NULL, $this->ref_cod_serie,
387   - $this->ref_cod_escola, $disciplina['ref_cod_disciplina'],
388   - $matricula['ref_cod_matricula'], NULL, NULL, NULL, NULL, NULL, 1);
  265 + if (isset($faltas[$componente->id])) {
  266 + $faltas = array_sum(CoreExt_Entity::entityFilterAttr(
  267 + $faltas[$componente->id], 'id', 'quantidade'
  268 + ));
389 269 }
390 270 else {
391   - $det_falta = $obj_falta->lista(NULL, NULL, NULL, $this->ref_cod_serie,
392   - $this->ref_cod_escola, NULL, $matricula['ref_cod_matricula'],
393   - NULL, NULL, NULL, NULL, NULL, 1, NULL, $disciplina['ref_cod_disciplina']);
394   - }
395   -
396   - if (is_array($det_falta)) {
397   - foreach ($det_falta as $key => $value) {
398   - $total_faltas += $det_falta[$key]['faltas'];
399   - }
  271 + $faltas = '';
400 272 }
401 273 }
402 274  
403   - if (strlen($matricula['nome']) > 30) {
404   - $matricula['nome'] = explode(' ', $matricula['nome']);
  275 + $etapas = range(1, count($notas[$componente->id]));
405 276  
406   - if (is_array($matricula['nome'])) {
407   - $nome_aluno = array_shift($matricula['nome']);
408   - }
  277 + // Se tiver mais etapas nas notas lançadas, significa que prestou exame
  278 + if (count($etapas) > $modulos) {
  279 + array_pop($etapas);
  280 + }
409 281  
410   - if (is_array($matricula['nome'])) {
411   - $nome_aluno .= ' ' . array_shift($matricula['nome']);
412   - }
  282 + $data = array(
  283 + array(40, $matricula['ref_cod_aluno']),
  284 + array(160, $matricula['nome'])
  285 + );
413 286  
414   - if (is_array($matricula['nome'])) {
415   - $nome_aluno .= ' ' . array_pop($matricula['nome']);
416   - }
  287 + foreach ($etapas as $i) {
  288 + $data[] = array(30, $boletim->getNotaComponente($componente->id, $i)->notaArredondada);
  289 + $media_parcial = $medias[$componente->id][0]->mediaArredondada;
417 290  
418   - $matricula['nome'] = $nome_aluno;
  291 + if ($i == $modulos) {
  292 + $media_final = $media_parcial;
  293 + $media_parcial = '';
  294 + $nota_exame = $boletim->getNotaComponente($componente->id, 'Rc')->notaArredondada;
  295 + }
419 296 }
420 297  
421   - if ($segue_padrão || !$conceitual) {
422   - $relatorio->novalinha(array($matricula['ref_cod_aluno'], $matricula['nome'],
423   - $nota1, $nota2, $nota3, $nota4, $media_parcial, $nota_exame,
424   - $media_final, $total_faltas), 0, 12, FALSE, 'arial',
425   - array(35, 165, 30, 30, 30, 40, 55, 50, 55), '#515151', '#D3D3D3',
426   - '#FFFFFF', FALSE, TRUE);
  298 + // Adiciona entradas em branco no array de dados
  299 + for ($i = 0, $loop = $modulos - count($etapas); $i < $loop; $i++) {
  300 + $data[] = array(30, '');
427 301 }
428   - else {
429   - $obj_matricula = new clsPmieducarMatricula($matricula["ref_cod_matricula"]);
430   - $situacao = $obj_matricula->detalhe();
431   - $situacao = $situacao["aprovado"];
432 302  
433   - if ($situacao == 1) {
434   - $situacao = 'Apr.';
435   - }
436   - elseif ($situacao == 2) {
437   - $situacao = 'Repr;';
438   - }
439   - elseif ($situacao == 3) {
440   - $situacao = 'And.';
441   - }
  303 + $data[] = array(55, $media_parcial);
  304 + $data[] = array(50, $nota_exame);
  305 + $data[] = array(50, $media_final);
  306 + $data[] = array(38, $faltas);
442 307  
443   - $relatorio->novalinha(array($matricula['ref_cod_aluno'], $matricula['nome'],
444   - $nota1, $nota2, $nota3, $nota4, $media_parcial, $nota_exame, $media_final,
445   - $total_faltas, $situacao), 0, 12, FALSE, 'arial',
446   - array(40, 160, 30, 30, 30, 30, 55, 50, 50, 38), '#515151', '#D3D3D3',
447   - '#FFFFFF', FALSE, TRUE);
448   - }
  308 + $relatorio->novalinha($arrFunc($data, 1), 0, 12, FALSE, 'arial',
  309 + $arrFunc($data, 0), '#515151', '#D3D3D3', '#FFFFFF', FALSE, TRUE);
449 310 }
450 311  
451 312 $relatorio->quebraPagina();
... ... @@ -480,14 +341,13 @@ class indice extends clsCadastro
480 341  
481 342 function Editar()
482 343 {
483   - return false;
  344 + return FALSE;
484 345 }
485 346  
486 347 function Excluir()
487 348 {
488   - return false;
  349 + return FALSE;
489 350 }
490   -
491 351 }
492 352  
493 353 // Instancia objeto de página
... ...
ieducar/intranet/educar_relatorio_ata_resultado_final_proc.php
... ... @@ -360,7 +360,7 @@ class indice extends clsCadastro
360 360 return $carga_global;
361 361 }
362 362  
363   - function getAlunoNotasFaltasTable($alunos_matriculados, $det_curso, $curso_conceitual)
  363 + function getAlunoNotasFaltasTable($alunos_matriculados)
364 364 {
365 365 $fonte = 'arial';
366 366 $corTexto = '#000000';
... ...
ieducar/lib/App/Model/IedFinder.php
... ... @@ -289,7 +289,7 @@ class App_Model_IedFinder extends CoreExt_Entity
289 289 * @return int
290 290 * @throws App_Model_Exception
291 291 */
292   - public static function getQuantidadeDeEtapasMatricula($codMatricula)
  292 + public static function getQuantidadeDeModulosMatricula($codMatricula)
293 293 {
294 294 $modulos = array();
295 295  
... ... @@ -297,9 +297,41 @@ class App_Model_IedFinder extends CoreExt_Entity
297 297 $matricula = self::getMatricula($codMatricula);
298 298 $codEscola = $matricula['ref_ref_cod_escola'];
299 299 $codCurso = $matricula['ref_cod_curso'];
  300 + $codTurma = NULL;
  301 +
  302 + $matriculaTurma = self::addClassToStorage('clsPmieducarMatriculaTurma',
  303 + NULL, 'include/pmieducar/clsPmieducarMatriculaTurma.inc.php');
  304 +
  305 + $matriculas = $matriculaTurma->lista($codMatricula);
  306 +
  307 + if (is_array($matriculas)) {
  308 + $matricula = array_shift($matriculas);
  309 + $codTurma = $matricula['ref_cod_turma'];
  310 + }
  311 + else {
  312 + throw new App_Model_Exception('Aluno não enturmado.');
  313 + }
  314 +
  315 + $modulos = self::getModulo($codEscola, $codCurso, $codTurma);
  316 +
  317 + return $modulos['total'];
  318 + }
  319 +
  320 + /**
  321 + *
  322 + * @param unknown_type $codEscola
  323 + * @param unknown_type $codCurso
  324 + * @param unknown_type $codTurma
  325 + * @param unknown_type $ano
  326 + * @return unknown_type
  327 + */
  328 + public static function getModulo($codEscola, $codCurso, $codTurma,
  329 + $ano = NULL)
  330 + {
  331 + $modulos = array();
300 332  
301 333 $curso = self::addClassToStorage('clsPmieducarCurso', NULL,
302   - 'include/pmieducar/clsPmieducar.inc.php');
  334 + 'include/pmieducar/clsPmieducarCurso.inc.php');
303 335  
304 336 $curso->cod_curso = $codCurso;
305 337 $curso = $curso->detalhe();
... ... @@ -311,7 +343,7 @@ class App_Model_IedFinder extends CoreExt_Entity
311 343 $escolaAnoLetivo = self::addClassToStorage('clsPmieducarEscolaAnoLetivo',
312 344 NULL, 'include/pmieducar/clsPmieducarEscolaAnoLetivo.inc.php');
313 345  
314   - $anosEmAndamento = $escolaAnoLetivo->lista($codEscola, NULL, NULL, NULL,
  346 + $anosEmAndamento = $escolaAnoLetivo->lista($codEscola, $ano, NULL, NULL,
315 347 1, NULL, NULL, NULL, NULL, 1);
316 348  
317 349 // Pela restrição na criação de anos letivos, eu posso confiar no primeiro
... ... @@ -330,19 +362,6 @@ class App_Model_IedFinder extends CoreExt_Entity
330 362 $modulos = $anoLetivoModulo->lista($ano, $codEscola);
331 363 }
332 364 else {
333   - $matriculaTurma = self::addClassToStorage('clsPmieducarMatriculaTurma',
334   - NULL, 'include/pmieducar/clsPmieducarMatriculaTurma.inc.php');
335   -
336   - $matriculas = $matriculaTurma->lista($codMatricula);
337   -
338   - if (is_array($matriculas)) {
339   - $matricula = array_shift($matriculas);
340   - $codTurma = $matricula['ref_cod_turma'];
341   - }
342   - else {
343   - throw new App_Model_Exception('Aluno não enturmado.');
344   - }
345   -
346 365 $turmaModulo = self::addClassToStorage('clsPmieducarTurmaModulo',
347 366 NULL, 'include/pmieducar/clsPmieducarTurmaModulo.inc.php');
348 367  
... ... @@ -353,7 +372,25 @@ class App_Model_IedFinder extends CoreExt_Entity
353 372 return 0;
354 373 }
355 374  
356   - return count($modulos);
  375 + // Total de módulos
  376 + $total = count($modulos);
  377 +
  378 + // Código do tipo de módulo
  379 + $modulo = array_shift($modulos);
  380 + $codModulo = $modulo['ref_cod_modulo'];
  381 +
  382 + // Recupera do regstry o objeto legado
  383 + $modulo = self::addClassToStorage('clsPmieducarModulo', NULL,
  384 + 'include/pmieducar/clsPmieducarModulo.inc.php');
  385 +
  386 + $modulo->cod_modulo = $codModulo;
  387 + $modulo = $modulo->detalhe();
  388 + $modulo = $modulo['nm_tipo'];
  389 +
  390 + return array(
  391 + 'total' => $total,
  392 + 'nome' => $modulo
  393 + );
357 394 }
358 395  
359 396 /**
... ...
ieducar/modules/Avaliacao/Service/Boletim.php
... ... @@ -779,7 +779,7 @@ class Avaliacao_Service_Boletim implements CoreExt_Configurable
779 779 // Valores scalar de referência
780 780 $matricula = App_Model_IedFinder::getMatricula($codMatricula);
781 781  
782   - $etapas = App_Model_IedFinder::getQuantidadeDeEtapasMatricula($codMatricula);
  782 + $etapas = App_Model_IedFinder::getQuantidadeDeModulosMatricula($codMatricula);
783 783 $this->setOption('matriculaData', $matricula);
784 784 $this->setOption('aprovado', $matricula['aprovado']);
785 785 $this->setOption('cursoHoraFalta', $matricula['curso_hora_falta']);
... ...
ieducar/modules/Avaliacao/_tests/Service/TestCommon.php
... ... @@ -199,10 +199,12 @@ abstract class Avaliacao_Service_TestCommon extends UnitBaseTest
199 199 // instâncias de objetos legados e novos
200 200 $this->_setConfigOptions('usuario', array('cod_usuario' => 1))
201 201 ->_setConfigOptions('matricula', $this->_getMatricula())
  202 + ->_setConfigOptions('matriculaTurma', $this->_getMatriculaTurma())
202 203 ->_setConfigOptions('serie', $this->_getSerie())
203 204 ->_setConfigOptions('curso', $this->_getCurso())
204 205 ->_setConfigOptions('escolaAnoLetivo', $this->_getEscolaAnoLetivo())
205 206 ->_setConfigOptions('anoLetivoModulo', $this->_getAnoLetivoModulo())
  207 + ->_setConfigOptions('modulo', $this->_getModulo())
206 208 ->_setConfigOptions('escolaSerieDisciplina', $this->_getEscolaSerieDisciplina())
207 209 ->_setConfigOptions('dispensaDisciplina', $this->_getDispensaDisciplina())
208 210 ->_setConfigOptions('componenteCurricular', $this->_getComponenteCurricular())
... ... @@ -235,10 +237,12 @@ abstract class Avaliacao_Service_TestCommon extends UnitBaseTest
235 237  
236 238 // Cria os mocks das classes legadas
237 239 $this->_setUpMatriculaMock()
  240 + ->_setUpMatriculaTurmaMock()
238 241 ->_setUpCursoMock()
239 242 ->_setUpSerieMock()
240 243 ->_setUpEscolaAnoLetivo()
241 244 ->_setUpAnoLetivoModulo()
  245 + ->_setUpModulo()
242 246 ->_setUpEscolaSerieDisciplinaMock()
243 247 ->_setUpDispensaDisciplinaMock();
244 248  
... ... @@ -364,6 +368,17 @@ abstract class Avaliacao_Service_TestCommon extends UnitBaseTest
364 368 /**
365 369 * @return array
366 370 */
  371 + protected function _getMatriculaTurma()
  372 + {
  373 + return array(
  374 + 'ref_cod_matricula' => 1,
  375 + 'ref_cod_turma' => 1
  376 + );
  377 + }
  378 +
  379 + /**
  380 + * @return array
  381 + */
367 382 protected function _getSerie()
368 383 {
369 384 return array(
... ... @@ -403,10 +418,20 @@ abstract class Avaliacao_Service_TestCommon extends UnitBaseTest
403 418 protected function _getAnoLetivoModulo()
404 419 {
405 420 return array(
406   - array('ref_ano' => 2009, 'ref_ref_cod_escola' => 1, 'sequencial' => 1),
407   - array('ref_ano' => 2009, 'ref_ref_cod_escola' => 1, 'sequencial' => 2),
408   - array('ref_ano' => 2009, 'ref_ref_cod_escola' => 1, 'sequencial' => 3),
409   - array('ref_ano' => 2009, 'ref_ref_cod_escola' => 1, 'sequencial' => 4)
  421 + array('ref_ano' => 2009, 'ref_ref_cod_escola' => 1, 'sequencial' => 1, 'ref_cod_modulo' => 1),
  422 + array('ref_ano' => 2009, 'ref_ref_cod_escola' => 1, 'sequencial' => 2, 'ref_cod_modulo' => 1),
  423 + array('ref_ano' => 2009, 'ref_ref_cod_escola' => 1, 'sequencial' => 3, 'ref_cod_modulo' => 1),
  424 + array('ref_ano' => 2009, 'ref_ref_cod_escola' => 1, 'sequencial' => 4, 'ref_cod_modulo' => 1)
  425 + );
  426 + }
  427 +
  428 + /**
  429 + * @return array
  430 + */
  431 + protected function _getModulo()
  432 + {
  433 + return array(
  434 + 'cod_modulo' => 1, 'nm_tipo' => 'Bimestre'
410 435 );
411 436 }
412 437  
... ... @@ -535,6 +560,25 @@ abstract class Avaliacao_Service_TestCommon extends UnitBaseTest
535 560 }
536 561  
537 562 /**
  563 + * @return clsPmieducarMatriculaTurma
  564 + */
  565 + protected function _setUpMatriculaTurmaMock()
  566 + {
  567 + $mock = $this->getCleanMock('clsPmieducarMatriculaTurma');
  568 +
  569 + $mock->expects($this->any())
  570 + ->method('lista')
  571 + ->with(1)
  572 + ->will($this->returnValue($this->_getConfigOptions('matriculaTurma')));
  573 +
  574 + CoreExt_Entity::addClassToStorage('clsPmieducarMatriculaTurma',
  575 + $mock, NULL, TRUE
  576 + );
  577 +
  578 + return $this;
  579 + }
  580 +
  581 + /**
538 582 * @return clsPmieducarSerie
539 583 */
540 584 protected function _setUpSerieMock()
... ... @@ -609,6 +653,22 @@ abstract class Avaliacao_Service_TestCommon extends UnitBaseTest
609 653 }
610 654  
611 655 /**
  656 + * @return clsPmieducarModulo
  657 + */
  658 + protected function _setUpModulo()
  659 + {
  660 + $mock = $this->getCleanMock('clsPmieducarModulo');
  661 +
  662 + $mock->expects($this->any())
  663 + ->method('detalhe')
  664 + ->will($this->returnValue($this->_getConfigOptions('modulo')));
  665 +
  666 + CoreExt_Entity::addClassToStorage('clsPmieducarModulo', $mock, NULL, TRUE);
  667 +
  668 + return $this;
  669 + }
  670 +
  671 + /**
612 672 * @return clsPmieducarEscolaSerieDisciplina
613 673 */
614 674 protected function _setUpEscolaSerieDisciplinaMock()
... ...
ieducar/tests/unit/App/Model/IedFinderTest.php
... ... @@ -323,19 +323,24 @@ class App_Model_IedFinderTest extends UnitBaseTest
323 323 /**
324 324 * @depends App_Model_IedFinderTest::testInstanciaRegraDeAvaliacaoPorMatricula
325 325 */
326   - public function testEtapasDeUmCursoPadraoAnoEscolar()
  326 + public function testModulosDeUmCursoPadraoAnoEscolar()
327 327 {
328 328 $returnEscolaAno = array(
329 329 array('ref_cod_escola' => 1, 'ano' => 2009, 'andamento' => 1, 'ativo' => 1)
330 330 );
331 331  
332 332 $returnAnoLetivo = array(
333   - array('ref_ano' => 2009, 'ref_ref_cod_escola' => 1, 'sequencial' => 1),
334   - array('ref_ano' => 2009, 'ref_ref_cod_escola' => 1, 'sequencial' => 2),
335   - array('ref_ano' => 2009, 'ref_ref_cod_escola' => 1, 'sequencial' => 3),
336   - array('ref_ano' => 2009, 'ref_ref_cod_escola' => 1, 'sequencial' => 4)
  333 + array('ref_ano' => 2009, 'ref_ref_cod_escola' => 1, 'sequencial' => 1, 'ref_cod_modulo' => 1),
  334 + array('ref_ano' => 2009, 'ref_ref_cod_escola' => 1, 'sequencial' => 2, 'ref_cod_modulo' => 1),
  335 + array('ref_ano' => 2009, 'ref_ref_cod_escola' => 1, 'sequencial' => 3, 'ref_cod_modulo' => 1),
  336 + array('ref_ano' => 2009, 'ref_ref_cod_escola' => 1, 'sequencial' => 4, 'ref_cod_modulo' => 1)
337 337 );
338 338  
  339 + $returnMatriculaTurma = array(
  340 + array('ref_cod_matricula' => 1, 'ref_cod_turma' => 1)
  341 + );
  342 +
  343 + $returnModulo = array('cod_modulo' => 1, 'nm_tipo' => 'Bimestre');
339 344  
340 345 // Mock para escola ano letivo (ano letivo em andamento)
341 346 $escolaAnoMock = $this->getCleanMock('clsPmieducarEscolaAnoLetivo');
... ... @@ -351,17 +356,35 @@ class App_Model_IedFinderTest extends UnitBaseTest
351 356 ->with(2009, 1)
352 357 ->will($this->returnValue($returnAnoLetivo));
353 358  
  359 + $matriculaTurmaMock = $this->getCleanMock('clsPmieducarMatriculaTurma');
  360 + $matriculaTurmaMock->expects($this->any())
  361 + ->method('lista')
  362 + ->with(1)
  363 + ->will($this->onConsecutiveCalls($returnMatriculaTurma, $returnMatriculaTurma));
  364 +
  365 + $moduloMock = $this->getCleanMock('clsPmieducarModulo');
  366 + $moduloMock->expects($this->any())
  367 + ->method('detalhe')
  368 + ->will($this->onConsecutiveCalls($returnModulo, $returnModulo));
  369 +
354 370 // Adiciona mocks ao repositório estático
355 371 App_Model_IedFinder::addClassToStorage('clsPmieducarEscolaAnoLetivo',
356 372 $escolaAnoMock, NULL, TRUE);
357 373 App_Model_IedFinder::addClassToStorage('clsPmieducarAnoLetivoModulo',
358 374 $anoLetivoMock, NULL, TRUE);
  375 + App_Model_IedFinder::addClassToStorage('clsPmieducarMatriculaTurma',
  376 + $matriculaTurmaMock, NULL, TRUE);
  377 + App_Model_IedFinder::addClassToStorage('clsPmieducarModulo',
  378 + $moduloMock, NULL, TRUE);
359 379  
360   - $etapas = App_Model_IedFinder::getQuantidadeDeEtapasMatricula(1);
  380 + $modulos = App_Model_IedFinder::getQuantidadeDeModulosMatricula(1);
361 381  
362   - $this->assertEquals(4, $etapas);
  382 + $this->assertEquals(4, $modulos);
363 383 }
364 384  
  385 + /**
  386 + * @depends App_Model_IedFinderTest::testInstanciaRegraDeAvaliacaoPorMatricula
  387 + */
365 388 public function testEtapasDeUmCursoAnoNaoPadrao()
366 389 {
367 390 // Curso não padrão
... ... @@ -375,7 +398,7 @@ class App_Model_IedFinderTest extends UnitBaseTest
375 398 CoreExt_Entity::addClassToStorage('clsPmieducarCurso', $cursoMock, NULL, TRUE);
376 399  
377 400 // Pega informação da turma
378   - $returnMatriculaTurma = array(
  401 + /*$returnMatriculaTurma = array(
379 402 array('ref_cod_matricula' => 1, 'ref_cod_turma' => 1)
380 403 );
381 404  
... ... @@ -383,7 +406,7 @@ class App_Model_IedFinderTest extends UnitBaseTest
383 406 $matriculaTurmaMock->expects($this->at(0))
384 407 ->method('lista')
385 408 ->with(1)
386   - ->will($this->returnValue($returnMatriculaTurma));
  409 + ->will($this->returnValue($returnMatriculaTurma));*/
387 410  
388 411 $returnTurmaModulo = array(
389 412 array('ref_cod_turma' => 1, 'ref_cod_modulo' => 1, 'sequencial' => 1),
... ... @@ -398,13 +421,13 @@ class App_Model_IedFinderTest extends UnitBaseTest
398 421 ->with(1)
399 422 ->will($this->returnValue($returnTurmaModulo));
400 423  
401   - App_Model_IedFinder::addClassToStorage('clsPmieducarMatriculaTurma',
402   - $matriculaTurmaMock, NULL, TRUE);
  424 + #App_Model_IedFinder::addClassToStorage('clsPmieducarMatriculaTurma',
  425 + # $matriculaTurmaMock, NULL, TRUE);
403 426  
404 427 App_Model_IedFinder::addClassToStorage('clsPmieducarTurmaModulo',
405 428 $turmaModuloMock, NULL, TRUE);
406 429  
407   - $etapas = App_Model_IedFinder::getQuantidadeDeEtapasMatricula(1);
  430 + $etapas = App_Model_IedFinder::getQuantidadeDeModulosMatricula(1);
408 431  
409 432 $this->assertEquals(4, $etapas);
410 433 }
... ...