Campus management system (02)Demand:From the "student elective system" these words can be seen, our core function is actually only elective courses.Role:Student administratorFunction:Landing: administrators and students can login and automatically distinguish their identity after landing.chooseLesson: students are free to choose courses for themselves.Create Users: The course selection system is for our students, so all users should be done by the administratorbecomeLook at the course selection: each student can check his own course selection, and the administrator should be able to check it.Information for all studentsWorkflow:Login: user enters user name and password.Identity Judgment: Users should be identified as students and lecturers when logging in.Or an administrator?Student users: for student users, landing work is almost unchanged.1. Look at all courses.2.Optional course3. Check out the selected courses.4. Exit procedureAdministrators users: administrators can do more things.1. Create courses2. Create student student accounts.3. Look at all courses.4. Look at all the students.5. Check the selection of all students.Advanced needs of lecturers6. Create lecturers.7. Assign classes for lecturers.8, create class9. Assign classes to students.10. Exit procedureLecturer user: for instructor users, the following functions can be completed.1. Look at all courses.2. Check the classes you have taught.3. Look at the students in the class.4. Exitprogram
Student selection process
readmefile information

import os import sys base_path = os.path.dirname(os.path.dirname(__file__)) sys.path.append(base_path) from core import cores if __name__ == '__main__': cores.start()
binNext start.py

userinfo = r'D:\python_23\day07\db\userinfo' courseinfo = r'D:\python_23\day07\db\courseinfo' select_course = r'D:\python_23\day07\db\select_course' gradeinfo = r'D:\python_23\day07\db\gradeinfo' tearch_grade = r'D:\python_23\day07\db\tearch_grade' student_grade = r'D:\python_23\day07\db\student_grade'
confNext settings.py

#Sign in import hashlib def md5(arg): # This is an encryption function that encrypts incoming functions. md5_pwd = hashlib.md5(bytes('123', encoding='utf-8')) md5_pwd.update(bytes(arg, encoding='utf-8')) return md5_pwd.hexdigest() # Return encrypted data from conf import settings def login(): usr = input('please user:') pwd = input('please password: ') with open(settings.userinfo,'r') as f: for line in f: user,passwd,identify = line.strip().split('|') if user == usr and passwd == md5(pwd): print('Login success') return {'user':user,'identify':identify} else: print('Login failed, enter the correct account password.') return {'user': user, 'identify': None}
coreNext auth.py

