码迷,mamicode.com
首页 > 其他好文 > 详细

开发一套选课系统

时间:2018-04-20 23:39:57      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:添加   cme   在北京   角色   inf   修改   简单   管理员   school   

一:项目题目:开发一套选课系统

二:项目需求:

角色:学校、学员、课程、讲师

要求:

1. 创建北京、上海 2 所学校
2. 创建linux , python , go 3个课程 , linux\py 在北京开, go 在上海开
3. 课程包含,周期,价格,通过学校创建课程 
4. 通过学校创建班级, 班级关联课程、讲师
5. 创建学员时,选择学校,关联班级
5. 创建讲师角色时要关联学校, 
6. 提供两个角色接口
    6.1 学员视图, 可以注册, 交学费, 选择班级,
    6.2 讲师视图, 讲师可管理自己的班级, 上课时选择班级, 查看班级学员列表 , 修改所管理的学员的成绩 
    6.3 管理视图,创建讲师, 创建班级,创建课程

7. 上面的操作产生的数据都通过pickle序列化保存到文件里

  

三:注意事项

1.(简单)实现70%+功能,充分使用类
2.(一般)类的设计比较清晰、合理
3.(完整)整体代码逻辑很清晰、角色划分清楚、不同角色的主要功能都实现了

  

四,项目思路

 1,先分析题目,,也就是找关键词,从上面可以看出有三个视图,分别是管理员视图,讲师视图,学员视图

对角色进行分类:学校,老师,学生,课堂,班级,管理者

三个视图,也就是三个管理接口,分别是学员视图,讲师视图,管理视图

五个角色,也就是定义五个类,分别是学校,学员,课程,讲师,班级

  

2,分析管理员创建什么东西,老师创建什么东西,学生创建什么东西

一个讲师可以教多个班
一个学员可以学多个班级的课
一个课程可以有多个班级
一个班级对应一个课程
一个班级对应一个讲师

学生视图:要选择学校,选择班级,其中班级显示其名称,课程,价钱,添加到对应的班级里面
讲师视图:可以查看所教授的课程的班级,班级学生的信息
管理员视图:可以创建讲师,创建班级,创建课程,查询讲师,班级,课程的功能

  

3,具体进行分析

    具体分析学生视图,学生视图进去可以注册学生(包括选择所在学校,选择所在班级,选择所学课程),
查看学生的成绩,查看学生的到课情况

具体分析讲师视图,讲师视图进去可以注册讲师(包括选择所在学校,选择所教班级,选择所教课程),
创建学生的成绩,创建学生的到课情况(管理班级)

具体分析管理视图,管理视图进去可以创建学生,创建讲师,创建课程,创建学校,创建班级,创建课程等等

对于管理系统,我附加了登陆认证,我认为管理不是随便就可以进去的,管理者账号admin,密码root,
认证成功后才可以进行一系列操作

  

4,写出大致的伪代码,并实现其功能,如下:

伪代码:
学校视图:
    选择学校
        1,创建班级
        2,创建讲师
        3,创建课程
     4,查询讲师
     5,查询班级
     6,查询课程

讲师视图
    1,查看班级
    2,查看班级学员列表
学员视图
    1,注册
    2,报名缴费
    3,选择班级

 

5,填充代码

 

五,项目流程图

 技术分享图片

 六,README文件

作者:zhanzhengrecheng

程序介绍:

    实现选课系统 常用功能

    功能全部用python的基础知识实现,用到了os\sys\pickle\函数\模块\类知识

概述

本次作业文件夹一共包含了以下6个文件:

流程图: Select Course思路流程图

程序结构图:整个Select Course的程序文件结构

程序结构文件:整个Select Course的程序文件结构

程序文件: Select Course

程序说明文件:README.md


