Subversion Repositories bacoAlunos

Compare Revisions

Ignore whitespace Rev 1379 → Rev 1380

/branches/v3/impl/conf/language/MessageResources.properties
587,6 → 587,8
targetService.pt.estgp.estgweb.services.sigesimports.GenerateCourseUnitProgramsService=Gerar PDF's Fichas Curriculares
targetService.pt.estgp.estgweb.services.questionarios.pedagogico.UpdateCoursesAndUnitsJobService=Selecção de Cursos Questionários
targetService.pt.estgp.estgweb.services.questionarios.pedagogico.AssignAnswersJobService=Atribuição de Respostas a Questionários
targetService.pt.estgp.estgweb.services.questionarios.pedagogico.TeachersAnswersProcessor=Atribuição de Respostas a Questionários de Docentes
targetService.pt.estgp.estgweb.services.questionarios.pedagogico.AnswersAlunosProcessor=Atribuição de Respostas a Questionários de Alunos
targetService.pt.estgp.estgweb.services.courses.CourseUnitsStatisticsJobService=Gerar Estatisticas Unidades Curriculares
 
 
/branches/v3/impl/src/java/pt/estgp/estgweb/services/questionarios/pedagogico/TeachersAnswersProcessor.java
New file
0,0 → 1,91
package pt.estgp.estgweb.services.questionarios.pedagogico;
 
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.QuestionarioImpl;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.jobs.ServiceJob;
import pt.estgp.estgweb.services.logresults.ILogMessages;
import pt.estgp.estgweb.services.logresults.LogMessageTypeEnum;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessage;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessages;
 
/**
* Created by jorgemachado on 28/05/16.
*/
public class TeachersAnswersProcessor extends ServiceJob {
 
private static Logger logger = Logger.getLogger(TeachersAnswersProcessor.class);
/**
*
* @return
* @throws Throwable
*/
@Override
protected ILogMessages runJobServiceTask() throws Throwable
{
 
DefaultLogMessages logMessages = new DefaultLogMessages();
long questionarioId = Long.parseLong(getParametersMap().get(ServiceJob.JOB_questionario_id_KEY).getObject());
QuestionarioImpl q = (QuestionarioImpl) DaoFactory.getQuestionarioDaoImpl().load(questionarioId);
 
 
//Colocamos já aqui o estado para nao se poder mudar o Ano e o Semestre
 
/**logging**/
String msg = "Starting running service answers generation for questionario: " + q.getId() + " - " + q.getiAnswersProcessorClass().getTitle();
serviceLogInfo(msg);
logger.info(msg);
/**logging**/
 
/*List<String> newCourseCodesList = new ArrayList<String>();
int count = 0;
int totalCourses = coursesList.length;
for(String courseStrId: coursesList)
{
count++;*/
try{
/*Long courseLong = Long.parseLong(courseStrId);
/** logging **/
//msg = "Loading Course BACO ID: " + courseStrId;
//serviceLogInfo(msg);
//logger.info(msg);
/** logging **/
 
 
 
/** COMMIT OPERATION **/
//setProgress((int)((((float)count)/((float)totalCourses))*100.0f));
//commitPartially();
//DaoFactory.getQuestionarioDaoImpl().update(q);
/** COMMIT OPERATION **/
}
catch(Throwable t)
{
logger.error(t,t);
serviceLogError(t.toString(),t);
logMessages.addMessage(new DefaultLogMessage("questionario.courses.selection", LogMessageTypeEnum.ERROR,t.toString()));
}
 
//}
 
 
//removeUnselectedCourses(q, newCourseCodesList);
 
/** COMMIT OPERATION **/
setProgress(100);
commitPartially();
DaoFactory.getQuestionarioDaoImpl().update(q);
/** COMMIT OPERATION **/
 
//TODO FALTA VERIFICAR SE HA COISAS DEPENDENTES DO COURSES_ASSIGNED TEM DE MUDAR PARA OU ANSWERS ASSIGNED
//OIU ENTAO SO DEPOIS DO REVERT E QUE PODEM VOLTAR A ATRIBUIR RESPOSTAS E ALTERAR SELECAO DE CURSOS
 
msg = "Set courses state as " + QuestionarioImpl.SubStatePedagogico.ANSWERS_ASSIGNED.name();
serviceLogInfo(msg);
logger.info(msg);
q.setSubStatePedagogicoClass(QuestionarioImpl.SubStatePedagogico.ANSWERS_ASSIGNED);
commitPartially();
 
return logMessages;
}
}
/branches/v3/impl/src/java/pt/estgp/estgweb/services/questionarios/pedagogico/AssignAnswersJobService.java
2,13 → 2,8
 
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.*;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.jobs.JobDeamon;
import pt.estgp.estgweb.services.jobs.ServiceJob;
import pt.estgp.estgweb.services.logresults.ILogMessages;
import pt.estgp.estgweb.services.logresults.LogMessageTypeEnum;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessage;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessages;
import pt.estgp.estgweb.web.exceptions.NotAuthorizedException;
import pt.utl.ist.berserk.logic.serviceManager.IService;
 
