Commit a750338588790d041b501fa6ce73504464ae822f
1 parent
cd62e105
Exists in
master
Criado regra para armazenar notas necessárias no exame
portabilis/ieducar#130
Showing
3 changed files
with
388 additions
and
2 deletions
Show diff stats
ieducar/intranet/include/modules/clsModulesNotaExame.inc.php
0 → 100644
... | ... | @@ -0,0 +1,337 @@ |
1 | +<?php | |
2 | +/** | |
3 | + * i-Educar - Sistema de gestão escolar | |
4 | + * | |
5 | + * Copyright (C) 2006 Prefeitura Municipal de Itajaí | |
6 | + * <ctima@itajai.sc.gov.br> | |
7 | + * | |
8 | + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo | |
9 | + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free | |
10 | + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) | |
11 | + * qualquer versão posterior. | |
12 | + * | |
13 | + * Este programa é distribuído na expectativa de que seja útil, porém, SEM | |
14 | + * NENHUMA GARANTIA; nem mesmo a garantia implícita de COMERCIABILIDADE OU | |
15 | + * ADEQUAÇÃO A UMA FINALIDADE ESPECÍFICA. Consulte a Licença Pública Geral | |
16 | + * do GNU para mais detalhes. | |
17 | + * | |
18 | + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto | |
19 | + * com este programa; se não, escreva para a Free Software Foundation, Inc., no | |
20 | + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. | |
21 | + * | |
22 | + * @author Lucas Schmoeller da Silva <lucas@portabilis.com.br> | |
23 | + * @category i-Educar | |
24 | + * @license @@license@@ | |
25 | + * @package Module | |
26 | + * @since ? | |
27 | + * @version $Id$ | |
28 | + */ | |
29 | + | |
30 | +require_once( "include/pmieducar/geral.inc.php" ); | |
31 | + | |
32 | +/** | |
33 | + * clsModulesNotaExame class. | |
34 | + * | |
35 | + * @author Lucas Schmoeller da Silva <lucas@portabilis.com.br> | |
36 | + * @category i-Educar | |
37 | + * @license @@license@@ | |
38 | + * @package Module | |
39 | + * @since ? | |
40 | + * @version @@package_version@@ | |
41 | + */ | |
42 | + | |
43 | +class clsModulesNotaExame | |
44 | +{ | |
45 | + var $ref_cod_matricula; | |
46 | + var $ref_cod_componente_curricular; | |
47 | + var $nota_exame; | |
48 | + | |
49 | + // propriedades padrao | |
50 | + | |
51 | + /** | |
52 | + * Armazena o total de resultados obtidos na ultima chamada ao metodo lista | |
53 | + * | |
54 | + * @var int | |
55 | + */ | |
56 | + var $_total; | |
57 | + | |
58 | + /** | |
59 | + * Nome do schema | |
60 | + * | |
61 | + * @var string | |
62 | + */ | |
63 | + var $_schema; | |
64 | + | |
65 | + /** | |
66 | + * Nome da tabela | |
67 | + * | |
68 | + * @var string | |
69 | + */ | |
70 | + var $_tabela; | |
71 | + | |
72 | + /** | |
73 | + * Lista separada por virgula, com os campos que devem ser selecionados na proxima chamado ao metodo lista | |
74 | + * | |
75 | + * @var string | |
76 | + */ | |
77 | + var $_campos_lista; | |
78 | + | |
79 | + /** | |
80 | + * Lista com todos os campos da tabela separados por virgula, padrao para selecao no metodo lista | |
81 | + * | |
82 | + * @var string | |
83 | + */ | |
84 | + var $_todos_campos; | |
85 | + | |
86 | + /** | |
87 | + * Valor que define a quantidade de registros a ser retornada pelo metodo lista | |
88 | + * | |
89 | + * @var int | |
90 | + */ | |
91 | + var $_limite_quantidade; | |
92 | + | |
93 | + /** | |
94 | + * Define o valor de offset no retorno dos registros no metodo lista | |
95 | + * | |
96 | + * @var int | |
97 | + */ | |
98 | + var $_limite_offset; | |
99 | + | |
100 | + /** | |
101 | + * Define o campo padrao para ser usado como padrao de ordenacao no metodo lista | |
102 | + * | |
103 | + * @var string | |
104 | + */ | |
105 | + var $_campo_order_by; | |
106 | + | |
107 | + | |
108 | + /** | |
109 | + * Construtor (PHP 4) | |
110 | + * | |
111 | + * @return object | |
112 | + */ | |
113 | + function clsModulesNotaExame($ref_cod_matricula = NULL , $ref_cod_componente_curricular = NULL, $nota_exame = NULL) | |
114 | + { | |
115 | + $db = new clsBanco(); | |
116 | + $this->_schema = "modules."; | |
117 | + $this->_tabela = "{$this->_schema}nota_exame"; | |
118 | + | |
119 | + $this->_campos_lista = $this->_todos_campos = "ref_cod_matricula, ref_cod_componente_curricular, nota_exame"; | |
120 | + | |
121 | + if( is_numeric( $ref_cod_matricula ) ) | |
122 | + { | |
123 | + $this->ref_cod_matricula = $ref_cod_matricula; | |
124 | + } | |
125 | + if( is_numeric( $ref_cod_componente_curricular ) ) | |
126 | + { | |
127 | + $this->ref_cod_componente_curricular = $ref_cod_componente_curricular; | |
128 | + } | |
129 | + if( is_numeric( $nota_exame ) ) | |
130 | + { | |
131 | + $this->nota_exame = $nota_exame; | |
132 | + } | |
133 | + } | |
134 | + | |
135 | + /** | |
136 | + * Cria um novo registro | |
137 | + * | |
138 | + * @return bool | |
139 | + */ | |
140 | + function cadastra() | |
141 | + { | |
142 | + if( is_numeric( $this->ref_cod_matricula ) && is_numeric( $this->ref_cod_componente_curricular ) && is_numeric( $this->nota_exame ) ) | |
143 | + { | |
144 | + $db = new clsBanco(); | |
145 | + | |
146 | + $campos = ""; | |
147 | + $valores = ""; | |
148 | + $gruda = ""; | |
149 | + | |
150 | + if( is_numeric( $this->ref_cod_matricula ) ) | |
151 | + { | |
152 | + $campos .= "{$gruda}ref_cod_matricula"; | |
153 | + $valores .= "{$gruda}'{$this->ref_cod_matricula}'"; | |
154 | + $gruda = ", "; | |
155 | + } | |
156 | + if( is_numeric( $this->ref_cod_componente_curricular ) ) | |
157 | + { | |
158 | + $campos .= "{$gruda}ref_cod_componente_curricular"; | |
159 | + $valores .= "{$gruda}'{$this->ref_cod_componente_curricular}'"; | |
160 | + $gruda = ", "; | |
161 | + } | |
162 | + if( is_numeric( $this->nota_exame ) ) | |
163 | + { | |
164 | + $campos .= "{$gruda}nota_exame"; | |
165 | + $valores .= "{$gruda}'{$this->nota_exame}'"; | |
166 | + $gruda = ", "; | |
167 | + } | |
168 | + | |
169 | + $db->Consulta( "INSERT INTO {$this->_tabela} ( $campos ) VALUES( $valores )" ); | |
170 | + return $this->ref_cod_matricula; | |
171 | + } | |
172 | + return false; | |
173 | + } | |
174 | + | |
175 | + /** | |
176 | + * Edita os dados de um registro | |
177 | + * | |
178 | + * @return bool | |
179 | + */ | |
180 | + function edita() | |
181 | + { | |
182 | + if( is_numeric( $this->ref_cod_matricula ) && is_numeric( $this->ref_cod_componente_curricular ) && is_numeric( $this->nota_exame ) ) | |
183 | + { | |
184 | + | |
185 | + $db = new clsBanco(); | |
186 | + $set = ""; | |
187 | + | |
188 | + if( is_numeric( $this->nota_exame ) ) | |
189 | + { | |
190 | + $set .= "{$gruda}nota_exame = '{$this->nota_exame}'"; | |
191 | + $gruda = ", "; | |
192 | + } | |
193 | + | |
194 | + if( $set ) | |
195 | + { | |
196 | + $db->Consulta( "UPDATE {$this->_tabela} SET $set WHERE ref_cod_matricula = '{$this->ref_cod_matricula}' AND ref_cod_componente_curricular = '{$this->ref_cod_componente_curricular}'" ); | |
197 | + return true; | |
198 | + } | |
199 | + } | |
200 | + return false; | |
201 | + } | |
202 | + | |
203 | + /** | |
204 | + * Retorna um array com os dados de um registro | |
205 | + * | |
206 | + * @return array | |
207 | + */ | |
208 | + function detalhe() | |
209 | + { | |
210 | + if( is_numeric( $this->ref_cod_matricula ) && is_numeric( $this->ref_cod_componente_curricular ) ) | |
211 | + { | |
212 | + | |
213 | + $db = new clsBanco(); | |
214 | + $db->Consulta( "SELECT {$this->_todos_campos} FROM {$this->_tabela} WHERE ref_cod_matricula = '{$this->ref_cod_matricula}' AND ref_cod_componente_curricular = '{$this->ref_cod_componente_curricular}'" ); | |
215 | + $db->ProximoRegistro(); | |
216 | + return $db->Tupla(); | |
217 | + } | |
218 | + return false; | |
219 | + } | |
220 | + | |
221 | + /** | |
222 | + * Retorna um array com os dados de um registro | |
223 | + * | |
224 | + * @return array | |
225 | + */ | |
226 | + function existe() | |
227 | + { | |
228 | + if( is_numeric( $this->ref_cod_matricula ) && is_numeric( $this->ref_cod_componente_curricular ) ) | |
229 | + { | |
230 | + | |
231 | + $db = new clsBanco(); | |
232 | + $db->Consulta( "SELECT 1 FROM {$this->_tabela} WHERE ref_cod_matricula = '{$this->ref_cod_matricula}' AND ref_cod_componente_curricular = '{$this->ref_cod_componente_curricular}'" ); | |
233 | + $db->ProximoRegistro(); | |
234 | + return $db->Tupla(); | |
235 | + } | |
236 | + return false; | |
237 | + } | |
238 | + | |
239 | + /** | |
240 | + * Exclui um registro | |
241 | + * | |
242 | + * @return bool | |
243 | + */ | |
244 | + function excluir() | |
245 | + { | |
246 | + if( is_numeric( $this->ref_cod_matricula ) && is_numeric( $this->ref_cod_componente_curricular ) ) | |
247 | + { | |
248 | + | |
249 | + $db = new clsBanco(); | |
250 | + $db->Consulta( "DELETE FROM {$this->_tabela} WHERE ref_cod_matricula = '{$this->ref_cod_matricula}' AND ref_cod_componente_curricular = '{$this->ref_cod_componente_curricular}'" ); | |
251 | + return true; | |
252 | + } | |
253 | + return false; | |
254 | + } | |
255 | + | |
256 | + /** | |
257 | + * Define quais campos da tabela serao selecionados na invocacao do metodo lista | |
258 | + * | |
259 | + * @return null | |
260 | + */ | |
261 | + function setCamposLista( $str_campos ) | |
262 | + { | |
263 | + $this->_campos_lista = $str_campos; | |
264 | + } | |
265 | + | |
266 | + /** | |
267 | + * Define que o metodo Lista devera retornoar todos os campos da tabela | |
268 | + * | |
269 | + * @return null | |
270 | + */ | |
271 | + function resetCamposLista() | |
272 | + { | |
273 | + $this->_campos_lista = $this->_todos_campos; | |
274 | + } | |
275 | + | |
276 | + /** | |
277 | + * Define limites de retorno para o metodo lista | |
278 | + * | |
279 | + * @return null | |
280 | + */ | |
281 | + function setLimite( $intLimiteQtd, $intLimiteOffset = null ) | |
282 | + { | |
283 | + $this->_limite_quantidade = $intLimiteQtd; | |
284 | + $this->_limite_offset = $intLimiteOffset; | |
285 | + } | |
286 | + | |
287 | + /** | |
288 | + * Retorna a string com o trecho da query resposavel pelo Limite de registros | |
289 | + * | |
290 | + * @return string | |
291 | + */ | |
292 | + function getLimite() | |
293 | + { | |
294 | + if( is_numeric( $this->_limite_quantidade ) ) | |
295 | + { | |
296 | + $retorno = " LIMIT {$this->_limite_quantidade}"; | |
297 | + if( is_numeric( $this->_limite_offset ) ) | |
298 | + { | |
299 | + $retorno .= " OFFSET {$this->_limite_offset} "; | |
300 | + } | |
301 | + return $retorno; | |
302 | + } | |
303 | + return ""; | |
304 | + } | |
305 | + | |
306 | + /** | |
307 | + * Define campo para ser utilizado como ordenacao no metolo lista | |
308 | + * | |
309 | + * @return null | |
310 | + */ | |
311 | + function setOrderby( $strNomeCampo ) | |
312 | + { | |
313 | + // limpa a string de possiveis erros (delete, insert, etc) | |
314 | + //$strNomeCampo = eregi_replace(); | |
315 | + | |
316 | + if( is_string( $strNomeCampo ) && $strNomeCampo ) | |
317 | + { | |
318 | + $this->_campo_order_by = $strNomeCampo; | |
319 | + } | |
320 | + } | |
321 | + | |
322 | + /** | |
323 | + * Retorna a string com o trecho da query resposavel pela Ordenacao dos registros | |
324 | + * | |
325 | + * @return string | |
326 | + */ | |
327 | + function getOrderby() | |
328 | + { | |
329 | + if( is_string( $this->_campo_order_by ) ) | |
330 | + { | |
331 | + return " ORDER BY {$this->_campo_order_by} "; | |
332 | + } | |
333 | + return ""; | |
334 | + } | |
335 | + | |
336 | +} | |
337 | +?> | |
0 | 338 | \ No newline at end of file | ... | ... |
ieducar/misc/database/deltas/portabilis/71_cria_tabela_nota_exame.sql
0 → 100644
... | ... | @@ -0,0 +1,27 @@ |
1 | + -- // | |
2 | + | |
3 | + -- | |
4 | + -- Cria tabela temporaria que guarda nota do exame dos alunos | |
5 | + -- | |
6 | + -- @author Lucas Schmoeller da Silva <lucas@portabilis.com.br> | |
7 | + -- @license @@license@@ | |
8 | + -- @version $Id$ | |
9 | + | |
10 | + CREATE TABLE modules.nota_exame | |
11 | + ( | |
12 | + ref_cod_matricula integer NOT NULL, | |
13 | + ref_cod_componente_curricular integer NOT NULL, | |
14 | + nota_exame numeric(5,3), | |
15 | + CONSTRAINT moradia_aluno_fkey FOREIGN KEY (ref_cod_matricula) | |
16 | + REFERENCES pmieducar.matricula(cod_matricula) MATCH SIMPLE | |
17 | + ON UPDATE RESTRICT ON DELETE RESTRICT | |
18 | + ) | |
19 | + WITH ( | |
20 | + OIDS=TRUE | |
21 | + ); | |
22 | + | |
23 | + -- //@UNDO | |
24 | + | |
25 | + DROP TABLE modules.nota_exame; | |
26 | + | |
27 | + -- // | |
0 | 28 | \ No newline at end of file | ... | ... |
ieducar/modules/Avaliacao/Views/DiarioApiController.php
... | ... | @@ -47,6 +47,7 @@ require_once 'RegraAvaliacao/Model/TipoPresenca.php'; |
47 | 47 | require_once 'RegraAvaliacao/Model/TipoParecerDescritivo.php'; |
48 | 48 | |
49 | 49 | require_once 'include/pmieducar/clsPmieducarMatricula.inc.php'; |
50 | +require_once 'include/modules/clsModulesNotaExame.inc.php'; | |
50 | 51 | |
51 | 52 | require_once 'Portabilis/Controller/ApiCoreController.php'; |
52 | 53 | require_once 'Portabilis/Array/Utils.php'; |
... | ... | @@ -404,7 +405,12 @@ class DiarioApiController extends ApiCoreController |
404 | 405 | $this->appendResponse('componente_curricular_id', $this->getRequest()->componente_curricular_id); |
405 | 406 | $this->appendResponse('matricula_id', $this->getRequest()->matricula_id); |
406 | 407 | $this->appendResponse('situacao', $this->getSituacaoMatricula()); |
407 | - $this->appendResponse('nota_necessaria_exame', $this->getNotaNecessariaExame($this->getRequest()->componente_curricular_id)); | |
408 | + $this->appendResponse('nota_necessaria_exame', $notaNecessariaExame = $this->getNotaNecessariaExame($this->getRequest()->componente_curricular_id)); | |
409 | + | |
410 | + if (!empty($notaNecessariaExame) && $this->getSituacaoMatricula()=='Em Exame') | |
411 | + $this->createOrUpdateNotaExame($this->getRequest()->matricula_id, $this->getRequest()->componente_curricular_id, $notaNecessariaExame); | |
412 | + else | |
413 | + $this->deleteNotaExame($this->getRequest()->matricula_id, $this->getRequest()->componente_curricular_id); | |
408 | 414 | } |
409 | 415 | |
410 | 416 | |
... | ... | @@ -753,10 +759,15 @@ class DiarioApiController extends ApiCoreController |
753 | 759 | $componente['nome'] = $this->safeString(strtoupper($_componente->get('nome')), false); |
754 | 760 | $componente['nota_atual'] = $this->getNotaAtual($etapa = null, $componente['id']); |
755 | 761 | $componente['nota_exame'] = $this->getNotaExame($componente['id']); |
756 | - $componente['nota_necessaria_exame'] = ($componente['situacao'] != 'Em andamento' ? $this->getNotaNecessariaExame($componente['id']) : null ); | |
757 | 762 | $componente['falta_atual'] = $this->getFaltaAtual($etapa = null, $componente['id']); |
758 | 763 | $componente['parecer_atual'] = $this->getParecerAtual($componente['id']); |
759 | 764 | $componente['situacao'] = $this->getSituacaoMatricula($componente['id']); |
765 | + $componente['nota_necessaria_exame'] = ($componente['situacao'] == 'Em Exame' ? $this->getNotaNecessariaExame($componente['id']) : null ); | |
766 | + | |
767 | + if (!empty($componente['nota_necessaria_exame'])) | |
768 | + $this->createOrUpdateNotaExame($matriculaId, $componente['id'], $componente['nota_necessaria_exame']); | |
769 | + else | |
770 | + $this->deleteNotaExame($matriculaId, $componente['id']); | |
760 | 771 | |
761 | 772 | //buscando pela área do conhecimento |
762 | 773 | $area = $this->getAreaConhecimento($componente['id']); |
... | ... | @@ -805,6 +816,17 @@ class DiarioApiController extends ApiCoreController |
805 | 816 | return $areaConhecimento; |
806 | 817 | } |
807 | 818 | |
819 | + protected function createOrUpdateNotaExame($matriculaId, $componenteCurricularId, $notaExame) { | |
820 | + | |
821 | + $obj = new clsModulesNotaExame($matriculaId, $componenteCurricularId, $notaExame); | |
822 | + | |
823 | + return ($obj->existe() ? $obj->edita() : $obj->cadastra()); | |
824 | + } | |
825 | + | |
826 | + protected function deleteNotaExame($matriculaId, $componenteCurricularId){ | |
827 | + $obj = new clsModulesNotaExame($matriculaId, $componenteCurricularId); | |
828 | + return ($obj->excluir()); | |
829 | + } | |
808 | 830 | |
809 | 831 | protected function getNotaAtual($etapa = null, $componenteCurricularId = null) { |
810 | 832 | // defaults | ... | ... |