Exemplo n.º 1
0
    def process_item(processed_items, index):

        lecture = Lecture()
        lecture.month = processed_items[0]
        lecture.day = processed_items[1]

        title = ''
        for position in range(2, index):
            title += "{} ".format(str(processed_items[position]).lower())
        lecture.title = capwords(title.strip())

        speaker = ''
        for position in range(index + 1, len(processed_items)):
            speaker += "{} ".format(str(processed_items[position]).strip('.').lower().title())
        lecture.speaker = speaker.strip()
        return lecture
Exemplo n.º 2
0
def rofi_list_lectures():
    lectures = CURRENT_PROJECT.course_info
    if not lectures:
        return
    lectures = lectures.get_lectures()
    lectures_str = [str(l) for l in lectures]

    rofi = Rofi(rofi_args=["-i"])
    index, key = rofi.select("Choose a lecture",
                             lectures_str,
                             key4=('Super+o', "Open lecture in Zathura"),
                             key5=('Super+e', "Open tex file in vim"),
                             key6=("Super+n", "Create a new Lecture"))
    if index == -1:
        return

    if key == 4:
        lectures[index].view().execute()
    elif key == 5:
        lectures[index].edit().execute()
    else:
        rofi = Rofi(rofi_args=["-i"])
        title = rofi.text_entry("Title for lecture: ")
        lecture = Lecture.create_new(CURRENT_PROJECT_PATH, title)
        lecture.edit().execute()
Exemplo n.º 3
0
    def test_swap_lectures(self):
        pass
        #Test later, not called in generator at the moment
        lecturer = Lecturer('Benjamin Kommey', 4564541, 'Mr')
        course = Course('Embedded Systems', 'COE 361')

        section = Section('ED CoE', 25, 3,
                          'Electrical and Electronics Engineering',
                          'Computer Engineering')
        c_item = CurriculumItem(section, course, lecturer)

        lecture = Lecture(c_item, 60)

        ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                               TimeSlot('8:00', '9:00'))
        ttslot1 = TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),
                                TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),
                                TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('11:00', '12:00'))
        self.assertTrue(self.timetable.add_lecture('Monday', lecture, ttslot))
        self.assertTrue(self.timetable.add_lecture('Tuesday', lecture,
                                                   ttslot1))
        self.assertTrue(
            self.timetable.add_lecture('Thursday', lecture, ttslot2))
        self.assertTrue(self.timetable.add_lecture('Friday', lecture, ttslot3))
        print(self.timetable)
Exemplo n.º 4
0
 def test_to_list(self):
     lists = [['Teacher name', ['7333'], '122', True],
              ['Teacher name', ['2780.2'], 'КВАНТ-КК', True],
              ['Teacher name', [], '', False]]
     for (l, init_value) in zip(lists, self.init_values):
         lecture = Lecture.cell_parser(init_value)
         self.assertEqual(l, lecture.to_list(teacher_name='Teacher name'))
Exemplo n.º 5
0
    def test_remove_lecture(self):
        #test for removing a lecture from a slot that exists and is occupied
        
        lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
        course = Course('Embedded Systems','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)

        print(self.timetable)
        print('--------TEST - REMOVE-------------------After Adding Lecture-----------------')
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot))
        print(self.timetable)
        self.assertTrue(self.timetable.remove_lecture(ttslot))
        print('-----TEST REMOVE-----------------------After removing Lecture---------------')
        print(self.timetable)

        #test for removing a lecture from a slot that is empty
        self.assertFalse(self.timetable.remove_lecture(ttslot))

        #test for removing a lecture from a slot that does not exists
        self.assertFalse(self.timetable.remove_lecture( TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('7:00', '8:00'))))
