Rev 1572 | Rev 1576 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1574 | jmachado | 1 | package pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.queries; |
1567 | jmachado | 2 | |
3 | import jomm.dao.impl.AbstractDao; |
||
4 | import org.hibernate.Query; |
||
5 | import pt.estgp.estgweb.domain.OlapStarFactQuestionarioAnswer; |
||
1568 | jmachado | 6 | import pt.estgp.estgweb.services.questionarios.PedagogicoAlunosProcessor; |
1574 | jmachado | 7 | import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.reportsdomain.DocenteReport; |
8 | import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.reportsdomain.EntityEvaluated; |
||
9 | import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.reportsdomain.QuestionariosAlunosReport; |
||
10 | import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.utils.ChartBuilderUtil; |
||
11 | import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.utils.DataTable; |
||
12 | import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.utils.MediasGrupo; |
||
13 | import pt.estgp.estgweb.services.questionarios.pedagogico.reportprocessors.utils.ReportUtils; |
||
1567 | jmachado | 14 | |
15 | import java.text.DecimalFormat; |
||
16 | import java.util.List; |
||
17 | |||
18 | /** |
||
19 | * Created by jorgemachado on 07/12/16. |
||
20 | */ |
||
21 | public class PerguntasGrupoQueryDao |
||
22 | { |
||
23 | public static final 1.5.0/docs/api/java/lang/String.html">String GRUPO_DOCENTE_CODE_PERGUNTAS = "Docente"; |
||
24 | public static final 1.5.0/docs/api/java/lang/String.html">String GRUPO_UNIDADE_CODE_PERGUNTAS = "Unidade"; |
||
25 | |||
1568 | jmachado | 26 | public static final 1.5.0/docs/api/java/lang/String.html">String GRUPO_DOCENTE_REL_ALUNO_CODE_PERGUNTAS = "D_RelAluno"; |
27 | public static final 1.5.0/docs/api/java/lang/String.html">String GRUPO_DOCENTE_PROFISSIONALISMO_DOCENTE_CODE_PERGUNTAS = "D_ProfissRigorDocente"; |
||
1567 | jmachado | 28 | |
1571 | jmachado | 29 | public static final 1.5.0/docs/api/java/lang/String.html">String GRUPO_SALAS_CODE_PERGUNTAS = "Salas"; |
30 | public static final 1.5.0/docs/api/java/lang/String.html">String GRUPO_ESTAGIO_CODE_PERGUNTAS = "EstagioProj"; |
||
31 | public static final 1.5.0/docs/api/java/lang/String.html">String GRUPO_ENSINO_CLINICO_CODE_PERGUNTAS = "PraEnsinoCliPraEnsinoSupervisionado"; |
||
1568 | jmachado | 32 | |
1571 | jmachado | 33 | |
34 | public static void getMediasGrupo(1.5.0/docs/api/java/lang/String.html">String[] codes, |
||
35 | EntityEvaluated entityEvaluated, |
||
36 | 1.5.0/docs/api/java/lang/String.html">String anoLectivo, |
||
37 | QuestionariosAlunosReport report, |
||
38 | List<String> codigosCurso, |
||
39 | List<String> codigosEscola, |
||
40 | 1.5.0/docs/api/java/lang/String.html">String grupo, |
||
41 | 1.5.0/docs/api/java/lang/String.html">String subGrupo, |
||
42 | MediasGrupo medias, |
||
43 | 1.5.0/docs/api/java/lang/String.html">String[] periodos, |
||
44 | 1.5.0/docs/api/java/lang/String.html">String[] degrees |
||
45 | ) |
||
46 | { |
||
47 | 1.5.0/docs/api/javax/management/Query.html">Query query; |
||
48 | |||
49 | 1.5.0/docs/api/java/lang/String.html">String periodosQuery = QueryDaoUtils.createPeriodosQuery(periodos, "quest", true); |
||
50 | 1.5.0/docs/api/java/lang/String.html">String degreesQuery = QueryDaoUtils.createDegreesQuery(degrees, "curso", true); |
||
51 | 1.5.0/docs/api/java/lang/String.html">String whereFragmentEntity = QuestionariosQueryDao.getWhereEntityCodesFragment(codes,entityEvaluated); |
||
52 | |||
53 | query = AbstractDao.getCurrentSession().createQuery("" + |
||
54 | "SELECT " + |
||
55 | "avg(fc.intResposta) as media," + |
||
56 | "std(fc.intResposta) as desvio," + |
||
57 | "count(fc.id) as total " + |
||
58 | |||
59 | "FROM " + OlapStarFactQuestionarioAnswer.class.getName() + " fc " + |
||
60 | "JOIN fc.olapTipologia tipo " + |
||
61 | "JOIN fc.olapQuestionario quest " + |
||
62 | "JOIN fc.olapPergunta prgp " + |
||
63 | "JOIN fc.olapCurso curso " + |
||
64 | "JOIN fc.olapTimeLine timeLine " + |
||
65 | |||
66 | "where " + |
||
67 | " quest.ano = :ano " + |
||
68 | whereFragmentEntity + |
||
69 | "and timeLine.nome = '" + PedagogicoAlunosProcessor.getHistoryDriveConstraintStatic() + "' " + |
||
70 | periodosQuery + |
||
71 | degreesQuery + |
||
72 | (grupo == null ? "" : " and prgp.grupoCode = :grupoCode ") + |
||
73 | (subGrupo == null ? "" : " and prgp.subGrupoCode = :subGrupoCode ") |
||
74 | ); |
||
75 | if(grupo != null) |
||
76 | query.setString("grupoCode",grupo); |
||
77 | if(subGrupo != null) |
||
78 | query.setString("subGrupoCode",subGrupo); |
||
79 | //query.setString("codigoSiges",teacherCode); |
||
80 | query.setString("ano",anoLectivo); |
||
81 | |||
82 | DataTable mediasGlobaisTable = new DataTable(); |
||
83 | |||
84 | |||
85 | DataTable.Row header = mediasGlobaisTable.addRowHeader(); |
||
86 | header.addColTextCenter("Resps."); |
||
87 | header.addColTextCenter("Média"); |
||
88 | header.addColTextCenter("Desvio Padrão"); |
||
89 | header.addColTextCenter("95% Resps no intervalo"); |
||
90 | if(entityEvaluated == EntityEvaluated.DOCENTE) |
||
91 | { |
||
92 | header.addColTextCenter("Média dos Cursos em que Lecciona"); |
||
93 | header.addColTextCenter("Média das Escolas em que Lecciona"); |
||
94 | } |
||
95 | else if(entityEvaluated == EntityEvaluated.CURSO) |
||
96 | { |
||
97 | header.addColTextCenter("Média da Escola"); |
||
98 | } |
||
99 | else |
||
100 | { |
||
101 | throw new 1.5.0/docs/api/java/lang/RuntimeException.html">RuntimeException("Não implementado"); |
||
102 | } |
||
103 | |||
104 | |||
105 | |||
106 | 5+0%2Fdocs%2Fapi+Object">Object[] result = (5+0%2Fdocs%2Fapi+Object">Object[]) query.uniqueResult(); |
||
107 | |||
108 | |||
109 | 1.5.0/docs/api/java/lang/Double.html">Double mediaGrupo = (1.5.0/docs/api/java/lang/Double.html">Double) result[0]; |
||
110 | 1.5.0/docs/api/java/lang/Double.html">Double desvio = (1.5.0/docs/api/java/lang/Double.html">Double) result[1]; |
||
111 | long total = report.getInquiridosComResposta(); |
||
112 | double min = mediaGrupo - (desvio*2); |
||
113 | double max = mediaGrupo + (desvio*2); |
||
114 | if(max > 5) max = 5; |
||
115 | 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat df = new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#.##"); |
||
116 | 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat df2 = new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#.#"); |
||
117 | |||
118 | DataTable.Row row = mediasGlobaisTable.addRowNormal(); |
||
119 | row.addColTextCenter(""+total); |
||
120 | row.addColPercentageDefinedCenter(df.format(mediaGrupo),"" + ((int)((mediaGrupo/5.0)*100.0)), true); |
||
121 | row.addColTextCenter(df.format(desvio)); |
||
122 | row.addColTextCenter("[" + df2.format(min) + "<->" + df2.format(max) + "]"); |
||
123 | |||
124 | |||
125 | double mediaCursos = QueryDaoUtils.getMediaCursos(codigosCurso, anoLectivo, grupo, subGrupo, periodos, degrees); |
||
126 | double mediaEscolas = QueryDaoUtils.getMediaEscolas(codigosEscola, anoLectivo, grupo,subGrupo, periodos, degrees); |
||
127 | |||
128 | |||
129 | if(entityEvaluated == EntityEvaluated.DOCENTE) |
||
130 | { |
||
131 | row.addColPercentageDefinedCenter(df.format(mediaCursos), "" + ((int) ((mediaCursos / 5.0) * 100.0)), true); |
||
132 | } |
||
133 | else if(entityEvaluated == EntityEvaluated.CURSO) |
||
134 | { |
||
135 | |||
136 | } |
||
137 | else |
||
138 | { |
||
139 | throw new 1.5.0/docs/api/java/lang/RuntimeException.html">RuntimeException("Não implementado"); |
||
140 | } |
||
141 | |||
142 | row.addColPercentageDefinedCenter(df.format(mediaEscolas),"" + ((int)((mediaEscolas/5.0)*100.0)),true); |
||
143 | |||
144 | |||
145 | |||
146 | medias.setAvaliacaoMediaArredondada((int) ReportUtils.round(mediaGrupo, 0)); |
||
147 | medias.setAvaliacaoMedia(mediaGrupo); |
||
148 | medias.setDesvioPadrao(desvio); |
||
149 | medias.setMediaGlobalNasEscolas(mediaEscolas); |
||
150 | medias.setMediaGlobalNosCursos(mediaCursos); |
||
151 | medias.setTotal((int) total); |
||
152 | |||
153 | medias.setMediasGlobaisTable(mediasGlobaisTable); |
||
154 | |||
155 | if(medias.getAvaliacaoMediaArredondada() == 1) |
||
156 | medias.setColorMedia(ChartBuilderUtil.COLOR_1_HEX); |
||
157 | else if(medias.getAvaliacaoMediaArredondada() == 2) |
||
158 | medias.setColorMedia(ChartBuilderUtil.COLOR_2_HEX); |
||
159 | else if(medias.getAvaliacaoMediaArredondada() == 3) |
||
160 | medias.setColorMedia(ChartBuilderUtil.COLOR_3_HEX); |
||
161 | else if(medias.getAvaliacaoMediaArredondada() == 4) |
||
162 | medias.setColorMedia(ChartBuilderUtil.COLOR_4_HEX); |
||
163 | else if(medias.getAvaliacaoMediaArredondada() == 5) |
||
164 | medias.setColorMedia(ChartBuilderUtil.COLOR_5_HEX); |
||
165 | } |
||
166 | |||
1572 | jmachado | 167 | |
168 | |||
169 | |||
1567 | jmachado | 170 | public static void getMediasGrupo(1.5.0/docs/api/java/lang/String.html">String teacherCode, |
171 | 1.5.0/docs/api/java/lang/String.html">String anoLectivo, |
||
172 | DocenteReport docenteReport, |
||
173 | List<String> codigosCurso, |
||
174 | List<String> codigosEscola, |
||
175 | 1.5.0/docs/api/java/lang/String.html">String grupo, |
||
1568 | jmachado | 176 | 1.5.0/docs/api/java/lang/String.html">String subGrupo, |
1567 | jmachado | 177 | MediasGrupo medias |
178 | ,1.5.0/docs/api/java/lang/String.html">String[] periodos |
||
179 | ,1.5.0/docs/api/java/lang/String.html">String[] degrees) |
||
180 | { |
||
181 | 1.5.0/docs/api/javax/management/Query.html">Query query; |
||
182 | |||
183 | 1.5.0/docs/api/java/lang/String.html">String periodosQuery = QueryDaoUtils.createPeriodosQuery(periodos, "quest", true); |
||
184 | 1.5.0/docs/api/java/lang/String.html">String degreesQuery = QueryDaoUtils.createDegreesQuery(degrees, "curso", true); |
||
185 | |||
186 | query = AbstractDao.getCurrentSession().createQuery("" + |
||
187 | "SELECT " + |
||
188 | "avg(fc.intResposta) as media," + |
||
189 | "std(fc.intResposta) as desvio," + |
||
190 | "count(fc.id) as total " + |
||
191 | |||
192 | "FROM " + OlapStarFactQuestionarioAnswer.class.getName() + " fc " + |
||
193 | "JOIN fc.olapTipologia tipo " + |
||
194 | "JOIN fc.olapQuestionario quest " + |
||
195 | "JOIN fc.olapPergunta prgp " + |
||
196 | "JOIN fc.olapCurso curso " + |
||
1568 | jmachado | 197 | "JOIN fc.olapTimeLine timeLine " + |
1567 | jmachado | 198 | |
199 | "where " + |
||
1568 | jmachado | 200 | " quest.ano = :ano " + |
201 | "and tipo.codigoSiges = :codigoSiges " + |
||
202 | "and timeLine.nome = '" + PedagogicoAlunosProcessor.getHistoryDriveConstraintStatic() + "' " + |
||
203 | periodosQuery + |
||
204 | degreesQuery + |
||
205 | (grupo == null ? "" : " and prgp.grupoCode = :grupoCode ") + |
||
206 | (subGrupo == null ? "" : " and prgp.subGrupoCode = :subGrupoCode ") |
||
1567 | jmachado | 207 | ); |
1568 | jmachado | 208 | if(grupo != null) |
209 | query.setString("grupoCode",grupo); |
||
210 | if(subGrupo != null) |
||
211 | query.setString("subGrupoCode",subGrupo); |
||
1567 | jmachado | 212 | query.setString("codigoSiges",teacherCode); |
213 | query.setString("ano",anoLectivo); |
||
214 | |||
215 | DataTable mediasGlobaisTable = new DataTable(); |
||
216 | |||
217 | |||
218 | DataTable.Row header = mediasGlobaisTable.addRowHeader(); |
||
219 | header.addColTextCenter("Resps."); |
||
220 | header.addColTextCenter("Média"); |
||
221 | header.addColTextCenter("Desvio Padrão"); |
||
222 | header.addColTextCenter("95% Resps no intervalo"); |
||
223 | header.addColTextCenter("Média dos Cursos em que Lecciona"); |
||
224 | header.addColTextCenter("Média das Escolas em que Lecciona"); |
||
225 | |||
226 | |||
227 | 5+0%2Fdocs%2Fapi+Object">Object[] result = (5+0%2Fdocs%2Fapi+Object">Object[]) query.uniqueResult(); |
||
228 | |||
229 | |||
230 | 1.5.0/docs/api/java/lang/Double.html">Double mediaGrupo = (1.5.0/docs/api/java/lang/Double.html">Double) result[0]; |
||
231 | 1.5.0/docs/api/java/lang/Double.html">Double desvio = (1.5.0/docs/api/java/lang/Double.html">Double) result[1]; |
||
232 | long total = docenteReport.getInquiridosComResposta(); |
||
233 | double min = mediaGrupo - (desvio*2); |
||
234 | double max = mediaGrupo + (desvio*2); |
||
235 | if(max > 5) max = 5; |
||
236 | 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat df = new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#.##"); |
||
237 | 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat df2 = new 1.5.0/docs/api/java/text/DecimalFormat.html">DecimalFormat("#.#"); |
||
238 | |||
239 | DataTable.Row row = mediasGlobaisTable.addRowNormal(); |
||
240 | row.addColTextCenter(""+total); |
||
241 | row.addColPercentageDefinedCenter(df.format(mediaGrupo),"" + ((int)((mediaGrupo/5.0)*100.0)), true); |
||
242 | row.addColTextCenter(df.format(desvio)); |
||
243 | row.addColTextCenter("[" + df2.format(min) + "<->" + df2.format(max) + "]"); |
||
244 | |||
245 | |||
1568 | jmachado | 246 | double mediaCursos = QueryDaoUtils.getMediaCursos(codigosCurso, anoLectivo, grupo, subGrupo, periodos, degrees); |
247 | double mediaEscolas = QueryDaoUtils.getMediaEscolas(codigosEscola, anoLectivo, grupo,subGrupo, periodos, degrees); |
||
1567 | jmachado | 248 | |
249 | |||
250 | row.addColPercentageDefinedCenter(df.format(mediaCursos),"" + ((int)((mediaCursos/5.0)*100.0)),true); |
||
251 | row.addColPercentageDefinedCenter(df.format(mediaEscolas),"" + ((int)((mediaEscolas/5.0)*100.0)),true); |
||
252 | |||
253 | |||
254 | |||
1569 | jmachado | 255 | medias.setAvaliacaoMediaArredondada((int) ReportUtils.round(mediaGrupo, 0)); |
1567 | jmachado | 256 | medias.setAvaliacaoMedia(mediaGrupo); |
257 | medias.setDesvioPadrao(desvio); |
||
258 | medias.setMediaGlobalNasEscolas(mediaEscolas); |
||
259 | medias.setMediaGlobalNosCursos(mediaCursos); |
||
1568 | jmachado | 260 | medias.setTotal((int) total); |
1567 | jmachado | 261 | |
262 | medias.setMediasGlobaisTable(mediasGlobaisTable); |
||
263 | |||
264 | if(medias.getAvaliacaoMediaArredondada() == 1) |
||
265 | medias.setColorMedia(ChartBuilderUtil.COLOR_1_HEX); |
||
266 | else if(medias.getAvaliacaoMediaArredondada() == 2) |
||
267 | medias.setColorMedia(ChartBuilderUtil.COLOR_2_HEX); |
||
268 | else if(medias.getAvaliacaoMediaArredondada() == 3) |
||
269 | medias.setColorMedia(ChartBuilderUtil.COLOR_3_HEX); |
||
270 | else if(medias.getAvaliacaoMediaArredondada() == 4) |
||
271 | medias.setColorMedia(ChartBuilderUtil.COLOR_4_HEX); |
||
272 | else if(medias.getAvaliacaoMediaArredondada() == 5) |
||
273 | medias.setColorMedia(ChartBuilderUtil.COLOR_5_HEX); |
||
274 | } |
||
275 | |||
1571 | jmachado | 276 | public static MediaGlobalCursoPergunta getMediaCursoPergunta(QuestionariosAlunosReport report,1.5.0/docs/api/java/lang/String.html">String codigoCurso, 1.5.0/docs/api/java/lang/String.html">String anoLectivo, 1.5.0/docs/api/java/lang/String.html">String numeroPergunta,1.5.0/docs/api/java/lang/String.html">String[] periodos) |
1567 | jmachado | 277 | { |
278 | |||
279 | 1.5.0/docs/api/java/lang/String.html">String key = codigoCurso + "-" + anoLectivo + "-" + numeroPergunta; |
||
280 | if(report.getMediasPerguntaNoCurso().get(key) != null) |
||
281 | return report.getMediasPerguntaNoCurso().get(key); |
||
282 | |||
1568 | jmachado | 283 | //String degreesQuery = QueryDaoUtils.createDegreesQuery(degrees,"curso",true); |
1567 | jmachado | 284 | 1.5.0/docs/api/java/lang/String.html">String periodosQuery = QueryDaoUtils.createPeriodosQuery(periodos,"quest",true); |
285 | |||
286 | |||
287 | MediaGlobalCursoPergunta mediaGlobalCursoPergunta = new MediaGlobalCursoPergunta(); |
||
288 | report.getMediasPerguntaNoCurso().put(key,mediaGlobalCursoPergunta); |
||
289 | |||
290 | 1.5.0/docs/api/javax/management/Query.html">Query query;//*****CRIAR REPOSTAS DO GRUPO DOCENTE*****/// |
||
291 | |||
292 | query = AbstractDao.getCurrentSession().createQuery("" + |
||
293 | "SELECT " + |
||
294 | "avg(fc.intResposta) as media," + |
||
295 | "std(fc.intResposta) as desvio," + |
||
296 | "count(fc.id) as total, " + |
||
297 | "avg(fc.tempoLevado) as tempoMedioLevado," + |
||
298 | "prgp.pergunta, " + |
||
299 | "curso.nomeCurso, " + |
||
300 | "count(distinct unit.codigo) " + |
||
301 | |||
302 | |||
303 | |||
304 | "FROM " + OlapStarFactQuestionarioAnswer.class.getName() + " fc " + |
||
305 | "JOIN fc.olapPergunta prgp " + |
||
306 | "JOIN fc.olapTipologia tipo " + |
||
307 | "JOIN fc.olapQuestionario quest " + |
||
308 | "JOIN fc.olapCurso curso " + |
||
309 | "JOIN fc.olapUnidade unit " + |
||
1568 | jmachado | 310 | "JOIN fc.olapTimeLine timeLine " + |
1567 | jmachado | 311 | |
312 | "where " + |
||
313 | " curso.codigoCurso = :codigoCurso " + |
||
314 | //"and quest.semestre = :semestre " + |
||
315 | "and quest.ano = :ano " + |
||
316 | "and prgp.numero = :numero " + |
||
1568 | jmachado | 317 | "and timeLine.nome = '" + PedagogicoAlunosProcessor.getHistoryDriveConstraintStatic() + "' " + |
318 | //degreesQuery + |
||
1567 | jmachado | 319 | periodosQuery); |
320 | |||
321 | |||
322 | query.setString("codigoCurso",codigoCurso); |
||
323 | //query.setString("semestre",semestre); |
||
324 | query.setString("ano",anoLectivo); |
||
325 | query.setString("numero",numeroPergunta); |
||
326 | |||
327 | 5+0%2Fdocs%2Fapi+Object">Object[] result = (5+0%2Fdocs%2Fapi+Object">Object[]) query.uniqueResult(); |
||
328 | |||
329 | |||
330 | mediaGlobalCursoPergunta.numeroPergunta = numeroPergunta; |
||
331 | mediaGlobalCursoPergunta.pergunta = (1.5.0/docs/api/java/lang/String.html">String) result[4]; |
||
332 | mediaGlobalCursoPergunta.codigoCurso = codigoCurso; |
||
333 | mediaGlobalCursoPergunta.nomeCurso = (1.5.0/docs/api/java/lang/String.html">String) result[5]; |
||
334 | mediaGlobalCursoPergunta.media = (1.5.0/docs/api/java/lang/Double.html">Double) result[0]; |
||
335 | mediaGlobalCursoPergunta.desvio = (1.5.0/docs/api/java/lang/Double.html">Double) result[1]; |
||
336 | mediaGlobalCursoPergunta.total = ((1.5.0/docs/api/java/lang/Long.html">Long) result[2]).intValue(); |
||
337 | mediaGlobalCursoPergunta.tempoLevadoMedia = (1.5.0/docs/api/java/lang/Double.html">Double) result[3]; |
||
338 | mediaGlobalCursoPergunta.numeroUnidades = ((1.5.0/docs/api/java/lang/Long.html">Long) result[6]).intValue(); |
||
339 | |||
340 | |||
341 | return mediaGlobalCursoPergunta; |
||
342 | } |
||
343 | |||
1571 | jmachado | 344 | public static MediaGlobalCursoGrupo getMediaCursoGrupo(QuestionariosAlunosReport report,1.5.0/docs/api/java/lang/String.html">String codigoCurso, 1.5.0/docs/api/java/lang/String.html">String anoLectivo, 1.5.0/docs/api/java/lang/String.html">String grupo,1.5.0/docs/api/java/lang/String.html">String subGrupo, |
1568 | jmachado | 345 | 1.5.0/docs/api/java/lang/String.html">String[] periodos) |
1567 | jmachado | 346 | { |
347 | |||
1568 | jmachado | 348 | 1.5.0/docs/api/java/lang/String.html">String key = codigoCurso + "-" + anoLectivo + "-" + (grupo == null ? "_" : grupo) + "-" + (subGrupo == null ? "_" : subGrupo); |
1567 | jmachado | 349 | if(report.getMediasGrupoNoCurso().get(key) != null) |
350 | return report.getMediasGrupoNoCurso().get(key); |
||
351 | |||
1568 | jmachado | 352 | //String degreesQuery = QueryDaoUtils.createDegreesQuery(degrees,"curso",true); |
1567 | jmachado | 353 | 1.5.0/docs/api/java/lang/String.html">String periodosQuery = QueryDaoUtils.createPeriodosQuery(periodos,"quest",true); |
354 | |||
355 | |||
356 | MediaGlobalCursoGrupo mediaGlobalCursoGrupo = new MediaGlobalCursoGrupo(); |
||
357 | report.getMediasGrupoNoCurso().put(key,mediaGlobalCursoGrupo); |
||
358 | |||
359 | 1.5.0/docs/api/javax/management/Query.html">Query query;//*****CRIAR REPOSTAS DO GRUPO DOCENTE*****/// |
||
360 | |||
361 | query = AbstractDao.getCurrentSession().createQuery("" + |
||
362 | "SELECT " + |
||
363 | "avg(fc.intResposta) as media," + |
||
364 | "std(fc.intResposta) as desvio," + |
||
365 | "count(fc.id) as total, " + |
||
366 | "avg(fc.tempoLevado) as tempoMedioLevado," + |
||
367 | "curso.nomeCurso, " + |
||
368 | "count(distinct unit.codigo) " + |
||
369 | |||
370 | "FROM " + OlapStarFactQuestionarioAnswer.class.getName() + " fc " + |
||
371 | "JOIN fc.olapPergunta prgp " + |
||
372 | "JOIN fc.olapTipologia tipo " + |
||
373 | "JOIN fc.olapQuestionario quest " + |
||
374 | "JOIN fc.olapCurso curso " + |
||
375 | "JOIN fc.olapUnidade unit " + |
||
1568 | jmachado | 376 | "JOIN fc.olapTimeLine timeLine " + |
1567 | jmachado | 377 | |
378 | "where " + |
||
1568 | jmachado | 379 | " curso.codigoCurso = :codigoCurso " + |
1567 | jmachado | 380 | //"and quest.semestre = :semestre " + |
381 | "and quest.ano = :ano " + |
||
1568 | jmachado | 382 | "and timeLine.nome = '" + PedagogicoAlunosProcessor.getHistoryDriveConstraintStatic() + "' " + |
383 | (grupo == null ? "" : " and prgp.grupoCode = :grupoCode ") + |
||
384 | (subGrupo == null ? "" : " and prgp.subGrupoCode = :subGrupoCode ") + |
||
385 | //degreesQuery + |
||
1567 | jmachado | 386 | periodosQuery); |
387 | |||
388 | |||
389 | query.setString("codigoCurso",codigoCurso); |
||
390 | //query.setString("semestre",semestre); |
||
391 | query.setString("ano",anoLectivo); |
||
1568 | jmachado | 392 | if(grupo != null) |
393 | query.setString("grupoCode",grupo); |
||
394 | if(subGrupo != null) |
||
395 | query.setString("subGrupoCode",subGrupo); |
||
1567 | jmachado | 396 | |
397 | 5+0%2Fdocs%2Fapi+Object">Object[] result = (5+0%2Fdocs%2Fapi+Object">Object[]) query.uniqueResult(); |
||
398 | |||
399 | |||
400 | mediaGlobalCursoGrupo.grupo = grupo; |
||
401 | mediaGlobalCursoGrupo.codigoCurso = codigoCurso; |
||
402 | mediaGlobalCursoGrupo.nomeCurso = (1.5.0/docs/api/java/lang/String.html">String) result[4]; |
||
403 | mediaGlobalCursoGrupo.media = (1.5.0/docs/api/java/lang/Double.html">Double) result[0]; |
||
404 | mediaGlobalCursoGrupo.desvio = (1.5.0/docs/api/java/lang/Double.html">Double) result[1]; |
||
405 | mediaGlobalCursoGrupo.total = ((1.5.0/docs/api/java/lang/Long.html">Long) result[2]).intValue(); |
||
406 | mediaGlobalCursoGrupo.tempoLevadoMedia = (1.5.0/docs/api/java/lang/Double.html">Double) result[3]; |
||
407 | mediaGlobalCursoGrupo.numeroUnidades = ((1.5.0/docs/api/java/lang/Long.html">Long) result[5]).intValue(); |
||
408 | |||
409 | |||
410 | return mediaGlobalCursoGrupo; |
||
411 | } |
||
1571 | jmachado | 412 | public static MediaGlobalEscolaPergunta getMediaEscolaPergunta(QuestionariosAlunosReport report,1.5.0/docs/api/java/lang/String.html">String codigoEscola, 1.5.0/docs/api/java/lang/String.html">String anoLectivo, 1.5.0/docs/api/java/lang/String.html">String numeroPergunta, |
1567 | jmachado | 413 | 1.5.0/docs/api/java/lang/String.html">String[] periodos ,1.5.0/docs/api/java/lang/String.html">String[] degrees) |
414 | { |
||
415 | 1.5.0/docs/api/java/lang/String.html">String key = codigoEscola + "-" + anoLectivo + "-" + numeroPergunta; |
||
416 | if(report.getMediasGrupoNaEscola().get(key) != null) |
||
417 | return report.getMediasPerguntaNaEscola().get(key); |
||
418 | |||
419 | 1.5.0/docs/api/java/lang/String.html">String degreesQuery = QueryDaoUtils.createDegreesQuery(degrees,"curso",true); |
||
420 | 1.5.0/docs/api/java/lang/String.html">String periodosQuery = QueryDaoUtils.createPeriodosQuery(periodos,"quest",true); |
||
421 | |||
422 | |||
423 | MediaGlobalEscolaPergunta mediaGlobalEscolaPergunta = new MediaGlobalEscolaPergunta(); |
||
424 | report.getMediasPerguntaNaEscola().put(key,mediaGlobalEscolaPergunta); |
||
425 | |||
426 | 1.5.0/docs/api/javax/management/Query.html">Query query;//*****CRIAR REPOSTAS DO GRUPO DOCENTE*****/// |
||
427 | |||
428 | query = AbstractDao.getCurrentSession().createQuery("" + |
||
429 | "SELECT " + |
||
430 | "avg(fc.intResposta) as media," + |
||
431 | "std(fc.intResposta) as desvio," + |
||
432 | "count(fc.id) as total, " + |
||
433 | "avg(fc.tempoLevado) as tempoMedioLevado," + |
||
434 | "curso.nomeInstituicao, " + |
||
435 | "prgp.pergunta," + |
||
436 | "count(distinct unit.codigo) " + |
||
437 | |||
438 | "FROM " + OlapStarFactQuestionarioAnswer.class.getName() + " fc " + |
||
439 | "JOIN fc.olapPergunta prgp " + |
||
440 | "JOIN fc.olapTipologia tipo " + |
||
441 | "JOIN fc.olapQuestionario quest " + |
||
442 | "JOIN fc.olapCurso curso " + |
||
443 | "JOIN fc.olapUnidade unit " + |
||
1568 | jmachado | 444 | "JOIN fc.olapTimeLine timeLine " + |
1567 | jmachado | 445 | |
446 | "where " + |
||
447 | " curso.codigoInstituicao = :codigoInstituicao " + |
||
448 | //"and quest.semestre = :semestre " + |
||
449 | "and quest.ano = :ano " + |
||
450 | "and prgp.numero = :numero " + |
||
1568 | jmachado | 451 | "and timeLine.nome = '" + PedagogicoAlunosProcessor.getHistoryDriveConstraintStatic() + "' " + |
1567 | jmachado | 452 | degreesQuery + |
453 | periodosQuery); |
||
454 | |||
455 | |||
456 | query.setString("codigoInstituicao",codigoEscola); |
||
457 | //query.setString("semestre",semestre); |
||
458 | query.setString("ano",anoLectivo); |
||
459 | query.setString("numero",numeroPergunta); |
||
460 | |||
461 | 5+0%2Fdocs%2Fapi+Object">Object[] result = (5+0%2Fdocs%2Fapi+Object">Object[]) query.uniqueResult(); |
||
462 | |||
463 | |||
464 | mediaGlobalEscolaPergunta.numeroPergunta = numeroPergunta; |
||
465 | mediaGlobalEscolaPergunta.pergunta = (1.5.0/docs/api/java/lang/String.html">String) result[5]; |
||
466 | mediaGlobalEscolaPergunta.codigoEscola = codigoEscola; |
||
467 | mediaGlobalEscolaPergunta.nomeDaEscola = (1.5.0/docs/api/java/lang/String.html">String) result[4]; |
||
468 | mediaGlobalEscolaPergunta.media = (1.5.0/docs/api/java/lang/Double.html">Double) result[0]; |
||
469 | mediaGlobalEscolaPergunta.desvio = (1.5.0/docs/api/java/lang/Double.html">Double) result[1]; |
||
470 | mediaGlobalEscolaPergunta.total = ((1.5.0/docs/api/java/lang/Long.html">Long) result[2]).intValue(); |
||
471 | mediaGlobalEscolaPergunta.tempoLevadoMedia = (1.5.0/docs/api/java/lang/Double.html">Double) result[3]; |
||
472 | mediaGlobalEscolaPergunta.numeroUnidades = ((1.5.0/docs/api/java/lang/Long.html">Long) result[6]).intValue(); |
||
473 | |||
474 | |||
475 | return mediaGlobalEscolaPergunta; |
||
476 | } |
||
477 | |||
1571 | jmachado | 478 | public static MediaGlobalEscolaGrupo getMediaEscolaGrupo(QuestionariosAlunosReport report,1.5.0/docs/api/java/lang/String.html">String codigoEscola, 1.5.0/docs/api/java/lang/String.html">String anoLectivo, 1.5.0/docs/api/java/lang/String.html">String grupo,1.5.0/docs/api/java/lang/String.html">String subGrupo, |
1567 | jmachado | 479 | 1.5.0/docs/api/java/lang/String.html">String[] periodos ,1.5.0/docs/api/java/lang/String.html">String[] degrees) |
480 | { |
||
1568 | jmachado | 481 | 1.5.0/docs/api/java/lang/String.html">String key = codigoEscola + "-" + anoLectivo + "-" + (grupo == null ? "_" : grupo) + "-" + (subGrupo == null ? "_" : subGrupo); |
1567 | jmachado | 482 | if(report.getMediasGrupoNaEscola().get(key) != null) |
483 | return report.getMediasGrupoNaEscola().get(key); |
||
484 | |||
485 | 1.5.0/docs/api/java/lang/String.html">String degreesQuery = QueryDaoUtils.createDegreesQuery(degrees,"curso",true); |
||
486 | 1.5.0/docs/api/java/lang/String.html">String periodosQuery = QueryDaoUtils.createPeriodosQuery(periodos,"quest",true); |
||
487 | |||
488 | MediaGlobalEscolaGrupo mediaGlobalEscolaGrupo = new MediaGlobalEscolaGrupo(); |
||
489 | report.getMediasGrupoNaEscola().put(key,mediaGlobalEscolaGrupo); |
||
490 | |||
491 | 1.5.0/docs/api/javax/management/Query.html">Query query;//*****CRIAR REPOSTAS DO GRUPO DOCENTE*****/// |
||
492 | |||
493 | query = AbstractDao.getCurrentSession().createQuery("" + |
||
494 | "SELECT " + |
||
495 | "avg(fc.intResposta) as media," + |
||
496 | "std(fc.intResposta) as desvio," + |
||
497 | "count(fc.id) as total, " + |
||
498 | "avg(fc.tempoLevado) as tempoMedioLevado," + |
||
499 | "curso.nomeInstituicao, " + |
||
500 | "count(distinct unit.codigo) " + |
||
501 | |||
502 | "FROM " + OlapStarFactQuestionarioAnswer.class.getName() + " fc " + |
||
503 | "JOIN fc.olapPergunta prgp " + |
||
504 | "JOIN fc.olapTipologia tipo " + |
||
505 | "JOIN fc.olapQuestionario quest " + |
||
506 | "JOIN fc.olapCurso curso " + |
||
507 | "JOIN fc.olapUnidade unit " + |
||
1568 | jmachado | 508 | "JOIN fc.olapTimeLine timeLine " + |
1567 | jmachado | 509 | "where " + |
1568 | jmachado | 510 | "curso.codigoInstituicao = :codigoInstituicao " + |
1567 | jmachado | 511 | //"and quest.semestre = :semestre " + |
512 | "and quest.ano = :ano " + |
||
1568 | jmachado | 513 | "and timeLine.nome = '" + PedagogicoAlunosProcessor.getHistoryDriveConstraintStatic() + "' " + |
514 | (grupo == null ? "" : " and prgp.grupoCode = :grupoCode ") + |
||
515 | (subGrupo == null ? "" : " and prgp.subGrupoCode = :subGrupoCode ") + |
||
1567 | jmachado | 516 | degreesQuery + |
517 | periodosQuery); |
||
518 | |||
519 | query.setString("codigoInstituicao",codigoEscola); |
||
520 | //query.setString("semestre",semestre); |
||
521 | query.setString("ano",anoLectivo); |
||
1568 | jmachado | 522 | if(grupo != null) |
523 | query.setString("grupoCode",grupo); |
||
524 | if(subGrupo != null) |
||
525 | query.setString("subGrupoCode",subGrupo); |
||
1567 | jmachado | 526 | |
527 | 5+0%2Fdocs%2Fapi+Object">Object[] result = (5+0%2Fdocs%2Fapi+Object">Object[]) query.uniqueResult(); |
||
528 | |||
529 | |||
530 | mediaGlobalEscolaGrupo.grupo = grupo; |
||
531 | mediaGlobalEscolaGrupo.codigoEscola = codigoEscola; |
||
532 | mediaGlobalEscolaGrupo.nomeDaEscola = (1.5.0/docs/api/java/lang/String.html">String) result[4]; |
||
533 | mediaGlobalEscolaGrupo.media = (1.5.0/docs/api/java/lang/Double.html">Double) result[0]; |
||
534 | mediaGlobalEscolaGrupo.desvio = (1.5.0/docs/api/java/lang/Double.html">Double) result[1]; |
||
535 | mediaGlobalEscolaGrupo.total = ((1.5.0/docs/api/java/lang/Long.html">Long) result[2]).intValue(); |
||
536 | mediaGlobalEscolaGrupo.tempoLevadoMedia = (1.5.0/docs/api/java/lang/Double.html">Double) result[3]; |
||
537 | mediaGlobalEscolaGrupo.numeroUnidades = ((1.5.0/docs/api/java/lang/Long.html">Long) result[5]).intValue(); |
||
538 | |||
539 | return mediaGlobalEscolaGrupo; |
||
540 | } |
||
541 | |||
542 | |||
543 | |||
544 | |||
545 | |||
546 | public static class MediaGlobalCurso extends MediaGlobalResult |
||
547 | { |
||
548 | public 1.5.0/docs/api/java/lang/String.html">String nomeCurso; |
||
549 | public 1.5.0/docs/api/java/lang/String.html">String codigoCurso; |
||
550 | public int numeroUnidades; |
||
551 | } |
||
552 | |||
553 | public static class MediaGlobalEscola extends MediaGlobalResult |
||
554 | { |
||
555 | public 1.5.0/docs/api/java/lang/String.html">String nomeDaEscola; |
||
556 | public 1.5.0/docs/api/java/lang/String.html">String codigoEscola; |
||
557 | public int numeroUnidades; |
||
558 | } |
||
559 | |||
560 | public static class MediaGlobalEscolaPergunta extends MediaGlobalEscola |
||
561 | { |
||
562 | public 1.5.0/docs/api/java/lang/String.html">String numeroPergunta; |
||
563 | public 1.5.0/docs/api/java/lang/String.html">String pergunta; |
||
564 | } |
||
565 | |||
566 | public static class MediaGlobalEscolaGrupo extends MediaGlobalEscola |
||
567 | { |
||
568 | public 1.5.0/docs/api/java/lang/String.html">String grupo; |
||
569 | } |
||
570 | |||
571 | public static class MediaGlobalCursoPergunta extends MediaGlobalCurso |
||
572 | { |
||
573 | public 1.5.0/docs/api/java/lang/String.html">String numeroPergunta; |
||
574 | public 1.5.0/docs/api/java/lang/String.html">String pergunta; |
||
575 | } |
||
576 | |||
577 | public static class MediaGlobalCursoGrupo extends MediaGlobalCurso |
||
578 | { |
||
579 | public 1.5.0/docs/api/java/lang/String.html">String grupo; |
||
580 | } |
||
581 | |||
582 | public static class MediaGlobalResult |
||
583 | { |
||
584 | public double media; |
||
585 | public double desvio; |
||
586 | public int total; |
||
587 | public double tempoLevadoMedia; |
||
588 | } |
||
589 | } |