コード例 #1
0
ファイル: role.py プロジェクト: wo1176765282/student-daily
def delroot():
    rid = request.args.get("rid")
    cur.execute("delete from role where rid=%s",(rid))
    db.commit()
    cur.execute("select * from role")
    result = cur.fetchall()
    return json.dumps(result)
コード例 #2
0
def dele():
    id = request.args.get('id')
    cur.execute("delete from questiontype where id=%s", (id))
    db.commit()
    cur.execute("select * from questiontype")
    result = cur.fetchall()
    return json.dumps(result)
コード例 #3
0
ファイル: user.py プロジェクト: wo1176765282/student-daily
def del1():
    id = request.args.get("id")
    cur.execute("delete from users where uid=%s", (id))
    db.commit()
    cur.execute("select * from users,role where users.rid=role.rid")
    data = cur.fetchall()
    return json.dumps(data)
コード例 #4
0
ファイル: role.py プロジェクト: wo1176765282/student-daily
def updaterole():
    rid = request.args.get("rid")
    rname = request.args.get("rname")
    power = request.args.get("power")
    cur.execute("update role set rname=%s,power=%s where rid=%s",(rname,power,rid))
    db.commit()
    return "ok"
コード例 #5
0
def del1():
    data = json.loads(request.args.get('datas'))
    cid = request.args.get('cid')
    print(data)
    cur.execute("delete from dircursor where cid=%s and step=%s",
                (cid, data['step']))
    db.commit()
    return 'ok'
コード例 #6
0
def add():
    # nid=request.args.get('nid')
    name = request.args.get('name')
    cur.execute("insert into questiontype (name) values (%s)", (name))
    db.commit()
    cur.execute("select * from questiontype")
    result = cur.fetchall()
    return json.dumps(result)
コード例 #7
0
    def get(self, id):
        db, cursor = self.db_init()
        sql = "Select * From api.users Where id = '{}' and deleted is not True".format(id)
        cursor.execute(sql)
        db.commit()
        user = cursor.fetchone()
        db.close()

        return jsonify({"data": user})
コード例 #8
0
def addjudge():
    con=request.args.get('con')
    answer=request.args.get('answer')
    nid = 3
    point = request.args.get('point') or 3
    cname = request.args.get('cname')
    cur.execute("select cid from `cursor` where cname=%s", (cname))
    fid = cur.fetchone()['cid']
    cur.execute("insert into question (fid,con,answer,point,nid) values (%s,%s,%s,%s,%s)",(fid, con, answer, point, nid))
    db.commit()
    return 'ok'
コード例 #9
0
def filedata(con):
    cur.execute("insert into `cursor` (cname) values (%s)", (con[0]))
    cid = db.insert_id()
    step = con[1].split("\n")
    part = con[2].split("\n")
    for index in range(len(step)):
        arr = []
        arr.append((step[index], part[index], cid))
        cur.executemany(
            "insert into `dircursor` (step,part,cid) values (%s,%s,%s)", (arr))
        db.commit()
コード例 #10
0
def edit():
    id = request.args.get('id')
    nid = request.args.get('nid')
    name = request.args.get('name')
    print(id, nid, name)
    cur.execute("update questiontype set nid=%s,name=%s where id=%s",
                (nid, name, id))
    db.commit()
    cur.execute("select * from questiontype")
    result = cur.fetchall()
    return json.dumps(result)
コード例 #11
0
ファイル: classes.py プロジェクト: wo1176765282/student-daily
def addone():
    name = request.args.get('name')
    f = request.args.get('f')
    start = request.args.get('start')
    end = request.args.get('end')
    cur.execute("select cid from `cursor` where cname=%s", (f))
    cid = cur.fetchone()['cid']
    cur.execute(
        "insert into classes (name,start,end,fid) values (%s,%s,%s,%s)",
        (name, start, end, cid))
    db.commit()
    return "ok"