Exemplo n.º 6
0
    def test_room_is_free(self):
        lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
        course = Course('Embedded Systems','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)

        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
        ttslot1 =TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('11:00', '12:00'))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot1))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot2))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot3))
        
        self.assertFalse(self.timetable.room_is_free(Classroom('LT ', 45, 'PBOO2'),TimeSlot('7:00', '8:00')))
        self.assertFalse(self.timetable.room_is_free(Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00')))
        self.assertFalse(self.timetable.room_is_free(Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00')))
        self.assertFalse(self.timetable.room_is_free(Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '11:00')))

        self.assertTrue(self.timetable.room_is_free(Classroom('LT ', 45, 'PBOO2'),TimeSlot('12:00', '13:00')))
        self.assertTrue(self.timetable.room_is_free(Classroom('LT ', 45, 'PBOO2'),TimeSlot('13:00', '14:00')))
        self.assertTrue(self.timetable.room_is_free(Classroom('LT ', 45, 'PBOO2'),TimeSlot('14:00', '15:00')))
        self.assertTrue(self.timetable.room_is_free(Classroom('LT ', 45, 'PBOO2'),TimeSlot('15:00', '16:00')))
Exemplo n.º 7
0
    def test_all_slots(self):
        lecturer = Lecturer('Benjamin Kommey', 4564541, 'Mr')
        course = Course('Embedded Systems', 'COE 361')

        section = Section('ED CoE', 25, 3,
                          'Electrical and Electronics Engineering',
                          'Computer Engineering')
        c_item = CurriculumItem(section, course, lecturer)

        lecture = Lecture(c_item, 60)

        ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                               TimeSlot('8:00', '9:00'))
        ttslot1 = TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),
                                TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),
                                TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('11:00', '12:00'))
        ttslot4 = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('10:00', '11:00'))

        #print(self.timetable)
        self.assertTrue(self.timetable.add_lecture('Monday', lecture, ttslot))
        self.assertTrue(self.timetable.add_lecture('Tuesday', lecture,
                                                   ttslot1))
        self.assertTrue(
            self.timetable.add_lecture('Thursday', lecture, ttslot2))
        self.assertTrue(self.timetable.add_lecture('Friday', lecture, ttslot3))
        print("############ Testing All Slots##############################")
        slots = self.timetable.all_slots()

        for slot in slots:
            print(slot)
Exemplo n.º 8
0
    def __init__(self, lectures: List[Lecture], agenda: List[str] = []):
        self.schedule = {}
        self.agenda = agenda

        def is_course_in_agenda(lecture: Lecture, agenda: List[str]):
            if not agenda:
                return True

            for course in agenda:
                if lecture.course.lower().find(course.lower()) >= 0:
                    return True
            else:
                return False

        for hour in hours:
            self.schedule[hour] = []

            filtered = [
                Lecture(
                    course=l.course,
                    room=l.room,
                    begin=l.begin.replace(hour=hour.hour, minute=hour.minute),
                    end=l.end.replace(hour=(hour + timedelta(hours=1)).hour),
                    day=l.day,
                ) for l in lectures if l.begin.hour <= hour.hour < l.end.hour
                and is_course_in_agenda(l, self.agenda)
            ]

            for day in range(0, 5):
                day_lectures = list(filter(lambda l: l.day == day, filtered))
                self.schedule[hour].append(day_lectures)
Exemplo n.º 9
0
    def getPendingCount(lector):
        """Vrátí počet nevyřízených zadání"""
        lectures = Lecture.getAll(lector)
        ids = [ str(lecture.lecture_id) for lecture in lectures ]
    
        if len(ids) == 0: return 0

        c = query('SELECT COUNT(*) AS cnt FROM assigments WHERE (state = ?) AND lecture_id IN (%s)' % (",".join(ids)) , (Model.STATE_LOCKED,) )
        
        return c.fetchone()["cnt"]
Exemplo n.º 10
0
    def get_lectures(self):
        lectures = []
        for root, dir_names, file_names in walk(
                path.join(self.project_root, "lectures")):
            for name in file_names:
                if name.endswith(".tex") and not name.startswith("preamble"):
                    lectures.append(Lecture(path.join(root, name)))

        lectures.sort(key=lambda x: x.date, reverse=True)
        return lectures