19,7 → 14,7
/**
* Created by jorgemachado on 22/03/16.
*/
public class AssignAnswersJobService extends ServiceJob implements IService
public class AssignAnswersJobService implements IService
{
 
public static final Logger logger = Logger.getLogger(AssignAnswersJobService.class);
47,7 → 42,7
paramJob.setObject("" + questionarioId);
paramsJob.add(paramJob);
 
JobServiceTask job = JobDeamon.createServiceJob(AssignAnswersJobService.class, session.getUser(), paramsJob,
JobServiceTask job = JobDeamon.createServiceJob(questionarioCleared.getiAnswersProcessorClass().getJobServiceTaskAnswersProcessor(), session.getUser(), paramsJob,
"Service: Atribuição de Respostas a um questionário Pedagógico");
questionarioCleared.setAnswerGenerationTaskId(job.getId());
 
56,78 → 51,6
 
 
 
/**
*
* @return
* @throws Throwable
*/
@Override
protected ILogMessages runJobServiceTask() throws Throwable
{
 
DefaultLogMessages logMessages = new DefaultLogMessages();
long questionarioId = Long.parseLong(getParametersMap().get(ServiceJob.JOB_questionario_id_KEY).getObject());
QuestionarioImpl q = (QuestionarioImpl) DaoFactory.getQuestionarioDaoImpl().load(questionarioId);
 
 
//Colocamos já aqui o estado para nao se poder mudar o Ano e o Semestre
 
/**logging**/
String msg = "Starting running service answers generation for questionario: " + q.getId() + " - " + q.getiAnswersProcessorClass().getTitle();
serviceLogInfo(msg);
logger.info(msg);
/**logging**/
 
/*List<String> newCourseCodesList = new ArrayList<String>();
int count = 0;
int totalCourses = coursesList.length;
for(String courseStrId: coursesList)
{
count++;*/
try{
/*Long courseLong = Long.parseLong(courseStrId);
/** logging **/
//msg = "Loading Course BACO ID: " + courseStrId;
//serviceLogInfo(msg);
//logger.info(msg);
/** logging **/
 
 
 
/** COMMIT OPERATION **/
//setProgress((int)((((float)count)/((float)totalCourses))*100.0f));
//commitPartially();
//DaoFactory.getQuestionarioDaoImpl().update(q);
/** COMMIT OPERATION **/
}
catch(Throwable t)
{
logger.error(t,t);
serviceLogError(t.toString(),t);
logMessages.addMessage(new DefaultLogMessage("questionario.courses.selection", LogMessageTypeEnum.ERROR,t.toString()));
}
 
//}
 
 
//removeUnselectedCourses(q, newCourseCodesList);
 
/** COMMIT OPERATION **/
setProgress(100);
commitPartially();
DaoFactory.getQuestionarioDaoImpl().update(q);
/** COMMIT OPERATION **/
 
//TODO FALTA VERIFICAR SE HA COISAS DEPENDENTES DO COURSES_ASSIGNED TEM DE MUDAR PARA OU ANSWERS ASSIGNED
//OIU ENTAO SO DEPOIS DO REVERT E QUE PODEM VOLTAR A ATRIBUIR RESPOSTAS E ALTERAR SELECAO DE CURSOS
 
msg = "Set courses state as " + QuestionarioImpl.SubStatePedagogico.ANSWERS_ASSIGNED.name();
serviceLogInfo(msg);
logger.info(msg);
q.setSubStatePedagogicoClass(QuestionarioImpl.SubStatePedagogico.ANSWERS_ASSIGNED);
commitPartially();
 
return logMessages;
}
 
}
/branches/v3/impl/src/java/pt/estgp/estgweb/services/questionarios/pedagogico/AnswersAlunosProcessor.java
New file
0,0 → 1,178
package pt.estgp.estgweb.services.questionarios.pedagogico;
 
import org.apache.log4j.Logger;
import pt.estgp.estgweb.domain.CourseUnitImpl;
import pt.estgp.estgweb.domain.QuestionarioImpl;
import pt.estgp.estgweb.domain.QuestionarioPedagogicoCursoAfeto;
import pt.estgp.estgweb.domain.QuestionarioPedagogicoUnidadeCurricularAfeta;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.services.jobs.ServiceJob;
import pt.estgp.estgweb.services.logresults.ILogMessages;
import pt.estgp.estgweb.services.logresults.LogMessageTypeEnum;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessage;
import pt.estgp.estgweb.services.logresults.impl.DefaultLogMessages;
 
import java.util.List;
 
 
/**
* Created by jorgemachado on 28/05/16.
*/
public class AnswersAlunosProcessor extends ServiceJob {
 
int unidadesNaoUtilizadas = 0;
int unidadesUtilizadas = 0;
int unidadesMarcadas = 0;
int unidadesNaoVistasProf = 0;
int unidadesNaoVistasAlunos = 0;
int cursosUtilizados = 0;
 
private static Logger logger = Logger.getLogger(AnswersAlunosProcessor.class);
/**
*
* @return
* @throws Throwable
*/
@Override
protected ILogMessages runJobServiceTask() throws Throwable
{
 
DefaultLogMessages logMessages = new DefaultLogMessages();
long questionarioId = Long.parseLong(getParametersMap().get(ServiceJob.JOB_questionario_id_KEY).getObject());
QuestionarioImpl q = (QuestionarioImpl) DaoFactory.getQuestionarioDaoImpl().load(questionarioId);
 
 
//Colocamos já aqui o estado para nao se poder mudar o Ano e o Semestre
 
/**logging**/
String msg = "Starting running service answers generation for questionario: " + q.getId() + " - " + q.getiAnswersProcessorClass().getTitle();
serviceLogInfo(msg);
logger.info(msg);
 
List<Long> cursosAfetosIds = DaoFactory.getQuestionarioPedagogicoCursoAfetoDaoImpl().findCursosAfetosIds(questionarioId);
int count = 0;
for(Long cursoAfetoId : cursosAfetosIds)
{
/** COMMIT OPERATION **/
count++;
cursosUtilizados++;
setProgress((int)((((float)count)/((float)cursosAfetosIds.size()))*100.0f));
commitPartially();
/** COMMIT OPERATION **/
 
 
QuestionarioPedagogicoCursoAfeto cu = DaoFactory.getQuestionarioPedagogicoCursoAfetoDaoImpl().get(cursoAfetoId);
msg = "(+) Iniciando atribuição de respostas de alunos para o curso " + cu.getNome() + " (" + cu.getCodigoCurso() + ") escola " + cu.getNomeInstituicao() + "(" + cu.getCodigoInstituicao() + ")";
logger.info(msg);
serviceLogInfo(msg);
int unidades;
if(cu.getUnidadesAfetas() != null)
{
unidades = cu.getUnidadesAfetas().size();
int countUnidadades = 0;
for(QuestionarioPedagogicoUnidadeCurricularAfeta unidadeCurricularAfeta: cu.getUnidadesAfetas())
{
countUnidadades++;
msg = unidadeCurricularAfeta.isUsar() ? "(+)" : "(----IGNORADA-----)";
msg += "(" + countUnidadades + "/" + unidades + ") Iniciando atribuição de Unidade Curricular Afeta " + unidadeCurricularAfeta.getCodigoUnidade() + " - " + unidadeCurricularAfeta.getNome();
logger.info(msg);
serviceLogInfo(msg);
 
VerificarAssgnementsParaRemover(logMessages, unidadeCurricularAfeta);
 
if(!unidadeCurricularAfeta.isUsar())
{
unidadesNaoUtilizadas++;
msg = "!!! A unidade está marcada para NÃO SER UTILIZADA, passando à próxima";
serviceLogWarn(msg);
logger.warn(msg);
logMessages.addMessage(new DefaultLogMessage("questionario.courses.selection", LogMessageTypeEnum.WARNING,msg));
}
else
{
unidadesUtilizadas++;
verificaAlertasUnidade(logMessages, unidadeCurricularAfeta);
List<CourseUnitImpl.Tipologia> tipologias;
if(unidadeCurricularAfeta.getCursoAfeto().isUsarTipologias())
{
tipologias = ((CourseUnitImpl)unidadeCurricularAfeta.getCourseUnit()).getTipologiasClass().obtainMergeTipologias();
}
else
{
tipologias = ((CourseUnitImpl)unidadeCurricularAfeta.getCourseUnit()).getTipologiasClass().obtainTipologiasSimples(unidadeCurricularAfeta.getCourseUnit());
}
if(tipologias.get(0).isUse())
{
//todo Criar Tipologia Requisitada
String cdDocente = tipologias.get(0).getCdDocente();
String cdTipologia = tipologias.get(0).getCdTipologia();
String dsTipologia = tipologias.get(0).getDsTipologia();
String cdTurma = tipologias.get(0).getCdTurma();
//todo percorrer as turmas da unidade à procura desta
//todo quando a encontrar criar um AlunoRequisitado para essa tipologia Requisitada
//todo Criar uma resposta requisitada para esse aluno Requisitado nessa tipologia
 
//Depois o home tem de procurar respostas requisitadas sem resposta
//para cada uma vai pelo aluno requisitado buscar a turma o docente e pela
//unidade afeta a unidade e o curso
//apresenta o questionario com o id da resposta requisitada
 
}
}
}
}
}
 
/** COMMIT OPERATION **/
setProgress(100);
commitPartially();
DaoFactory.getQuestionarioDaoImpl().update(q);
/** COMMIT OPERATION **/
 
msg = "Set courses state as " + QuestionarioImpl.SubStatePedagogico.ANSWERS_ASSIGNED.name();
serviceLogInfo(msg);
logger.info(msg);
q.setSubStatePedagogicoClass(QuestionarioImpl.SubStatePedagogico.ANSWERS_ASSIGNED);
commitPartially();
 
return logMessages;
}
 
private void VerificarAssgnementsParaRemover(DefaultLogMessages logMessages, QuestionarioPedagogicoUnidadeCurricularAfeta unidadeCurricularAfeta) {
String msg;
if(unidadeCurricularAfeta.getTipologiasRequisitadas() != null && unidadeCurricularAfeta.getTipologiasRequisitadas().size() > 0)
{
msg = "A unidade tem tipologias requisitadas afetas que tem de ser removidas primeiro, iremos remover todas as tipologias e respostas associadas";
logger.warn(msg);
serviceLogWarn(msg);
logMessages.addMessage(new DefaultLogMessage("questionario.courses.selection", LogMessageTypeEnum.WARNING,msg));
new UpdateCoursesAndUnitsJobService().removeTipologiasERespostasCascade(unidadeCurricularAfeta);
}
}
 
private void verificaAlertasUnidade(DefaultLogMessages logMessages, QuestionarioPedagogicoUnidadeCurricularAfeta unidadeCurricularAfeta) {
String msg;
if(unidadeCurricularAfeta.isMarked() || !unidadeCurricularAfeta.isVista() || !unidadeCurricularAfeta.isVistaProfs())
{
msg = " !!!! ALERTA :--> ";
if(unidadeCurricularAfeta.isMarked())
{
unidadesMarcadas++;
msg+= " MARCADA ; ";
}
if(!unidadeCurricularAfeta.isVista())
{
unidadesNaoVistasAlunos++;
msg+= " NÃO VISTA ALUNOS ; ";
}
if(!unidadeCurricularAfeta.isVistaProfs())
{
unidadesNaoVistasProf++;
msg+= " NÃO VISTA PROFS ; ";
}
serviceLogWarn(msg);
logger.warn(msg);
logMessages.addMessage(new DefaultLogMessage("questionario.courses.selection", LogMessageTypeEnum.WARNING,msg));
}
}
}
/branches/v3/impl/src/java/pt/estgp/estgweb/services/questionarios/pedagogico/UpdateCoursesAndUnitsJobService.java
179,7 → 179,7
/**
*
*/
private void removeTipologiasERespostasCascade(QuestionarioPedagogicoUnidadeCurricularAfeta unidadeAfeta)
protected void removeTipologiasERespostasCascade(QuestionarioPedagogicoUnidadeCurricularAfeta unidadeAfeta)
{
for(QuestionarioPedagogicoTipologiaRequisitada tr: unidadeAfeta.getTipologiasRequisitadas())
{
/branches/v3/impl/src/java/pt/estgp/estgweb/services/questionarios/PedagogicoAlunosProcessor.java
7,6 → 7,7
import pt.estgp.estgweb.domain.UserSessionImpl;
import pt.estgp.estgweb.domain.dao.DaoFactory;
import pt.estgp.estgweb.domain.utils.SimpleClearanceRuledSupport;
import pt.estgp.estgweb.services.questionarios.pedagogico.AnswersAlunosProcessor;
import pt.estgp.estgweb.services.questionarios.pedagogico.UpdateCoursesAndUnitsJobService;
import pt.estgp.estgweb.utils.ConfigProperties;
 
148,4 → 149,11
}
 
}
 
@Override
public Class getJobServiceTaskAnswersProcessor() {
return AnswersAlunosProcessor.class;
}
 
 
}
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/IAnswersProcessor.java
20,4 → 20,6
/** to be used on clearances initialization**/
public void initClearances(QuestionarioImpl questionario, UserSessionImpl session, SimpleClearanceRuledSupport s);
 
