Exemplo n.º 1
0
    def post(self):

        if (self.request.get('guardar')):
            #NDB
            porcentaje = BD_PorcentajeSuspensosProfes(parent = ndb.Key("Estadisticas_almacenadas","PorcentajeSuspensosProfe"),id_profe=1,porcentaje=0.5)
            porcentaje_key = porcentaje.put()
            #porcentaje = BD_PorcentajeSuspensosProfes(parent = ndb.Key("Estadisticas_almacenadas","PorcentajeSuspensosProfe"),1,0.5)
            #porcentaje.put()
            self.redirect('/configurar_estadisticas')
        if (self.request.get('ver_estadisticas')):
            ancestor_key = ndb.Key("Estadisticas_almacenadas","PorcentajeSuspensosProfe")
            estadisticas_suspensos_profes = BD_PorcentajeSuspensosProfes.estadisticas_guardadas(ancestor_key).fetch(20)
            vector_estadisticas=[];
            for estadistica in estadisticas_suspensos_profes:
                leido =[]
                leido.append(estadistica.fecha)
                leido.append(estadistica.id_profe)
                leido.append(estadistica.porcentaje)
                vector_estadisticas.append(leido)
            self.response.out.write(vector_estadisticas)
                #sprint estadistica.id_profe

            #self.redirect('/configurar_estadisticas')
        if not(self.request.get('orden')):
            plantilla = plantilla_env.get_template('plantilla/index.html')
            self.response.out.write(plantilla.render())

        else:
            string = "Orden no encontrada"
            if(self.request.get('orden')) =="obtenerPorcentajeSuspensosProfesores":
                string = str(Estadisticas.obtenerPorcentajeSuspensosProfesores("SinFiltros"))

            string = string +'<input type="submit" id="guardar" name="guardar" value="Guardar Estadisticas"></input> <input type="submit" name="ver_estadisticas" id="ver_estadisticas" value="Ver Estadisticas anteriores"></input>'
            templateVars = {"texto" : string}
            plantilla = plantilla_env.get_template('plantilla/index.html')
            self.response.out.write(plantilla.render(templateVars))
 def test_getRankingProfeSuspensos(self):
     respuesta = Estadisticas.obtenerPorcentajeSuspensosProfesores("Sin filtro")
     self.assertTrue(len(respuesta))