コード例 #12
0
ファイル: models.py プロジェクト: j-000/joalex.dev
 def __init__(self, name, email, password, surname=None, is_admin=False):
     self.name = name
     self.email = email
     self.password = generate_password_hash(password,
                                            method='pbkdf2:sha256',
                                            salt_length=8)
     if surname:
         self.surname = surname
     if is_admin:
         self.is_admin = True
     db.add(self)
     db.commit()
コード例 #13
0
ファイル: user.py プロジェクト: wo1176765282/student-daily
def add():
    name = request.form['name']
    upass = request.form['pass']
    phone = request.form['phone']
    rid = request.form['rid']
    md5 = hashlib.md5()
    md5.update(upass.encode())
    upass = md5.hexdigest()
    cur.execute(
        "insert into users(name,uname,upass,phone,rid)values (%s,%s,%s,%s,%s)",
        (name, phone, upass, phone, rid))
    db.commit()
    return 'ok'
コード例 #14
0
def upload1():
    UPLOAD_FOLDER = 'upload/teacher/'
    current_app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
    if request.method == 'POST':
        db1 = pymysql.connect(host="localhost",
                              user="******",
                              password="******",
                              db="lzm",
                              charset="utf8")
        cur1 = db1.cursor()
        cur1.execute("select cname,cid from `cursor`")
        c = dict(cur1.fetchall())
        db1.close()
        f = request.files['file']  # 从表单的file字段获取文件,myfile为该表单的name值
        if f and allowed_file(f.filename):  # 判断是否是允许上传的文件类型
            fname = secure_filename(f.filename)
            suf = fname.rsplit('.', 1)[1]  #截取文件后缀名
            now = int(time.time())
            newfile = str(now) + '.' + suf
            f.save(os.path.join(current_app.config['UPLOAD_FOLDER'], newfile))
            book = xlrd.open_workbook('upload/teacher/' + newfile)
            sheet = book.sheet_by_index(0)  #定义一个对象
            arr = []
            user = []
            for i in range(1, sheet.nrows):
                con = sheet.row_values(i)
                if isinstance(con[1], float):
                    con[1] = str(int(con[1]))
                if isinstance(con[3], float):
                    con[3] = int(con[3])
                con[2] = c[con[2]]
                arr.append(con)

                name = con[0]
                phone = con[1]
                md5 = hashlib.md5()
                md5.update(b'111111')
                up = md5.hexdigest()
                arr1 = [name, phone, up, phone, 2]
                user.append(arr1)
            cur.executemany(
                "insert into teacher (name,phone,fid,class) values (%s,%s,%s,%s)",
                (arr))
            cur.executemany(
                "insert into users (name,uname,upass,phone,rid) values (%s,%s,%s,%s,%s)",
                (user))
            db.commit()
            return 'ok'
        else:
            return "error"
コード例 #15
0
    def __init__(self, original_url, url_identifier_length=4):
        self.original_url = original_url

        # Identifiers need to start with B to ensure nginx can catch the request
        # and proxy it to the backend
        url_identifier = 'B'
        url_identifier += ''.join(
            random.choices(string.ascii_uppercase + string.digits,
                           k=url_identifier_length))

        self.follow_url = f'{HOST}/{url_identifier}'
        self.identifier = url_identifier

        db.add(self)
        db.commit()
コード例 #16
0
def editonecursor():
    data = request.args.get('data')
    data = json.loads(data)
    print(data)
    cid = request.args.get('id')
    cur.execute("update `cursor` set cname=%s where cid=%s", (data[0], cid))
    cur.execute("delete from dircursor  where cid=%s", (cid))
    step = data[1].split("\n")
    part = data[2].split("\n")
    for index in range(len(step)):
        arr = []
        arr.append((step[index], part[index], cid))
        cur.executemany(
            "insert into `dircursor` (step,part,cid) values (%s,%s,%s)", (arr))
    db.commit()
    return 'ok'
