Пример #1
0
 def __init__(self, next_state=None):
     super().__init__(next_state)
     self.player = Player("John Doe")
     self.player_info = PlayerInfo(self.player)
     self.lesson = Lesson()
     self.ui = None
     self.choice = ChoiceUI(self.lesson)
Пример #2
0
 def update(self):
     self.active = True
     if self.lesson.stage == Lesson.CHOICE:
         self.ui = self.choice
     else:
         self.lesson = Lesson()
         self.choice = ChoiceUI(self.lesson)
     self.handle_events()
Пример #3
0
 def create_lesson(self, lesson_name):
     for lesson in self.lessons:
         if lesson.lesson_name == lesson_name:
             print("Error, this lesson already exists")
             return None
     l = Lesson(lesson_name, self.next_id())
     self.lessons.append(l)
     return l
Пример #4
0
def selectschedule():
    if session.get('login'):
        schedule = Schedule(dsn=app.config['dsn'])
        classroom = Class(dsn=app.config['dsn'])
        lesson = Lesson(dsn=app.config['dsn'])
        teacher_id = session['login']
        schedules = schedule.get_all_schedules_for_teacher(teacher_id)
        schedule_ids = []
        class_names = []
        lesson_names = []
        for a in schedules:
            schedule_ids.append(a[0])
            my_classroom = classroom.get_class(a[1])
            class_names.append(my_classroom[1])
            my_lesson = lesson.get_lesson(a[2])
            lesson_names.append(my_lesson[1])
        return render_template('schedule_selection.html',
                               zipped=zip(schedule_ids, lesson_names,
                                          class_names))
    else:
        return redirect(url_for('home_page'))
Пример #5
0
 def parse_data(self):
     for row in self.__information:
         lesson = Lesson(row[0], row[1], row[5], row[6], row[7])
         subject = Subject(row[4], row[9], lesson)
         student = Student(row[3], row[2], row[8], row[9], subject)
         if self.check_student(student):
             self.__student_list.append(student)
         else:
             for stud in self.__student_list:
                 if stud.get_surname() == student.get_surname(
                 ) and stud.get_group_code() == student.get_group_code():
                     stud.get_subject_list().append(subject)
Пример #6
0
 def add_lesson(self, name, path=os.getcwdu()):
     if isinstance(name, Lesson):
         self.techLogger.debug("adding lesson object: %s, path: %s" %
                               (name.name, name.path))
         self.lessons.add(name)
         self.lessonsNames.add(name.name)
     else:
         #we consider name is the name of the lesson, and thus the directory.
         self.techLogger.debug(
             "creating a lesson before adding it: %s, path: %s" %
             (name, path))
         lesson = Lesson(name, path)
         self.add_lesson(lesson)
 def import_lessons(self, major, no_lessons):
     """
     administrator inserts lessons to the system. it returns the list of lessons
     """
     lessons = []
     for lsn in range(no_lessons):
         print("------------------------------------------")
         name = input("enter lesson's name: ")
         teacher = input("enter lesson's teacher: ")
         units = input("enter lesson's units: ")
         capacity = input("enter lesson's capacity: ")
         print("------------------------------------------")
         lesson = Lesson(name, teacher, units, capacity)
         lessons.append(lesson)
     with open(f"{major}.txt", 'ab') as lessons_file:
         pickle.dump(lessons, lessons_file)
Пример #8
0
    def get_by_user_name_and_lesson_name(cls, connection, user_name,
                                         lesson_name):
        """Get an activity with user_name, lesson_name from 'activity_lesson' table

        :param connection: DB connection object
        :param user_name: user name
        :param lesson_name: lesson name
        :return: activity details
            {
                'user_id': user_id,
                'lesson_id': lesson_id,
                'opened_at': <datetime>,
                'completed': True (or) False,
                'completed_at': <datetime>
            }
        """
        user_id = User.get_user_id(connection, user_name)
        lesson_id = Lesson.get_lesson_id(connection, lesson_name)
        return cls.get_by_user_id_and_lesson_id(connection, user_id, lesson_id)
Пример #9
0
    def get_by_lesson_name(cls, connection, lesson_name, completed=None):
        """Get all activities with lesson_name from 'activity_lesson' table of all users

        :param connection: DB connection object
        :param lesson_name: lesson name
        :param completed: status of the activity (True/False/None)
                True - returns all the completed lesson_name lessons of all users
                False - return all the in-progress lesson_name lessons of all user
                None - return all the lesson_name lessons of all users
        :return: list of activities of all users with lesson_name
            [{
                'user_id': <user-id>,
                'lesson_id': lesson_id,
                'opened_at': <datetime>,
                'completed': True (or) False,
                'completed_at': <datetime>
            }]
        """
        lesson_id = Lesson.get_lesson_id(connection, lesson_name)
        return cls.get_by_lesson_id(connection, lesson_id, completed=completed)
