Commit 2ec380bbc48d14c5850098e3274efd9d7ffcfdbb
1 parent
1f2a7d73
Exists in
master
Adicionada classe {{{ComponenteCurricular_Model_Turma}}}. Usuário poderá definir…
… componentes curriculares específicos para uma turma: * Pode-se atribuir uma grade curricular específica para uma turma durante o seu cadastro ou atualização * {{{App_Model_IedFinder}}}: * Adicionado método {{{getComponentesTurma()}}} para selecionar os componentes curriculares de uma turma. Caso não existam componentes específicos para a turma, retorna os componentes da escola-série (através de {{{getEscolaSerieDisciplina()}}}) * Adicionado arquivo delta (23) para criar a tabela {{{modules.componente_curricular_turma}}}. Arquivo {{{misc/database/ieducar.sql}}} atualizado * Módulo {{{ComponenteCurricular}}}: * Novas classes: {{{ComponenteCurricular_Model_Turma}}} e {{{ComponenteCurricular_Model_TurmaDataMapper}}} * Atualizado arquivo {{{_data/install.sql}}} com a definição da tabela {{{modules.componente_curricular_turma}}} * Módulo {{{Avaliacao}}}: * Nova dependência opcional em {{{Avaliacao_Service_Boletim}}}: {{{ComponenteCurricular_Model_TurmaDataMapper}}} * Testes atualizados
Showing
12 changed files
with
945 additions
and
98 deletions
Show diff stats
ieducar/intranet/educar_turma_cad.php
... | ... | @@ -324,8 +324,93 @@ class indice extends clsCadastro |
324 | 324 | |
325 | 325 | $this->campoHora( 'hora_fim_intervalo', 'Hora Fim Intervalo', $this->hora_fim_intervalo, FALSE); |
326 | 326 | |
327 | - // Inclui módulo | |
328 | - $this->campoQuebra(); | |
327 | + if ($this->ref_ref_cod_serie) { | |
328 | + require_once 'ComponenteCurricular/Model/ComponenteDataMapper.php'; | |
329 | + require_once 'ComponenteCurricular/Model/AnoEscolarDataMapper.php'; | |
330 | + require_once 'ComponenteCurricular/Model/TurmaDataMapper.php'; | |
331 | + | |
332 | + $disciplinas = ''; | |
333 | + $conteudo = ''; | |
334 | + | |
335 | + // Instancia o mapper de componente curricular | |
336 | + $mapper = new ComponenteCurricular_Model_ComponenteDataMapper(); | |
337 | + | |
338 | + // Instancia o mapper de ano escolar | |
339 | + $anoEscolar = new ComponenteCurricular_Model_AnoEscolarDataMapper(); | |
340 | + $lista = $anoEscolar->findComponentePorSerie($this->ref_ref_cod_serie); | |
341 | + | |
342 | + // Instancia o mapper de turma | |
343 | + $componenteTurmaMapper = new ComponenteCurricular_Model_TurmaDataMapper(); | |
344 | + $componentesTurma = $componenteTurmaMapper->findAll(array(), array('turma' => $this->cod_turma)); | |
345 | + | |
346 | + $componentes = array(); | |
347 | + foreach ($componentesTurma as $componenteTurma) { | |
348 | + $componentes[$componenteTurma->get('componenteCurricular')] = $componenteTurma; | |
349 | + } | |
350 | + unset($componentesTurma); | |
351 | + | |
352 | + $this->escola_serie_disciplina = array(); | |
353 | + | |
354 | + if (is_array($lista) && count($lista)) { | |
355 | + $conteudo .= '<div style="margin-bottom: 10px;">'; | |
356 | + $conteudo .= ' <span style="display: block; float: left; width: 250px;">Nome</span>'; | |
357 | + $conteudo .= ' <span style="display: block; float: left; width: 100px;">Carga horária</span>'; | |
358 | + $conteudo .= ' <span style="display: block; float: left">Usar padrão do componente?</span>'; | |
359 | + $conteudo .= '</div>'; | |
360 | + $conteudo .= '<br style="clear: left" />'; | |
361 | + | |
362 | + foreach ($lista as $registro) { | |
363 | + $checked = ''; | |
364 | + | |
365 | + if (isset($componentes[$registro->id])) { | |
366 | + $checked = 'checked="checked"'; | |
367 | + } | |
368 | + | |
369 | + if (is_null($componentes[$registro->id]->cargaHoraria) || | |
370 | + 0 == $componentes[$registro->id]->cargaHoraria) { | |
371 | + $usarComponente = TRUE; | |
372 | + } | |
373 | + else { | |
374 | + $cargaHoraria = $componentes[$registro->id]->cargaHoraria; | |
375 | + } | |
376 | + $cargaComponente = $registro->cargaHoraria; | |
377 | + | |
378 | + $conteudo .= '<div style="margin-bottom: 10px; float: left">'; | |
379 | + $conteudo .= " <label style='display: block; float: left; width: 250px'><input type=\"checkbox\" $checked name=\"disciplinas[$registro->id]\" id=\"disciplinas[]\" value=\"{$registro->id}\">{$registro}</label>"; | |
380 | + $conteudo .= " <label style='display: block; float: left; width: 100px;'><input type='text' name='carga_horaria[$registro->id]' value='{$cargaHoraria}' size='5' maxlength='7'></label>"; | |
381 | + $conteudo .= " <label style='display: block; float: left'><input type='checkbox' name='usar_componente[$registro->id]' value='1' ". ($usarComponente == TRUE ? $checked : '') .">($cargaComponente h)</label>"; | |
382 | + $conteudo .= '</div>'; | |
383 | + $conteudo .= '<br style="clear: left" />'; | |
384 | + | |
385 | + $cargaHoraria = ''; | |
386 | + } | |
387 | + | |
388 | + $disciplinas = '<table cellspacing="0" cellpadding="0" border="0">'; | |
389 | + $disciplinas .= sprintf('<tr align="left"><td>%s</td></tr>', $conteudo); | |
390 | + $disciplinas .= '</table>'; | |
391 | + } | |
392 | + else { | |
393 | + $disciplinas = 'A série/ano escolar não possui componentes curriculares cadastrados.'; | |
394 | + } | |
395 | + } | |
396 | + | |
397 | + $this->campoQuebra2(); | |
398 | + | |
399 | + $help = array(); | |
400 | + $componentes = App_Model_IedFinder::getEscolaSerieDisciplina($this->ref_ref_cod_serie, $this->ref_cod_escola); | |
401 | + foreach ($componentes as $componente) { | |
402 | + $help[] = sprintf('%s (%.0f h)', $componente->nome, $componente->cargaHoraria); | |
403 | + } | |
404 | + $help = '<ul><li>' . implode('</li><li>', $help) . '</li></ul>'; | |
405 | + | |
406 | + $label = 'Componentes curriculares:<br />' | |
407 | + . '<strong>Observação:</strong> caso não defina os componentes<br />' | |
408 | + . 'curriculares para a turma, esta usará a definição<br />' | |
409 | + . 'da série/ano escolar da escola' | |
410 | + . $help; | |
411 | + | |
412 | + $this->campoRotulo('disciplinas_', $label, | |
413 | + "<div id='disciplinas'>$disciplinas</div>"); | |
329 | 414 | |
330 | 415 | if ($_POST['turma_modulo']) { |
331 | 416 | $this->turma_modulo = unserialize(urldecode($_POST['turma_modulo'])); |
... | ... | @@ -540,14 +625,14 @@ class indice extends clsCadastro |
540 | 625 | |
541 | 626 | $this->ref_cod_instituicao_regente = $this->ref_cod_instituicao; |
542 | 627 | |
543 | - if ($this->multiseriada == 'on') { | |
628 | + if (isset($this->multiseriada)) { | |
544 | 629 | $this->multiseriada = 1; |
545 | 630 | } |
546 | 631 | else { |
547 | 632 | $this->multiseriada = 0; |
548 | 633 | } |
549 | 634 | |
550 | - if ($this->visivel == 'on') { | |
635 | + if (isset($this->visivel)) { | |
551 | 636 | $this->visivel = TRUE; |
552 | 637 | } |
553 | 638 | else { |
... | ... | @@ -648,6 +733,11 @@ class indice extends clsCadastro |
648 | 733 | |
649 | 734 | return FALSE; |
650 | 735 | } |
736 | + | |
737 | + $this->atualizaComponentesCurriculares( | |
738 | + $this->ref_ref_cod_serie, $this->ref_cod_escola, $this->cod_turma, | |
739 | + $this->disciplinas, $this->carga_horaria, $this->usar_componente | |
740 | + ); | |
651 | 741 | } |
652 | 742 | |
653 | 743 | function Editar() |
... | ... | @@ -658,14 +748,14 @@ class indice extends clsCadastro |
658 | 748 | |
659 | 749 | $this->ref_cod_instituicao_regente = $this->ref_cod_instituicao; |
660 | 750 | |
661 | - if ($this->multiseriada == 'on') { | |
751 | + if (isset($this->multiseriada)) { | |
662 | 752 | $this->multiseriada = 1; |
663 | 753 | } |
664 | 754 | else { |
665 | 755 | $this->multiseriada = 0; |
666 | 756 | } |
667 | 757 | |
668 | - if ($this->visivel == 'on') { | |
758 | + if (isset($this->visivel)) { | |
669 | 759 | $this->visivel = TRUE; |
670 | 760 | } |
671 | 761 | else { |
... | ... | @@ -761,6 +851,11 @@ class indice extends clsCadastro |
761 | 851 | $editou = $obj->edita(); |
762 | 852 | } |
763 | 853 | |
854 | + $this->atualizaComponentesCurriculares( | |
855 | + $this->ref_ref_cod_serie, $this->ref_cod_escola, $this->cod_turma, | |
856 | + $this->disciplinas, $this->carga_horaria, $this->usar_componente | |
857 | + ); | |
858 | + | |
764 | 859 | if ($editou) { |
765 | 860 | $this->mensagem .= 'Edição efetuada com sucesso.'; |
766 | 861 | header('Location: educar_turma_lst.php'); |
... | ... | @@ -774,6 +869,26 @@ class indice extends clsCadastro |
774 | 869 | } |
775 | 870 | } |
776 | 871 | |
872 | + function atualizaComponentesCurriculares($codSerie, $codEscola, $codTurma, $componentes, $cargaHoraria, $usarComponente) | |
873 | + { | |
874 | + require_once 'ComponenteCurricular/Model/TurmaDataMapper.php'; | |
875 | + $mapper = new ComponenteCurricular_Model_TurmaDataMapper(); | |
876 | + | |
877 | + $componentesTurma = array(); | |
878 | + | |
879 | + foreach ($componentes as $key => $value) { | |
880 | + $carga = isset($usarComponente[$key]) ? | |
881 | + NULL : $cargaHoraria[$key]; | |
882 | + | |
883 | + $componentesTurma[] = array( | |
884 | + 'id' => $value, | |
885 | + 'cargaHoraria' => $carga | |
886 | + ); | |
887 | + } | |
888 | + | |
889 | + $mapper->bulkUpdate($codSerie, $codEscola, $codTurma, $componentesTurma); | |
890 | + } | |
891 | + | |
777 | 892 | function Excluir() |
778 | 893 | { |
779 | 894 | @session_start(); |
... | ... | @@ -1140,15 +1255,59 @@ document.getElementById('ref_ref_cod_serie').onchange = function() |
1140 | 1255 | { |
1141 | 1256 | if (this.value) { |
1142 | 1257 | getHoraEscolaSerie(); |
1258 | + getComponentesCurriculares(this.value); | |
1143 | 1259 | } |
1144 | 1260 | |
1145 | - if(document.getElementById('multiseriada').checked == true) { | |
1261 | + if (document.getElementById('multiseriada').checked == true) { | |
1146 | 1262 | changeMultiSerie(); |
1147 | 1263 | } |
1148 | 1264 | |
1149 | 1265 | hideMultiSerie(); |
1150 | 1266 | } |
1151 | 1267 | |
1268 | +function getComponentesCurriculares(campoSerie) | |
1269 | +{ | |
1270 | + var xml_disciplina = new ajax(parseComponentesCurriculares); | |
1271 | + xml_disciplina.envia("educar_disciplina_xml.php?ser=" + campoSerie); | |
1272 | +} | |
1273 | + | |
1274 | +function parseComponentesCurriculares(xml_disciplina) | |
1275 | +{ | |
1276 | + var campoDisciplinas = document.getElementById('disciplinas'); | |
1277 | + var DOM_array = xml_disciplina.getElementsByTagName('disciplina'); | |
1278 | + var conteudo = ''; | |
1279 | + | |
1280 | + if (DOM_array.length) { | |
1281 | + conteudo += '<div style="margin-bottom: 10px; float: left">'; | |
1282 | + conteudo += ' <span style="display: block; float: left; width: 250px;">Nome</span>'; | |
1283 | + conteudo += ' <label span="display: block; float: left; width: 100px">Carga horária</span>'; | |
1284 | + conteudo += ' <label span="display: block; float: left">Usar padrão do componente?</span>'; | |
1285 | + conteudo += '</div>'; | |
1286 | + conteudo += '<br style="clear: left" />'; | |
1287 | + | |
1288 | + for (var i = 0; i < DOM_array.length; i++) { | |
1289 | + id = DOM_array[i].getAttribute("cod_disciplina"); | |
1290 | + | |
1291 | + conteudo += '<div style="margin-bottom: 10px; float: left">'; | |
1292 | + conteudo += ' <label style="display: block; float: left; width: 250px;"><input type="checkbox" name="disciplinas['+ id +']" id="disciplinas[]" value="'+ id +'">'+ DOM_array[i].firstChild.data +'</label>'; | |
1293 | + conteudo += ' <label style="display: block; float: left; width: 100px;"><input type="text" name="carga_horaria['+ id +']" value="" size="5" maxlength="7"></label>'; | |
1294 | + conteudo += ' <label style="display: block; float: left"><input type="checkbox" name="usar_componente['+ id +']" value="1">('+ DOM_array[i].getAttribute("carga_horaria") +' h)</label>'; | |
1295 | + conteudo += '</div>'; | |
1296 | + conteudo += '<br style="clear: left" />'; | |
1297 | + } | |
1298 | + } | |
1299 | + else { | |
1300 | + campoDisciplinas.innerHTML = 'A série/ano escolar não possui componentes ' | |
1301 | + + 'curriculares cadastrados.'; | |
1302 | + } | |
1303 | + | |
1304 | + if (conteudo) { | |
1305 | + campoDisciplinas.innerHTML = '<table cellspacing="0" cellpadding="0" border="0">'; | |
1306 | + campoDisciplinas.innerHTML += '<tr align="left"><td>'+ conteudo +'</td></tr>'; | |
1307 | + campoDisciplinas.innerHTML += '</table>'; | |
1308 | + } | |
1309 | +} | |
1310 | + | |
1152 | 1311 | function hideMultiSerie() |
1153 | 1312 | { |
1154 | 1313 | setVisibility('tr_multiseriada', document.getElementById('ref_ref_cod_serie').value != '' ? true : false); |
... | ... | @@ -1159,6 +1318,7 @@ function hideMultiSerie() |
1159 | 1318 | setVisibility('ref_ref_cod_serie_mult', multiBool); |
1160 | 1319 | setVisibility('tr_ref_ref_cod_serie_mult',multiBool); |
1161 | 1320 | } |
1321 | + | |
1162 | 1322 | function PadraoAnoEscolar(xml) |
1163 | 1323 | { |
1164 | 1324 | var escola_curso_ = new Array(); | ... | ... |
ieducar/lib/App/Model/IedFinder.php
... | ... | @@ -239,20 +239,24 @@ class App_Model_IedFinder extends CoreExt_Entity |
239 | 239 | * Retorna array com as referências de pmieducar.escola_serie_disciplina |
240 | 240 | * a modules.componente_curricular ('ref_ref_cod_disciplina'). |
241 | 241 | * |
242 | - * @param int $codSerie | |
243 | - * @param int $codEscola | |
244 | - * @param ComponenteCurricular_Model_ComponenteDataMapper $mapper | |
242 | + * @param int $anoEscolar O código do ano escolar/série. | |
243 | + * @param int $escola O código da escola. | |
244 | + * @param ComponenteCurricular_Model_ComponenteDataMapper $mapper (Opcional) | |
245 | + * Instância do mapper para recuperar todas as instâncias persistidas de | |
246 | + * ComponenteCurricular_Model_Componente atribuídas no ano escolar/série da | |
247 | + * escola. | |
245 | 248 | * @return array |
246 | - * @throws App_Model_Exception | |
249 | + * @throws App_Model_Exception caso não existam componentes curriculares | |
250 | + * atribuídos ao ano escolar/série da escola. | |
247 | 251 | */ |
248 | - public static function getEscolaSerieDisciplina($codSerie, $codEscola, | |
252 | + public static function getEscolaSerieDisciplina($anoEscolar, $escola, | |
249 | 253 | ComponenteCurricular_Model_ComponenteDataMapper $mapper = NULL) |
250 | 254 | { |
251 | 255 | // Disciplinas na série na escola |
252 | 256 | $escolaSerieDisciplina = self::addClassToStorage('clsPmieducarEscolaSerieDisciplina', |
253 | 257 | NULL, 'include/pmieducar/clsPmieducarEscolaSerieDisciplina.inc.php'); |
254 | 258 | |
255 | - $disciplinas = $escolaSerieDisciplina->lista($codSerie, $codEscola, NULL, 1); | |
259 | + $disciplinas = $escolaSerieDisciplina->lista($anoEscolar, $escola, NULL, 1); | |
256 | 260 | |
257 | 261 | if (FALSE === $disciplinas) { |
258 | 262 | throw new App_Model_Exception(sprintf( |
... | ... | @@ -261,19 +265,91 @@ class App_Model_IedFinder extends CoreExt_Entity |
261 | 265 | )); |
262 | 266 | } |
263 | 267 | |
268 | + $componentes = array(); | |
269 | + foreach ($disciplinas as $disciplina) { | |
270 | + $componente = new stdClass(); | |
271 | + | |
272 | + $componente->id = $disciplina['ref_cod_disciplina']; | |
273 | + $componente->cargaHoraria = $disciplina['carga_horaria']; | |
274 | + | |
275 | + $componentes[] = $componente; | |
276 | + } | |
277 | + | |
278 | + return self::_hydrateComponentes($componentes, $anoEscolar, $mapper); | |
279 | + } | |
280 | + | |
281 | + /** | |
282 | + * Retorna as instâncias de ComponenteCurricular_Model_Componente de uma turma. | |
283 | + * | |
284 | + * @param int $anoEscolar O código do ano escolar/série da turma. | |
285 | + * @param int $escola O código da escola da turma. | |
286 | + * @param int $turma O código da turma. | |
287 | + * @param ComponenteCurricular_Model_TurmaDataMapper $mapper (Opcional) Instância | |
288 | + * do mapper para selecionar todas as referências de | |
289 | + * ComponenteCurricular_Model_Componente persistidas para a turma. | |
290 | + * @param ComponenteCurricular_Model_ComponenteDataMapper $componenteMapper (Opcional) | |
291 | + * Instância do mapper para recuperar as instâncias de | |
292 | + * ComponenteCurricular_Model_Componente recuperadas por $mapper. | |
293 | + * @return array | |
294 | + */ | |
295 | + public static function getComponentesTurma($anoEscolar, $escola, $turma, | |
296 | + ComponenteCurricular_Model_TurmaDataMapper $mapper = NULL, | |
297 | + ComponenteCurricular_Model_ComponenteDataMapper $componenteMapper = NULL) | |
298 | + { | |
299 | + if (is_null($mapper)) { | |
300 | + require_once 'ComponenteCurricular/Model/TurmaDataMapper.php'; | |
301 | + $mapper = new ComponenteCurricular_Model_TurmaDataMapper(); | |
302 | + } | |
303 | + | |
304 | + $componentesTurma = $mapper->findAll(array(), array('turma' => $turma)); | |
305 | + | |
306 | + // Não existem componentes específicos para a turma | |
307 | + if (0 == count($componentesTurma)) { | |
308 | + return self::getEscolaSerieDisciplina($anoEscolar, $escola, $componenteMapper); | |
309 | + } | |
310 | + | |
311 | + $componentes = array(); | |
312 | + foreach ($componentesTurma as $componenteTurma) { | |
313 | + $componente = new stdClass(); | |
314 | + | |
315 | + $componente->id = $componenteTurma->get('componenteCurricular'); | |
316 | + $componente->cargaHoraria = $componenteTurma->cargaHoraria; | |
317 | + | |
318 | + $componentes[] = $componente; | |
319 | + } | |
320 | + | |
321 | + return self::_hydrateComponentes($componentes, $anoEscolar, $componenteMapper); | |
322 | + } | |
323 | + | |
324 | + /** | |
325 | + * Recupera instâncias persistidas de ComponenteCurricular_Model_Componente, | |
326 | + * retornando-as com a carga horária padrão caso o componente identificado | |
327 | + * em $componentes possua uma carga horária (atributo cargaHoraria) nula. | |
328 | + * | |
329 | + * @param array $componentes (array(stdClass->id, stdClass->cargaHoraria)) | |
330 | + * @param int $anoEscolar O ano escolar/série para recuperar a carga | |
331 | + * horária padrão do componente curricular. | |
332 | + * @param ComponenteCurricular_Model_ComponenteDataMapper $mapper (Opcional) | |
333 | + * O mapper para recuperar a instância persistida com a carga horária padrão. | |
334 | + * @return array | |
335 | + */ | |
336 | + protected static function _hydrateComponentes(array $componentes, $anoEscolar, | |
337 | + ComponenteCurricular_Model_ComponenteDataMapper $mapper = NULL) | |
338 | + { | |
264 | 339 | if (is_null($mapper)) { |
265 | 340 | require_once 'ComponenteCurricular/Model/ComponenteDataMapper.php'; |
266 | 341 | $mapper = new ComponenteCurricular_Model_ComponenteDataMapper(); |
267 | 342 | } |
268 | 343 | |
269 | 344 | $ret = array(); |
270 | - foreach ($disciplinas as $disciplina) { | |
271 | - $id = $disciplina['ref_cod_disciplina']; | |
272 | - $carga = $disciplina['carga_horaria']; | |
273 | 345 | |
274 | - $componente = $mapper->findComponenteCurricularAnoEscolar($id, $codSerie); | |
346 | + foreach ($componentes as $componentePlaceholder) { | |
347 | + $id = $componentePlaceholder->id; | |
348 | + $carga = $componentePlaceholder->cargaHoraria; | |
349 | + | |
350 | + $componente = $mapper->findComponenteCurricularAnoEscolar($id, $anoEscolar); | |
275 | 351 | |
276 | - if (!is_null($carga)) { | |
352 | + if (! is_null($carga)) { | |
277 | 353 | $componente->cargaHoraria = $carga; |
278 | 354 | } |
279 | 355 | |
... | ... | @@ -375,22 +451,27 @@ class App_Model_IedFinder extends CoreExt_Entity |
375 | 451 | * de cursar. |
376 | 452 | * |
377 | 453 | * @param int $codMatricula |
378 | - * @param ComponenteCurricular_Model_ComponenteDataMapper $mapper | |
454 | + * @param ComponenteCurricular_Model_ComponenteDataMapper $componenteMapper | |
455 | + * @param ComponenteCurricular_Model_TurmaDataMapper $turmaMapper | |
379 | 456 | * @return array |
380 | 457 | * @throws App_Model_Exception |
381 | 458 | */ |
382 | 459 | public static function getComponentesPorMatricula($codMatricula, |
383 | - ComponenteCurricular_Model_ComponenteDataMapper $mapper = NULL) | |
460 | + ComponenteCurricular_Model_ComponenteDataMapper $componenteMapper = NULL, | |
461 | + ComponenteCurricular_Model_TurmaDataMapper $turmaMapper = NULL) | |
384 | 462 | { |
385 | 463 | $matricula = self::getMatricula($codMatricula); |
386 | 464 | |
387 | 465 | $codEscola = $matricula['ref_ref_cod_escola']; |
388 | 466 | $codSerie = $matricula['ref_ref_cod_serie']; |
467 | + $turma = $matricula['ref_cod_turma']; | |
389 | 468 | |
390 | 469 | $serie = self::getSerie($codSerie); |
391 | 470 | |
392 | 471 | // Disciplinas da escola na série em que o aluno está matriculado |
393 | - $componentes = self::getEscolaSerieDisciplina($codSerie, $codEscola, $mapper); | |
472 | + $componentes = self::getComponentesTurma( | |
473 | + $codSerie, $codEscola, $turma, $turmaMapper, $componenteMapper | |
474 | + ); | |
394 | 475 | |
395 | 476 | // Dispensas do aluno |
396 | 477 | $disciplinasDispensa = self::getDisciplinasDispensadasPorMatricula( | ... | ... |
ieducar/misc/database/deltas/23_cria_tabela_modules_componente_curricular_turma.sql
0 → 100644
... | ... | @@ -0,0 +1,48 @@ |
1 | +-- // | |
2 | + | |
3 | +-- | |
4 | +-- Cria a tabela modules.componente_curricular_turma para permitir a atribuição | |
5 | +-- de componentes curriculares a uma turma, dando mais flexibilidade de | |
6 | +-- configuração ao usuário. | |
7 | +-- | |
8 | +-- @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | |
9 | +-- @license @@license@@ | |
10 | +-- @version $Id$ | |
11 | +-- | |
12 | + | |
13 | +CREATE TABLE "modules"."componente_curricular_turma" ( | |
14 | + "componente_curricular_id" int NOT NULL, | |
15 | + "ano_escolar_id" int NOT NULL, | |
16 | + "escola_id" int NOT NULL, | |
17 | + "turma_id" int NOT NULL, | |
18 | + "carga_horaria" numeric(6,3), | |
19 | + PRIMARY KEY("componente_curricular_id","turma_id") | |
20 | +); | |
21 | + | |
22 | +ALTER TABLE "modules"."componente_curricular_turma" | |
23 | + ADD CONSTRAINT "componente_curricular_turma_componente_curricular_fkey" | |
24 | + FOREIGN KEY("componente_curricular_id") | |
25 | + REFERENCES "modules"."componente_curricular"("id") | |
26 | + ON DELETE RESTRICT | |
27 | + ON UPDATE NO ACTION; | |
28 | + | |
29 | +ALTER TABLE "modules"."componente_curricular_turma" | |
30 | + ADD CONSTRAINT "componente_curricular_turma_fkey" | |
31 | + FOREIGN KEY("turma_id") | |
32 | + REFERENCES "pmieducar"."turma"("cod_turma") | |
33 | + ON DELETE CASCADE | |
34 | + ON UPDATE NO ACTION; | |
35 | + | |
36 | +CREATE INDEX "componente_curricular_turma_turma_idx" | |
37 | + ON "modules"."componente_curricular_turma"("turma_id"); | |
38 | + | |
39 | +-- //@UNDO | |
40 | + | |
41 | +DROP INDEX "componente_curricular_turma_turma_idx"; | |
42 | +ALTER TABLE "modules"."componente_curricular_turma" | |
43 | + DROP CONSTRAINT "componente_curricular_turma_componente_curricular_fkey" CASCADE; | |
44 | +ALTER TABLE "modules"."componente_curricular_turma" | |
45 | + DROP CONSTRAINT "componente_curricular_turma_fkey" CASCADE; | |
46 | +DROP TABLE "modules"."componente_curricular_turma"; | |
47 | + | |
48 | +-- // | |
0 | 49 | \ No newline at end of file | ... | ... |
ieducar/misc/database/ieducar.sql
... | ... | @@ -10337,6 +10337,19 @@ SELECT pg_catalog.setval('componente_curricular_id_seq', 1, false); |
10337 | 10337 | |
10338 | 10338 | |
10339 | 10339 | -- |
10340 | +-- Name: componente_curricular_turma; Type: TABLE; Schema: modules; Owner: -; Tablespace: | |
10341 | +-- | |
10342 | + | |
10343 | +CREATE TABLE componente_curricular_turma ( | |
10344 | + componente_curricular_id integer NOT NULL, | |
10345 | + ano_escolar_id integer NOT NULL, | |
10346 | + escola_id integer NOT NULL, | |
10347 | + turma_id integer NOT NULL, | |
10348 | + carga_horaria numeric(6,3) | |
10349 | +); | |
10350 | + | |
10351 | + | |
10352 | +-- | |
10340 | 10353 | -- Name: falta_aluno; Type: TABLE; Schema: modules; Owner: -; Tablespace: |
10341 | 10354 | -- |
10342 | 10355 | |
... | ... | @@ -17718,6 +17731,12 @@ SET search_path = modules, pg_catalog; |
17718 | 17731 | |
17719 | 17732 | |
17720 | 17733 | -- |
17734 | +-- Data for Name: componente_curricular_turma; Type: TABLE DATA; Schema: modules; Owner: - | |
17735 | +-- | |
17736 | + | |
17737 | + | |
17738 | + | |
17739 | +-- | |
17721 | 17740 | -- Data for Name: falta_aluno; Type: TABLE DATA; Schema: modules; Owner: - |
17722 | 17741 | -- |
17723 | 17742 | |
... | ... | @@ -20115,6 +20134,7 @@ INSERT INTO changelog VALUES (19, 'Main', 'NOW()', 'NOW()', 'dbdeploy', '19_atua |
20115 | 20134 | INSERT INTO changelog VALUES (20, 'Main', 'NOW()', 'NOW()', 'dbdeploy', '20_remove_permissao_e_menu_diario_avaliacao_temp.sql'); |
20116 | 20135 | INSERT INTO changelog VALUES (21, 'Main', 'NOW()', 'NOW()', 'dbdeploy', '21_cria_tabelas_modulo_calendario.sql'); |
20117 | 20136 | INSERT INTO changelog VALUES (22, 'Main', 'NOW()', 'NOW()', 'dbdeploy', '22_cria_primary_key_em_modules_calendario_turma.sql'); |
20137 | +INSERT INTO changelog VALUES (23, 'Main', 'NOW()', 'NOW()', 'dbdeploy', '23_cria_tabela_modules_componente_curricular_turma.sql'); | |
20118 | 20138 | |
20119 | 20139 | |
20120 | 20140 | -- |
... | ... | @@ -27017,6 +27037,14 @@ ALTER TABLE ONLY componente_curricular |
27017 | 27037 | |
27018 | 27038 | |
27019 | 27039 | -- |
27040 | +-- Name: componente_curricular_turma_pkey; Type: CONSTRAINT; Schema: modules; Owner: -; Tablespace: | |
27041 | +-- | |
27042 | + | |
27043 | +ALTER TABLE ONLY componente_curricular_turma | |
27044 | + ADD CONSTRAINT componente_curricular_turma_pkey PRIMARY KEY (componente_curricular_id, turma_id); | |
27045 | + | |
27046 | + | |
27047 | +-- | |
27020 | 27048 | -- Name: falta_aluno_pkey; Type: CONSTRAINT; Schema: modules; Owner: -; Tablespace: |
27021 | 27049 | -- |
27022 | 27050 | |
... | ... | @@ -28960,6 +28988,13 @@ CREATE UNIQUE INDEX componente_curricular_id_key ON componente_curricular USING |
28960 | 28988 | |
28961 | 28989 | |
28962 | 28990 | -- |
28991 | +-- Name: componente_curricular_turma_turma_idx; Type: INDEX; Schema: modules; Owner: -; Tablespace: | |
28992 | +-- | |
28993 | + | |
28994 | +CREATE INDEX componente_curricular_turma_turma_idx ON componente_curricular_turma USING btree (turma_id); | |
28995 | + | |
28996 | + | |
28997 | +-- | |
28963 | 28998 | -- Name: regra_avaliacao_id_key; Type: INDEX; Schema: modules; Owner: -; Tablespace: |
28964 | 28999 | -- |
28965 | 29000 | |
... | ... | @@ -32810,6 +32845,22 @@ ALTER TABLE ONLY componente_curricular |
32810 | 32845 | |
32811 | 32846 | |
32812 | 32847 | -- |
32848 | +-- Name: componente_curricular_turma_componente_curricular_fkey; Type: FK CONSTRAINT; Schema: modules; Owner: - | |
32849 | +-- | |
32850 | + | |
32851 | +ALTER TABLE ONLY componente_curricular_turma | |
32852 | + ADD CONSTRAINT componente_curricular_turma_componente_curricular_fkey FOREIGN KEY (componente_curricular_id) REFERENCES componente_curricular(id) ON DELETE RESTRICT; | |
32853 | + | |
32854 | + | |
32855 | +-- | |
32856 | +-- Name: componente_curricular_turma_fkey; Type: FK CONSTRAINT; Schema: modules; Owner: - | |
32857 | +-- | |
32858 | + | |
32859 | +ALTER TABLE ONLY componente_curricular_turma | |
32860 | + ADD CONSTRAINT componente_curricular_turma_fkey FOREIGN KEY (turma_id) REFERENCES pmieducar.turma(cod_turma) ON DELETE CASCADE; | |
32861 | + | |
32862 | + | |
32863 | +-- | |
32813 | 32864 | -- Name: falta_componente_curricular_falta_aluno_fk; Type: FK CONSTRAINT; Schema: modules; Owner: - |
32814 | 32865 | -- |
32815 | 32866 | ... | ... |
ieducar/modules/Avaliacao/Service/Boletim.php
... | ... | @@ -79,6 +79,11 @@ class Avaliacao_Service_Boletim implements CoreExt_Configurable |
79 | 79 | protected $_componenteDataMapper = NULL; |
80 | 80 | |
81 | 81 | /** |
82 | + * @var ComponenteCurricular_Model_TurmaDataMapper | |
83 | + */ | |
84 | + protected $_componenteTurmaDataMapper = NULL; | |
85 | + | |
86 | + /** | |
82 | 87 | * @var RegraAvaliacao_Model_RegraDataMapper |
83 | 88 | */ |
84 | 89 | protected $_regraDataMapper = NULL; |
... | ... | @@ -273,6 +278,11 @@ class Avaliacao_Service_Boletim implements CoreExt_Configurable |
273 | 278 | unset($options['ComponenteDataMapper']); |
274 | 279 | } |
275 | 280 | |
281 | + if (isset($options['ComponenteTurmaDataMapper'])) { | |
282 | + $this->setComponenteTurmaDataMapper($options['ComponenteTurmaDataMapper']); | |
283 | + unset($options['ComponenteTurmaDataMapper']); | |
284 | + } | |
285 | + | |
276 | 286 | if (isset($options['RegraDataMapper'])) { |
277 | 287 | $this->setRegraDataMapper($options['RegraDataMapper']); |
278 | 288 | unset($options['RegraDataMapper']); |
... | ... | @@ -383,6 +393,30 @@ class Avaliacao_Service_Boletim implements CoreExt_Configurable |
383 | 393 | |
384 | 394 | /** |
385 | 395 | * Setter. |
396 | + * @param ComponenteCurricular_Model_TurmaDataMapper $mapper | |
397 | + * @return App_Service_Boletim Provê interface fluída | |
398 | + */ | |
399 | + public function setComponenteTurmaDataMapper(ComponenteCurricular_Model_TurmaDataMapper $mapper) | |
400 | + { | |
401 | + $this->_componenteTurmaDataMapper = $mapper; | |
402 | + return $this; | |
403 | + } | |
404 | + | |
405 | + /** | |
406 | + * Getter. | |
407 | + * @return ComponenteCurricular_Model_TurmaDataMapper | |
408 | + */ | |
409 | + public function getComponenteTurmaDataMapper() | |
410 | + { | |
411 | + if (is_null($this->_componenteTurmaDataMapper)) { | |
412 | + require_once 'ComponenteCurricular/Model/TurmaDataMapper.php'; | |
413 | + $this->setComponenteTurmaDataMapper(new ComponenteCurricular_Model_TurmaDataMapper()); | |
414 | + } | |
415 | + return $this->_componenteTurmaDataMapper; | |
416 | + } | |
417 | + | |
418 | + /** | |
419 | + * Setter. | |
386 | 420 | * @param RegraAvaliacao_Model_RegraDataMapper $mapper |
387 | 421 | * @return App_Service_Boletim Provê interface fluída |
388 | 422 | */ |
... | ... | @@ -773,7 +807,8 @@ class Avaliacao_Service_Boletim implements CoreExt_Configurable |
773 | 807 | )) |
774 | 808 | |
775 | 809 | ->_setComponentes(App_Model_IedFinder::getComponentesPorMatricula( |
776 | - $codMatricula, $this->getComponenteDataMapper() | |
810 | + $codMatricula, $this->getComponenteDataMapper(), | |
811 | + $this->getComponenteTurmaDataMapper() | |
777 | 812 | )); |
778 | 813 | |
779 | 814 | // Valores scalar de referência | ... | ... |
ieducar/modules/Avaliacao/_data/install.sql
... | ... | @@ -8,14 +8,14 @@ |
8 | 8 | -- @version $Id$ |
9 | 9 | -- |
10 | 10 | |
11 | -CREATE TABLE "modules"."falta_aluno" ( | |
11 | +CREATE TABLE "modules"."falta_aluno" ( | |
12 | 12 | "id" serial NOT NULL, |
13 | 13 | "matricula_id" int NOT NULL, |
14 | 14 | "tipo_falta" smallint NOT NULL, |
15 | 15 | PRIMARY KEY("id") |
16 | 16 | ); |
17 | 17 | |
18 | -CREATE TABLE "modules"."falta_componente_curricular" ( | |
18 | +CREATE TABLE "modules"."falta_componente_curricular" ( | |
19 | 19 | "id" serial NOT NULL, |
20 | 20 | "falta_aluno_id" int NOT NULL, |
21 | 21 | "componente_curricular_id" int NOT NULL, |
... | ... | @@ -24,7 +24,7 @@ CREATE TABLE "modules"."falta_componente_curricular" ( |
24 | 24 | PRIMARY KEY("id") |
25 | 25 | ); |
26 | 26 | |
27 | -CREATE TABLE "modules"."falta_geral" ( | |
27 | +CREATE TABLE "modules"."falta_geral" ( | |
28 | 28 | "id" serial NOT NULL, |
29 | 29 | "falta_aluno_id" int NOT NULL, |
30 | 30 | "quantidade" int NULL DEFAULT 0, |
... | ... | @@ -32,13 +32,13 @@ CREATE TABLE "modules"."falta_geral" ( |
32 | 32 | PRIMARY KEY("id") |
33 | 33 | ); |
34 | 34 | |
35 | -CREATE TABLE "modules"."nota_aluno" ( | |
35 | +CREATE TABLE "modules"."nota_aluno" ( | |
36 | 36 | "id" serial NOT NULL, |
37 | 37 | "matricula_id" int NOT NULL, |
38 | 38 | PRIMARY KEY("id") |
39 | 39 | ); |
40 | 40 | |
41 | -CREATE TABLE "modules"."nota_componente_curricular" ( | |
41 | +CREATE TABLE "modules"."nota_componente_curricular" ( | |
42 | 42 | "id" serial NOT NULL, |
43 | 43 | "nota_aluno_id" int NOT NULL, |
44 | 44 | "componente_curricular_id" int NOT NULL, |
... | ... | @@ -48,7 +48,7 @@ CREATE TABLE "modules"."nota_componente_curricular" ( |
48 | 48 | PRIMARY KEY("id") |
49 | 49 | ); |
50 | 50 | |
51 | -CREATE TABLE "modules"."nota_componente_curricular_media" ( | |
51 | +CREATE TABLE "modules"."nota_componente_curricular_media" ( | |
52 | 52 | "nota_aluno_id" int NOT NULL, |
53 | 53 | "componente_curricular_id" int NOT NULL, |
54 | 54 | "media" decimal(5,3) NULL DEFAULT 0, |
... | ... | @@ -57,50 +57,83 @@ CREATE TABLE "modules"."nota_componente_curricular_media" ( |
57 | 57 | PRIMARY KEY("nota_aluno_id","componente_curricular_id") |
58 | 58 | ); |
59 | 59 | |
60 | +CREATE TABLE "modules"."componente_curricular_turma" ( | |
61 | + "componente_curricular_id" int NOT NULL, | |
62 | + "ano_escolar_id" int NOT NULL, | |
63 | + "escola_id" int NOT NULL, | |
64 | + "turma_id" int NOT NULL, | |
65 | + "carga_horaria" numeric(6,3), | |
66 | + PRIMARY KEY("componente_curricular_id","turma_id") | |
67 | +); | |
68 | + | |
60 | 69 | ALTER TABLE "modules"."falta_componente_curricular" |
61 | 70 | ADD CONSTRAINT "falta_componente_curricular_falta_aluno_fk" |
62 | 71 | FOREIGN KEY("falta_aluno_id") |
63 | 72 | REFERENCES "modules"."falta_aluno"("id") |
64 | - ON DELETE CASCADE | |
65 | - ON UPDATE NO ACTION ; | |
73 | + ON DELETE CASCADE | |
74 | + ON UPDATE NO ACTION; | |
66 | 75 | |
67 | 76 | ALTER TABLE "modules"."falta_geral" |
68 | 77 | ADD CONSTRAINT "falta_geral_falta_aluno_fk" |
69 | 78 | FOREIGN KEY("falta_aluno_id") |
70 | 79 | REFERENCES "modules"."falta_aluno"("id") |
71 | - ON DELETE CASCADE | |
72 | - ON UPDATE NO ACTION ; | |
80 | + ON DELETE CASCADE | |
81 | + ON UPDATE NO ACTION; | |
73 | 82 | |
74 | 83 | ALTER TABLE "modules"."nota_componente_curricular" |
75 | 84 | ADD CONSTRAINT "nota_componente_curricular_nota_aluno_fk" |
76 | 85 | FOREIGN KEY("nota_aluno_id") |
77 | 86 | REFERENCES "modules"."nota_aluno"("id") |
78 | - ON DELETE CASCADE | |
79 | - ON UPDATE NO ACTION ; | |
87 | + ON DELETE CASCADE | |
88 | + ON UPDATE NO ACTION; | |
80 | 89 | |
81 | 90 | ALTER TABLE "modules"."nota_componente_curricular_media" |
82 | 91 | ADD CONSTRAINT "nota_componente_curricular_media_nota_aluno_fk" |
83 | 92 | FOREIGN KEY("nota_aluno_id") |
84 | 93 | REFERENCES "modules"."nota_aluno"("id") |
85 | - ON DELETE CASCADE | |
86 | - ON UPDATE NO ACTION ; | |
94 | + ON DELETE CASCADE | |
95 | + ON UPDATE NO ACTION; | |
96 | + | |
97 | +ALTER TABLE "modules"."componente_curricular_turma" | |
98 | + ADD CONSTRAINT "componente_curricular_turma_componente_curricular_fkey" | |
99 | + FOREIGN KEY("componente_curricular_id") | |
100 | + REFERENCES "modules"."componente_curricular"("id") | |
101 | + ON DELETE RESTRICT | |
102 | + ON UPDATE NO ACTION; | |
87 | 103 | |
104 | +ALTER TABLE "modules"."componente_curricular_turma" | |
105 | + ADD CONSTRAINT "componente_curricular_turma_fkey" | |
106 | + FOREIGN KEY("turma_id") | |
107 | + REFERENCES "pmieducar"."turma"("cod_turma") | |
108 | + ON DELETE CASCADE | |
109 | + ON UPDATE NO ACTION; | |
110 | + | |
111 | +CREATE INDEX "componente_curricular_turma_turma_idx" | |
112 | + ON "modules"."componente_curricular_turma"("turma_id"); | |
88 | 113 | |
89 | 114 | -- //@UNDO |
90 | 115 | |
116 | +DROP INDEX "componente_curricular_turma_turma_idx"; | |
117 | + | |
91 | 118 | ALTER TABLE "modules"."falta_componente_curricular" |
92 | - DROP CONSTRAINT "falta_componente_curricular_falta_aluno_fk" CASCADE ; | |
119 | + DROP CONSTRAINT "falta_componente_curricular_falta_aluno_fk" CASCADE; | |
93 | 120 | ALTER TABLE "modules"."falta_geral" |
94 | - DROP CONSTRAINT "falta_geral_falta_aluno_fk" CASCADE ; | |
121 | + DROP CONSTRAINT "falta_geral_falta_aluno_fk" CASCADE; | |
95 | 122 | ALTER TABLE "modules"."nota_componente_curricular" |
96 | - DROP CONSTRAINT "nota_componente_curricular_nota_aluno_fk" CASCADE ; | |
123 | + DROP CONSTRAINT "nota_componente_curricular_nota_aluno_fk" CASCADE; | |
97 | 124 | ALTER TABLE "modules"."nota_componente_curricular_media" |
98 | - DROP CONSTRAINT "nota_componente_curricular_media_nota_aluno_fk" CASCADE ; | |
125 | + DROP CONSTRAINT "nota_componente_curricular_media_nota_aluno_fk" CASCADE; | |
126 | +ALTER TABLE "modules"."componente_curricular_turma" | |
127 | + DROP CONSTRAINT "componente_curricular_turma_componente_curricular_fkey" CASCADE; | |
128 | +ALTER TABLE "modules"."componente_curricular_turma" | |
129 | + DROP CONSTRAINT "componente_curricular_turma_fkey" CASCADE; | |
130 | + | |
99 | 131 | DROP TABLE "modules"."falta_aluno"; |
100 | 132 | DROP TABLE "modules"."falta_componente_curricular"; |
101 | 133 | DROP TABLE "modules"."falta_geral"; |
102 | 134 | DROP TABLE "modules"."nota_aluno"; |
103 | 135 | DROP TABLE "modules"."nota_componente_curricular"; |
104 | 136 | DROP TABLE "modules"."nota_componente_curricular_media"; |
137 | +DROP TABLE "modules"."componente_curricular_turma"; | |
105 | 138 | |
106 | 139 | -- // |
107 | 140 | \ No newline at end of file | ... | ... |
ieducar/modules/Avaliacao/_tests/Service/TestCommon.php
... | ... | @@ -49,6 +49,8 @@ require_once 'TabelaArredondamento/Model/TabelaDataMapper.php'; |
49 | 49 | require_once 'RegraAvaliacao/Model/Regra.php'; |
50 | 50 | require_once 'RegraAvaliacao/Model/RegraDataMapper.php'; |
51 | 51 | |
52 | +require_once 'ComponenteCurricular/Model/TurmaDataMapper.php'; | |
53 | + | |
52 | 54 | require_once 'Avaliacao/Model/NotaAlunoDataMapper.php'; |
53 | 55 | require_once 'Avaliacao/Model/NotaComponenteDataMapper.php'; |
54 | 56 | require_once 'Avaliacao/Model/NotaComponenteMediaDataMapper.php'; |
... | ... | @@ -179,6 +181,8 @@ abstract class Avaliacao_Service_TestCommon extends UnitBaseTest |
179 | 181 | |
180 | 182 | protected $_componenteDataMapperMock = NULL; |
181 | 183 | |
184 | + protected $_componenteTurmaDataMapperMock = NULL; | |
185 | + | |
182 | 186 | protected $_notaAlunoDataMapperMock = NULL; |
183 | 187 | |
184 | 188 | protected $_notaComponenteDataMapperMock = NULL; |
... | ... | @@ -205,6 +209,7 @@ abstract class Avaliacao_Service_TestCommon extends UnitBaseTest |
205 | 209 | ->_setConfigOptions('escolaAnoLetivo', $this->_getEscolaAnoLetivo()) |
206 | 210 | ->_setConfigOptions('anoLetivoModulo', $this->_getAnoLetivoModulo()) |
207 | 211 | ->_setConfigOptions('modulo', $this->_getModulo()) |
212 | + ->_setConfigOptions('componentesTurma', $this->_getComponentesTurma()) | |
208 | 213 | ->_setConfigOptions('escolaSerieDisciplina', $this->_getEscolaSerieDisciplina()) |
209 | 214 | ->_setConfigOptions('dispensaDisciplina', $this->_getDispensaDisciplina()) |
210 | 215 | ->_setConfigOptions('componenteCurricular', $this->_getComponenteCurricular()) |
... | ... | @@ -224,6 +229,7 @@ abstract class Avaliacao_Service_TestCommon extends UnitBaseTest |
224 | 229 | $mappers = array( |
225 | 230 | 'RegraDataMapper' => $this->_getRegraDataMapperMock(), |
226 | 231 | 'ComponenteDataMapper' => $this->_getComponenteDataMapperMock(), |
232 | + 'ComponenteTurmaDataMapper' => $this->_getComponenteTurmaDataMapperMock(), | |
227 | 233 | 'NotaAlunoDataMapper' => $this->_getNotaAlunoDataMapperMock(), |
228 | 234 | 'NotaComponenteDataMapper' => $this->_getNotaComponenteDataMapperMock(), |
229 | 235 | 'NotaComponenteMediaDataMapper' => $this->_getNotaComponenteMediaDataMapperMock(), |
... | ... | @@ -261,6 +267,7 @@ abstract class Avaliacao_Service_TestCommon extends UnitBaseTest |
261 | 267 | 'usuario' => $this->_getConfigOption('usuario', 'cod_usuario'), |
262 | 268 | 'RegraDataMapper' => $this->_getConfigOption('mappers', 'RegraDataMapper'), |
263 | 269 | 'ComponenteDataMapper' => $this->_getConfigOption('mappers', 'ComponenteDataMapper'), |
270 | + 'ComponenteTurmaDataMapper' => $this->_getConfigOption('mappers', 'ComponenteTurmaDataMapper'), | |
264 | 271 | 'NotaAlunoDataMapper' => $this->_getConfigOption('mappers', 'NotaAlunoDataMapper'), |
265 | 272 | 'NotaComponenteDataMapper' => $this->_getConfigOption('mappers', 'NotaComponenteDataMapper'), |
266 | 273 | 'NotaComponenteMediaDataMapper' => $this->_getConfigOption('mappers', 'NotaComponenteMediaDataMapper'), |
... | ... | @@ -449,6 +456,14 @@ abstract class Avaliacao_Service_TestCommon extends UnitBaseTest |
449 | 456 | /** |
450 | 457 | * @return array |
451 | 458 | */ |
459 | + protected function _getComponentesTurma() | |
460 | + { | |
461 | + return array(); | |
462 | + } | |
463 | + | |
464 | + /** | |
465 | + * @return array | |
466 | + */ | |
452 | 467 | protected function _getEscolaSerieDisciplina() |
453 | 468 | { |
454 | 469 | return array( |
... | ... | @@ -850,6 +865,29 @@ abstract class Avaliacao_Service_TestCommon extends UnitBaseTest |
850 | 865 | return $this->_componenteDataMapperMock; |
851 | 866 | } |
852 | 867 | |
868 | + protected function _setComponenteTurmaDataMapperMock(ComponenteCurricular_Model_TurmaDataMapper $mapper) | |
869 | + { | |
870 | + $this->_componenteTurmaDataMapperMock = $mapper; | |
871 | + return $this; | |
872 | + } | |
873 | + | |
874 | + protected function _getComponenteTurmaDataMapperMock() | |
875 | + { | |
876 | + if (is_null($this->_componenteTurmaDataMapperMock)) { | |
877 | + $componentes = $this->_getConfigOptions('componentesTurma'); | |
878 | + | |
879 | + // Mock para ComponenteCurricular_Model_TurmaDataMapper | |
880 | + $mock = $this->getCleanMock('ComponenteCurricular_Model_TurmaDataMapper'); | |
881 | + $mock->expects($this->any()) | |
882 | + ->method('findAll') | |
883 | + ->will(new PHPUnit_Framework_MockObject_Stub_ConsecutiveCalls($componentes)); | |
884 | + | |
885 | + $this->_setComponenteTurmaDataMapperMock($mock); | |
886 | + } | |
887 | + | |
888 | + return $this->_componenteTurmaDataMapperMock; | |
889 | + } | |
890 | + | |
853 | 891 | protected function _setNotaAlunoDataMapperMock(Avaliacao_Model_NotaAlunoDataMapper $mapper = NULL) |
854 | 892 | { |
855 | 893 | $this->_notaAlunoDataMapperMock = $mapper; | ... | ... |
... | ... | @@ -0,0 +1,85 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package ComponenteCurricular | |
27 | + * @subpackage Modules | |
28 | + * @since Arquivo disponível desde a versão 1.2.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'CoreExt/Entity.php'; | |
33 | + | |
34 | +/** | |
35 | + * ComponenteCurricular_Model_Turma class. | |
36 | + * | |
37 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | |
38 | + * @category i-Educar | |
39 | + * @license @@license@@ | |
40 | + * @package ComponenteCurricular | |
41 | + * @subpackage Modules | |
42 | + * @since Classe disponível desde a versão 1.2.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class ComponenteCurricular_Model_Turma extends CoreExt_Entity | |
46 | +{ | |
47 | + protected $_data = array( | |
48 | + 'componenteCurricular' => NULL, | |
49 | + 'anoEscolar' => NULL, | |
50 | + 'escola' => NULL, | |
51 | + 'turma' => NULL, | |
52 | + 'cargaHoraria' => NULL | |
53 | + ); | |
54 | + | |
55 | + protected $_dataTypes = array( | |
56 | + 'cargaHoraria' => 'numeric' | |
57 | + ); | |
58 | + | |
59 | + protected $_references = array( | |
60 | + 'componenteCurricular' => array( | |
61 | + 'value' => NULL, | |
62 | + 'class' => 'ComponenteCurricular_Model_ComponenteDataMapper', | |
63 | + 'file' => 'ComponenteCurricular/Model/ComponenteDataMapper.php' | |
64 | + ) | |
65 | + ); | |
66 | + | |
67 | + /** | |
68 | + * Construtor. Remove o campo identidade já que usa uma chave composta. | |
69 | + * @see CoreExt_Entity#__construct($options = array()) | |
70 | + */ | |
71 | + public function __construct($options = array()) { | |
72 | + parent::__construct($options); | |
73 | + unset($this->_data['id']); | |
74 | + } | |
75 | + | |
76 | + /** | |
77 | + * @see CoreExt_Entity_Validatable#getDefaultValidatorCollection() | |
78 | + */ | |
79 | + public function getDefaultValidatorCollection() | |
80 | + { | |
81 | + return array( | |
82 | + 'cargaHoraria' => new CoreExt_Validate_Numeric(array('required' => FALSE)) | |
83 | + ); | |
84 | + } | |
85 | +} | |
0 | 86 | \ No newline at end of file | ... | ... |
ieducar/modules/ComponenteCurricular/Model/TurmaDataMapper.php
0 → 100644
... | ... | @@ -0,0 +1,137 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package ComponenteCurricular | |
27 | + * @subpackage Modules | |
28 | + * @since Arquivo disponível desde a versão 1.2.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'CoreExt/DataMapper.php'; | |
33 | +require_once 'ComponenteCurricular/Model/Turma.php'; | |
34 | + | |
35 | +/** | |
36 | + * ComponenteCurricular_Model_TurmaDataMapper class. | |
37 | + * | |
38 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | |
39 | + * @category i-Educar | |
40 | + * @license @@license@@ | |
41 | + * @package ComponenteCurricular | |
42 | + * @subpackage Modules | |
43 | + * @since Classe disponível desde a versão 1.2.0 | |
44 | + * @version @@package_version@@ | |
45 | + */ | |
46 | +class ComponenteCurricular_Model_TurmaDataMapper extends CoreExt_DataMapper | |
47 | +{ | |
48 | + protected $_entityClass = 'ComponenteCurricular_Model_Turma'; | |
49 | + protected $_tableName = 'componente_curricular_turma'; | |
50 | + protected $_tableSchema = 'modules'; | |
51 | + | |
52 | + /** | |
53 | + * Os atributos anoEscolar e escola estão presentes apenas para | |
54 | + * fins de desnormalização. | |
55 | + * @var array | |
56 | + */ | |
57 | + protected $_attributeMap = array( | |
58 | + 'componenteCurricular' => 'componente_curricular_id', | |
59 | + 'anoEscolar' => 'ano_escolar_id', | |
60 | + 'escola' => 'escola_id', | |
61 | + 'turma' => 'turma_id', | |
62 | + 'cargaHoraria' => 'carga_horaria' | |
63 | + ); | |
64 | + | |
65 | + protected $_primaryKey = array( | |
66 | + 'componenteCurricular', 'turma' | |
67 | + ); | |
68 | + | |
69 | + /** | |
70 | + * Realiza uma operação de atualização em todas as instâncias persistidas de | |
71 | + * ComponenteCurricular_Model_Turma. A atualização envolve criar, atualizar | |
72 | + * e/ou apagar instâncias persistidas. | |
73 | + * | |
74 | + * No exemplo de código a seguir, se uma instância de | |
75 | + * ComponenteCurricular_Model_Turma com uma referência a componenteCurricular | |
76 | + * "1" existisse, esta teria seus atributos atualizados e persistidos | |
77 | + * novamente. Se a referência não existisse, uma nova instância de | |
78 | + * ComponenteCurricular_Model_Turma seria criada e persistida. Caso uma | |
79 | + * referência a "2" existisse, esta seria apagada por não estar referenciada | |
80 | + * no array $componentes. | |
81 | + * | |
82 | + * <code> | |
83 | + * <?php | |
84 | + * $componentes = array( | |
85 | + * array('id' => 1, 'cargaHoraria' => 100) | |
86 | + * ); | |
87 | + * $mapper->bulkUpdate(1, 1, 1, $componentes); | |
88 | + * </code> | |
89 | + * | |
90 | + * | |
91 | + * | |
92 | + * @param int $anoEscolar O código do ano escolar/série. | |
93 | + * @param int $escola O código da escola. | |
94 | + * @param int $turma O código da turma. | |
95 | + * @param array $componentes (id => integer, cargaHoraria => float|null) | |
96 | + * @throws Exception | |
97 | + */ | |
98 | + public function bulkUpdate($anoEscolar, $escola, $turma, array $componentes) | |
99 | + { | |
100 | + $update = $insert = $delete = array(); | |
101 | + | |
102 | + $componentesTurma = $this->findAll(array(), array('turma' => $turma)); | |
103 | + | |
104 | + $objects = array(); | |
105 | + foreach ($componentesTurma as $componenteTurma) { | |
106 | + $objects[$componenteTurma->get('componenteCurricular')] = $componenteTurma; | |
107 | + } | |
108 | + | |
109 | + foreach ($componentes as $componente) { | |
110 | + $id = $componente['id']; | |
111 | + | |
112 | + if (isset($objects[$id])) { | |
113 | + $insert[$id] = $objects[$id]; | |
114 | + $insert[$id]->cargaHoraria = $componente['cargaHoraria']; | |
115 | + continue; | |
116 | + } | |
117 | + | |
118 | + $insert[$id] = new ComponenteCurricular_Model_Turma(array( | |
119 | + 'componenteCurricular' => $id, | |
120 | + 'anoEscolar' => $anoEscolar, | |
121 | + 'escola' => $escola, | |
122 | + 'turma' => $turma, | |
123 | + 'cargaHoraria' => $componente['cargaHoraria'] | |
124 | + )); | |
125 | + } | |
126 | + | |
127 | + $delete = array_diff(array_keys($objects), array_keys($insert)); | |
128 | + | |
129 | + foreach ($delete as $id) { | |
130 | + $this->delete($objects[$id]); | |
131 | + } | |
132 | + | |
133 | + foreach ($insert as $entry) { | |
134 | + $this->save($entry); | |
135 | + } | |
136 | + } | |
137 | +} | |
0 | 138 | \ No newline at end of file | ... | ... |
ieducar/modules/ComponenteCurricular/_tests/TurmaDataMapperTest.php
0 → 100644
... | ... | @@ -0,0 +1,96 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package ComponenteCurricular | |
27 | + * @subpackage UnitTests | |
28 | + * @since Arquivo disponível desde a versão 1.2.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'ComponenteCurricular/Model/TurmaDataMapper.php'; | |
33 | + | |
34 | +/** | |
35 | + * TurmDataMapperTest class. | |
36 | + * | |
37 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | |
38 | + * @category i-Educar | |
39 | + * @license @@license@@ | |
40 | + * @package ComponenteCurricular | |
41 | + * @subpackage UnitTests | |
42 | + * @since Classe disponível desde a versão 1.2.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class TurmaDataMapperTest extends UnitBaseTest | |
46 | +{ | |
47 | + protected $_mapper = NULL; | |
48 | + | |
49 | + public function testBulkUpdate() | |
50 | + { | |
51 | + $returnValue = array( | |
52 | + array( | |
53 | + 'componente_curricular_id' => 1, | |
54 | + 'ano_escolar_id' => 1, | |
55 | + 'escola_id' => 1, | |
56 | + 'turma_id' => 1, | |
57 | + 'carga_horaria' => NULL | |
58 | + ), | |
59 | + array( | |
60 | + 'componente_curricular_id' => 3, | |
61 | + 'ano_escolar_id' => 1, | |
62 | + 'escola_id' => 1, | |
63 | + 'turma_id' => 1, | |
64 | + 'carga_horaria' => 100 | |
65 | + ) | |
66 | + ); | |
67 | + | |
68 | + $componentes = array( | |
69 | + array( | |
70 | + 'id' => 1, | |
71 | + 'cargaHoraria' => 100 | |
72 | + ), | |
73 | + array( | |
74 | + 'id' => 2, | |
75 | + 'cargaHoraria' => NULL | |
76 | + ) | |
77 | + ); | |
78 | + | |
79 | + $mock = $this->getDbMock(); | |
80 | + | |
81 | + // 1 SELECT, 1 DELETE, 1 INSERT e 1 UPDATE | |
82 | + $mock->expects($this->exactly(4)) | |
83 | + ->method('Consulta'); | |
84 | + | |
85 | + $mock->expects($this->exactly(3)) | |
86 | + ->method('ProximoRegistro') | |
87 | + ->will($this->onConsecutiveCalls(TRUE, TRUE, FALSE)); | |
88 | + | |
89 | + $mock->expects($this->exactly(2)) | |
90 | + ->method('Tupla') | |
91 | + ->will($this->onConsecutiveCalls($returnValue[0], $returnValue[1])); | |
92 | + | |
93 | + $mapper = new ComponenteCurricular_Model_TurmaDataMapper($mock); | |
94 | + $mapper->bulkUpdate(1, 1, 1, $componentes); | |
95 | + } | |
96 | +} | |
0 | 97 | \ No newline at end of file | ... | ... |
ieducar/modules/ComponenteCurricular/_tests/TurmaTest.php
0 → 100644
... | ... | @@ -0,0 +1,59 @@ |
1 | +<?php | |
2 | + | |
3 | +/** | |
4 | + * i-Educar - Sistema de gestão escolar | |
5 | + * | |
6 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
7 | + * <ctima@itajai.sc.gov.br> | |
8 | + * | |
9 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
10 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
11 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
12 | + * qualquer versão posterior. | |
13 | + * | |
14 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
15 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
16 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
17 | + * do GNU para mais detalhes. | |
18 | + * | |
19 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
20 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
21 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
22 | + * | |
23 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | |
24 | + * @category i-Educar | |
25 | + * @license @@license@@ | |
26 | + * @package ComponenteCurricular | |
27 | + * @subpackage UnitTests | |
28 | + * @since Arquivo disponível desde a versão 1.2.0 | |
29 | + * @version $Id$ | |
30 | + */ | |
31 | + | |
32 | +require_once 'ComponenteCurricular/Model/Turma.php'; | |
33 | + | |
34 | +/** | |
35 | + * ComponenteCurricular_Model_TurmaTest class. | |
36 | + * | |
37 | + * @author Eriksen Costa Paixão <eriksen.paixao_bs@cobra.com.br> | |
38 | + * @category i-Educar | |
39 | + * @license @@license@@ | |
40 | + * @package ComponenteCurricular | |
41 | + * @subpackage UnitTests | |
42 | + * @since Classe disponível desde a versão 1.2.0 | |
43 | + * @version @@package_version@@ | |
44 | + */ | |
45 | +class ComponenteCurricular_Model_TurmaTest extends UnitBaseTest | |
46 | +{ | |
47 | + protected $_entity = NULL; | |
48 | + | |
49 | + protected function setUp() | |
50 | + { | |
51 | + $this->_entity = new ComponenteCurricular_Model_Turma(); | |
52 | + } | |
53 | + | |
54 | + public function testEntityValidators() | |
55 | + { | |
56 | + $validators = $this->_entity->getValidatorCollection(); | |
57 | + $this->assertType('CoreExt_Validate_Numeric', $validators['cargaHoraria']); | |
58 | + } | |
59 | +} | |
0 | 60 | \ No newline at end of file | ... | ... |
ieducar/tests/unit/App/Model/IedFinderTest.php
... | ... | @@ -44,6 +44,7 @@ require_once 'TabelaArredondamento/Model/TabelaDataMapper.php'; |
44 | 44 | require_once 'TabelaArredondamento/Model/TabelaValorDataMapper.php'; |
45 | 45 | require_once 'ComponenteCurricular/Model/ComponenteDataMapper.php'; |
46 | 46 | require_once 'ComponenteCurricular/Model/AnoEscolarDataMapper.php'; |
47 | +require_once 'ComponenteCurricular/Model/TurmaDataMapper.php'; | |
47 | 48 | require_once 'AreaConhecimento/Model/AreaDataMapper.php'; |
48 | 49 | |
49 | 50 | /** |
... | ... | @@ -101,6 +102,58 @@ class App_Model_IedFinderTest extends UnitBaseTest |
101 | 102 | return $tabela; |
102 | 103 | } |
103 | 104 | |
105 | + /** | |
106 | + * Configura mocks para ComponenteCurricular_Model_ComponenteDataMapper e | |
107 | + * ComponenteCurricular_Model_TurmaDataMapper para o método getComponentesTurma(). | |
108 | + * | |
109 | + * @return array ('componenteMock', 'turmaMock', 'expected') | |
110 | + */ | |
111 | + protected function _getComponentesTurmaMock() | |
112 | + { | |
113 | + $returnComponenteMock = array( | |
114 | + 1 => new ComponenteCurricular_Model_Componente( | |
115 | + array('id' => 1, 'nome' => 'Matemática', 'cargaHoraria' => 100) | |
116 | + ), | |
117 | + 2 => new ComponenteCurricular_Model_Componente( | |
118 | + array('id' => 2, 'nome' => 'Português', 'cargaHoraria' => 100) | |
119 | + ) | |
120 | + ); | |
121 | + | |
122 | + $expected = $returnComponenteMock; | |
123 | + | |
124 | + $componenteMock = $this->getCleanMock('ComponenteCurricular_Model_ComponenteDataMapper'); | |
125 | + $componenteMock->expects($this->exactly(2)) | |
126 | + ->method('findComponenteCurricularAnoEscolar') | |
127 | + ->will($this->onConsecutiveCalls( | |
128 | + $returnComponenteMock[1], $returnComponenteMock[2] | |
129 | + )); | |
130 | + | |
131 | + $returnTurmaMock = array( | |
132 | + new ComponenteCurricular_Model_Turma( | |
133 | + array('componenteCurricular' => 1, 'cargaHoraria' => 200) | |
134 | + ), | |
135 | + new ComponenteCurricular_Model_Turma( | |
136 | + array('componenteCurricular' => 2, 'cargaHoraria' => NULL) | |
137 | + ) | |
138 | + ); | |
139 | + | |
140 | + $turmaMock = $this->getCleanMock('ComponenteCurricular_Model_TurmaDataMapper'); | |
141 | + $turmaMock->expects($this->once()) | |
142 | + ->method('findAll') | |
143 | + ->with(array(), array('turma' => 1)) | |
144 | + ->will($this->returnValue($returnTurmaMock)); | |
145 | + | |
146 | + // O primeiro componente tem carga horária definida na turma, o segundo usa o padrão do componente | |
147 | + $expected[1] = clone $expected[1]; | |
148 | + $expected[1]->cargaHoraria = 200; | |
149 | + | |
150 | + return array( | |
151 | + 'componenteMock' => $componenteMock, | |
152 | + 'turmaMock' => $turmaMock, | |
153 | + 'expected' => $expected | |
154 | + ); | |
155 | + } | |
156 | + | |
104 | 157 | public function testGetCurso() |
105 | 158 | { |
106 | 159 | $returnValue = array( |
... | ... | @@ -237,6 +290,10 @@ class App_Model_IedFinderTest extends UnitBaseTest |
237 | 290 | |
238 | 291 | App_Model_IedFinder::addClassToStorage('clsPmieducarEscolaSerieDisciplina', $escolaMock, NULL, TRUE); |
239 | 292 | |
293 | + // O primeiro componente tem uma carga horária definida em escola-série. | |
294 | + $expected[1] = clone $returnAnoEscolar[1]; | |
295 | + $expected[1]->cargaHoraria = 80; | |
296 | + | |
240 | 297 | $componentes = App_Model_IedFinder::getEscolaSerieDisciplina(1, 1, $anoEscolarMock); |
241 | 298 | $this->assertEquals( |
242 | 299 | $expected, $componentes, |
... | ... | @@ -244,6 +301,20 @@ class App_Model_IedFinderTest extends UnitBaseTest |
244 | 301 | ); |
245 | 302 | } |
246 | 303 | |
304 | + public function testGetComponentesTurma() | |
305 | + { | |
306 | + $mocks = $this->_getComponentesTurmaMock(); | |
307 | + | |
308 | + $componentes = App_Model_IedFinder::getComponentesTurma( | |
309 | + 1, 1, 1, $mocks['turmaMock'], $mocks['componenteMock'] | |
310 | + ); | |
311 | + | |
312 | + $this->assertEquals( | |
313 | + $mocks['expected'], $componentes, | |
314 | + '::getComponentesTurma() retorna os componentes de uma turma.' | |
315 | + ); | |
316 | + } | |
317 | + | |
247 | 318 | public function testGetMatricula() |
248 | 319 | { |
249 | 320 | $expected = array( |
... | ... | @@ -353,81 +424,34 @@ class App_Model_IedFinderTest extends UnitBaseTest |
353 | 424 | */ |
354 | 425 | public function testGetComponentesPorMatricula() |
355 | 426 | { |
356 | - $componentes = array( | |
357 | - new ComponenteCurricular_Model_Componente( | |
358 | - array('id' => 1, 'nome' => 'Matemática', 'cargaHoraria' => 100) | |
359 | - ), | |
360 | - new ComponenteCurricular_Model_Componente( | |
361 | - array('id' => 2, 'nome' => 'Português', 'cargaHoraria' => 100) | |
362 | - ), | |
363 | - new ComponenteCurricular_Model_Componente( | |
364 | - array('id' => 3, 'nome' => 'Ciências', 'cargaHoraria' => 60) | |
365 | - ), | |
366 | - new ComponenteCurricular_Model_Componente( | |
367 | - array('id' => 4, 'nome' => 'Física', 'cargaHoraria' => 60) | |
368 | - ) | |
369 | - ); | |
370 | - | |
371 | - $expected = array( | |
372 | - 1 => $componentes[0], | |
373 | - 3 => $componentes[2] | |
374 | - ); | |
375 | - | |
376 | - // Retorna para clsPmieducarEscolaSerieDisciplina | |
377 | - $returnEscolaSerieDisciplina = array( | |
378 | - array('ref_cod_serie' => 1, 'ref_cod_disciplina' => 1, 'carga_horaria' => 80), | |
379 | - array('ref_cod_serie' => 1, 'ref_cod_disciplina' => 2, 'carga_horaria' => NULL), | |
380 | - array('ref_cod_serie' => 1, 'ref_cod_disciplina' => 3, 'carga_horaria' => NULL), | |
381 | - array('ref_cod_serie' => 1, 'ref_cod_disciplina' => 4, 'carga_horaria' => NULL), | |
382 | - ); | |
383 | - | |
384 | - // Mock para clsPmieducarEscolaSerieDisciplina | |
385 | - $escolaMock = $this->getCleanMock('clsPmieducarEscolaSerieDisciplina'); | |
386 | - $escolaMock->expects($this->any()) | |
387 | - ->method('lista') | |
388 | - ->will($this->returnValue($returnEscolaSerieDisciplina)); | |
427 | + // A turma possui apenas 2 componentes, com os ids: 1 e 2 | |
428 | + $mocks = $this->_getComponentesTurmaMock(); | |
389 | 429 | |
390 | 430 | // Retorna para clsPmieducarDispensaDisciplina |
391 | 431 | $returnDispensa = array( |
392 | - array('ref_cod_matricula' => 1, 'ref_cod_disciplina' => 2), | |
393 | - array('ref_cod_matricula' => 1, 'ref_cod_disciplina' => 4), | |
432 | + array('ref_cod_matricula' => 1, 'ref_cod_disciplina' => 2) | |
394 | 433 | ); |
395 | 434 | |
396 | 435 | // Mock para clsPmieducarDispensaDisciplina |
397 | 436 | $dispensaMock = $this->getCleanMock('clsPmieducarDispensaDisciplina'); |
398 | - $dispensaMock->expects($this->any()) | |
437 | + $dispensaMock->expects($this->once()) | |
399 | 438 | ->method('lista') |
400 | 439 | ->with(1, 1, 1) |
401 | 440 | ->will($this->returnValue($returnDispensa)); |
402 | 441 | |
403 | - // Mock para ComponenteCurricular_Model_ComponenteDataMapper | |
404 | - $mapperMock = $this->getCleanMock('ComponenteCurricular_Model_ComponenteDataMapper'); | |
405 | - $mapperMock->expects($this->exactly(4)) | |
406 | - ->method('findComponenteCurricularAnoEscolar') | |
407 | - ->will($this->onConsecutiveCalls( | |
408 | - $componentes[0], $componentes[1], $componentes[2], $componentes[3] | |
409 | - )); | |
410 | - | |
411 | - // Registra mocks | |
412 | - CoreExt_Entity::addClassToStorage('clsPmieducarEscolaSerieDisciplina', | |
413 | - $escolaMock, NULL, TRUE); | |
414 | 442 | CoreExt_Entity::addClassToStorage('clsPmieducarDispensaDisciplina', |
415 | 443 | $dispensaMock, NULL, TRUE); |
416 | 444 | |
417 | - $disciplinas = App_Model_IedFinder::getComponentesPorMatricula(1, $mapperMock); | |
418 | - | |
419 | - // O esperado é que use a carga horária de escola_serie_disciplina ao | |
420 | - // invés de componente_curricular_ano_escolar. | |
421 | - // Usa clone para clonar a instância, senão usaria a mesma (copy by reference) | |
422 | - $expected[1] = clone($expected[1]); | |
423 | - $expected[1]->cargaHoraria = 80; | |
445 | + $componentes = App_Model_IedFinder::getComponentesPorMatricula( | |
446 | + 1, $mocks['componenteMock'], $mocks['turmaMock'] | |
447 | + ); | |
424 | 448 | |
425 | - $expected[3] = clone($expected[3]); | |
426 | - $expected[3]->cargaHoraria = 60; | |
449 | + $expected = $mocks['expected']; | |
450 | + $expected = array(1 => clone $expected[1]); | |
427 | 451 | |
428 | 452 | $this->assertEquals( |
429 | - $expected, $disciplinas, | |
430 | - '::getComponentesPorMatricula() retorna um array de ComponenteCurricular_Model_Componente para uma matrícula.' | |
453 | + $expected, $componentes, | |
454 | + '::getComponentesPorMatricula() retorna os componentes curriculares de uma matrícula, descartando aqueles em regime de dispensa (dispensa de componente)' | |
431 | 455 | ); |
432 | 456 | } |
433 | 457 | ... | ... |