Rev 1387 | Rev 1404 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1379 | jmachado | 1 | <%@ page import="jomm.dao.impl.AbstractDao" %> |
1399 | jmachado | 2 | <%@ page import="org.hibernate.Query" %> |
3 | <%@ page import="pt.estgp.estgweb.domain.JobServiceTaskImpl" %> |
||
4 | <%@ page import="pt.estgp.estgweb.domain.QuestionarioImpl" %> |
||
5 | <%@ page import="pt.estgp.estgweb.domain.QuestionarioPedagogicoCursoAfeto" %> |
||
1379 | jmachado | 6 | <%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %> |
1399 | jmachado | 7 | <%@ page import="pt.estgp.estgweb.domain.dao.impl.QuestionarioPedagogicoCursoAfetoDaoImpl" %> |
1379 | jmachado | 8 | <%@ page import="pt.estgp.estgweb.utils.ConfigProperties" %> |
1399 | jmachado | 9 | <%@ page import="pt.estgp.estgweb.web.form.configuration.SchedulleTasksForm" %> |
1379 | jmachado | 10 | <%@ page import="pt.estgp.estgweb.web.utils.RequestUtils" %> |
11 | <%@ page import="pt.utl.ist.berserk.logic.serviceManager.IServiceManager" %> |
||
12 | <%@ page import="pt.utl.ist.berserk.logic.serviceManager.ServiceManager" %> |
||
13 | <%@ page import="java.util.List" %> |
||
14 | <%@ page contentType="text/html;charset=UTF-8" language="java" %> |
||
15 | <%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %> |
||
16 | <%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %> |
||
17 | <%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %> |
||
18 | <%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %> |
||
19 | <%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %> |
||
20 | <%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %> |
||
21 | <%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %> |
||
22 | <% |
||
23 | String qId = request.getParameter("questionarioId"); |
||
24 | if(qId == null) |
||
25 | qId = request.getParameter("questionario.id"); |
||
26 | Long questionarioId = Long.parseLong(qId); |
||
27 | |||
28 | IServiceManager sm = ServiceManager.getInstance(); |
||
29 | String[] names = {"questionarioId"}; |
||
30 | Object[] args = {questionarioId}; |
||
31 | QuestionarioImpl questionario = (QuestionarioImpl) sm.execute(RequestUtils.getRequester(request, response),"loadQuestionarioAdmin",args,names); |
||
32 | |||
33 | |||
34 | request.setAttribute("Questionario", questionario); |
||
35 | |||
36 | |||
37 | AbstractDao.getCurrentSession().beginTransaction(); |
||
38 | JobServiceTaskImpl job = questionario.getAnswerGenerationTaskId() > 0 ? |
||
39 | (JobServiceTaskImpl) DaoFactory.getJobServiceTaskDaoImpl().load(questionario.getAnswerGenerationTaskId()) : |
||
40 | null; |
||
41 | request.setAttribute("Job", job); |
||
42 | |||
43 | List<String> institutionCodes = ConfigProperties.getListValues("questionario.instituition."); |
||
44 | |||
45 | %> |
||
46 | |||
47 | |||
48 | |||
49 | <html:form action="/user/questionariosPaeSelectCourses"> |
||
50 | <jsp:useBean id="QuestionarioForm" type="pt.estgp.estgweb.web.form.questionarios.QuestionarioForm" scope="request"/> |
||
51 | |||
52 | <div class="container-fluid"> |
||
53 | |||
54 | |||
55 | <div class="panel panel-primary"> |
||
56 | <div class="panel-heading"> |
||
57 | Atribuição de Questionários/Alunos para o Questionário ${Questionario.id} - Periodo: ${Questionario.semestre} de ${Questionario.year} |
||
58 | </div> |
||
59 | <div class="panel-body"> |
||
60 | <html:errors/> |
||
61 | <jomm:messages/> |
||
62 | |||
63 | |||
64 | |||
65 | <div class="panel panel-primary" id="institutionGerarFinal"> |
||
66 | <div class="panel-heading"> |
||
67 | Atribuição de Questionários/Alunos ao Questionário |
||
68 | </div> |
||
69 | <div class="panel-body"> |
||
70 | |||
1399 | jmachado | 71 | <div class="col-sm-6"> |
72 | <baco:clearOperation name="Questionario" op="QUESTIONARIO_START_ASSIGN_ANSWERS"> |
||
73 | <div class="alert alert-warning">Esta operação vai atribuir questionários aos alunos das unidades curriculares seleccionadas |
||
74 | para o questionário ${Questionario.id} criado para o periodo ${Questionario.semestre} de ${Questionario.year}</div> |
||
75 | <div class="alert alert-info alert-small">Esta operação poderá ser revertida ou então repetida para atualizar os questionários atribuidos</div> |
||
76 | <div class="alert alert-info alert-small">Esta operação poderá demorar alguns instantes, consulte a barra de progresso</div> |
||
77 | <html:hidden property="questionario.id" value="${Questionario.id}"/> |
||
78 | <input type="hidden" name="questionarioId" value="${Questionario.id}"/> |
||
79 | <input type="hidden" name="dispatch" value="assignAnswers"/> |
||
80 | <button class="btn btn-warning" type="button" onclick="this.form.submit()">Atribuir</button> |
||
81 | </baco:clearOperation> |
||
1379 | jmachado | 82 | |
1399 | jmachado | 83 | <baco:notClearOperation name="Questionario" op="QUESTIONARIO_START_ASSIGN_ANSWERS"> |
84 | <baco:clearOperation name="Questionario" op="QUESTIONARIO_SEE_START_ASSIGN_ANSWERS"> |
||
85 | <div class="alert alert-warning">O sistema agendou a atribuição de cursos e unidades ao questionário ${Questionario.id} criado para o periodo ${Questionario.semestre} de ${Questionario.year}. Veja o progresso em baixo, caso não termine no final de 30 minutos esta tarefa ficará de novo disponivel</div> |
||
86 | </baco:clearOperation> |
||
87 | <baco:notClearOperation name="Questionario" op="QUESTIONARIO_SEE_START_ASSIGN_ANSWERS"> |
||
88 | <div class="alert alert-warning">Não têm autorização para ver esta secção</div> |
||
89 | </baco:notClearOperation> |
||
1379 | jmachado | 90 | |
1399 | jmachado | 91 | </baco:notClearOperation> |
92 | <a class="btn btn-default" href="#" data-href="<%=request.getContextPath()%>/user/questionarios/pedagogicoEstudante/questionarioLogState.jsp?questionarioId=${Questionario.id}" data-title="Registo de mudanças de estado do questionario ${Questionario.id}" data-toggle="modal" data-target="#modalAjaxRequest"> |
||
93 | Registo de Mudanças de Estado |
||
94 | </a> |
||
95 | </div> |
||
96 | |||
97 | <div class="col-sm-6"> |
||
1379 | jmachado | 98 | <baco:clearOperation name="Questionario" op="QUESTIONARIO_SEE_START_ASSIGN_ANSWERS"> |
1399 | jmachado | 99 | <% |
100 | if(job != null) |
||
101 | { |
||
102 | SchedulleTasksForm schedulleTasksForm = new SchedulleTasksForm(); |
||
103 | schedulleTasksForm.setJobServiceTask(job); |
||
104 | schedulleTasksForm.setId(job.getId()); |
||
105 | request.setAttribute("SchedulleTasksForm",schedulleTasksForm); |
||
106 | %> |
||
107 | <div class="task-log task-log-xs" data-href="<%=request.getContextPath()%>/user/questionarioPedagogicoStartAssignAnswers.do?questionarioId=${Questionario.id}"> |
||
108 | <jsp:include page="/admin/configuration/taskLog.jsp"/> |
||
109 | </div> |
||
110 | <% |
||
111 | } |
||
112 | else |
||
113 | { |
||
114 | %> |
||
115 | <div class="alert alert-danger">O sistema não conseguiu encontrar a tarefa de atribuição nas tarefas agendadas, por favor verifique em todos os logs de tarefas <html:link action="/user/configurationJobTasks">Aqui</html:link> </div> |
||
116 | <% |
||
117 | } |
||
118 | %> |
||
119 | |||
1379 | jmachado | 120 | </baco:clearOperation> |
1399 | jmachado | 121 | </div> |
1379 | jmachado | 122 | |
1399 | jmachado | 123 | <div class="col-sm-12" style="margin-top: 20px"> |
124 | |||
1379 | jmachado | 125 | <% |
1399 | jmachado | 126 | //QuestionarioPedagogicoCursoAfetoDaoImpl.QuestionarioStatsVars questionarioStatsVars = DaoFactory.getQuestionarioPedagogicoCursoAfetoDaoImpl().loadQuestionarioStats(questionarioId); |
127 | QuestionarioPedagogicoCursoAfetoDaoImpl.QuestionarioStatsVars questionarioStatsVars = new QuestionarioPedagogicoCursoAfetoDaoImpl.QuestionarioStatsVars(); |
||
128 | Query q = AbstractDao.getCurrentSession().createQuery("SELECT " + |
||
129 | " count(distinct c.id) AS cursos " + |
||
130 | ",count(distinct u.id) AS unidades " + |
||
131 | ",sum (u.profs) AS profs " + |
||
132 | ",sum (u.turmas) AS turmas " + |
||
133 | ",sum (u.students) AS students " + |
||
134 | ",sum (case when u.usar = true then u.students else 0 end) AS alunosDeUsadas " + |
||
135 | ",sum (case when u.usar = true then u.profs else 0 end) AS profsDeUsadas " + |
||
136 | ",sum (case when u.usar = true then 1 else 0 end) AS unidadesUsadas " + |
||
137 | ",sum (case when u.usar = true then 1 else 1 end) AS unidadesTodasCheck " + |
||
138 | ",sum (case when u.usar = true then (u.profs * u.students) else 0 end) AS respostasEsperadas " + |
||
139 | "from " + QuestionarioPedagogicoCursoAfeto.class.getName() + " c " + |
||
140 | "JOIN c.questionario q " + |
||
141 | "JOIN c.unidadesAfetas u " + |
||
142 | "WHERE q.id = :id " + |
||
143 | "GROUP BY q.id"); |
||
144 | |||
145 | q.setLong("id",questionarioId); |
||
146 | Object[] results = (Object[]) q.uniqueResult(); |
||
147 | |||
148 | if(results != null && results[0] != null) |
||
1379 | jmachado | 149 | { |
1399 | jmachado | 150 | questionarioStatsVars.cursos = (Long) results[0]; |
151 | questionarioStatsVars.unidades = (Long) results[1]; |
||
152 | questionarioStatsVars.profs = (Long) results[2]; |
||
153 | questionarioStatsVars.turmas = (Long) results[3]; |
||
154 | questionarioStatsVars.alunos = (Long) results[4]; |
||
155 | questionarioStatsVars.alunosDeUsadas = (Long) results[5]; |
||
156 | questionarioStatsVars.profsDeUsadas = (Long) results[6]; |
||
157 | questionarioStatsVars.unidadesUsadas = (Long) results[7]; |
||
158 | |||
159 | if(((Long) results[8]) != questionarioStatsVars.unidades) |
||
160 | out.print("TEM UM ERRO NA QUERY, a contagem de usadas com o distinct da diferente de com o SUM"); |
||
161 | |||
1379 | jmachado | 162 | } |
163 | |||
1399 | jmachado | 164 | %> |
165 | <div class="alert alert-info">Por favor confira estes valores com os resultados apresentados no LOG</div> |
||
166 | <table class="tablesorter-blue"> |
||
167 | <thead> |
||
168 | <th>Cursos Selecionados</th> |
||
169 | <th>Total de Unidades</th> |
||
170 | <th>Unidades Não Selecionadas</th> |
||
171 | <th>Unidades Selecionadas</th> |
||
172 | <th>Turmas Selecionadas</th> |
||
173 | <th>Alunos Selecionados</th> |
||
174 | <th>Professores Selecionados</th> |
||
175 | <th>Máximo de questionários simples admitidos (Somatorio (Por cada Unidade Profs*Alunos))</th> |
||
176 | </thead> |
||
177 | <tbody> |
||
178 | <td><%=questionarioStatsVars.cursos%></td> |
||
179 | <td><%=questionarioStatsVars.unidades%></td> |
||
180 | <td><%=questionarioStatsVars.unidades - questionarioStatsVars.unidadesUsadas%></td> |
||
181 | <td><%=questionarioStatsVars.unidadesUsadas%></td> |
||
182 | <td><%=questionarioStatsVars.turmas%></td> |
||
183 | <td><%=questionarioStatsVars.alunosDeUsadas%></td> |
||
184 | <td><%=questionarioStatsVars.profsDeUsadas%></td> |
||
185 | <td><%=(Long) results[9]%></td> |
||
186 | </tbody> |
||
187 | </table> |
||
188 | </div> |
||
1379 | jmachado | 189 | </div> |
190 | |||
191 | </div> |
||
192 | <div class="col-sm-12"> |
||
193 | <html:link action="/user/adminQuestionario?questionario.id=${Questionario.id}#NOWTASK" styleClass="btn btn-danger">Voltar à administração</html:link> |
||
194 | </div> |
||
195 | |||
1399 | jmachado | 196 | |
1379 | jmachado | 197 | </div> |
198 | </div> |
||
199 | </div> |
||
200 | <% |
||
201 | AbstractDao.getCurrentSession().getTransaction().commit(); |
||
202 | %> |
||
203 | |||
204 | </html:form> |