Exemplo n.º 11
0
    def test_move_lecture(self):
         #test for moving lecture from a slot that is occupied

        #first create a new lecture and then add it to a slot
        lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
        course = Course('Embedded Systems','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)

        print(self.timetable)
        print('---------------------------After Adding Lecture-----------------')
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot))
        print(self.timetable)

         #test for moving lecture from a slot that is not occupied

        self.assertFalse(self.timetable.move_lecture(TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '11:00')),
        TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('14:00', '15:00'))))
        print('---------------------After attempting wrong move-------------------')
        print(self.timetable)

         #test for moving lecture to a slot that is not occupied
        self.assertTrue(self.timetable.move_lecture(TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00')),
        TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '11:00'))
        ))
        print('------------------------------After moving lecture (unoccupied)-------------------------')
        print(self.timetable)
         #test for moving lecture to a slot that is occupied with free as True
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('9:00', '10:00'))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot))
        self.assertFalse(self.timetable.move_lecture(TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00')),
        TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '11:00'))
        ))
        print(self.timetable)

        #test for moving lecture to a slot that is not occupied with free as False


        #test for moving a lecture back to itself



        #test for moving from a slot that does not exits 
        self.assertFalse(self.timetable.move_lecture(TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '10:00')),
        TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '11:00'))
        ))

        #test for moving to a slot that does not exits 
        self.assertFalse(self.timetable.move_lecture(TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00')),
        TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '12:00'))
        ))
Exemplo n.º 12
0
 def getPending(lector):
     """Vrátí nevyřízená zadání"""
     lectures = Lecture.getAll(lector)
     ids = [ str(lecture.lecture_id) for lecture in lectures ]
     
     if len(ids) == 0: raise StopIteration
     
     c = query('SELECT * FROM assigments WHERE (state = ?) AND lecture_id IN (%s) ORDER BY changed ASC' % (",".join(ids)) , (Model.STATE_LOCKED,) )
     
     for row in c.fetchall():
         yield Model(row)
Exemplo n.º 13
0
 def getForLector(lector):
     """Vrátí zadaná cvičení """
     lectures = Lecture.getAll(lector)
     ids = [ str(lecture.lecture_id) for lecture in lectures ]
     
     if len(ids) == 0: raise StopIteration
     
     c = query('SELECT * FROM assigments WHERE (NOT state = ?) AND lecture_id IN (%s)' % (",".join(ids)) , (Model.STATE_NEW,) )
     
     for row in c.fetchall():
         yield Model(row)            
Exemplo n.º 14
0
 def getSilent(lector):
     """Vrátí zadání, která nepotřebují vyřídit"""
     lectures = Lecture.getAll(lector)
     ids = [ str(lecture.lecture_id) for lecture in lectures ]
     
     if len(ids) == 0: raise StopIteration
     
     c = query('SELECT * FROM assigments WHERE (NOT state = ?) AND lecture_id IN (%s)  ORDER BY state ASC, generated DESC' % (",".join(ids)) , (Model.STATE_LOCKED,) )
     
     for row in c.fetchall():
         yield Model(row)            
Exemplo n.º 15
0
def list():
    """Seznam aktivních cvičení, na které se student může přihlásit"""
    
    usr = getUser() 

    # zjistíme v jaké jsme skupině
    grp = usr.getGroup()
    #todo: assert group != None
      
    lectures = Lecture.getAvailable( grp.lector ) 
    
    return template("assigments_student", {"lectures" : lectures, } )
Exemplo n.º 16
0
def get_speakers():
    if 'lecture_id' in request.args:
        _lecture_id = int(request.args['lecture_id'])
        _lecture = Lecture.get(_lecture_id)
        if _lecture:
            _speaker = _lecture.speaker
            if _speaker:
                return jsonify({'speaker': _speaker, 'lecture': _lecture})
            else:
                abort(404)
        else:
            abort(404)
    return jsonify({'speakers': speakers})