Пример #10
0
def create_db():
    if session.get('login'):
        school = School(dsn=app.config['dsn'])
        school.init_table()
        #deneme

        lesson = Lesson(dsn=app.config['dsn'])
        lesson.init_table()

        teacher = Teacher(dsn=app.config['dsn'])
        teacher.init_table()

        parent = Parent(dsn=app.config['dsn'])
        parent.init_table()

        teacher_account = TeacherAccount(dsn=app.config['dsn'])
        teacher_account.init_table()

        student = Student(dsn=app.config['dsn'])
        student.init_table()
        #student.insert_student("Boran","Sivrikaya","hotmail")
        #student.delete_student(student.get_student_id("Boran","Sivrikaya"))
        #student.insert_student("Boran","Sivrikaya","hotmail")
        #student.update_student(student.get_student_id("Boran","Sivrikaya"),"Hamza","Tuna","gmail")

        school = School(dsn=app.config['dsn'])
        school.init_table()
        #school.insert_school("Makif")
        #school.delete_school(school.get_school_id("Makif"))
        #school.insert_school("GOP")
        #school.update_school(school.get_school_id("GOP"),"IAFL")

        classroom = Class(dsn=app.config['dsn'])
        classroom.init_table()
        #class.insert_class("9A",2013)
        #class.delete_class(class.get_class_id("9A",2013))
        #class.insert_class("10A",2013)
        #class.update_class(class.get_class_id("10A",2013),"12C",2015)

        lesson = Lesson(dsn=app.config['dsn'])
        lesson.init_table()
        #lesson.insert_lesson("Math")
        #lesson.delete_lesson(lesson.get_lesson_id("Math"))
        #lesson.insert_lesson("History")
        #lesson.update_lesson(lesson.get_lesson_id("History"),"Science")

        parent = Parent(dsn=app.config['dsn'])
        parent.init_table()
        #parent.insert_parent("Zekiye","Sivrikaya")
        #parent.delete_parent(parent.get_parent_id("Zekiye","Sivrikaya"))
        #parent.insert_parent("Hamdi","Sivrikaya")
        #parent.update_parent(parent.get_parent_id("Hamdi","Sivrikaya"),"Ahmet","Yalcin")

        schedule = Schedule(dsn=app.config['dsn'])
        schedule.init_table()
        #schedule.insert_schedule(5,4,6,2013)
        #schedule.delete_schedule(schedule.get_schedule_id(5,4))
        #schedule.insert_schedule(5,4,6,2013)
        #schedule.update_schedule(schedule.get_schedule_id(5,4),3,4,6,2020)

        #session = Session(dsn=app.config['dsn'])
        #session.init_table()
        #session.insert_session(3,"2-2-1922",3)
        #session.delete_session(session.get_session_id(3,"2-2-1922",3))
        #session.insert_session(3,"2-2-1922",7)
        #session.update_session(session.get_session_id(3,"2-2-1922",7),4,"8-8-1994",1)

        attendance = Attendance(dsn=app.config['dsn'])
        attendance.init_table()
        #attendance.insert_attendance(2,4,True)
        #attendance.delete_attendance(attendance.get_attendance_id(2,4))
        #attendance.insert_attendance(2,5,True)
        #attendance.update_attendance(attendance.get_attendance_id(2,5),4,6,False)

        grade = Grade(dsn=app.config['dsn'])
        grade.init_table()
        #grade.insert_grade(3,2,75,"Iyi not")
        #grade.delete_grade(grade.get_grade_id(3,2))
        #grade.insert_grade(3,2,85,"Daha iyi")
        #grade.update_grade(grade.get_grade_id(3,2),4,4,20,"VF")

        schoolclass = SchoolClass(dsn=app.config['dsn'])
        schoolclass.init_table()
        #schoolclass.insert_school_class(3,8)
        #schoolclass.delete_school_class(schoolclass.get_school_class_id(3,8))
        #schoolclass.insert_school_class(3,8)
        #schoolclass.update_school_class(schoolclass.get_school_class_id(3,8),5,10)

        student_class = Student_Class(dsn=app.config['dsn'])
        student_class.init_table()
        #student_class.insert_student_class(3,2)
        #student_class.delete_student_class(student_class.get_student_class_id(3,2))
        #student_class.insert_student_class(5,2)
        #student_class.update_student_class(student_class.get_student_class_id(5,2),7,4)

        studentparent = StudentParent(dsn=app.config['dsn'])
        studentparent.init_table()
        #studentparent.insert_studentparent(2,2)
        #studentparent.delete_studentparent(studentparent.get_studentparent_id(2,2))
        #studentparent.insert_studentparent(2,2)
        #studentparent.update_studentparent(studentparent.get_studentparent_id(2,2),4,2)

        studentschool = StudentSchool(dsn=app.config['dsn'])
        studentschool.init_table()
        #studentschool.insert_studentschool(2,8)
        #studentschool.delete_studentschool(studentschool.get_studentschool_id(2,8))
        #studentschool.insert_studentschool(4,10)
        #studentschool.update_studentschool(studentschool.get_studentschool_id(4,10),4,12)

        teacherschool = TeacherSchool(dsn=app.config['dsn'])
        teacherschool.init_table()
        #teacherschool.insert_teacherschool(2,8)
        #teacherschool.delete_teacherschool(teacherschool.get_teacherschool_id(2,8))
        #teacherschool.insert_teacherschool(4,10)
        #teacherschool.update_teacherschool(teacherschool.get_teacherschool_id(4,10),6,12)
        return "Database created"
    else:
        return redirect(url_for('home_page'))