コード例 #17
0
def addstudaily():
    uid = session.get('uid')
    # classid=session.get('classid')
    cur.execute("select phone from users where uid=%s", (uid))
    phone = cur.fetchone()['phone']
    name = session.get('name')
    motto = request.args.get('motto')
    con = request.args.get('con')
    heart = request.args.get('heart')
    suggest = request.args.get('suggest')
    date = request.args.get('date')
    cur.execute(
        "insert into studaily (uid,name,motto,con,heart,suggest,date,phone) values (%s,%s,%s,%s,%s,%s,%s,%s)",
        (uid, name, motto, con, heart, suggest, date, phone))
    db.commit()
    return 'ok'
コード例 #18
0
def upload():
    UPLOAD_FOLDER = 'upload/exam/'
    current_app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
    if request.method == 'POST':
        f = request.files['file']  # 从表单的file字段获取文件,myfile为该表单的name值
        if f and allowed_file(f.filename):  # 判断是否是允许上传的文件类型
            fname = secure_filename(f.filename)
            suf = fname.rsplit('.', 1)[1]     #截取文件后缀名
            now = int(time.time())
            newfile = str(now)+'.'+suf
            f.save(os.path.join(current_app.config['UPLOAD_FOLDER'],newfile))
            book=xlrd.open_workbook('upload/exam/'+newfile)
            sheet = book.sheet_by_index(0)   #定义一个对象
            question=[]
            for i in range(1,sheet.nrows):
                arr=[]
                con = sheet.row_values(i)
                cur.execute("select cid from `cursor` where cname=%s",(con[0]))
                fid=cur.fetchone()['cid']
                cur.execute("select nid from questiontype where name=%s", (con[1]))
                nid=cur.fetchone()['nid']
                sel=con[3].split('|')
                if nid==1:
                    answer=sel.index(str(int(con[4])))
                elif nid==2:
                    answer=''
                    ans = con[4].split('|')
                    for i in range(len(sel)):
                        for j in range(len(ans)):
                            if sel[i] == ans[j]:
                                a=str(i)+'|'
                                answer+=a
                    answer=answer[0:-1]
                elif nid==3:
                    con[3]=None
                    if con[4]=='错':
                        answer=0
                    elif con[4]=='对':
                        answer=1
                arr+=[fid]+[con[2]]+[con[3]]+[answer]+[int(con[5])]+[nid]
                question.append(tuple(arr))

            cur.executemany("insert into question (fid,con,`option`,answer,point,nid) values (%s,%s,%s,%s,%s,%s)",(question))
            db.commit()
            return 'ok'
        else:
            return "error"
コード例 #19
0
def addone():
    name = request.args.get('name')
    school = request.args.get('school')
    phone = request.args.get('phone')
    classes = request.args.get('classes')
    md5 = hashlib.md5()
    md5.update(b'111111')
    up = md5.hexdigest()
    cur.execute("select id from classes where name=%s", (classes))
    classid = cur.fetchone()['id']
    cur.execute(
        "insert into studentes (name,phone,school,classid) values (%s,%s,%s,%s)",
        (name, phone, school, classid))
    cur.execute(
        "insert into users (name,uname,upass,phone,rid) values (%s,%s,%s,%s,%s)",
        (name, phone, up, phone, 1))
    db.commit()
    return "ok"
コード例 #20
0
def addone():
    name = request.args.get('name')
    f = request.args.get('f')
    phone = request.args.get('phone')
    classes = request.args.get('classes')
    md5 = hashlib.md5()
    md5.update(b'111111')
    up = md5.hexdigest()
    cur.execute("select cid from `cursor` where cname=%s", (f))
    fid = cur.fetchone()['cid']
    cur.execute(
        "insert into teacher (name,phone,class,fid) values (%s,%s,%s,%s)",
        (name, phone, classes, fid))
    cur.execute(
        "insert into users (name,uname,upass,phone,rid) values (%s,%s,%s,%s,%s)",
        (name, phone, up, phone, 2))
    db.commit()
    return "ok"