Exemplo n.º 17
0
    def get_lecture(c):
        weekday = int(c["giorno"]) - 1
        day = first_day + timedelta(days=weekday)
        b_hours, b_minutes = map(int, c["ora_inizio"].split(":"))
        e_hours, e_minutes = map(int, c["ora_fine"].split(":"))

        return Lecture(
            course=c["nome_insegnamento"],
            room=c["codice_aula"],
            begin=day.replace(hour=b_hours, minute=b_minutes),
            end=day.replace(hour=e_hours, minute=e_minutes),
            day=weekday,
        )
Exemplo n.º 18
0
    def test_first_fit(self):
        lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
        course = Course('Embedded Systems','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)

        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))

        print('----------------First Fit-----------------------------')
        print(self.timetable.first_fit(lecture))
Exemplo n.º 19
0
    def test_add_lecture(self):

        #test for the case of adding a lecture to a slot that is free with free parameter
        lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
        course = Course('Embedded Systems','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)

        print(self.timetable)
        print('---------------------------After Adding Lecture-----------------')
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot))
        print(self.timetable)

        #test for the case of adding a lecture to a slot that is not free with free parameter
        lecturer = Lecturer('Selasi Agbemenu',4564541,'Mr')
        course = Course('Linear Electronics','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)
        
        print('---------------------------After Adding Lecture to Occupied---------')
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
        self.assertFalse(self.timetable.add_lecture(lecture,ttslot))
        print(self.timetable)
        


        #test for adding a lecture to slot that is not in the timetable 
        print('---------------------------After Adding Lecture to Occupied---------')
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('6:00', '7:00'))
        self.assertFalse(self.timetable.add_lecture(lecture,ttslot))
        print(self.timetable)
Exemplo n.º 20
0
    def test_timetableslot(self):
        lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
        course = Course('Embedded Systems','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)

        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot))
        self.assertEqual(self.timetable.timetableslot(ttslot.room,ttslot.time_slot),ttslot)
        ttslot1 = TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('9:00', '10:00'))
        self.assertEqual(self.timetable.timetableslot(ttslot1.room,ttslot1.time_slot),ttslot1)
Exemplo n.º 21
0
def list():
    """Seznam aktivních cvičení, na které se student může přihlásit"""

    usr = getUser()

    # zjistíme v jaké jsme skupině
    grp = usr.getGroup()
    #todo: assert group != None

    lectures = Lecture.getAvailable(grp.lector)

    return template("assigments_student", {
        "lectures": lectures,
    })
Exemplo n.º 22
0
def parse_days(day):

    lectures = day.find_all('font', attrs={'size': '1'})
    daily_lectures = []
    for lecture in lectures:
        lecture_raw = lecture.find('b').get_text()
        newstr = lecture_raw.replace('-', '')
        attrs = newstr.split()
        if (str(attrs[3]) == 'LAB') or (str(attrs[3]) == 'TUT'):
            attrs[3] = attrs[3] + '-' + attrs[4]
            attrs[4] = attrs[5]
        lecture_attr = Lecture(attrs[0], attrs[1], attrs[2], attrs[3],
                               attrs[4])
        daily_lectures.append(lecture_attr)
    return daily_lectures
Exemplo n.º 23
0
	def processLecture(self,lectureTr):
		columns = lectureTr.findAll("td")
		serierNumber = columns[0]
		date = columns[3]
		title = columns[4]
		try:
			serierInt = int(serierNumber.text)
		except ValueError:
			return 
		if "Re:" in title.text:
			return 
		else :
			lecture = Lecture()
			url = title.find('a')
			lecture.link = url.attrs['href']
			try:
				dateAndTitle = (title.text.split('[')[1]).split("]")
				if len(dateAndTitle[0]) != 5:
					return 
				lecture.date = dateAndTitle[0]
				lecture.title = dateAndTitle[1]
				self.lectures.append(lecture)
			except IndexError:
				return
