Subversion Repositories bacoAlunos

Rev

Rev 1621 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1407 jmachado 1
<%@ page import="jomm.dao.impl.AbstractDao" %>
2
<%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %>
1411 jmachado 3
<%@ page import="pt.estgp.estgweb.web.form.questionarios.QuestionarioRespostaForm" %>
4
<%@ page import="java.util.List" %>
5
<%@ page import="pt.estgp.estgweb.domain.*" %>
1407 jmachado 6
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
7
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
8
<%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %>
9
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
10
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
11
<%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %>
12
<%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %>
13
<%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %>
14
<jsp:useBean id="UserSession" type="pt.estgp.estgweb.domain.UserSessionImpl" scope="request"/>
15
<%
1411 jmachado 16
    QuestionarioRespostaForm form = (QuestionarioRespostaForm) request.getAttribute("QuestionarioRespostaForm");
17
    long alunoRequesitadoId;
18
    if(form != null)
19
    {
20
        alunoRequesitadoId = form.getAlunoRequesitadoId();
21
    }
22
    else
23
    {
24
        alunoRequesitadoId = Long.parseLong(request.getParameter("alunoRequisitadoId"));
25
    }
1407 jmachado 26
 
1411 jmachado 27
 
28
 
29
    request.setAttribute("alunoRequisitadoId",alunoRequesitadoId);
30
 
1412 jmachado 31
 
1407 jmachado 32
    AbstractDao.getCurrentSession().beginTransaction();
33
 
34
    //todo MUDAR AQUI QUANDO HOUVER OUTROS TIPOS DE QUESTIONARIOS ASSIM CARREGA O ALUNO
35
    //NAO DEVE SER PRECISO PORQUE A LISTAGEM E ESPECIFICA DO PEDAGOGICO
36
 
37
    QuestionarioPedagogicoAlunoRequisitado alunoRequisitado
38
            = DaoFactory.getQuestionarioPedagogicoAlunoRequisitadoDaoImpl().load(alunoRequesitadoId);
39
    QuestionarioRespostaRequisitada respostaRequisitada
40
            = alunoRequisitado.getRespostaRequisitada();
41
 
42
    Questionario qLoad = respostaRequisitada.getQuestionario();
43
    QuestionarioImpl questionario = (QuestionarioImpl) DaoFactory.getQuestionarioDaoImpl().narrow(qLoad);
44
 
1412 jmachado 45
    request.setAttribute("questionario",questionario);
1407 jmachado 46
 
47
    if(respostaRequisitada.getUser().getId() != UserSession.getUser().getId() || (questionario.getStateEnum() != QuestionarioImpl.State.PROCESSING &&
48
            questionario.getStateEnum() != QuestionarioImpl.State.PROCESSING_WITH_ANSWERS))
49
    {
50
%>
51
        <div class="panel panel-danger">
52
            <div class="panel-heading">ATENÇÃO</div>
53
            <div class="panel-body">
54
                <div class="alert alert-danger">Lamentamos mas o questionário ao qual está a tentar responder não lhe pertence!</div>
55
            </div>
56
        </div>
57
<%
58
    }
59
    else if(respostaRequisitada.getResposta() != null)
60
    {
61
%>
62
        <div class="panel panel-info">
63
            <div class="panel-heading">ATENÇÃO</div>
64
            <div class="panel-body">
65
                <div class="alert alert-info">O questionário que está a tentar responder já está entregue. Obrigado!</div>
66
            </div>
67
        </div>
68
<%
69
    }
70
    else
