Example #1
0
 def recursos_asig(self, ident):
     '''
     Devuelve la lista de recursos de una asignatura
     '''
     d = select_all_by_subject(ident)
     a = d.fetchall()
     return list(dedupe([reg['resource'] for reg in a]))
Example #2
0
 def all_aula_text(self):
     '''
     devuelve todos los nombres de las aulas
     '''
     d = search_resource_by_type(resourcetype='Room')
     a = d.fetchall()
     temp = list(dedupe( [(reg['resource'],reg['D.name']) for reg in a]))
     temp.sort(key = lambda x:x[1])
     self.set_aula_text =  [i[1] for i in temp]
     return self.set_aula_text
Example #3
0
 def all_prof_text(self):
     '''
     devuelve todos los nombres de los profesores
     '''
     d = search_resource_by_type(resourcetype='Teacher')
     a = d.fetchall()
     temp = list(dedupe( [(reg['resource'],reg['D.name']) for reg in a]))
     new_temp = []
     for i,j in temp:
         l0 = j.split()
         if len(l0)>2:
             variable = ' '.join(l0[:-2])
             l0 = f'{l0[-2]} {l0[-1]}, {variable}'
         else:
             l0 = f'{l0[1]}, {l0[0]}'
         new_temp.append((i,l0))
     temp = new_temp
     temp.sort(key = lambda x:x[1])
     self.set_prof_text =  [i[1] for i in temp]
     return self.set_prof_text
Example #4
0
 def contain(self, datos):
     '''
     devuelve listas de registros que contengan alguno de los elementos en datos.
     El formato tiene que ser (AULA_ID,ASIG_ID,TIME_ID,NOMBRE_ASIG,NOMBRE_AULA)
     '''
     #TODO: Ahora lo que hago es coger todas las asignaturas, coger el identificador y adelante.
     # Esto puede dar problemas
     cursor_d = mostrar_todas_asignaturas()
     nombres = cursor_d.fetchall()
     nombres = {d['id']: d['name'] for d in nombres}
     result = []
     for dato in datos:
         codigo = dato.split('_')[0]
         nombre_asig = nombres[codigo]
         for d in mostrar_todo_asignatura(codigo).fetchall():
             result.append((d['name'].replace(' ', '_'),
                            d['id'],
                            d['time'],
                            nombre_asig,
                            d['name']
             ))
     return list(dedupe(result))
Example #5
0
 def contain2(self, datos):
     '''
     devuelve listas de registros que contengan alguno de los elementos en datos.
     El formato tiene que ser (AULA_ID,ASIG_ID,TIME_ID,NOMBRE_ASIG,NOMBRE_AULA)
     '''
     #TODO: Ahora lo que hago es coger todas las asignaturas, coger el identificador y adelante.
     # Esto puede dar problemas
     result = []
     d = search_resource_by_type()
     all_events = d.fetchall()
     for reg in all_events:
         if any(dato in reg.values() for dato in datos):
             aula_id = 'AULA_8'
             asig_id = reg['id']
             for temp in select_all_by_subject(asig_id).fetchall():
                 if 'LABORATORIO' in temp['resource'] or 'AULA' in temp['resource']:
                     aula_id = temp['resource']
             time_id = reg['time']
             nombre_asig = reg['name']
             nombre_aula = aula_id.replace('_', ' ')
             result.append((aula_id,asig_id, time_id, nombre_asig, nombre_aula))
     return list(dedupe(result))
Example #6
0
    def __init__(self, horarioPrincipal, filterTotal, bd, **kwargs):
        ''' Inicialización del horario '''

        timeTable = horarioPrincipal
        filterLoad = filterTotal
        self.bd = bd
        super(Boxes, self).__init__(**kwargs)
        #añado los botones al horario
        for dia in horarioPrincipal.dias:
            bx_m = BoxLayout(orientation='vertical')  #mañana
            bx_t = BoxLayout(orientation='vertical')  #tarde
            bx_m_f = BoxLayout(orientation='vertical')  #mañana_free
            bx_t_f = BoxLayout(orientation='vertical')  #tarde_free
            relleno = [
                [9, bx_m, '_morning', horarioPrincipal.clases_manana],
                [15, bx_t, '_afternoon', horarioPrincipal.clases_tarde],
                [9, bx_m_f, '_morning_free', horarioPrincipal.clases_manana],
                [15, bx_t_f, '_afternoon_free', horarioPrincipal.clases_tarde]
            ]
            for hour, bx_iter, turno, asignacion in relleno:

                #añado las cabeceras (dias)
                nombre = dia
                btn = Boton(text=nombre, size_hint_y=0.02)
                btn.setIdent(nombre)
                bx_iter.add_widget(btn)

                #Botones  (Clase/Aula/Hora)
                for texto, porcentaje, asignaturaID, aulaID in asignacion(
                        nombre):
                    btn = Boton(text=texto, size_hint_y=porcentaje)
                    btn.bind(on_release=lambda x: self.intercambia(
                        horario=horarioPrincipal))
                    btn.setIdent(hour)
                    btn.setAsigID(asignaturaID)
                    btn.setAulaID(aulaID)
                    btn.text_size = (300, 100)
                    bx_iter.add_widget(btn)
                    hour = hour + 1
                self.ids[turno].add_widget(bx_iter)

        #Añado los desplegables de selección a la primera pantalla
        profes = FilterDDTrigger(orientation='vertical')
        aulas = FilterDDTrigger(orientation='vertical')
        asigns = FilterDDTrigger(orientation='vertical')
        curs = FilterDDTrigger(orientation='vertical')
        aulas_libres = FilterDDTrigger(orientation='vertical')
        profText = self.bd.all_prof_text()
        profId = self.bd.all_prof_id()
        aulaText = self.bd.all_aula_text()
        aulaId = self.bd.all_aula_id()
        cursoText = self.bd.all_curso_text()
        cursoId = self.bd.all_curso_id()
        asigText = self.bd.all_asignatura_text()
        asigId = self.bd.all_asignatura_id()
        # No voy a dividir a los cursos por grupos de practicas
        temporal = list(
            dedupe([(c_i, c_t[0:-10]) for c_i, c_t in zip(cursoId, cursoText)],
                   key=lambda x: x[1]))
        cursoText = [i[1] for i in temporal]
        cursoId = [i[0] for i in temporal]
        datos_scroll = [(profes, 'Profesores', 350, profText, profId),
                        (aulas, 'Aulas', 250, aulaText, aulaId),
                        (asigns, 'Asignaturas', 350, asigText, asigId),
                        (curs, 'Cursos', 350, cursoText, cursoId)]
        loadSelection = Button(text='Cargar selección',
                               size_hint=(None, None),
                               width=200)
        loadSelection.bind(
            on_release=lambda btn: self.loadTimetable(horarioPrincipal))
        self.ids['_main'].add_widget(loadSelection)
        for tipo_scroll, nombre_scroll, tamano, tupla_text, tupla_id in datos_scroll:
            tipo_scroll.text = nombre_scroll
            tipo_scroll.dropdown = FilterDD(width=tamano,
                                            des=tipo_scroll,
                                            options=zip(tupla_text, tupla_id))
            self.ids['_main'].add_widget(tipo_scroll)
        nInc = 0
        for incidencia in self.bd.colisiones():
            btn = Button(text=incidencia)
            self.ids['_incidences'].add_widget(btn)
            nInc += 1
            if nInc >= self.numIncidences:
                break
        self.children[1].children[0].children[
            2].text = 'Acción: Intercambiar asignaturas'
        self.resetDropdown()