Exemplo n.º 24
0
def show(lecture_id):
    """Zobrazení a odevzdávání zadání """

    usr = getUser()
    lec = Lecture.get(lecture_id)

    if not lec: return HTTPError(404, "Cvičení nebylo nalezeno")

    if not lec.isActive():
        msg("Cvičení není aktivní", "error")
        redirect("/assigments")

    assigment = Assigment.getUnique(lecture_id, usr.login)

    if not assigment:
        assigment = Assigment.create(lec.lecture_id, lec.generate(), usr.login)
        msg("Cvičení bylo vygenerováno", "success")

    if request.method == 'POST' and request.files.response:
        try:
            assigment.respond(request.files.response.file.read())
            msgTxt = "Řešení bylo úspěšně odesláno"

            if request.is_xhr:
                return HTTPResponse({
                    "type": "success",
                    "msg": msgTxt
                })
            msg(msgTxt, "success")

        except Exception as e:
            msgTxt = "Chyba při odesílání řešení - %s" % e

            if request.is_xhr:
                return HTTPResponse({
                    "type": "error",
                    "msg": msgTxt
                })

            msg(msgTxt, "error")

        redirect(request.path)

    return template("assigments_show", {
        "assigment": assigment,
        "lecture": lec
    })
Exemplo n.º 25
0
    def test_add_lecture(self):
        pass
        lecturer = Lecturer('Benjamin Kommey', 4564541, 'Mr')
        course = Course('Embedded Systems', 'COE 361')

        section = Section('ED CoE', 25, 3,
                          'Electrical and Electronics Engineering',
                          'Computer Engineering')
        c_item = CurriculumItem(section, course, lecturer)

        lecture = Lecture(c_item, 60)

        ttslot = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                               TimeSlot('8:00', '9:00'))
        ttslot1 = TimetableSlot('Tuesday', Classroom(' A110', 300, 'Libary'),
                                TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Thursday', Classroom('Room C', 67, 'N1'),
                                TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Friday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('11:00', '12:00'))
        ttslot4 = TimetableSlot('Monday', Classroom('LT ', 45, 'PBOO2'),
                                TimeSlot('10:00', '11:00'))
        print(self.timetable)
        self.assertTrue(self.timetable.add_lecture('Monday', lecture, ttslot))
        self.assertTrue(
            self.timetable.timetableslot('Monday', ttslot1.room,
                                         ttslot1.time_slot).is_occupied, True)
        self.assertTrue(self.timetable.add_lecture('Tuesday', lecture,
                                                   ttslot1))
        self.assertTrue(
            self.timetable.add_lecture('Thursday', lecture, ttslot2))
        self.assertTrue(self.timetable.add_lecture('Friday', lecture, ttslot3))
        print(
            '############################### Add Lecture ############################'
        )
        print(self.timetable)
        self.timetable.timetable['Monday'].remove_time_table_slot(
            Classroom('LT ', 45, 'PBOO2'), TimeSlot('9:00', '10:00'))
        print(
            '####################################################################'
        )
        print(self.timetable)
        self.timetable.timetable['Monday'].move_lecture(ttslot, ttslot4)
        print(self.timetable.timetable)

        self.assertNotEqual(self.timetable.timetable['Monday'],
                            self.timetable.timetable['Tuesday'])
Exemplo n.º 26
0
    def df_parser(teacher_df):
        """
        Парсит входные данные из листа с занятиями
        преподавателя и возвращает объект типа Преподаватель
        :param: pd.DataFrame
        :return: Teacher
        """
        teacher = Teacher()
        teacher._df = teacher_df
        teacher._dates = []
        teacher._pairs = {}

        months = [
            'сентября', 'октября', 'ноября', 'декабря', 'января', 'февраля',
            'марта', 'апреля', 'мая', 'июня', 'июля', 'августа'
        ]

        for col_num in teacher._df.columns:

            dates = []
            selected_rows = []
            rows_num = len(teacher._df.index) + 1

            for row_num, row in teacher._df.iterrows():
                cell = row[col_num]
                try:
                    if cell.split(' ')[1] in months:
                        dates.append(cell)
                        selected_rows.append(row_num + 1)
                except:
                    pass

            teacher._dates += dates
            selected_rows.append(rows_num)

            for i, date in enumerate(dates):
                pairs_df = teacher._df[col_num][
                    selected_rows[i]:selected_rows[i + 1] - 1]
                pairs = pairs_df.replace(pd.np.nan, '')
                teacher._pairs[date] = [
                    Lecture.cell_parser(pair) for pair in pairs
                ]

        for date in teacher._pairs:
            teacher._pairs[date] = Teacher.parse_pairs(teacher._pairs[date])
        return teacher
