Ejemplo n.º 1
0
def Dashboard( ):
    from database_managment import Get_Student
    student_list = Get_Student.Check_student()
    import datetime
    today = str(datetime.date.today())
    yesterday = str( datetime.date.today()+datetime.timedelta(days=-1) )
    return render_template( 'Dashboard.html',content=student_list,today = today,yesterday=yesterday )
Ejemplo n.º 2
0
def Student_info(  ):

    from database_managment import Get_Student
    result = Get_Student.Get_student()
    import time
    time.sleep(1)

    return render_template( 'student_info.html',result = result )
Ejemplo n.º 3
0
def Student_create(  ):
    from database_managment import Get_Student
    student_list = Get_Student.Check_student()
    import time
    time.sleep(1)

    if request.method == 'GET':
        stu_name = request.args.get( 'name','' )



        if stu_name in student_list:
            return render_template( 'alert.html',student_name = stu_name )

        else:
            try:
                Get_Student.Create_student(stu_name )
            except:
                stu_name = 'Error'
            return render_template('complete.html',stu_name = stu_name)
Ejemplo n.º 4
0
def Band():
    from database_managment import Get_Student
    student_list = Get_Student.Check_student()
    import numpy as np
    Band = np.linspace(0.0,9.0,19,endpoint=True)
    Band=np.delete(Band,12)
    import datetime
    today = str(datetime.date.today())
    Writing_Band = [ 'TR(W)','CC(W)','LR(W)','GRA(W)','Total(W)' ]
    Speaking_Band = [ 'FC(S)','LR(S)','GRA(S)','PR(S)','Total(S)' ]
    number = list( range(1,41) )
    return render_template('Band.html',content = student_list,Band=Band,Writing_Band=Writing_Band,Speaking_Band=Speaking_Band,today=today,number=number)
Ejemplo n.º 5
0
def Query(  ):
    if request.method=='GET':
        from database_managment import Get_Student
        section = request.args.get('Section','')
        stu_name = request.args.get('Name(Query)','')
        try:
            result = Get_Student.Check_date(section,stu_name)[0][0]
            return 'the latest update time of '+stu_name+' is :' + result.strftime( '%Y-%m-%d' )
        except:
            return  'there is no record for '+stu_name

    else:
        return '1'
Ejemplo n.º 6
0
def visualization():
    if request.method=='GET':
        name = request.args.get('Name(Dash)','')
        start = request.args.get('start_date','')
        end = request.args.get('end_date','')
        sec = request.args.get('Dash_Section','')
        from database_managment import Get_Student
        result = Get_Student.Visualization(name,sec,start,end)
        if len(result) > 1:
            period=[]
            band =[]
            for each in result:
                period.append( each[0])
                band.append(each[1])
            title = name+'_'+sec
            import matplotlib.pyplot as plt
            from matplotlib.font_manager import FontProperties

            plt.style.use('ggplot')
            font = FontProperties(fname=r'/System/Library/Fonts/STHeiti Light.ttc', size=14)
            plt.rcParams['axes.unicode_minus'] = False
            plt.figure( figsize=[12,6] )
            plt.subplot( 121 )
            plt.plot( period,band,'b--' )

            plt.xticks( rotation=45 )
            #plt.legend()
            plt.subplot(122)
            import seaborn as sns
            sns.distplot( band )

            path = '/Users/xiaoking/PycharmProjects/CRM_project/static/dashimg/'+title+'.jpg'
            link = '/static/dashimg/'+title+'.jpg'
            plt.title(title, fontproperties=font, fontsize='small')
            plt.savefig( path )
            import numpy as np
            avg = round(np.mean( band ),2)
            att = band.__len__()
            content = [ name,avg,att ]
            return render_template('visualization.html',link=link,title=title,content=content)

        else:
            return name+' has no records during the input period, pls check again\n '
    else:
        return 'ERROR'
Ejemplo n.º 7
0
from database_managment import Get_Student

Get_Student.Delete_student('模版')
#result = Get_Student.Get_student()
'''

from database_managment import db_connection
con = db_connection.connect()
cur = con.cursor()

cur.execute( ''select max(test_date) from  writing_band where student_name= in (陈鑫宇);'' )
result = cur.fetchall()
print(result)

r = Get_Student.Check_date('listening','徐静文')
print(r)

r  = Get_Student.Visualization('叶海博','reading','2018-06-01','2018-10-01')
print(r.__len__())
'''

#from database_managment import db_connection
#con = db_connection.connect()
#cur = con.cursor()
sql = '''
select test_date,total_input from speaking_band where student_name='马婧飏' and test_date>'2018-05-01' and total_input>4.5;
'''
'''
cur.execute(sql)
result = cur.fetchall()
time = []