def run(self, site, messages=None): site.clear() show_messages(messages) course_list = paginator(site.get_verified_courses(), 20) page_number = 0 while True: menu = ['Home'] if page_number - 1 >= 0: menu.append('Previous Page') if page_number + 1 < len(course_list): menu.append('Next Page') if len(course_list) == 0: print("There is no verified course in the system.") else: pprint_table('Courses', course_list[page_number], foot='Page {} of {}'.format( page_number + 1, len(course_list))) choice = choose_from_menu(menu) if choice == 'Home': site.state = '/manager/' break elif choice == 'Previous Page': page_number -= 1 site.clear() elif choice == 'Next Page': page_number += 1 site.clear() return None
def run(self, site, messages=None): site.clear() site.print_header() show_messages(messages) username = get_input('Username(left blank if you want): ', null=True) serial = get_input('Serial Number(left blank if you want): ', null=True) name = get_input('Name: ') field = get_input('Field: ') email = get_input('Email Address: ') role = choose_from_menu(User.ROLES, message="What's your role? ") phone_number = get_input('Phone Number: ') password = get_secret_input('Password: '******'Password Again: ') if password != password2: return ["Passwords do not match."] user = User( username=username, serial=serial, email=email, role=role, phone_number=phone_number, password=password, name=name, field=field ) if user.is_valid(site.user_list): site.add_user(user) site.state = '/' return ['You successfully registered in the system. Wait for the manager to verify you.'] else: return user.errors
def run(self, site, messages=None): site.clear() show_messages(messages) course_list = paginator(site.get_current_courses(site.active_user), 20) page_number = 0 while True: menu = { 'Home': '/teacher/', } if page_number - 1 >= 0: menu['Previous Page'] = '/teacher/courses/' if page_number + 1 < len(course_list): menu['Next Page'] = '/teacher/courses/' if len(course_list) == 0: print("There is no course for you.") else: pprint_table('Courses', course_list[page_number], foot='Page {} of {}'.format( page_number + 1, len(course_list))) choice = choose_from_menu(menu.keys()) if choice == 'Home': site.state = menu[choice] break elif choice == 'Previous Page': page_number -= 1 site.clear() elif choice == 'Next Page': page_number += 1 site.clear() return None
def run(self, site, messages=None): site.clear() show_messages(messages) course_list = paginator(site.active_user.get_scores(), 20) page_number = 0 while True: menu = { 'Home': '/student/', } if page_number - 1 >= 0: menu['Previous Page'] = '/student/workbook/' if page_number + 1 < len(course_list): menu['Next Page'] = '/student/workbook/' if len(course_list) == 0: print("There is no passed course in the system.") else: pprint_table( 'Workbook', course_list[page_number], foot='Page {} of {}'.format(page_number + 1, len(course_list)), cols_title=site.active_user.get_score_columns_title()) choice = choose_from_menu(menu.keys()) if choice == 'Home': site.state = menu[choice] break elif choice == 'Previous Page': page_number -= 1 site.clear() elif choice == 'Next Page': page_number += 1 site.clear() return None
def run(self, site, messages=None): site.clear() site.print_header() show_messages(messages) choice = choose_from_menu(self.MENU.keys()) site.state = self.MENU[choice] if choice == 'Exit': exit(0) return None
def run(self, site, messages=None): site.clear() show_messages(messages) user_list = paginator(site.get_unverified_users(), 20) page_number = 0 while True: if len(user_list) == 0: print("There is no unverified user in the system.\n") else: pprint_table('New Users', copy.copy(user_list[page_number]), foot='Page {} of {}'.format( page_number + 1, len(user_list))) menu = ['Home'] if page_number - 1 >= 0: menu.append('Previous Page') if page_number + 1 < len(user_list): menu.append('Next Page') if len(user_list) > 0: menu.append('Accept') menu.append('Reject') choice = choose_from_menu(menu) if choice == 'Home': site.state = '/manager/' break elif choice == 'Previous Page': page_number -= 1 site.clear() elif choice == 'Next Page': page_number += 1 site.clear() else: student_row = get_input("Enter row number of the student: ", output_type=int) student_row -= 1 if student_row >= len( user_list[page_number]) or student_row < 0: return ['Invalid row number!'] if choice == 'Accept': site.accept_user(user_list[page_number][student_row]) else: site.reject_user(user_list[page_number][student_row]) return ['Operation completed successfully.'] return None
def run(self, site, messages=None): site.clear() show_messages(messages) course_list = paginator(site.get_available_courses(), 20) page_number = 0 while True: if len(course_list) == 0: print("There is no available course in the system.") else: pprint_table('Available Courses', copy.copy(course_list[page_number]), foot='Page {} of {}'.format( page_number + 1, len(course_list))) menu = ['Home'] if page_number - 1 >= 0: menu.append('Previous Page') if page_number + 1 < len(course_list): menu.append('Next Page') if len(course_list) > 0: menu.append('Select') choice = choose_from_menu(menu) if choice == 'Home': site.state = '/student/' break elif choice == 'Previous Page': page_number -= 1 site.clear() elif choice == 'Next Page': page_number += 1 site.clear() else: course_row = get_input( "Enter row number of the course to get it: ", output_type=int) course_row -= 1 if course_row >= len( course_list[page_number]) or course_row < 0: return ['Invalid row number!'] site.active_user.add_course( course_list[page_number][course_row]) return ['You added course successfully.'] return None
def run(self, site, messages=None): site.clear() show_messages(messages) teacher_list = paginator(site.get_verified_teachers(), 20) page_number = 0 while True: if len(teacher_list) == 0: print("There is no student in the system.") else: pprint_table('Teachers', copy.copy(teacher_list[page_number]), foot='Page {} of {}'.format(page_number + 1, len(teacher_list))) menu = ['Home'] if page_number - 1 >= 0: menu.append('Previous Page') if page_number + 1 < len(teacher_list): menu.append('Next Page') if len(teacher_list) > 0: menu.append('Rate') choice = choose_from_menu(menu) if choice == 'Home': site.state = '/student/' break elif choice == 'Previous Page': page_number -= 1 site.clear() elif choice == 'Next Page': page_number += 1 site.clear() else: teacher_row = get_input('Enter the row number of the teacher you wanna rate: ', output_type=int) teacher_row -= 1 if teacher_row < 0 or teacher_row >= len(teacher_list[page_number]): return ['Invalid row number!'] rate = get_input('How do you rate this teacher?\nChoose a natural number from 1 to 5: ', output_type=int) if rate < 1 or rate > 5: return ['Invalid rating!'] teacher_list[page_number][teacher_row].rates[rate - 1] += 1 return ['You rated the teacher successfully.'] return None
def run(self, site, messages=None): site.clear() show_messages(messages) student_list = [(student.get_average_score(), student) for student in site.get_verified_students()] student_list.sort() student_list = student_list[::-1] student_list = [[t[0], t[1].name, t[1].serial, t[1].field] for t in student_list] student_list = paginator(student_list, 20) page_number = 0 while True: if len(student_list) == 0: print("There is no verified students in the system.\n") else: pprint_table( 'Students', student_list[page_number], foot='Page {} of {}'.format(page_number + 1, len(student_list)), cols_title=['Avg. Score', 'Name', 'Student No.', 'Field']) menu = ['Home'] if page_number - 1 >= 0: menu.append('Previous Page') if page_number + 1 < len(student_list): menu.append('Next Page') choice = choose_from_menu(menu) if choice == 'Home': site.state = '/manager/' break elif choice == 'Previous Page': page_number -= 1 site.clear() elif choice == 'Next Page': page_number += 1 site.clear() return None
def run(self, site, messages=None): site.clear() show_messages(messages) choice = choose_from_menu(self.MENU.keys()) site.state = self.MENU[choice] return None