Пример #11
0
        return word

    def __unicode__(self):
        return "\n".join([unicode(w) for w in self.words])

    def pretty_print(self):
        s = self.name + "\n" + "-" * len(self.name) + "\n"
        s += "%15s | %s\n" % ('word', 'file')
        s += '-' * 15 + ' | ' + '-' * 80 + '\n'
        for w in self.words:
            s += '%15s | %s\n' % (w.word, w.file)
        return s


if __name__ == "__main__":
    quiz = Quiz('test', 5)
    lesson = Lesson(
        'mots1',
        os.path.normpath(os.getcwdu() + '/../resources/lessons/mots1'))
    quiz.add_lesson(lesson)
    quiz.generate()
    print quiz.pretty_print()
    quiz.length = 20
    quiz.generate()
    print quiz.pretty_print()

    word = quiz.next()
    while word is not None:
        print(unicode(word))
        word = quiz.next()
Пример #12
0
def take_input():
    """
    The last element of the return tuple, which is an integer, is representing the semester amount in which the user
    wanted to be graduated.
    :return: tuple(Student, list(Lesson), int)
    """

    print('You will be prompted for several inputs.')
    print('With each input you will be told the form of input.')
    print('Please, comply.')

    while True:
        try:
            year = int(
                input(
                    'Which year will the evaluation process start? (As a positive integer.):'
                ))
        except ValueError:
            print('Please use integers.')
            continue
        if year <= 0:
            print('At least one year is needed.')
            continue
        break

    while True:
        try:
            spend_semester = int(
                input(
                    'How many semesters did you spend including Summers? (As a positive integer.):'
                ))
        except ValueError:
            print('Please use integers.')
            continue
        if spend_semester <= 0:
            print('At least one semester is needed.')
            continue
        break

    while True:
        try:
            semester = int(
                input('Which semester will the evaluation process start? ' +
                      '1 for Fall, 2 for Spring and 3 for Summer:'))
        except ValueError:
            print('Please use integers.')
            continue
        if 3 < semester <= 0:
            print('Input form is not correct.')
            continue
        break
    if semester == 1:
        semester = 3
    else:
        semester -= 1

    while True:
        try:
            graduate_in = int(
                input(
                    'How many semesters in which you want to graduate? (As a positive integer.):'
                ))
        except ValueError:
            print('Please use integers.')
            continue
        if graduate_in <= 0:
            print('At least one semester is needed.')
            continue
        break

    lessons = []
    i = 0
    while i < spend_semester:
        semester_lessons = []
        lessons.append(semester_lessons)
        print(
            'You will be asked questions for the lessons you have taken in your semester number '
            + str(i + 1) + '.')
        while True:
            if input(
                    'Type --END-- if you have not taken any more lessons in this semester. '
                    +
                    'Otherwise press Enter without that input:') == '--END--':
                break
            code = input(
                'Type the code of the lesson, it does not checked for correctness, so type carefully:'
            )
            credit = 0
            try:
                credit = int(
                    input(
                        'How many credits the lesson have? (As a positive integer.):'
                    ))
            except ValueError:
                print('Please use integers.')
            if credit < 0:
                print('A neutral credit is needed.')
                continue
            lesson_year = 0
            try:
                lesson_year = int(
                    input(
                        'Which year is the lesson in? (As a positive integer.):'
                    ))
            except ValueError:
                print('Please use integers.')
            if lesson_year <= 0:
                print('A positive year is needed.')
                continue
            prerequisites = input(
                'Type the codes of prerequisites, do not use any white spaces, separate with "|". '
                +
                'Be careful since there is no correctness check for this input:'
            ).split('|')

            while True:
                is_ok = True
                open_semesters = input(
                    'Type the semesters of lesson, do not use any white spaces, separate with "|". '
                    'No ordering needed; type 1 for Fall, 2 for Spring and 3 for Summer:'
                ).split('|')
                open_semesters = list(map(lambda x: int(x), open_semesters))
                for semester_numb in open_semesters:
                    if semester_numb > 3 or semester_numb < 1:
                        is_ok = False
                if is_ok:
                    break
                continue

            grade = input(
                'Grade of the lesson as letter grade. Type carefully, if typed wrong the program may crash:'
            )

            semester_lessons.append(
                Lesson(code, credit, lesson_year, prerequisites,
                       open_semesters, grade))
        i += 1

    new_lessons = []
    while True:
        print('You will be asked questions for the lessons you will take.')
        while True:
            if input('Type --END-- if you will not take any more lessons. Otherwise hit Enter without typing:') \
                    == '--END--':
                break
            code = input(
                'Type the code of the lesson, it does not checked for correctness, so type carefully:'
            )
            credit = 0
            try:
                credit = int(
                    input(
                        'How many credits the lesson have? (As a positive integer.):'
                    ))
            except ValueError:
                print('Please use integers.')
            if credit < 0:
                print('A neutral credit is needed.')
                continue
            lesson_year = 0
            try:
                lesson_year = int(
                    input(
                        'Which year is the lesson in? (As a positive integer.):'
                    ))
            except ValueError:
                print('Please use integers.')
            if lesson_year <= 0:
                print('A positive year is needed.')
                continue
            prerequisites = input(
                'Type the codes of prerequisites, do not use any white spaces, separate with "|". '
                +
                'Be careful since there is no correctness check for this input:'
            ).split('|')

            if prerequisites[0] == '':
                prerequisites = []

            while True:
                is_ok = True
                open_semesters = input(
                    'Type the semesters of lesson, do not use any white spaces, separate with "|". '
                    'No ordering needed; type 1 for Fall, 2 for Spring and 3 for Summer:'
                ).split('|')
                open_semesters = list(map(lambda x: int(x), open_semesters))
                for semester_numb in open_semesters:
                    if semester_numb > 3 or semester_numb < 1:
                        is_ok = False
                if is_ok:
                    break
                continue

            new_lessons.append(
                Lesson(code, credit, lesson_year, prerequisites,
                       open_semesters))
        break

    return Student(year, semester, lessons), new_lessons, graduate_in
