-
Notifications
You must be signed in to change notification settings - Fork 0
/
Student.py
124 lines (116 loc) · 4.95 KB
/
Student.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import sqlite3
from User import User
DbName = 'db_leslesan.db'
conn = sqlite3.connect(DbName)
cursor = conn.cursor()
#class murid, merupakan peranakan / turunan dari class user
class Student(User):
#inisialisasi class object, atribut diambil dari class user dan terdapat perbedaan/tambahan atribut kelas
def __init__(self, nama, kelas, gender, alamat, phone, iD):
super().__init__(nama, gender, alamat, phone, iD)
self._kelas = kelas
#mengambil atribut kelas
def getKelas(self):
return self._kelas
#merubah atau menambahkan atribut kelas
def setKelas(self, value):
self._kelas = value
#melihat data diri murid
def dataDiri(self):
query = cursor.execute('''\
SELECT tab_students.student_id, tab_students.nama, tab_classes.nama, tab_students.jenis_kelamin, tab_students.alamat, tab_students.phone
FROM tab_students
INNER JOIN tab_classes
ON tab_students.kelas = tab_classes.class_id
WHERE tab_students.student_id = ?''', (self.id,))
for row in query:
print(f"""=============================================
DATA DIRI
=============================================
ID\t\t: {row[0]}
Nama\t\t: {row[1]}
Kelas\t\t: {row[2]}
Jenis Kelamin\t: {row[3]}
Alamat\t\t: {row[4]}
Nomor telepon\t: {row[5]}
=============================================
""")
#melihat jadwal murid
def lihatJadwal(self):
query0 = cursor.execute(
"""SELECT KELAS from tab_students
WHERE student_id = ?""", (self.id,))
for row in query0:
kelas = row[0]
query = cursor.execute("""
SELECT tab_teachers.NAMA, tab_teachers.MAPEL, tab_classes.NAMA, tab_schedules.DAY, tab_schedules.DATE, tab_schedules.TIME, tab_schedules.NOTE
FROM tab_schedules
INNER JOIN tab_classes
ON tab_schedules.class_id = tab_classes.class_id
INNER JOIN tab_teachers
ON tab_schedules.teacher_id = tab_teachers.teacher_id
WHERE tab_classes.class_id = ?""", (kelas,))
print("""=============================================
JADWAL PELAJARAN
=============================================""")
for row in query:
print(f"""Pengajar: {row[0]}
Mata Pelajaran: {row[1]}
Waktu: {row[3]}, {row[4]}, {row[5]}
Note: {row[6]}
=============================================""")
print()
#melihat data guru yang mengajar
def lihatPengajar(self):
self.pilihan = input("""=============================================
LIHAT PENGAJAR
=============================================
Silahkan pilih menu yang anda inginkan:
[a] Lihat semua pengajar
[b] Lihat berdasarkan mata pelajaran
=============================================
Masukkan pilihan >> """)
if self.pilihan == "a":
self.clear()
query = cursor.execute('''
SELECT tab_teachers.nama, tab_teachers.mapel, tab_teachers.jenis_kelamin, tab_teachers.alamat, tab_teachers.phone FROM tab_teachers''')
if query.fetchone() is None:
print("Tidak ada pengajar")
else:
query = cursor.execute(
'''SELECT tab_teachers.nama, tab_teachers.mapel, tab_teachers.jenis_kelamin, tab_teachers.alamat, tab_teachers.phone FROM tab_teachers''')
print("""=============================================
DAFTAR PENGAJAR
=============================================""")
for row in query:
print(f"""Nama: {row[0]}
Bidang: {row[1]}
Jenis Kelamin: {row[2]}
Alamat: {row[3]}
No.HP: {row[4]}
=============================================""")
print()
elif self.pilihan == "b":
self.clear()
mapel = input(
"Masukkan mata pelajaran yang diampu >> ").title()
query = cursor.execute('''
SELECT tab_teachers.nama, tab_teachers.mapel, tab_teachers.jenis_kelamin, tab_teachers.alamat, tab_teachers.phone FROM tab_teachers WHERE tab_teachers.Mapel = ?''', (mapel,))
if query.fetchone() is None:
print(f"\nTidak ada pengajar mata pelajaran {mapel}\n")
else:
query = cursor.execute(
'''SELECT tab_teachers.nama, tab_teachers.mapel, tab_teachers.jenis_kelamin, tab_teachers.alamat, tab_teachers.phone FROM tab_teachers WHERE tab_teachers.Mapel = ?''', (mapel,))
print("""=============================================
DAFTAR PENGAJAR
=============================================""")
for row in query:
print(f"""Nama: {row[0]}
Bidang: {row[1]}
Jenis Kelamin: {row[2]}
Alamat: {row[3]}
No.HP: {row[4]}
=============================================""")
print()
else:
print("\n============ Menu Tidak Tersedia ============\n")