コード例 #21
0
ファイル: classes.py プロジェクト: wo1176765282/student-daily
def upload1():
    UPLOAD_FOLDER = 'upload/classes/'
    current_app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
    if request.method == 'POST':
        db1 = pymysql.connect(host="localhost",
                              user="******",
                              password="******",
                              db="lzm",
                              charset="utf8")
        cur1 = db1.cursor()
        cur1.execute("select cname,cid from `cursor`")
        c = dict(cur1.fetchall())
        db1.close()
        f = request.files['file']  # 从表单的file字段获取文件,myfile为该表单的name值
        if f and allowed_file(f.filename):  # 判断是否是允许上传的文件类型
            fname = secure_filename(f.filename)
            suf = fname.rsplit('.', 1)[1]  #截取文件后缀名
            now = int(time.time())
            newfile = str(now) + '.' + suf
            f.save(os.path.join(current_app.config['UPLOAD_FOLDER'], newfile))
            book = xlrd.open_workbook('upload/classes/' + newfile)
            sheet = book.sheet_by_index(0)  #定义一个对象
            arr = []
            for i in range(1, sheet.nrows):
                con = sheet.row_values(i)
                if isinstance(con[0], float):
                    con[0] = int(con[0])
                con[2] = xlrd.xldate_as_datetime(
                    con[2], 0).strftime("%Y-%m-%d %H:%M:%S")
                con[3] = xlrd.xldate_as_datetime(
                    con[3], 0).strftime("%Y-%m-%d %H:%M:%S")
                con[1] = c[con[1]]
                arr.append(con)
            cur.executemany(
                "insert into classes (name,fid,start,end) values (%s,%s,%s,%s)",
                (arr))
            db.commit()
            return 'ok'
        else:
            return "error"
コード例 #22
0
def addPoint():
    id = session.get('uid') or 10
    data = request.args.get('data')
    data = json.loads(data)
    myanswer = ''
    aid = ''
    for item in data:
        if isinstance(item['myanswer'], list):
            a = ''
            for i in item['myanswer']:
                a += str(i) + '|'
            a = a[:-1]
            item['myanswer'] = a
        myanswer += str(item['myanswer']) + '/n'
        aid += str(item['id']) + '/n'
    myanswer = myanswer[:-2]
    aid = aid[:-2]
    point = data[len(data) - 1]['point']
    nowdate = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
    cur.execute(
        "insert into point (stuid,point,myanswer,aid,nowdate) values (%s,%s,%s,%s,%s)",
        (id, point, myanswer, aid, nowdate))
    db.commit()
    return 'ok'
コード例 #23
0
ファイル: models.py プロジェクト: j-000/joalex.dev
 def __init__(self, text, p_id):
     self.pawn_id = p_id
     self.text = text
     db.add(self)
     db.commit()
コード例 #24
0
ファイル: models.py プロジェクト: j-000/joalex.dev
 def delete(self):
     db.delete(self)
     db.commit()
コード例 #25
0
ファイル: role.py プロジェクト: wo1176765282/student-daily
def addrole():
    rname = request.args.get("rname")
    power = request.args.get("power")
    cur.execute("insert into role (rname,power)values (%s,%s)",(rname,power))
    db.commit()
    return "ok"
コード例 #26
0
ファイル: models.py プロジェクト: j-000/joalex.dev
 def __init__(self, name):
     self.name = name
     db.add(self)
     db.commit()
コード例 #27
0
ファイル: classes.py プロジェクト: wo1176765282/student-daily
def del1():
    name = request.args.get('name')
    cur.execute("delete from classes where name=%s", (name))
    db.commit()
    return 'ok'
コード例 #28
0
def del1():
    phone = request.args.get('phone')
    cur.execute("delete from teacher where phone=%s", (phone))
    cur.execute("delete from users where phone=%s", (phone))
    db.commit()
    return 'ok'
コード例 #29
0
def addarrange():
    cid=request.args.get('cid')
    alltime=request.args.get('alltime')
    cur.execute("insert into exam1 (fid,alltime) values (%s,%s)",(cid,alltime))
    db.commit()
    return 'ok'