def cekJawaban(uuid_materi, uuid_soal, jawaban): sql = """select kunci_jawaban, skor from soal where uuid_materi = %s and uuid = %s""" hasil = db.get_one(sql, [uuid_materi, uuid_soal]) if hasil["kunci_jawaban"] == jawaban: return {"jawaban": True, "skor": hasil["skor"]} else: return {"jawaban": False}
def get(self, uuid_materi): sql = """select tampil from soal where uuid_materi = %s""" res = db.get_one(sql, [uuid_materi]) if res["tampil"] == 1: res["tampil"] = True else: res["tampil"] = False return res
def put(self, id): now = datetime.now() data = request.get_json() sql = """select uuid_siswa from bio_siswa where uuid = %s""" uuid_siswa = db.get_one(sql, [id])["uuid_siswa"] tanggal_lahir = stringTime(data["tanggal_lahir"]) putBioSiswa(id, data["nama"], data["jk"], data["alamat"], data["tempat_lahir"], tanggal_lahir, data["hp"], data["email"], now) putSiswa(uuid_siswa, data["uuid_kelas"], now)
def put(self, id): now = datetime.now() data = request.get_json() sql = """select uuid_user from bio_user where uuid = %s""" id_user = db.get_one(sql, [id])["uuid_user"] tanggal_lahir = stringTime(data["tanggal_lahir"]) putBioUser(id, data["nama"], data["jk"], data["alamat"], tanggal_lahir, data["tempat_lahir"], data["hp"], data["email"], now) putUser(id_user, data["superadmin"], now) if len(data["ampu"]) > 0: db.commit_data("""delete from pengampu where uuid_user = %s""", [id_user]) for i in data["ampu"]: putPengampu(id_user, i["uuid_kelas"], i["uuid_mapel"], now) else: db.commit_data("""delete from pengampu where uuid_user = %s""", [id_user])
def get(self, id): sql = """select nama, jk, alamat, tempat_lahir, tanggal_lahir, hp, email, superadmin, ampu.uuid_mapel as uuid_mapel, ampu.kelas_ampu as uuid_kelas from bio_user left outer join user on bio_user.uuid_user = user.uuid, (select user.uuid, group_concat(uuid_mapel) as uuid_mapel, group_concat(uuid_kelas) as kelas_ampu from user left outer join pengampu on user.uuid = pengampu.uuid_user group by user.uuid) as ampu where user.uuid = ampu.uuid and bio_user.uuid = %s""" res = db.get_one(sql, [id]) res["ampu"] = [] if res["uuid_mapel"] != None: res["uuid_mapel"] = res["uuid_mapel"].split(",") res["uuid_kelas"] = res["uuid_kelas"].split(",") for i in range(len(res["uuid_mapel"])): ampu = { "uuid_mapel": res["uuid_mapel"][i], "uuid_kelas": res["uuid_kelas"][i] } res["ampu"].append(ampu) del res["uuid_mapel"] del res["uuid_kelas"] if res["superadmin"] == 1: res["superadmin"] = True else: res["superadmin"] = False return res
def checkPengembalian(id): sql = """select waktu_pengembalian from peminjam where id = %s""" res = db.get_one(sql, [id]) hasil = datetime.now() - res['waktu_pengembalian'] return hasil
def get(self, id): sql = """select * from peminjam where id = %s""" return db.get_one(sql, [id])
def getUser(uuid_user): sql = """select nama from bio_user where uuid_user = %s""" return db.get_one(sql, [uuid_user])
def checkBuku(kode): sql = """select * from list_buku where kode = %s""" res = db.get_one(sql, [kode]) return res
def get(self,id): sql = """select * from list_buku where id = %s""" return db.get_one(sql,[id])
def get(self, id): sql = """select * from bio_siswa where uuid_siswa = %s""" return db.get_one(sql, [id])
def get(self, id): sql = """select * from siswa where id = %s""" return db.get_one(sql, [id])
def get(self, id): sql = """select username from user where uuid = %s""" return db.get_one(sql, [id])
def getKelasMapelMateri(uuid_materi): sql = """select kelas, label, mapel, materi from soal join kelas on soal.uuid_kelas = kelas.uuid join mapel on soal.uuid_mapel = mapel.uuid join materi on soal.uuid_materi = materi.uuid where soal.uuid_materi = %s""" res = db.get_one(sql, [uuid_materi]) res["kelas"] = str(res["kelas"]) + " " + res["label"] del res["label"] return res
def checkAdmin(user): sql = """select user.uuid, user.username, user.password, superadmin from user where username = %s""" params = [user] res = db.get_one(sql, params) return res
def get(self, uuid_materi, uuid_siswa): sql = """select uuid from skor where uuid_materi = %s and uuid_siswa = %s""" return db.get_one(sql, [uuid_materi, uuid_siswa])
def get(self, id): sql = """select soal from soal where soal.uuid = %s""" hasil = db.get_one(sql, [id]) hasil["pilihan"] = getMC(id) shuffle(hasil["pilihan"]) return hasil
def get(self, uuid_materi): sql = """select count(*) as jml_soal from soal where uuid_materi = %s group by uuid_materi""" return db.get_one(sql, [uuid_materi])
def checkAnggota(id): sql = """select * from anggota where id = %s""" res = db.get_one(sql, [id]) return res
def checkSiswa(user): sql = """select * from siswa where username = %s""" params = [user] res = db.get_one(sql, params) return res
def get(self, id): sql = "select * from bio_user where uuid_user = %s" return db.get_one(sql, [id])
def get(self, uuid_kelas): sql = """select * from kelas where uuid = %s""" return db.get_one(sql, [uuid_kelas])
def checkingUser(username): sql = """select * from user where username = %s""" return db.get_one(sql, [username])
def getUser(uuid_materi): sql = """select materi.uuid_user, materi.uuid_kelas, materi.uuid_mapel from pengampu join materi on materi.uuid_mapel = pengampu.uuid_mapel join kelas on kelas.uuid = materi.uuid_kelas where materi.uuid = %s""" return db.get_one(sql, [uuid_materi])
def delete(self, id): sql = """select uuid_user from bio_user where uuid = %s""" id_user = db.get_one(sql, [id])["uuid_user"] deleteBioUser(id) deleteUser(id_user) deletePengampu(id_user)
def getKelas(uuid_kelas): sql = """select kelas, label from kelas where uuid = %s""" res = db.get_one(sql, [uuid_kelas]) res["kelas"] = str(res["kelas"]) + " " + res["label"] del res["label"] return res
def verifyPassword(id, password): sql = """select password from user where uuid = %s""" return sha256.verify(password, db.get_one(sql, [id])["password"])
def getMapel(uuid_mapel): sql = """select mapel from mapel where uuid = %s""" return db.get_one(sql, [uuid_mapel])
def checkingUser(user): sql = """select * from user where username=%s""" params = [user] res = db.get_one(sql, params) return res
def get(self, id): sql = """select * from materi where uuid = %s""" return db.get_one(sql, [id])