Пример #13
0
def start_lesson(lesson_name):
    lesson = Lesson(lesson_name)

    lesson.start()
Пример #14
0
            self.exam.answers.append(answer)
        print "Fin de l'examen."

    def get_score(self):
        """
        Correct the exam and print the score.
        """
        self.exam.correct()
        print u"Ton score est de %d sur %d" % (self.exam.score,
                                               self.quiz.length)
        if self.exam.score != self.quiz.length:
            print u"Tu t'es trompé sur les mots suivants:"
            for index in self.exam.mistakes:
                answer = self.exam.answers[index]
                word = self.quiz.words[index].word
                print "%25s --> %s" % (word, answer)
        else:
            print u"Magnifique %s!" % self.exam.student


if __name__ == "__main__":
    import os
    from lesson import Lesson
    quiz = Quiz("test", 15)
    lesson = Lesson('mots17', os.path.normpath(os.getcwdu() + '/../mots17'))
    quiz.add_lesson(lesson)
    quiz.generate()
    exam_runner = ExamRunner(u"Eléa", quiz)
    exam_runner.do_exam()
    exam_runner.get_score()
Пример #15
0
            break

    # The dates of the week that is loaded get extracted here
    # They get put into a list with the weekday stripped.
    # The first item in the list is the date for Monday,
    # the second for Tuesday etc.
    d = soup.find_all('td', class_='week_header')
    dates = list()
    for i in d:
        dates.append(
            dateconvert.rapladate_to_iso("{}{}".format(
                i.text.split(' ')[1], year)))

    s = soup.find_all('td', class_='week_block')
    for i in s:
        lesson = Lesson()

        # Instructor:
        # Rapla sends the instructor as "name,surname,".
        # To make this pretty, we switch both parts and remove
        # both commas
        person = i.find('span', class_='person')

        # If there is now person, it is an exam
        if person:
            person = person.text.split(',')
            lesson.instructor = "{} {}".format(person[1].strip(),
                                               person[0].strip())
        else:
            print('The week {} contains exams'.format(
                current_date.isocalendar()[1]))
