Ejemplo n.º 1
0
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}
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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])
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
 def get(self, id):
     sql = """select * from peminjam where id = %s"""
     return db.get_one(sql, [id])
Ejemplo n.º 8
0
def getUser(uuid_user):
    sql = """select nama from bio_user where uuid_user = %s"""
    return db.get_one(sql, [uuid_user])
Ejemplo n.º 9
0
def checkBuku(kode):
    sql = """select * from list_buku where kode = %s"""
    res = db.get_one(sql, [kode])
    return res
Ejemplo n.º 10
0
 def get(self,id):
     sql = """select * from list_buku where id = %s"""
     return db.get_one(sql,[id])
Ejemplo n.º 11
0
 def get(self, id):
     sql = """select * from bio_siswa where uuid_siswa = %s"""
     return db.get_one(sql, [id])
Ejemplo n.º 12
0
 def get(self, id):
     sql = """select * from siswa where id = %s"""
     return db.get_one(sql, [id])
Ejemplo n.º 13
0
 def get(self, id):
     sql = """select username from user where uuid = %s"""
     return db.get_one(sql, [id])
Ejemplo n.º 14
0
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
Ejemplo n.º 15
0
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
Ejemplo n.º 16
0
 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])
Ejemplo n.º 17
0
 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
Ejemplo n.º 18
0
 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])
Ejemplo n.º 19
0
def checkAnggota(id):
    sql = """select * from anggota where id = %s"""
    res = db.get_one(sql, [id])
    return res
Ejemplo n.º 20
0
def checkSiswa(user):
    sql = """select * from siswa where username = %s"""
    params = [user]
    res = db.get_one(sql, params)
    return res
Ejemplo n.º 21
0
 def get(self, id):
     sql = "select * from bio_user where uuid_user = %s"
     return db.get_one(sql, [id])
Ejemplo n.º 22
0
 def get(self, uuid_kelas):
     sql = """select * from kelas where uuid = %s"""
     return db.get_one(sql, [uuid_kelas])
Ejemplo n.º 23
0
def checkingUser(username):
    sql = """select * from user where username = %s"""
    return db.get_one(sql, [username])
Ejemplo n.º 24
0
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])
Ejemplo n.º 25
0
 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)
Ejemplo n.º 26
0
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
Ejemplo n.º 27
0
def verifyPassword(id, password):
    sql = """select password from user where uuid = %s"""
    return sha256.verify(password, db.get_one(sql, [id])["password"])
Ejemplo n.º 28
0
def getMapel(uuid_mapel):
    sql = """select mapel from mapel where uuid = %s"""
    return db.get_one(sql, [uuid_mapel])
Ejemplo n.º 29
0
def checkingUser(user):
    sql = """select * from user where username=%s"""
    params = [user]
    res = db.get_one(sql, params)
    return res
Ejemplo n.º 30
0
 def get(self, id):
     sql = """select * from materi where uuid = %s"""
     return db.get_one(sql, [id])