Exemplo n.º 27
0
def setup_database_contents():
    if not Speaker.query.all():
        print 'speakers db rebuilt'
        for s in Speaker.get():
            db.session.add(s)
        db.session.commit()

    if not Lecture.query.all():
        print 'lectures db rebuilt'
        for l in Lecture.get():
            db.session.add(l)
        db.session.commit()

    if not Sponsor.query.all():
        print 'sponsors db rebuilt'
        for l in Sponsor.get():
            db.session.add(l)
        db.session.commit()
Exemplo n.º 28
0
def show(lecture_id):
    """Zobrazení a odevzdávání zadání """
                  
    usr = getUser()
    lec = Lecture.get( lecture_id );
    
    if not lec: return HTTPError(404, "Cvičení nebylo nalezeno")

    if not lec.isActive():
        msg("Cvičení není aktivní", "error")
        redirect("/assigments");
                      
    assigment = Assigment.getUnique( lecture_id, usr.login ) 
    
    if not assigment:
        assigment = Assigment.create( lec.lecture_id, lec.generate(), usr.login )
        msg("Cvičení bylo vygenerováno", "success")
        
    if request.method == 'POST' and request.files.response:
        try:        
            assigment.respond( request.files.response.file.read() )
            msgTxt = "Řešení bylo úspěšně odesláno";

            if request.is_xhr:
                 return HTTPResponse({"type": "success", "msg": msgTxt});
            msg(msgTxt ,"success")
            
        except Exception as e:
           msgTxt = "Chyba při odesílání řešení - %s" % e 
           
           if request.is_xhr:
                 return HTTPResponse({"type": "error", "msg": msgTxt});
                 
           msg(msgTxt, "error")
        
        redirect(request.path)
            
    return template("assigments_show", {"assigment" : assigment, "lecture": lec } )    
Exemplo n.º 29
0
    def test_remove_all(self):
         #test for the case of adding a lecture to a slot that is free with free parameter
        lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
        course = Course('Embedded Systems','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)
        
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
        ttslot1 =TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('11:00', '12:00'))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot1))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot2))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot3))
        print('---------------------------After Adding Lectures-----------------')
        print(self.timetable)
        self.assertTrue(self.timetable.remove_all())
        print('---------------------------After Removing Lectures-----------------')
        print(self.timetable)
Exemplo n.º 30
0
    def test_occupied_slots(self):
        #if all slots are empty return an empty lists
        self.assertEqual([],self.timetable.occupied_slots())
        print(self.timetable.occupied_slots())

        lecturer = Lecturer('Benjamin Kommey',4564541,'Mr')
        course = Course('Embedded Systems','COE 361')

        section = Section('ED CoE',25,3,'Electrical and Electronics Engineering','Computer Engineering')
        c_item = CurriculumItem(section,course,lecturer)

        lecture = Lecture(c_item,60)
        
        ttslot =  TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('8:00', '9:00'))
        ttslot1 =TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('9:00', '10:00'))
        ttslot2 = TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('10:00', '11:00'))
        ttslot3 = TimetableSlot('Mon', Classroom('LT ', 45, 'PBOO2'),TimeSlot('11:00', '12:00'))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot1))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot2))
        self.assertTrue(self.timetable.add_lecture(lecture,ttslot3))

        self.assertEqual([ttslot,ttslot1,ttslot2,ttslot3],self.timetable.occupied_slots())