Пример #16
0
from lesson import Lesson
from lesson_schedule import LessonSchedule

lesson1 = Lesson('Monday', 8, 0, 'Polish')
lesson2 = Lesson('Monday', 8, 50, 'English')
lesson3 = Lesson('Tuesday', 9, 45, 'Math')
lesson4 = Lesson('Monday', 8, 0, 'Polish')

lesson_schedule = LessonSchedule()
lesson_schedule.addLesson(lesson1)
lesson_schedule.addLesson(lesson2)
lesson_schedule.addLesson(lesson3)
lesson_schedule.addLesson(lesson4)

lesson_schedule.print_all()
Пример #17
0
    camId = int(sys.argv[1])
else:
# If no node is specified then 0 will be set as the default node
    camId = 0
try:
# If the user has no camera, unplugs camera or incorrectly configures camera it will exit the environment and give feedback to the user.
    camera=Camera(camId)
    camera.showDisplay(keyb)
except:
    print("\nThere is an issue with camera with ID {}.".format(camId))
    print("Please fix the error or use a different camera.")
    sys.exit()
# Creates a new screen object
screen = Screen()
# Creates a new lesson object
les = Lesson(screen, camera)
# This prints the menu to the user upon starting the game up
screen.showOption()
# This captures the users input key to determine which mode they requested
key = screen.getKey()
while key != 113:
    # This clears the screen at as the user's request for the mode is no process
    screen.clear()
    # If the user presses the 'r' key then they will open a live display with the alignment tool.
    if key == 114:
        camera.showDisplay(keyb) 
        screen.scrPrint("Camera re-align finished", newline=True)
        screen.continuePrompt()
    # If the user presses the 'p' key then the game will be started
    elif key == 112:
        # starts the env
    def take_lessons(self, major):
        try:
            with open(f"{major}.txt", 'rb') as my_file:
                lessons = pickle.load(my_file)
                print("------------------------------------------")
                print("this is the list of lessons you are allowed to take:")
                for i, lsson in enumerate(lessons):
                    print(
                        f"{i+1}-name: {lsson.name}, teacher: {lsson.teacher},"
                        f" units: {lsson.units}, capacity: {lsson.capacity}")
        except OSError as err:
            print(f"OS error: {err}")
        try:
            with open('students.csv', 'r', newline='') as my_file:
                students = list(csv.reader(my_file))
                for j, student in enumerate(students):
                    if student[0] == self.username:
                        while True:
                            if int(student[2]) < 20:
                                print()
                                lsn_no = int(
                                    input(
                                        "which lesson do you want to choose? ")
                                ) - 1
                                if f"{lessons[lsn_no].name}" not in student[
                                        3].strip().split(','):

                                    if lessons[lsn_no].active == True:
                                        if int(lessons[lsn_no].units) + int(
                                                student[2]) < 20:
                                            students[j][3] = lessons[lsn_no].name + ',' +\
                                                             students[j][3]
                                            students[j][2] = int(lessons[lsn_no].units) +\
                                                             int(student[2])
                                            Lesson.update_status(
                                                major, lessons[lsn_no].name)
                                        else:
                                            print(
                                                "you can not take more than 20 units in"
                                                " a semester!")
                                            return False
                                    else:
                                        print(
                                            "this lesson's capacity is full!")
                                else:
                                    print(
                                        "you can not take a lesson two times in a semester!"
                                    )
                            if int(students[j][2]) < 10:
                                print("you need to take at least 10 units")
                                continue
                            else:
                                break
        except OSError as err:
            print(f"OS error: {err}")
        try:
            with open('students.csv', 'w', newline='') as my_file:
                csv_writer = csv.writer(my_file)
                csv_writer.writerows(students)
        except OSError as err:
            print(f"OS error: {err}")