Example #7
0
 def resetDropdown(self):
     #Añado los desplegables de selección a la primera pantalla
     profes = FilterDDTrigger(orientation='vertical', height=200)
     aulas = FilterDDTrigger(orientation='vertical', height=200)
     asigns = FilterDDTrigger(orientation='vertical', height=200)
     curs = FilterDDTrigger(orientation='vertical', height=200)
     aulas_libres = FilterDDTrigger(orientation='vertical', height=200)
     profText = self.bd.all_prof_text()
     profId = self.bd.all_prof_id()
     aulaText = self.bd.all_aula_text()
     aulaId = self.bd.all_aula_id()
     cursoText = self.bd.all_curso_text()
     cursoId = self.bd.all_curso_id()
     asigText = self.bd.all_asignatura_text()
     asigId = self.bd.all_asignatura_id()
     temporal = list(
         dedupe([(c_i, c_t[0:-10]) for c_i, c_t in zip(cursoId, cursoText)],
                key=lambda x: x[1]))
     cursoText = [i[1] for i in temporal]
     cursoId = [i[0] for i in temporal]
     for i in range(len(self.ids['_main'].children)):
         print(i, self.ids['_main'].children[i].text)
     datos_scroll = [(profes, 'Profesoresss', 350,
                      self.ids['_main'].children[3], profText, profId),
                     (aulas, 'Aulasss', 300, self.ids['_main'].children[2],
                      aulaText, aulaId),
                     (asigns, 'Asignaturas', 400,
                      self.ids['_main'].children[1], asigText, asigId),
                     (curs, 'Cursos', 400, self.ids['_main'].children[0],
                      cursoText, cursoId)]
     filterLoad = set(self.filterTotal)
     for tipo_scroll, nombre_scroll, tamano, wid_pos, tupla_text, tupla_id in datos_scroll:
         tipo_scroll.text = nombre_scroll
         tipo_scroll.dropdown = FilterDD(width=tamano,
                                         des=tipo_scroll,
                                         options=zip(tupla_text, tupla_id))
         self.ids['_main'].add_widget(tipo_scroll)
     self.children[1].children[0].children[
         0].text = 'Filtro seleccionado: Ninguno'
     for turno in ['_morning', '_afternoon']:
         for pos, j in self.botones_turno(turno):
             if j.getIdent() in self.days:
                 continue
             j.setAsigID('')
             j.setAulaID('')
             texto = "{0}\n{1}\n{2}--{3}".format('Libre', 'Sin Aula', pos,
                                                 pos + 1)
             j.setText(texto)
             j.background_color = [1, 1, 1, 1]
     for turno in ['_morning_free', '_afternoon_free']:
         for pos, j in self.botones_turno(turno):
             dia_id = j.getIdent() if j.getIdent() in self.days else dia_id
             if j.getIdent() in self.days:
                 continue
             aulas_libres = self.bd.aula_libre(dia_id + str(pos))
             texto = []
             for i in ['AULAS', 'LABORATORIOS', 'SEMINARIOS']:
                 contador = 0
                 texto.append(f'\n{i}:')
                 for j0 in aulas_libres:
                     if i[:3] in j0:
                         texto.append(j0.split('_')[-1])
                         contador += 1
                         if contador % 13 == 0:
                             pass
             j.setText(texto[0] + ','.join(texto[1:]))
             j.background_color = [1, 1, 1, 1]
     self.ids['_main'].children[4].disabled = False
     self.lastIdentificador = ''
     self.filterTotal = set()
     self.filterLoad = set()