Exemplo n.º 31
0
 def setUpClass(cls):
     super().setUpClass()
     session = Session(DatabaseTest.connection)
     semester = Semester('WS', 2017)
     s1 = Student('Max', 'Mustermann', '*****@*****.**')
     s2 = Student('Maike', 'Musterfrau', '*****@*****.**')
     l1 = Lecturer('Jack', 'Johnson', '*****@*****.**', 'male')
     l2 = Lecturer('Jacky', 'Johnsons', '*****@*****.**', 'female')
     lecture = Lecture(title='Learn this',
                       tutorial=False,
                       lecturer=l2,
                       semester=semester)
     lecture2 = Lecture(title='Learn this too',
                        tutorial=False,
                        lecturer=l1,
                        semester=semester)
     lecture.participants = [s1, s2]
     lecture2.participants = [s1]
     session.add_all([semester, s1, s2, l1, l2, lecture, lecture2])
     TestLecture.lecture = lecture
     session.commit()
     session.close()
Exemplo n.º 32
0
 def test_groups(self):
     groups = [['7333'], ['2780.2'], []]
     for (groups, init_value) in zip(groups, self.init_values):
         lecture = Lecture.cell_parser(init_value)
         self.assertEqual(groups, lecture.get_groups())
Exemplo n.º 33
0
 def getLecture(self):
     from lecture import Lecture
     return Lecture.get( self.lecture_id )
Exemplo n.º 34
0
 def test_entry_value(self):
     for init_value in self.init_values:
         lecture = Lecture.cell_parser(init_value)
         self.assertEqual(init_value, lecture.get_full_value())
Exemplo n.º 35
0
 def test_types(self):
     types = ['ПЗ', 'ПЗ', '']
     for (tp, init_value) in zip(types, self.init_values):
         lecture = Lecture.cell_parser(init_value)
         self.assertEqual(tp, lecture.get_type())
Exemplo n.º 36
0
        """
		Sets the GUI label

		With the vars `self.song_dict["name"]`, `self.song_dict["descr"]` and
		`self.song_dict["parsed_trans"]`.
		"""
        text = "<b>"
        text += ptp.escape_pango_chars(self.song_dict["name"])
        text += "</b> <i>"
        text += ptp.escape_pango_chars(self.song_dict["descr"])
        text += "</i> "
        text += self.song_dict["parsed_trans"]
        self.song_label.set_text(text)
        self.song_label.set_use_markup(True)


if __name__ == "__main__":
    from window import Window
    from lecture import Lecture
    lecture = Lecture()
    window = Window()
    song = {
        "name": "song_title",
        "descr": "song_descr",
        "trans": ["1", "", "s"]
    }
    lecture.add_song_to_list(SongListItem(song))
    window.set_content(lecture)
    window.show()
    Gtk.main()
Exemplo n.º 37
0
 def test_names(self):
     names = ['Безопасность ОС', '2780', '']
     for (name, init_value) in zip(names, self.init_values):
         lecture = Lecture.cell_parser(init_value)
         self.assertEqual(name, lecture.get_name())
Exemplo n.º 38
0
 def test_get_pairs_dict(self):
     pairs_list = [{
         '11 сентября': [
             Lecture.cell_parser(''),
             Lecture.cell_parser(''),
             Lecture.cell_parser(
                 'Безопасность ОС:\nПЗ-15 ауд. 122\nгр. 7334'),
             Lecture.cell_parser(''),
         ]
     }, {
         '02 октября': [
             Lecture.cell_parser(''),
             Lecture.cell_parser(''),
             Lecture.cell_parser(
                 'Безопасность ОС: \nлаб.раб-1 ауд. 122\nгр. 7334'),
             Lecture.cell_parser(
                 'Безопасность ОС: \nсем.-1 ауд. 209\nгр. 7334'),
         ]
     }, {
         '06 ноября': [
             Lecture.cell_parser(''),
             Lecture.cell_parser(''),
             Lecture.cell_parser(''),
             Lecture.cell_parser(''),
         ]
     }]
     for (pairs, df) in zip(pairs_list, self.init_dataframes):
         teacher = Teacher.df_parser(df)
         self.assertEqual(pairs, teacher.get_pairs_dict())
Exemplo n.º 39
0
def get_lecture(lecture_id):
    lecture = Lecture.get(lecture_id)
    if not lecture:
        abort(404)
    return jsonify({'lecture': lecture})