def get(self, uuid_user): if uuid_user == "admin": sql = """select distinct kelas from kelas""" return db.get_data(sql) else: sql = """select kelas from kelas join pengampu on kelas.uuid = pengampu.uuid_kelas where pengampu.uuid_user = %s""" return db.get_data(sql, [uuid_user])
def get(self, uuid_user, kelas, label): if uuid_user == "admin": sql = """select distinct mapel from mapel join pengampu on mapel.uuid = pengampu.uuid_mapel join kelas on pengampu.uuid_kelas = kelas.uuid where kelas = %s and label = %s""" return db.get_data(sql, [kelas, label]) else: sql = """select distinct mapel from mapel join pengampu on mapel.uuid = pengampu.uuid_mapel join kelas on pengampu.uuid_kelas = kelas.uuid where pengampu.uuid_user = %s and kelas = %s and label = %s""" return db.get_data(sql, [uuid_user, kelas, label])
def get(self, uuid_user, kelas): if uuid_user == "admin": sql = """select label from kelas where kelas = %s""" return db.get_data(sql, [kelas]) else: sql = """select label from kelas join pengampu on kelas.uuid = pengampu.uuid_kelas where pengampu.uuid_user = %s and kelas = %s""" return db.get_data(sql, [uuid_user, kelas])
def get(self, uuid_user, uuid_materi): if uuid_user == "admin": sql = """select nama, skor, skor.created_at from bio_siswa join siswa on bio_siswa.uuid_siswa = siswa.uuid join materi on siswa.uuid_kelas = materi.uuid_kelas left outer join skor on siswa.uuid = skor.uuid_siswa and materi.uuid = skor.uuid_materi where materi.uuid = %s""" return db.get_data(sql, [uuid_materi]) else: sql = """select nama, skor, skor.created_at from bio_siswa join siswa on bio_siswa.uuid_siswa = siswa.uuid join materi on siswa.uuid_kelas = materi.uuid_kelas left outer join skor on siswa.uuid = skor.uuid_siswa and materi.uuid = skor.uuid_materi where materi.uuid_user = %s and materi.uuid = %s""" return db.get_data(sql, [uuid_user, uuid_materi])
def get(self, uuid_user, kelas, label, mapel): if uuid_user == "admin": sql = """select materi.uuid, materi from materi join kelas on materi.uuid_kelas = kelas.uuid join mapel on mapel.uuid = materi.uuid_mapel where kelas = %s and label = %s and mapel = %s""" return db.get_data(sql, [kelas, label, mapel]) else: sql = """select materi.uuid, materi from materi join pengampu on materi.uuid_user = pengampu.uuid_user join kelas on materi.uuid_kelas = kelas.uuid join mapel on mapel.uuid = materi.uuid_mapel where materi.uuid_user = %s and kelas = %s and label = %s and mapel = %s""" return db.get_data(sql, [uuid_user, kelas, label, mapel])
def get(self, uuid_user): if uuid_user == "admin": sql = """select kelas, label, uuid from kelas""" res = db.get_data(sql) else: sql = """select kelas, label, uuid from pengampu join kelas on pengampu.uuid_kelas = kelas.uuid where uuid_user = %s""" res = db.get_data(sql, [uuid_user]) for i in res: i["text"] = str(i["kelas"])+" "+i["label"] i["value"] = i["uuid"] del i["label"] del i["uuid"] del i["kelas"] return res
def getMC(uuid_soal): sql = """select opsi from mc_soal where uuid_soal = %s""" res = db.get_data(sql, [uuid_soal]) for i in res: i["text"] = i["opsi"] i["value"] = i["opsi"] del i["opsi"] return res
def get(self, uuid_kelas, uuid_mapel): sql = """select materi, uuid from materi where uuid_kelas = %s and uuid_mapel = %s""" res = db.get_data(sql, [uuid_kelas, uuid_mapel]) for i in res: i["text"] = i["materi"] i["value"] = i["uuid"] del i["uuid"] del i["materi"] return res
def get(self): sql = "select nama, superadmin, bio_user.uuid, uuid_user, bio_user.created_at, bio_user.updated_at from bio_user join user on bio_user.uuid_user = user.uuid" hasil = db.get_data(sql) for i in hasil: if i["superadmin"] == 1: i["superadmin"] = True else: i["superadmin"] = False return hasil
def get(self, uuid_materi): kop = getKelasMapelMateri(uuid_materi) sql = """select soal.uuid from soal where uuid_materi = %s and tampil = 1""" hasil = db.get_data(sql, [uuid_materi]) shuffle(hasil) return { "kelas": kop["kelas"], "mapel": kop["mapel"], "materi": kop["materi"], "soal": hasil }
def get(self, uuid_materi): kop = getKelasMapelMateri(uuid_materi) sql = """select uuid, kunci_jawaban, skor, soal from soal where uuid_materi = %s""" hasil = db.get_data(sql, [uuid_materi]) for i in hasil: i["opsi"] = getMC(i["uuid"]) return { "kelas": kop["kelas"], "mapel": kop["mapel"], "materi": kop["materi"], "soal": hasil }
def get_response(conn, path): """ Parses url params from Path Creates params dictionary params: { fields: <values>. conditions: <values> } for building query by db.query_builder Parameters ---------- conn: object, mandatory postgres connection object path: str, mandatory url parameters of API Returns ---------- list a list of dictionaries of active cyclones with time updated into string """ params = {} params['conditions'] = [] if '?' in path: path = path[2:] for p in path.split('&'): if 'search' in p: params['fields'] = p.split('=')[1] params['conditions'].append(p) data = get_data(conn, params) resp = [] for i in data: d = dict(zip(KEYS, i)) d['updated_at'] = d['updated_at'].\ strftime('%d-%m-%Y%H:%M:%S.%f') d['created_at'] = d['created_at'].\ strftime('%d-%m-%Y%H:%M:%S.%f') resp.append(d) return resp
def get_simlar_file(filepath): f = codecs.open(filepath, 'r', 'gb2312') filecontent = f.read() # 当前文件的hash filehash = simhash.simhash(filecontent) # 获取数据库中的hash值 dict_hash = db.get_data() # 存储文件与数据库hash码的汉明距离 minfilepath = '' min_distance = 64 for k, v in dict_hash.items(): distance = filehash.hamming_distance(int(v)) if (distance < min_distance): min_distance = distance minfilepath = k param = (filepath, filehash) db.save_file_hash(param) simpercent = 0 if minfilepath == '': simpercent = 0 else: simpercent = filehash.similarity(int(dict_hash[minfilepath])) return (minfilepath, filecontent, min_distance, simpercent)
def get_simlar_file(filepath): f = codecs.open(filepath, 'r', 'gb2312') filecontent = f.read() # 当前文件的hash filehash = simhash.simhash(filecontent) # 获取数据库中的hash值 dict_hash = db.get_data() # 存储文件与数据库hash码的汉明距离 minfilepath = '' min_distance = 64 for k, v in dict_hash.items(): distance = filehash.hamming_distance(int(v)) if (distance < min_distance): min_distance = distance minfilepath = k param = (filepath, filehash) db.save_file_hash(param) simpercent = 0 if minfilepath == '': simpercent = 0 else: simpercent = filehash.similarity(int(dict_hash[minfilepath])) return (minfilepath, filecontent, min_distance, simpercent)
def get(self, kelas, label): sql = """select nama, jk, bio_siswa.uuid, bio_siswa.created_at, bio_siswa.updated_at from bio_siswa join siswa on siswa.uuid = bio_siswa.uuid_siswa join kelas on siswa.uuid_kelas = kelas.uuid where kelas = %s and label = %s""" return db.get_data(sql, [kelas, label])
def get(self, kelas): sql = """select uuid, kelas, label from kelas where kelas = %s""" return db.get_data(sql, [kelas])
def get(self): sql = """select distinct kelas from kelas""" return db.get_data(sql)
def get(self): sql = """select * from siswa""" return db.get_data(sql)
def get(self): """ Mengeluarkan peminjam """ sql = """select peminjam.id, anggota.nama, list_buku.judul, peminjam.created_at, waktu_pengembalian from peminjam join list_buku on peminjam.kode_buku = list_buku.kode join anggota on anggota.id = peminjam.no_anggota""" return db.get_data(sql, [])
def get(self): """ Mengeluarkan buku """ sql = """select * from list_buku""" return db.get_data(sql,[])
def get(self, uuid_kelas): kelas = getKelas(uuid_kelas) sql = """select distinct mapel, uuid_mapel from soal join mapel on mapel.uuid = soal.uuid_mapel join siswa on soal.uuid_kelas = siswa.uuid_kelas where siswa.uuid_kelas = %s""" res = db.get_data(sql, [uuid_kelas]) return {"kelas": kelas, "mapel": res}
def get(self, uuid_kelas, uuid_mapel): kelas = getKelas(uuid_kelas) mapel = getMapel(uuid_mapel) sql = """select materi, materi.uuid from materi join mapel on materi.uuid_mapel = mapel.uuid where uuid_mapel = %s""" res = db.get_data(sql, [uuid_mapel]) return {"kelas": kelas, "mapel": mapel, "materi": res}
def get(self, uuid_kelas): kelas = getKelas(uuid_kelas) sql = """select distinct mapel, uuid_mapel from mapel join pengampu on mapel.uuid = pengampu.uuid_mapel join kelas on pengampu.uuid_kelas = kelas.uuid where pengampu.uuid_kelas = %s""" result = db.get_data(sql, [uuid_kelas]) return {"kelas": kelas, "mapel": result}
def get(self, uuid_kelas, uuid_mapel): kelas = getKelas(uuid_kelas) mapel = getMapel(uuid_mapel) sql = """select distinct materi, materi.uuid from soal join materi on materi.uuid = soal.uuid_materi where soal.uuid_mapel = %s and tampil = 1""" res = db.get_data(sql, [uuid_mapel]) return {"kelas": kelas, "mapel": mapel, "materi": res}
def get(self): sql = """select * from anggota""" return db.get_data(sql,[])