public Class getJobServiceTaskAnswersProcessor();
 
}
/branches/v3/impl/src/java/pt/estgp/estgweb/domain/dao/impl/QuestionarioPedagogicoCursoAfetoDaoImpl.java
2,6 → 2,7
 
import jomm.dao.impl.AbstractDao;
import org.hibernate.Query;
import org.hibernate.criterion.Projections;
import pt.estgp.estgweb.domain.QuestionarioPedagogicoCursoAfeto;
 
import java.util.List;
33,9 → 34,17
.list();
}
 
public List<Long> findCursosAfetosIds(long questionarioId)
{
return createCriteria()
.setProjection(Projections.distinct(Projections.property("id")))
.add(eq("questionario.id", questionarioId))
.list();
}
 
 
 
 
public static class CourseStatsVars
{
public long unidades;
/branches/v3/impl/src/web/user/home/studentPae.jsp
New file
0,0 → 1,22
<%@ page import="jomm.utils.MessageResources" %>
<%@ page import="pt.estgp.estgweb.Globals" %>
<%@ page import="pt.estgp.estgweb.domain.CourseUnit" %>
<%@ page import="pt.estgp.estgweb.domain.StudentImpl" %>
<%@ page import="pt.estgp.estgweb.domain.dao.DaoFactory" %>
<%@ page import="pt.estgp.estgweb.domain.views.AnnouncementView" %>
<%@ page import="pt.estgp.estgweb.utils.DatesUtils" %>
<%@ page import="pt.estgp.estgweb.web.utils.RequestUtils" %>
<%@ page import="pt.utl.ist.berserk.logic.serviceManager.IServiceManager" %>
<%@ page import="pt.utl.ist.berserk.logic.serviceManager.ServiceManager" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/tlds/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/tlds/baco.tld" prefix="baco" %>
<%@ taglib uri="/WEB-INF/tlds/jomm.tld" prefix="jomm" %>
<jsp:useBean id="UserSession" type="pt.estgp.estgweb.domain.UserSession" scope="request"/>
 
 
/branches/v3/impl/src/web/user/questionarios/pedagogicoEstudante/questionarioAdminPanel.jsp
168,7 → 168,7
</baco:clearOperation>
 
<baco:clearOperation name="Questionario" op="QUESTIONARIO_FINNISH_ASSIGNEMENTS">
<button class="btn btn-success pullright" type="button" >Terminar Atribuições</button>
<button class="btn btn-success pull-right" type="button" >Terminar Atribuições</button>
</baco:clearOperation>
</div>
</div>
/branches/v3/impl/src/web/user/questionarios/pedagogicoEstudante/pedagogicoEstudanteCoursesCheck.jsp
460,7 → 460,7
</div>
<div class="col-sm-12">
 
<button id="updateTipologiasButton" class="btn btn-success">Atualizar Tipologias</button>
<button id="updateTipologiasButton" class="btn btn-success pull-right">Atualizar Tipologias</button>
<html:link action="/user/adminQuestionario?questionario.id=${Questionario.id}#NOWTASK" styleClass="btn btn-danger">Voltar à administração</html:link>
</div>
</div>