程序要求


    创建北京、上海 2 所学校

    创建linux , python , go 3个课程 , linux\py 在北京开, go 在上海开

    课程包含,周期,价格,通过学校创建课程

    通过学校创建班级, 班级关联课程、讲师
    
    创建学员时,选择学校,关联班级

    创建讲师角色时要关联学校,
    
    提供两个角色接口

    学员视图, 可以注册, 交学费, 选择班级,

    讲师视图, 讲师可管理自己的班级, 上课时选择班级, 查看班级学员列表 , 修改所管理的学员的成绩

    管理视图,创建讲师, 创建班级,创建课程  

    上面的操作产生的数据都通过pickle序列化保存到文件里


 本程序思路是写了一个Select Course的程序



    先分析题目,,也就是找关键词,从上面可以看出有三个视图,分别是管理员视图,讲师视图,学员视图

    对角色进行分类:学校,老师,学生,课堂,班级,管理者

    分析管理员创建什么东西,老师创建什么东西,学生创建什么东西

    具体分析学生视图,学生视图进去可以注册学生(包括选择所在学校,选择所在班级,选择所学课程),
    查看学生的成绩,查看学生的到课情况

    具体分析讲师视图,讲师视图进去可以注册讲师(包括选择所在学校,选择所教班级,选择所教课程),
    创建学生的成绩,创建学生的到课情况(管理班级)

    具体分析管理视图,管理视图进去可以创建学生,创建讲师,创建课程,创建学校,创建班级,创建课程等等

    对于管理系统,我附加了登陆认证,我认为管理不是随便就可以进去的,管理者账号admin,密码root,
    认证成功后才可以进行一系列操作

    写出伪代码,然后填充

程序结构

备注(程序结构)

    目前还不会在windows中用树的结构,所以做出程序结构的txt版本,放在文件外面

    对几个实例文件的说明

── admin # 管理者账户数据,只存了一个管理者,账号是admin,密码是root

── c++	# 这是存课程类中其中一个课程的详细信息

── class #这是存班级的文件,比如创建了python全栈1班,。。。

── class_grade # 这是存班级中学生成绩的文件,比如王二:87

── class_record # 这是存班级中学生到课次数的文件,比如王二:8次

── Course # 这是存所有课程的文件,比如目前开的课程有‘python‘, ‘linux‘, ‘java‘,c++,.。。

── java #这是存课程类中其中一个课程的详细信息

── linux # 这是存课程类中其中一个课程的详细信息

── python # 这是存课程类中其中一个课程的详细信息

── school # 这是存所有学校的文件,比如目前只有北京分校,上海分校,。。。


不足及其改进的方面

1,未能熟练的使用类方法,好多类中函数为了方便类与对象都可以调用,写成了普通函数,

2,希望对类有更熟悉的认识之后,重构代码,用class写,不出现很多@staticmethod

3,想法比较简单,希望能学习更好的用类写出来的选课系统,自己再研究研究

  

七,程序结构图

技术分享图片

 

八,程序代码

 8.1 bin

bin下run.py

# _*_ coding: utf-8 _*_ 
import os
import sys

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(BASE_DIR)

from core import main

if __name__ ==‘__main__‘:
    main.begin()

  

8.2 conf

conf下settings.py

# _*_ coding: utf-8 _*_
import sys
import os
import logging

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(BASE_DIR)

DATABASE = {
    ‘engine‘:‘file_storage‘, #文件存储,这里可扩展成数据库形式
    ‘name‘:‘accounts‘,       #db下的文件名称
    ‘path‘:‘%s/db‘%BASE_DIR
}
LOGIN_LEVEL = logging.INFO     #初始化日志记录级别为INFO,INFO以下的可以直接打印
#日志类型
LOGIN_TYPE = {
    ‘system‘:‘system.log‘,
}

  

8.3 core

core下的accounts.py

# _*_ coding: utf-8 _*_ 
#读取数据和保存数据
import os
import sys
import pickle,json
import  logging

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(BASE_DIR)  #添加环境变量

from core import auth
from core import db_handler
from conf import settings

