Ejemplo n.º 1
0
def main():
    student_list = [('1001', '111'), ('1002', '222'), ('1003', '333'),
                    ('1004', '444')]
    course_list = ['CSC101', 'CSC102', 'CSC103']
    max_size_list = [3, 2, 1]
    roster_list = [['1004', '1003'], ['1001'], ['1002']]
    # print("main called")  # debug area

    student_id = "1"
    while student_id != "0":
        student_id = input("Enter ID to log in, or 0 to quit: ")
        if student_id == "0":
            break
        else:
            if login(student_id, student_list) == True:
                choice = -1
                while choice != 0:
                    choice = int(
                        input(
                            "Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: "
                        ))
                    if choice == 0:
                        print("session ended.")
                        student_id = "0"
                    elif choice == 1:
                        student.add_course(student_id, course_list,
                                           max_size_list, roster_list)
                    elif choice == 2:
                        student.drop_course(student_id, course_list,
                                            roster_list)
                    else:
                        student.list_courses(student_id, course_list,
                                             roster_list)
            """
Ejemplo n.º 2
0
 def add_student(self, student):  #O(1)
     if len(self.current_students
            ) >= self.max_students:  #If the class is full          O(1)
         self.queue_to_enter.enqueue(
             student)  #Add a student to the overflow queue
     else:
         self.current_students.append(
             student)  #If it's not, add them to the course         O(1)
         student.add_course(
             self)  #also remember to add the student to the course
Ejemplo n.º 3
0
def main():

    # ------------------------------------------------------------
    # This function manages the whole registration system.  It has
    # no parameter.  It creates student list, course list,
    # max class size list and roster list.  It uses a loop to serve
    # multiple students. Inside the loop, ask student to enter ID,
    # and call the login function to verify student's identity. Then
    # let student choose to add course, drop course or list courses.
    # This function has no return value.
    # -------------------------------------------------------------

    student_list = [('1001', '111'), ('1002', '222'), ('1003', '333'), ('1004', '444')]
    course_list = ['CSC101', 'CSC102', 'CSC103']
    roster_list = [['1004', '1003'], ['1001'], ['1002']]
    max_size_list = [3, 2, 1]

    id = 0
    selection = 4

    while True:
            id = input("Please enter your student ID, or 0 to quit: ")
            if int(id) == 0:
                exit()
            elif id not in (element for sublist in student_list for element in sublist):
                while id not in (element for sublist in student_list for element in sublist):
                    print("Student ID incorrect, please enter your student number")
                    id = input("Please enter your student ID, or 0 to quit: ")
                    if id in (element for sublist in student_list for element in sublist):
                        login(id, student_list)
            elif id in (element for sublist in student_list for element in sublist):
                login(id, student_list)

            while selection != 0:
                try:
                    selection = int(input("Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: "))
                    if selection == 1:
                        student.add_course(id=id, c_list=course_list, r_list=roster_list, m_list=max_size_list)
                    elif selection == 2:
                        student.drop_course(id=id, c_list=course_list, r_list=roster_list)
                    elif selection == 3:
                        student.list_courses(id=id, c_list=course_list, r_list=roster_list)
                    elif selection == 0:
                        main()

                except ValueError:
                    print("Invalid entry, please try again.")
Ejemplo n.º 4
0
def main():

    # ------------------------------------------------------------
    # This function manages the whole registration system.  It has
    # no parameter.  It creates student list, course list,
    # max class size list and roster list.  It uses a loop to serve
    # multiple students. Inside the loop, ask student to enter ID,
    # and call the login function to verify student's identity. Then
    # let student choose to add course, drop course or list courses.
    # This function has no return value.
    # -------------------------------------------------------------

    student_list = [('1001', '111'), ('1002', '222'), ('1003', '333'),
                    ('1004', '444')]
    course_list = ['CSC101', 'CSC102', 'CSC103']
    max_size_list = [3, 2, 1]
    roster_list = [['1004', '1003'], ['1001'], ['1002']]
    # print("main called")  # debug area

    student_id = "1"
    while student_id != "0":
        student_id = input("Enter ID to log in, or 0 to quit: ")
        if student_id == "0":
            break
        else:
            if login(student_id, student_list) == True:
                choice = -1
                while choice != 0:
                    choice = int(
                        input(
                            "Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: "
                        ))
                    if choice == 0:
                        print("session ended.")
                        student_id = "0"
                    elif choice == 1:
                        student.add_course(student_id, course_list,
                                           max_size_list, roster_list)
                    elif choice == 2:
                        student.drop_course(student_id, course_list,
                                            roster_list)
                    else:
                        student.list_courses(student_id, course_list,
                                             roster_list)
Ejemplo n.º 5
0
def main():
    # ------------------------------------------------------------
    # This function manages the whole registration system.  It has
    # no parameter.  It creates student list, course list,
    # max class size list and roster list.  It uses a loop to serve
    # multiple students. Inside the loop, ask student to enter ID,
    # and call the login function to verify student's identity. Then
    # let student choose to add course, drop course or list courses.
    # This function has no return value.
    # -------------------------------------------------------------

    student_list = [('1001', '111'), ('1002', '222'), ('1003', '333'),
                    ('1004', '444')]
    course_list = ['CSC101', 'CSC102', 'CSC103']
    roster_list = [['1004', '1003'], ['1001'], ['1002']]
    max_size_list = [3, 2, 1]
    id = 1
    while id != "0":
        id = input("Enter ID to log in, or 0 to quit: ")
        if id == "0":
            break
        success = login(id, student_list)
        if success == True:
            print("ID and PIN verified.\n")
            decision_tree = "1"
            while decision_tree != "0":
                decision_tree = input(
                    "Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: "
                )
                if decision_tree == "1":
                    student.add_course(id, course_list, roster_list,
                                       max_size_list)
                elif decision_tree == "2":
                    student.drop_course(id, course_list, roster_list)
                elif decision_tree == "3":
                    student.list_courses(id, course_list, roster_list)
                elif decision_tree == "0":
                    print("Session ended.\n")
                    break
                else:
                    print("Incorrect choice.\n")
        else:
            print("ID or PIN incorrect.\n")
Ejemplo n.º 6
0
def student_session(r_list, m_list, s_list):
    """Calls functions from student module allowing the student to enroll/drop a course or view currently registered for courses"""
    verified, id = login(s_list)

    if verified == 'Yes':
        while True:
            student_activity = int(
                input(
                    'Enter 1 to add a course, 2 to drop a course, 3 to see what courses you have registered for, or 0 to exit: '
                ))

            if student_activity == 1:
                student.add_course(id, r_list, m_list)
            elif student_activity == 2:
                student.drop_course(id, r_list)
            elif student_activity == 3:
                student.list_courses(id, r_list)
            else:
                print('Student session ended')
                return
Ejemplo n.º 7
0
def main():

    # ------------------------------------------------------------
    # This function manages the whole registration system.  It has
    # no parameter.  It creates student list, course list,
    # max class size list and roster list.  It uses a loop to serve
    # multiple students. Inside the loop, ask student to enter ID,
    # and call the login function to verify student's identity. Then
    # let student choose to add course, drop course or list courses.
    # This function has no return value.
    # -------------------------------------------------------------

    student_list = [('1001', '111'), ('1002', '222'), ('1003', '333'), ('1004', '444')]
    course_list = ['CSC101', 'CSC102', 'CSC103']
    roster_list = [['1004', '1003'], ['1001'], ['1002']]
    max_size_list = [3, 2, 1]

    while True:
        add_drop_list_courses = 1
        identify = input("Enter ID to log in, or 0 to quit: ")
        if identify == '0':
            print("Session ended.")
            sys.exit(0)
        else:
            is_login_successful = login(id=identify, s_list=student_list)
            if is_login_successful == True:
                while add_drop_list_courses != 0:
                    add_drop_list_courses = int(input("Enter 1 to add course, 2 to drop course, 3 to list courses, 0 to exit: "))
                    if add_drop_list_courses == 3:
                        student.list_courses(id=identify, c_list=course_list, r_list=roster_list)
                    elif add_drop_list_courses == 1:
                        student.add_course(id=identify, c_list=course_list, r_list=roster_list, m_list=max_size_list)
                    elif add_drop_list_courses == 2:
                        student.drop_course(id=identify, c_list=course_list, r_list=roster_list)
                    elif add_drop_list_courses == 0:
                        print("Session ended. \n")
                        pass
                    else:
                        print("Please enter a correct option. \n")
Ejemplo n.º 8
0
def course_added():
    if "role" in session and session["role"] == "teacher":
        teacher.add_course(request.form["course"], session["user_id"])
    else:
        student.add_course(request.form["course"])
    return redirect("/courses")