#Sign in import sys import os from core import auth from conf import settings import pickle import hashlib def md5(arg): # This is an encryption function that encrypts incoming functions. md5_pwd = hashlib.md5(bytes('123', encoding='utf-8')) md5_pwd.update(bytes(arg, encoding='utf-8')) return md5_pwd.hexdigest() # Return encrypted data class Die: def show_select_courese(self): with open(settings.courseinfo,'rb') as f: while True: try: obj = pickle.load(f) print('Course Name:%s, course price:%s, course cycle:%s, instructors:%s' % (obj.name, obj.price, obj.period, obj.tearch)) except EOFError: break class Course: def __init__(self,name,price,period,tearch): self.name = name self.price = price self.period = period self.tearch = tearch class Student: operat_list = [('View optional courses','show_courese'),('Choice of courses','choose_course'),('View selected courses','show_select_courese'),('Sign out','exit')] courses_list1 = [] def __init__(self,name): self.name = name def show_courese(self): Die.show_select_courese(self.name) def choose_course(self): Die.show_select_courese(self.name) with open(settings.select_course, 'ab') as f1: cours = input('Please choose the name of the course.') if cours in Student.courses_list1: print('Courses already exist') else: Student.courses_list1.append(cours) pickle.dump({self.name: Student.courses_list1}, f1) print('User%s, add course%s success' % (self.name, cours)) # pickle.dump({ret['user']:Student.courses_list1},f1) # print('User%s, add course%s success "% (ret['user'], cours)" def show_select_courese(self): with open(settings.select_course, 'rb') as f1: while True: try: obj = pickle.load(f1) print(obj) except EOFError: break def exit(self): exit('Looking forward to your next visit') class Manager(Die): operat_list = [('Create a course', 'create_course'), ('Create students', 'create_student'), ('View optional courses', 'show_select_course'), ('Check all students', 'show_select_student'), ('Check all students and selected courses.', 'show_stu_course'), ('Create a lecturer', 'create_tearch'), ('Designate classes for lecturers', 'tearch_grade'), ('Create a class', 'create_grade'), ('Assign classes to students', 'select_stu_grade'), ('Sign out', 'exit')] def __init__(self,name): self.name = name def create_course(self): name = input('Please input the course:') price = input('Price:') period = input('Cycle:') tearch = input('tearch:') course = Course(name,price,period,tearch) with open(settings.courseinfo,'ab') as f: pickle.dump(course,f) print('Curriculum success') def create_student(self): user = input('Please input the student name:') pwd = input('Please input a password:') ret = input('Input students' categories, such as Student:') if ret == 'Student': course = '\n%s|%s|%s'%(user,md5(pwd),ret) with open(settings.userinfo,'a') as f: f.write('%s'%course) print('%sCreate success'%user) else: print('You did not enter Student.') def show_select_course(self): Die.show_select_courese(self.name) def show_select_student(self): with open(settings.userinfo,'r') as f: for i in f: name,pwd,identify = i.strip().split('|') if identify == 'Manager' or identify == 'Tearch': pass else: print(name) def show_stu_course(self): with open(settings.select_course, 'rb') as f1: while True: try: obj = pickle.load(f1) for x,y in obj.items(): print('User%s has studied%s courses.'%(x,y)) # print(obj) except EOFError: break def create_tearch(self): user = input('Please input the name of the lecturer created:') pwd = input('Please input a password:') ret = input('Input categories of lecturers, such as Tearch:') if ret == 'Tearch': course = '\n%s|%s|%s'%(user,md5(pwd),ret) with open(settings.userinfo,'a') as f: f.write('%s'%course) print('%sTeachers create success'%user) else: print('You did not enter Student.') def tearch_grade(self): grade_list = [] with open(settings.userinfo,'r') as f: for line in f: name,pwd,identify = line.strip().split('|') with open(settings.gradeinfo,'rb') as f1: obj = pickle.load(f1) grade_list.append(obj) if identify == 'Tearch': print('You can assign classes for%s teachers with class \n (%s).'%(name,obj)) print('-------------') grade = int(input('Please enter class number.')) with open(settings.tearch_grade,'ab') as f2: pickle.dump({name:grade_list},f2) print('%sThe teacher has been a lecturer in class%s.'%(name,grade)) def create_grade(self): grade = input('Please enter the class number you want to create.') with open(settings.gradeinfo,'ab') as f: pickle.dump(grade,f) print('%sThe number class has been created successfully.'%grade) def select_stu_grade(self): stu_grade = [] with open(settings.userinfo,'r') as f: with open(settings.gradeinfo, 'rb') as f1: obj = pickle.load(f1) for line in f: name, pwd, identify = line.strip().split('|') if identify == 'Manager' or identify == 'Tearch': pass else: print('Please select class for students below (%s), \n optional class, (%s) class \n.'%(name,obj)) ret = input('Please enter the class number you want to choose.') # stu_grade.append('ret') with open(settings.student_grade,'ab') as f3: pickle.dump({name:ret},f3) print('Student%s has joined the%s class.'%(name,ret)) def exit(self): exit('Look forward to seeing you next time') class Tearch(Die): operat_list = [('View all courses', 'select_course'), ('View the class taught', 'select_grade'), ('Class students', 'select_grade_stu'), ('Sign out', 'exit')] def __init__(self,name): self.name = name def select_course(self): Die.show_select_courese(self.name) def select_grade(self): with open(settings.tearch_grade,'rb') as f: obj = pickle.load(f) for x,y in obj.items(): print('%sThe teacher's class has%s.'%(x,y)) def select_grade_stu(self): with open(settings.student_grade,'rb') as f: obj = pickle.load(f) for x,y in obj.items(): print('%sThere are%s students in the class.'%(y,x)) def start(): ret = auth.login() if ret['identify']: cls = getattr(sys.modules[__name__],ret['identify']) obj = cls(ret['user']) while True: for index,i in enumerate(cls.operat_list,1): print(index,i[0]) ind = int(input('please num')) print('----------------') func = cls.operat_list[ind-1][1] getattr(obj,func)() print('----------------')
coreNext cores.py
dbThe next document
courseinfo ##Course name data fileGradeinfo class data fileSelect_course data fileStudent_grade student data fileTearch_gradeTeacher's class data fileUserinfo # holds the user password and identity data file admin | 4297f44b139535245b24979d7a93 | Manager
logFor the time being