class MyPickle:
    def __init__(self):
        pass

    def load_account(account):
        db_path = db_handler.db_handler(settings.DATABASE)
        account_file = ‘%s/%s‘ % (db_path, account)
        if os.path.isfile(account_file):  # 如果用户名存在
            with open(account_file, ‘rb‘) as f:
                account_data = pickle.load( f)
                return account_data
        else:
            print("\033[31;1mAccount [%s] does not exist!\033[0m" % account)
            exit()

    def save_account(account_dic):
        db_path = db_handler.db_handler(settings.DATABASE)
        filename = ‘%s/%s‘ % (db_path, account_dic[‘account‘])
        with open(filename,‘wb‘) as f:
            acc_data = pickle.dump(account_dic, f)

    def save_course(account_dic):
        db_path = db_handler.db_handler(settings.DATABASE)
        filename = ‘%s/%s‘ % (db_path, account_dic[‘course_name‘])
        with open(filename,‘wb‘) as f:
            acc_data = pickle.dump(account_dic, f)

    def load_course(course_name):
        db_path = db_handler.db_handler(settings.DATABASE)
        account_file = ‘%s/%s‘ % (db_path, course_name)
        if os.path.isfile(account_file):#如果用户名存在
            with open(account_file, ‘rb‘) as f:
                account_data = pickle.load( f)
                print("\033[34;1m--------这是您查找的课程信息----------\033[0m")
                print(‘\033[32;1m%s\033[0m‘%account_data)
                return account_data
        else:
            print("\033[31;1mCourse [%s] does not exist!\033[0m" % course_name)
            exit()

    def save_class(name,class_name):
        db_path = db_handler.db_handler(settings.DATABASE)
        filename = ‘%s/%s‘ % (db_path, name)
        with open(filename, ‘a+‘,encoding=‘utf-8‘) as f:
            f.write(class_name)
            f.write(‘,‘)

    def load_class(name):
        db_path = db_handler.db_handler(settings.DATABASE)
        account_file = ‘%s/%s‘ % (db_path, name)
        if os.path.isfile(account_file):  # 如果用户名存在
            with open(account_file, ‘r‘,encoding=‘utf-8‘) as f:
                account_data = f.read()
                print("----------\033[34;1m目前存在的班级\033[0m----------")
                print("\033[31;1m%s\033[0m" % account_data)
                print("-----------------------------------")
                return account_data
        else:
            print("\033[31;1mClass [%s] does not exist!\033[0m" % name)
            exit()

    def save_classrecord(name,classrecord_dict):
        db_path = db_handler.db_handler(settings.DATABASE)
        filename = ‘%s/%s‘ % (db_path, name)
        with open(filename, ‘a+‘,encoding=‘utf-8‘) as f:
            f.write(classrecord_dict)
            f.write(‘,‘)

    def load_classrecord(name):
        db_path = db_handler.db_handler(settings.DATABASE)
        account_file = ‘%s/%s‘ % (db_path, name)
        if os.path.isfile(account_file):  # 如果用户名存在
            with open(account_file, ‘r‘,encoding=‘utf-8‘) as f:
                account_data = f.read()
                print("-----------------课堂记录-------------------")
                print("\033[31;1m%s\033[0m" % account_data)
                print("-------------------------------------------")
                return account_data
        else:
            print("\033[31;1mClass record does not exist!\033[0m" )
            exit()

    def save_classgrade(name,classgrade_dict):
        db_path = db_handler.db_handler(settings.DATABASE)
        filename = ‘%s/%s‘ % (db_path, name)
        with open(filename, ‘a+‘,encoding=‘utf-8‘) as f:
            f.write(classgrade_dict)
            f.write(‘,‘)

    def load_classgrade(name):
        db_path = db_handler.db_handler(settings.DATABASE)
        account_file = ‘%s/%s‘ % (db_path, name)
        if os.path.isfile(account_file):  # 如果用户名存在
            with open(account_file, ‘r‘,encoding=‘utf-8‘) as f:
                account_data = f.read()
                print("-----------------学生成绩-------------------")
                print("\033[31;1m%s\033[0m" % account_data)
                print("-------------------------------------------")
                return account_data
        else:
            print("\033[31;1mClass grade does not exist!\033[0m")
            exit()

    def save_school(name, school_name):
        db_path = db_handler.db_handler(settings.DATABASE)
        filename = ‘%s/%s‘ % (db_path, name)
        with open(filename, ‘a+‘,encoding=‘utf-8‘) as f:
            f.write(school_name)
            f.write(‘,‘)

    def load_school(name):
        db_path = db_handler.db_handler(settings.DATABASE)
        account_file = ‘%s/%s‘ % (db_path, name)
        if os.path.isfile(account_file):  # 如果用户名存在
            with open(account_file, ‘r‘,encoding=‘utf-8‘) as f:
                account_data = f.read()
                print("----------\033[34;1m目前存在的学校\033[0m----------")
                print("\033[31;1m%s\033[0m" % account_data)
                print("-----------------------------------")
                return account_data
        else:
            print("\033[31;1mSchool  does not exist!\033[0m")
            exit()

    def save_coursedata(name, course_name):
        db_path = db_handler.db_handler(settings.DATABASE)
        filename = ‘%s/%s‘ % (db_path, name)
        with open(filename,‘a+‘,encoding=‘utf-8‘) as f:
            f.write(course_name)
            f.write(‘,‘)

    def load_coursedata(name):
        db_path = db_handler.db_handler(settings.DATABASE)
        account_file = ‘%s/%s‘ % (db_path, name)
        if os.path.isfile(account_file):  # 如果用户名存在
            with open(account_file, ‘r‘,encoding=‘utf-8‘) as f:
                account_data = f.read()
                print("----------\033[34;1m这是已经有的课程\033[0m----------")
                print("\033[31;1m%s\033[0m" % account_data)
                print("----------------------------------------------------")
                return account_data
        else:
            print("\033[31;1mCourse  does not exist!\033[0m")
            exit()

  

core下auth.py

# _*_ coding: utf-8 _*_ 
import os
import json
from core import accounts
#用户认证

def access_login(user_data,log_obj):
    ‘‘‘
    登陆函数,当登陆失败超过三次,则退出
    登陆成功之后,查看这个人的身份,来确定进入那个视图
    :return: 如果用户账号密码正确,则返回用户数据的字典
    ‘‘‘
    retry_count = 0
    while user_data[‘is_authenticated‘] is not True and retry_count <3:
        account = input(‘\033[34;1mplease input Administrator Acount:\033[0m‘).strip()
        password = input(‘\033[34;1mplease input Administrator Password:\033[0m‘).strip()
        #用户账号密码正确,则返回用户数据的字典
        auth = access_auth(account,password,log_obj)
        if auth:
            user_data[‘is_authenticated‘] = True  #用户认证为True
            user_data[‘account_id‘]  = account   #用户账号ID为账号名
            return auth
        retry_count +=1
    else:
        print("Account [%s] try logging too many times..." % account)
        log_obj.error("Account [%s] try logging too many times..." % account)
        exit()

def access_auth(account,password,log_obj):
    ‘‘‘
    下面access_login调用access_auth方法,用于登陆
    :param account: 用户名
    :param password: 密码
    :param log_obj:
    :return:
    ‘‘‘
    account_data = accounts.MyPickle.load_account(account)
    if account_data.get(‘vip_password‘) is not None:
        if account_data[‘vip_password‘] == password:
            log_obj.info("Account [%s] logging success" % account)
            return account_data
        else:
            log_obj.error(" Password does not correct!")
            print("\033[31;1m Password not correct!\033[0m")
    else:
        log_obj.error("Account or Password does not correct!")
        print("\033[31;1mAccount or Passwordoes not correct!\033[0m")

  

core下db_handler.py

# _*_ coding: utf-8 _*_ 
‘‘‘处理与数据之间的交互,如果file_db_storage,返回路径‘‘‘
import pickle
import os
from conf import settings

def db_handler(conn_parms):
    if conn_parms[‘engine‘] == ‘file_storage‘:
        return file_db_handle(conn_parms)

def file_db_handle(conn_parms):
    ‘‘‘
    对文件路劲做语法分析
    :param conn_parms:
    :return:
    ‘‘‘
    db_path = ‘%s/%s‘%(conn_parms[‘path‘],conn_parms[‘name‘])
    return db_path

  

core下logger.py

# _*_ coding: utf-8 _*_
‘‘‘操作所有的日志工作‘‘‘
import logging
from conf import settings

def logger(log_type):

    #创建日志
    logger = logging.getLogger(log_type)
    logger.setLevel(settings.LOGIN_LEVEL)

    #创建屏幕对象和设置等级debug
    # ch = logging.StreamHandler()
    # ch.setLevel(settings.LOGIN_LEVEL)

    #创建文件对象,给文件对象设置等级
    log_file = "%s/log/%s"%(settings.BASE_DIR,settings.LOGIN_TYPE[log_type])
    fh = logging.FileHandler(log_file)
    fh.setLevel(settings.LOGIN_LEVEL)
    # 设置输出对象格式
    formatter = logging.Formatter(‘%(asctime)s - %(name)s - %(levelname)s - %(message)s‘)

    #把格式添加到配置中
    # ch.setFormatter(formatter)
    fh.setFormatter(formatter)

    #把日志打印到指定的handler
    # logger.addHandler(ch)
    logger.addHandler(fh)

    return logger

  

core下main.py

# _*_ coding: utf-8 _*_
from core import Manager
from core import Student
from core import Teacher
from conf import settings
from core import  logger
from core import auth
import sys

#初始化账户数据
user_data = {
    ‘account_id‘:None,
    ‘is_authenticated‘:False,
    ‘account_data‘:None
}
#系统日志记录到文件中
access_logger = logger.logger(‘system‘)

def interactive(msg,menu_dic):
    exit_flag = False
    while not exit_flag:
        print(msg)
        user_choice = input("please choice >>>>").strip()
        if user_choice in menu_dic:
            menu_dic[user_choice]()
        else:
            print("\033[31;1myou choice doesn‘t exist\033[0m")

def Student_view():
    msg = ‘‘‘\033[32;1m-------welcome to student manage view------
            1   注册新学生用户
            2   查看上课记录
            3   查看作业成绩
            4   退出
    \033[0m‘‘‘
    menu_dic = {
        "1": Student.Student.resistered,
        "2":Student.Student.find_classrecord,
        "3":Student.Student.find_grade,
        "4":logout,
    }
    interactive(msg,menu_dic)

def  Teacher_view():
    msg = ‘‘‘\033[32;1m-------welcome to teacher manage view------
            1   创建新讲师
            2   创建学生上课情况
            3   创建学生考试成绩
            4   logout
    \033[0m‘‘‘
    menu_dic = {
        "1":Teacher.Teacher.resistered,
        "2":Teacher.Teacher.create_classrecord,
        "3":Teacher.Teacher.create_grade,
        "4":logout,
    }
    interactive(msg, menu_dic)

def Manager_view():
    msg = ‘‘‘\033[32;1m-------welcome to admin manage view------
            1   创建讲师
            2   创建学生
            3   创建学校
            4   创建课程
            5   查看课程
            6   查看学校
            7   创建班级
            8   查看班级
            9   退出
    \033[0m‘‘‘
    menu_dic = {
        "1":Manager.Manager.create_teacher,
        "2":Manager.Manager.create_student,
        "3":Manager.Manager.create_school,
        "4": Manager.Manager.create_course,
        "5": Manager.Manager.show_course,
        "6":Manager.Manager.show_school,
        "7": Manager.Manager.create_class,
        "8": Manager.Manager.show_class,
        "9": logout,
    }
    # login_judge()
    interactive(msg, menu_dic)

#退出,写简单函数即可
def logout():
    ‘‘‘
    退出登陆
    :return:
    ‘‘‘
    print("\033[32;1m-------Looking forward to your next visit-------\033[0m")
    exit()

def begin():
    ‘‘‘
    开始入口
    :return:
    ‘‘‘
    msg = ‘‘‘\033[32;1m-------welcome to course selectionn system------
            1   Student_system
            2   Teacher_system
            3   Manager_system
            4   logout
    \033[0m‘‘‘
    menu_dic = {
        "1":Student_view,
        "2":Teacher_view,
        "3":Manager_view,
        "4":logout,
    }

    interactive(msg, menu_dic)

def login_judge():
    # 调用认证模块,返回用户文件json.load后的字典,传入access_logger日志对象

    access_data = auth.access_login(user_data,access_logger)
    if user_data[‘is_authenticated‘]:       #如果用户认证成功
        user_data["account_data"] = access_data

  

core下Manager.py

# _*_ coding: utf-8 _*_
from core import Teacher
from core import Student
from core import accounts
from lib import Course
from lib import Classes
from lib import School

class Manager:
    def __init__(self):
        pass
    @staticmethod
    def create_student():
        Student.Student.resistered()

    @staticmethod
    def create_teacher():
        Teacher.Teacher.resistered()

    @staticmethod
    def create_course():
        Course.Course.create_course()

    @staticmethod
    def show_course():
        Course.Course.show_course()

    @staticmethod
    def create_class():
        Classes.Classes.create_class()

    @staticmethod
    def show_class():
        Classes.Classes.show_class()

    @staticmethod
    def create_school():
        School.School.create_school()

    @staticmethod
    def show_school():
        School.School.show_school()

  

core下Student.py

# _*_ coding: utf-8 _*_
‘‘‘
学员视图,学员创建姓名,年龄,所报的班级,所报的学校等等
‘‘‘
from core import main
from core import accounts
from core import Manager
from lib import Course
class Student:
    def __init__(self):
        pass

    #学生注册
    @staticmethod
    def resistered():
        student_dict = {}
        print(‘\033[32;1m-------welcome to student registered system------\033[0m‘)
        student_name = input("student_name >>>")
        student_password = input("student_password >>>")
        Manager.Manager.show_school()
        student_school = input("student_school >>>")
        Manager.Manager.show_class()
        student_class = input("student_class >>>")
        accounts.MyPickle.load_coursedata(‘course‘)
        student_course = input("student_course >>>")
        student_score = None
        student_identity = ‘student‘
        student_dict[‘account‘] = student_name
        student_dict[‘password‘] = student_password
        student_dict[‘school‘] = student_school
        student_dict[‘class‘] = student_class
        student_dict[‘course‘] = student_course
        student_dict[‘score‘] = student_score
        student_dict[‘identity‘] = student_identity
        print("\033[32;1m--------这是您登记的信息,请查看----------\033[0m")
        print(‘\033[31;1m%s\033[0m‘%student_dict)
        accounts.MyPickle.save_account(student_dict)

    #查看上课记录
    @staticmethod
    def find_classrecord():
        ‘‘‘上课记录是老师给的‘‘‘
        print(‘\033[32;1m-------welcome to Student system(find classrecord)------\033[0m‘)
        name = ‘class_record‘
        accounts.MyPickle.load_classrecord(name)

    #查看作业成绩
    @staticmethod
    def find_grade():
        ‘‘‘成绩是老师给的‘‘‘
        print(‘\033[32;1m-------welcome to Student system(find classgrade)------\033[0m‘)
        name = ‘class_grade‘
        accounts.MyPickle.load_classgrade(name)

  

core下Teacher.py

# _*_ coding: utf-8 _*_
from core import accounts
from core import Manager

class Teacher:
    def __init__(self):
        pass

    #讲师注册
    @staticmethod
    def resistered():
        teacher_dict = {}
        print(‘\033[32;1m-------welcome to teacher registered system------\033[0m‘)
        teacher_name = input("teacher_name >>>")
        teacher_password = input("teacher_password >>>")
        Manager.Manager.show_school()
        teacher_school = input("teacher_school >>>")
        Manager.Manager.show_class()
        teacher_class = input("teacher_class >>>")
        teacher_identity = ‘teacher‘
        teacher_dict[‘account‘] = teacher_name
        teacher_dict[‘password‘] = teacher_password
        teacher_dict[‘school‘] = teacher_school
        teacher_dict[‘class‘] = teacher_class
        teacher_dict[‘identity‘] = teacher_identity
        print("\033[32;1m--------这是您登记的信息,请查看----------\033[0m")
        print(‘\033[31;1m%s\033[0m‘ % teacher_dict)
        accounts.MyPickle.save_account(teacher_dict)

    #创建上课记录,想法是每一个人对应一个记录,比如王某:8次
    @staticmethod
    def create_classrecord():
        classrecord_dict = {}
        print(‘\033[32;1m-------welcome to teacher  system(create class_record)------\033[0m‘)
        student_name = input("student_name >>>")
        class_record = input("class_record >>>")
        classrecord_dict[student_name] = class_record
        name = ‘class_record‘
        classrecord_dict = str(classrecord_dict)
        accounts.MyPickle.save_classrecord(name,classrecord_dict)

    #创建作业成绩,想法是每一个人对应一个记录,比如王某:98
    @staticmethod
    def create_grade():
        classgrade_dict = {}
        print(‘\033[32;1m-------welcome to teacher  system(create class_grade)------\033[0m‘)
        student_name = input("student_name >>>")
        class_grade = input("class_grade >>>")
        classgrade_dict[student_name] = class_grade
        name = ‘class_grade‘
        classgrade_dict = str(classgrade_dict)
        accounts.MyPickle.save_classgrade(name,classgrade_dict)

  

8.4 db

db下accounts

(这是文件,在这里就不一一展示了)

8.5lib

lib下Classes

# _*_ coding: utf-8 _*_
from lib import Course
from core import accounts
from core import Manager
class Classes:
    def __init__(self):
        pass

    @staticmethod
    def create_class():
        name = ‘class‘
        print(‘\033[32;1m-------welcome to manage  system(create class)------\033[0m‘)
        class_data = accounts.MyPickle.load_class(name)
        class_name = input("class_name >>>")
        accounts.MyPickle.save_class(name,class_name)

    @staticmethod
    def show_class():
        print(‘\033[32;1m-------welcome to Manager system(find class)------\033[0m‘)
        name = ‘class‘
        accounts.MyPickle.load_class(name)

  

lib下Course

# _*_ coding: utf-8 _*_ 
#创建一个课程类,包括课程名称,课程周期,课程价格
from core import accounts
from core import Manager
class Course:
    def __init__(self):
       pass
    @staticmethod
    def create_course():
        name = ‘course‘
        print(‘\033[32;1m-------welcome to Manager system(create course)------\033[0m‘)
        course_data = accounts.MyPickle.load_coursedata(name)
        course_dict = {}
        accounts.MyPickle.load_school(‘school‘)
        course_school = input("The school of course:>>>")
        course_name = input("course name:>>>")
        course_period = input("course period:>>>")
        course_prices = input("course prices:>>>")
        course_dict["course_school"] = course_school
        course_dict["course_name"] = course_name
        course_dict["course_period"] = course_period
        course_dict["course_prices"] = course_prices
        print("\033[32;1m--------这是您创建课程的信息,请查看----------\033[0m")
        print(‘\033[31;1m%s\033[0m‘ % course_dict)
        accounts.MyPickle.save_course(course_dict)
        accounts.MyPickle.save_coursedata(name, course_name)
    @staticmethod
    def show_course():
        ‘‘‘
        输入课程信息
        :return:
        ‘‘‘
        print(‘\033[32;1m-------welcome to Manager system(find course)------\033[0m‘)
        name = ‘course‘
        accounts.MyPickle.load_coursedata(name)
        course_name = input("请输入要查找的课程名:>>>")
        accounts.MyPickle.load_course(course_name)

  

lib下School

# _*_ coding: utf-8 _*_
from lib import Course
from core import accounts
class School:
    def __init__(self):
        pass

    @staticmethod
    def create_school():
        name = ‘school‘
        school_data = accounts.MyPickle.load_school(name)
        print(‘\033[32;1m-------welcome to manage  system(create school)------\033[0m‘)
        school_name = input("school_name >>>")
        accounts.MyPickle.save_school(name,school_name)
    @staticmethod
    def show_school():
        print(‘\033[32;1m-------welcome to Manager system(find school)------\033[0m‘)
        name = ‘school‘
        accounts.MyPickle.load_school(name)

  

8.6log

system.log

2018-04-19 09:15:24,489 - system - ERROR - Account or Password does not correct!
2018-04-19 09:15:36,036 - system - ERROR - Account or Password does not correct!
2018-04-19 09:15:43,911 - system - ERROR - Account or Password does not correct!
2018-04-19 09:15:43,911 - system - ERROR - Account [admin] try logging too many times...
2018-04-19 09:20:48,536 - system - ERROR - Account or Password does not correct!
2018-04-19 09:23:00,911 - system - INFO - Account [admin] logging success
2018-04-19 09:29:27,238 - system - INFO - Account [admin] logging success
2018-04-19 09:40:13,110 - system - INFO - Account [admin] logging success
2018-04-19 10:02:58,567 - system - INFO - Account [admin] logging success
2018-04-19 10:03:16,395 - system - INFO - Account [admin] logging success
2018-04-20 13:57:36,289 - system - ERROR - Account or Password does not correct!
2018-04-20 13:58:19,360 - system - ERROR - Account or Password does not correct!
2018-04-20 13:58:52,241 - system - ERROR - Account or Password does not correct!
2018-04-20 14:00:03,168 - system - INFO - Account [admin] logging success
2018-04-20 14:00:43,360 - system - INFO - Account [admin] logging success
2018-04-20 14:01:50,831 - system - INFO - Account [admin] logging success
2018-04-20 14:02:24,279 - system - INFO - Account [admin] logging success

  

开发一套选课系统

标签:添加   cme   在北京   角色   inf   修改   简单   管理员   school   

原文地址:https://www.cnblogs.com/wj-1314/p/8707772.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!