71
    {
72
%>
73
 
1411 jmachado 74
        <style>
75
            .questionarioTable
76
            {
77
                width: 100%;
78
            }
79
            .questionarioTable .pergunta
80
            {
81
                width: 60%;
82
            }
83
            .questionarioTable td
84
            {
85
                padding: 10px;
86
 
87
            }
88
            .questionarioTable input[type=radio]
89
            {
90
                margin-right: 4px;
91
 
92
            }
93
            .questionarioTable tr
94
            {
95
                border-bottom: 1px solid #939393;
96
            }
97
            .questionarioTable tr.nao-respondida
98
            {
99
 
100
            }
101
            .questionarioTable tr.respondida
102
            {
103
 
104
                background-color: #e2ffef;
105
            }
106
 
107
        </style>
108
        <script>
109
            //START SERVICE PING
110
 
111
 
112
            var lastEvent = 0;
113
            var lastDiferentElementEvent = 0;
114
            var lastDiferentElement;
115
            function addEvent(targetElementId,targetDurationElementId)
116
            {
117
                $("#"+targetElementId).closest("tr").removeClass("alert-warning");
118
                $("#"+targetElementId).closest("tr").removeClass("nao-respondida");
119
                $("#"+targetElementId).closest("tr").addClass("respondida");
120
 
121
                if(targetElementId != lastDiferentElement)
122
                {
123
                    lastDiferentElementEvent = lastEvent;
124
                    lastDiferentElement = targetElementId;
125
                    var eventTime = new Date().getTime();
126
                    $("#" + targetElementId).val(""+eventTime);
127
                    $("#" + targetDurationElementId).val(""+(eventTime-lastEvent));
128
                    lastEvent = eventTime;
129
                }
130
                else
131
                {
132
                    var eventTime = new Date().getTime();
133
                    $("#" + targetElementId).val(""+eventTime);
134
                    $("#" + targetDurationElementId).val(""+(eventTime-lastDiferentElementEvent));
135
                    lastEvent = eventTime;
136
                }
137
            }
138
            $(document).ready(
139
                    function()
140
                    {
141
                        ping();
142
                        var startTime = new Date().getTime();
143
                        $("#timeStart").val(startTime+"");
144
                        lastDiferentElementEvent = startTime;
145
                        lastEvent = startTime;
146
                        lastDiferentElement = null;
147
 
148
                        $("#submeterBtn").on("click",function()
149
                        {
150
                            var end = new Date().getTime();
151
                            $("#timeEnd").val(end+"");
152
                            $("#totalTime").val((end-startTime)+"");
153
                            $("#respostaForm").submit();
154
                        });
155
 
156
                        <%
157
                            if(request.getAttribute("respostasVazias")!= null)
158
                            {
159
                                List<String> respostasVazias = (List<String>) request.getAttribute("respostasVazias");
160
                               for(String resposta: respostasVazias)
161
                                {
162
                        %>
163
                                $("#pergunta<%=resposta%>").removeClass("nao-respondida").addClass("alert-warning");
164
                        <%
165
                                }
166
                            }
167
                        %>
168
                    }
169
            );
170
 
171
 
172
        </script>
173
 
1407 jmachado 174
        <div class="panel panel-default">
175
            <div class="panel-heading">Resposta ao Questionário de
176
                <label class="label label-pill label-default" style="font-size: 1.1em"><%=alunoRequisitado.getTipologiaRequisitada().getUnidadeAfeta().getNome()%></label>
177
                (<%=alunoRequisitado.getTipologiaRequisitada().getUnidadeAfeta().getCodigoUnidade()%>)
178
                de <%=alunoRequisitado.getTipologiaRequisitada().getUnidadeAfeta().getCursoAfeto().getNome()%>
179
                (<%=alunoRequisitado.getTipologiaRequisitada().getUnidadeAfeta().getCursoAfeto().getCodigoCurso()%>)
180
                Periodo lectivo (<%=questionario.getYear()%> - <%=questionario.getSemestre()%>)
181
                <br/>
182
                Docente: <label class="label label-pill label-info" style="font-size: 1.1em"><%=alunoRequisitado.getTipologiaRequisitada().getNomeDocente()%> (<%=alunoRequisitado.getTipologiaRequisitada().getCdDocente()%>)</label>
183
                /
184
                <label class="label label-pill label-default" style="font-size: 1.1em"><%=alunoRequisitado.getTipologiaRequisitada().getDsTipologia()%>
185
            </div>
186
            <div class="panel-body">
1409 jmachado 187
                <html:errors/>
188
                <jomm:messages/>
1407 jmachado 189
                <div class="panel panel-default">
190
                    <div class="panel-body">
191
                        <%=qLoad.getIntroHtml()%>
192
                    </div>
193
                    <div class="panel-body">
1572 jmachado 194
                        <p class="lead">Nas suas respostas deverá considerar 1 para nada satisfeito e 5 para muito satisfeito, exceptuando os casos de questões de esforço que estão mensuradas em horas.</p>
1407 jmachado 195
                    </div>
196
                </div>
197
 
198
 
199
                <html:form action="/user/questionariosPaeResposta" styleId="respostaForm">
1408 jmachado 200
                    <input type="hidden" name="dispatch" value="submitResposta"/>
1411 jmachado 201
                    <html:hidden styleId="timeStart" property="resposta.timeStart"/>
202
                    <html:hidden styleId="timeEnd" property="resposta.timeEnd"/>
203
                    <html:hidden styleId="totalTime" property="resposta.totalTime"/>
204
                    <html:hidden property="alunoRequesitadoId" value="${alunoRequisitadoId}"/>
1412 jmachado 205
                    <html:hidden property="resposta.questionario.id" value="${questionario.id}"/>
1411 jmachado 206
                    <jsp:useBean id="QuestionarioRespostaForm" type="pt.estgp.estgweb.web.form.questionarios.QuestionarioRespostaForm" scope="request"/>
207
                    <div class="panel panel-primary">
208
                        <div class="panel-heading">Identificação da Unidade Curricular</div>
1407 jmachado 209
                        <div class="panel-body">
1411 jmachado 210
                            <p>Curso: <label class="label label-pill label-default" style="font-size: 1.1em"><%=alunoRequisitado.getTipologiaRequisitada().getUnidadeAfeta().getCursoAfeto().getNome()%></label> (<%=alunoRequisitado.getTipologiaRequisitada().getUnidadeAfeta().getCursoAfeto().getCodigoCurso()%>)</p>
211
                            <p>Unidade Curricular: <label class="label label-pill label-default" style="font-size: 1.1em"><%=alunoRequisitado.getTipologiaRequisitada().getUnidadeAfeta().getNome()%></label> (<%=alunoRequisitado.getTipologiaRequisitada().getUnidadeAfeta().getCodigoUnidade()%>)</p>
212
                            <p>Docente em Avaliação: <label class="label label-pill label-default" style="font-size: 1.1em"><%=alunoRequisitado.getTipologiaRequisitada().getNomeDocente()%></label> (<%=alunoRequisitado.getTipologiaRequisitada().getCdDocente()%>)</p>
213
                            <p>Tipologia de Aulas: <label class="label label-pill label-default" style="font-size: 1.1em"><%=alunoRequisitado.getTipologiaRequisitada().getDsTipologia()%></label> </p>
1407 jmachado 214
                        </div>
215
                    </div>
216
                    <%
217
                        for(int i = 1;i<=10;i++)
218
                        {
219
                            String titulo = (String) QuestionarioImpl.class.getMethod("getGroup" + i + "Title").invoke(questionario);
1572 jmachado 220
                            String groupCodeComplete = (String) QuestionarioImpl.class.getMethod("getGroup" + i + "Code").invoke(questionario);
221
                            String groupNumber = ""+i;
222
                            if(groupCodeComplete != null && !groupCodeComplete.startsWith("D_") && titulo != null && titulo.trim().length() > 0)
1407 jmachado 223
                            {
224
                    %>
225
                                <div class="panel panel-default">
226
                                    <div class="panel-heading">
1411 jmachado 227
                                        <%=(i)%> - <%=titulo%>
1407 jmachado 228
                                    </div>
229
                                    <div class="panel-body">
1411 jmachado 230
                                        <table class="questionarioTable">
1407 jmachado 231
                                    <%
232
                                        for(int p = 1; p <= 40; p++)
233
                                        {
234
                                            request.setAttribute("p",p);
1655 jmachado 235
                                            Object pGroupObj = QuestionarioImpl.class.getMethod("getP" + p + "Group").invoke(questionario);
236
                                            if(pGroupObj == null)
237
                                                continue;
238
                                            String pGroup = (String)  pGroupObj;
1572 jmachado 239
                                            if(pGroup.equals(groupNumber))
1407 jmachado 240
                                            {
241
                                                String pergunta = (String) QuestionarioImpl.class.getMethod("getP" + p).invoke(questionario);
1411 jmachado 242
 
243
                                                String resposta = (String) QuestionarioResposta.class.getMethod("getR" + p).invoke(QuestionarioRespostaForm.getResposta());
244
 
245
                                                String naoRespondida = resposta != null && Long.parseLong(resposta) > 0 ? "respondida":" nao-respondida";
1407 jmachado 246
                                    %>
1411 jmachado 247
                                            <tr id="pergunta${p}" class="pergunta <%=naoRespondida%>">
1655 jmachado 248
                                                <td style="width: 70%">
1407 jmachado 249
 
1411 jmachado 250
                                                    <%=pergunta%>
251
                                                    <html:hidden property="resposta.timeEventR${p}" styleId="timeEventR${p}"/>
252
                                                    <html:hidden property="resposta.timeTakenR${p}" styleId="timeTakenR${p}"/>
253
                                                </td>
254
                                                <td style="padding-left: 10px"><html:radio property="resposta.r${p}" value="1" onclick="addEvent('timeEventR${p}','timeTakenR${p}');">1</html:radio></td>
255
                                                <td style="padding-left: 10px"><html:radio property="resposta.r${p}" value="2" onclick="addEvent('timeEventR${p}','timeTakenR${p}');">2</html:radio></td>
256
                                                <td style="padding-left: 10px"><html:radio property="resposta.r${p}" value="3" onclick="addEvent('timeEventR${p}','timeTakenR${p}');">3</html:radio></td>
257
                                                <td style="padding-left: 10px"><html:radio property="resposta.r${p}" value="4" onclick="addEvent('timeEventR${p}','timeTakenR${p}');">4</html:radio></td>
258
                                                <td style="padding-left: 10px"><html:radio property="resposta.r${p}" value="5" onclick="addEvent('timeEventR${p}','timeTakenR${p}');">5</html:radio></td>
259
 
1407 jmachado 260
                                            </tr>
261
                                    <%
262
 
263
                                            }
264
                                        }
265
                                    %>
1572 jmachado 266
 
267
                                            <!-- GRUPO PERGUNTAS "e" esforço e1, e2, etc-->
268
                                    <%
269
                                        boolean umaQuestão = false;
270
                                        for(int e = 1; e <= 10; e++)
271
                                        {
272
                                            request.setAttribute("e",e);
1621 jmachado 273
                                            Object eGroupObj = QuestionarioImpl.class.getMethod("getE" + e + "Group").invoke(questionario);
274
                                            if(eGroupObj == null)
275
                                                continue;
276
                                            String eGroup = (String) eGroupObj;
277
 
278
                                            if(eGroup.equals(groupNumber))
1572 jmachado 279
                                            {
280
                                                if(!umaQuestão)
281
                                                {
282
                                                    umaQuestão = true;
283
                                            %>
284
                                                <tr>
285
                                                    <th colspan="6">
286
                                                        Questões relativas a esforço mensuradas em horas de dedicação
287
                                                    </th>
288
                                                </tr>
289
                                            <%
290
                                                }
291
                                                String pergunta = (String) QuestionarioImpl.class.getMethod("getE" + e).invoke(questionario);
292
 
293
                                                String resposta = (String) QuestionarioResposta.class.getMethod("getRe" + e).invoke(QuestionarioRespostaForm.getResposta());
294
 
295
                                                String naoRespondida = resposta != null && Long.parseLong(resposta) > 0 ? "respondida":" nao-respondida";
296
 
297
                                                //TODO VER AQUI O pergunta
298
                                    %>
299
                                                <tr id="perguntaE${e}" class="pergunta <%=naoRespondida%>">
300
                                                    <td>
301
 
302
                                                        <%=pergunta%>
303
                                                        <html:hidden property="resposta.timeEventRe${e}" styleId="timeEventRe${e}"/>
304
                                                        <html:hidden property="resposta.timeTakenRe${e}" styleId="timeTakenRe${e}"/>
305
                                                    </td>
306
                                                    <td style="padding-left: 10px"><html:radio property="resposta.re${e}" value="1" onclick="addEvent('timeEventRe${e}','timeTakenRe${e}');">menos de 1 hora</html:radio></td>
1655 jmachado 307
                                                    <td style="padding-left: 10px"><html:radio property="resposta.re${e}" value="2" onclick="addEvent('timeEventRe${e}','timeTakenRe${e}');">1 a 5 horas</html:radio></td>
308
                                                    <td style="padding-left: 10px"><html:radio property="resposta.re${e}" value="3" onclick="addEvent('timeEventRe${e}','timeTakenRe${e}');">5 a 10 horas</html:radio></td>
309
                                                    <td style="padding-left: 10px"><html:radio property="resposta.re${e}" value="4" onclick="addEvent('timeEventRe${e}','timeTakenRe${e}');">10 a 15 horas</html:radio></td>
310
                                                    <td style="padding-left: 10px"><html:radio property="resposta.re${e}" value="5" onclick="addEvent('timeEventRe${e}','timeTakenRe${e}');">mais de 15 horas</html:radio></td>
1572 jmachado 311
 
312
 
313
                                                </tr>
314
                                    <%
315
 
316
                                            }
317
                                        }
318
                                    %>
1407 jmachado 319
                                        </table>
320
                                    </div>
321
                                </div>
322
                    <%
323
                            }
324
 
325
                        }
326
                    %>
327
 
328
 
1411 jmachado 329
                    <button class="btn btn-success" type="button" id="submeterBtn">Submeter</button>
1407 jmachado 330
                </html:form>
331
            </div>
332
        </div>
333
<%
334
    }
335
    AbstractDao.getCurrentSession().getTransaction().commit();
336
%>