diff options
author | cecigg <caggsld@gmail.com> | 2014-10-11 16:28:02 (GMT) |
---|---|---|
committer | cecigg <caggsld@gmail.com> | 2014-10-11 16:28:02 (GMT) |
commit | 5be0bbabcdf61d1e684a3c5c284962764940d915 (patch) | |
tree | 22db73b284a50a1b20ae6a6047259693e7e32f87 | |
parent | 5270f36069849801c0949a922ca2b3de031003d4 (diff) |
se agrego sesion
-rw-r--r-- | EjercitarServer/ejbModule/beans/Simulacion.java | 38 | ||||
-rw-r--r-- | EjercitarServer/ejbModule/util/ReadWriteExcel.java | 19 |
2 files changed, 48 insertions, 9 deletions
diff --git a/EjercitarServer/ejbModule/beans/Simulacion.java b/EjercitarServer/ejbModule/beans/Simulacion.java index 5ee614e..69b38a8 100644 --- a/EjercitarServer/ejbModule/beans/Simulacion.java +++ b/EjercitarServer/ejbModule/beans/Simulacion.java @@ -5,13 +5,12 @@ import java.util.List; import java.util.Random; import javax.ejb.EJB; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; import model.Alumno; import model.Asignatura; import model.Curso; import model.Ejercicio; +import model.Sesion; import model.Tarea; public class Simulacion { @@ -41,6 +40,21 @@ public class Simulacion { } + public Integer crearSesion(Integer idAlumno, Integer idTarea){ + String [] estados = {"triste","enamorado","suenho","feliz"}; + Random rnd = new Random(); + int estado = rnd.nextInt(4); + int ayuda = rnd.nextInt(2); + int hogar = rnd.nextInt(2); + String estadoAnimo = estados[estado]; + Boolean ayudaPadres = (ayuda%2==0) ? true:false; + Boolean desdeHogar = (hogar%2==0) ? true:false; + + Integer idSesion = ws.registrarSesion(idAlumno, idTarea, ayudaPadres, desdeHogar, estadoAnimo); + return idSesion; + + } + public List<Alumno> generacionAlumnos(Asignatura asignatura){ Curso curso = asignatura.getCurso(); @@ -73,19 +87,24 @@ public class Simulacion { List<Alumno> alumnos = generacionAlumnos(asignatura); - + for(Alumno alumno : alumnos) { String siguienteEjercicio = ws.getSiguienteEjercicio(tarea.getIdTarea(), alumno.getIdAlumno(), 0, "respuesta"); Boolean parada = false; int cant = 0; - while(!parada) { + Random rnd = new Random(); + + Integer idSesion = crearSesion(alumno.getIdAlumno(), tarea.getIdTarea()); + + + for (int i = 0; i < tarea.getCantidadEjercicioParada(); i++) { String [] ejercicioString = siguienteEjercicio.split("#"); int idEjercicio = Integer.valueOf(ejercicioString[0]); Ejercicio ejercicio = null;//admin.getEjercicio(idEjercicio); - Random rnd = new Random(); + int decision = rnd.nextInt(100); String respuesta = null; int idRespuesta; @@ -102,15 +121,16 @@ public class Simulacion { siguienteEjercicio = ws.getSiguienteEjercicio(tarea.getIdTarea(), alumno.getIdAlumno(), idRespuesta, respuesta); } + + ws.terminarTarea(idSesion); } } public static class TipoAlumno { - public static final Double NIVEL_CONOCIMIENTO_BAJO = 0.0; + public static final Double NIVEL_CONOCIMIENTO_BAJO = 0.1; public static final Double NIVEL_CONOCIMIENTO_MEDIO = 0.5; - public static final Double NIVEL_CONOCIMIENTO_ALTO = 1.0; - - } + public static final Double NIVEL_CONOCIMIENTO_ALTO = 0.9; + } } diff --git a/EjercitarServer/ejbModule/util/ReadWriteExcel.java b/EjercitarServer/ejbModule/util/ReadWriteExcel.java index 248a0bb..4b7deba 100644 --- a/EjercitarServer/ejbModule/util/ReadWriteExcel.java +++ b/EjercitarServer/ejbModule/util/ReadWriteExcel.java @@ -121,4 +121,23 @@ public class ReadWriteExcel { throw new Exception("No se pudo exportar en el archivo"); } } + + public static void main (String []args){ + + File tmpFile = new File ("prueba.xlsx"); + if(tmpFile != null) { + ReadWriteExcel rwExcel = new ReadWriteExcel(); + ArrayList<Object[]> datos = new ArrayList(); + datos.add(new Object[] {new Date(), "a", 1}); + try { + String actual = rwExcel.exportarExcel( + rwExcel.cargarLista(datos, "TEST EXCEL"), + tmpFile.getAbsolutePath()); + + + } catch(Exception e) { + e.printStackTrace(); + } + } + } }
\ No newline at end of file |