208 lines
8.2 KiB
Python
208 lines
8.2 KiB
Python
|
import sqlite3
|
|||
|
from messages import PSEVDO
|
|||
|
|
|||
|
class poiskPredm:
|
|||
|
|
|||
|
def __init__(self, database):
|
|||
|
"""Подключаемся к БД и сохраняем курсор соединения"""
|
|||
|
self.connection = sqlite3.connect(database)
|
|||
|
self.cursor = self.connection.cursor()
|
|||
|
|
|||
|
|
|||
|
def check_predm(self, user_id):
|
|||
|
"""Выбраные предметы"""
|
|||
|
with self.connection:
|
|||
|
math = ''
|
|||
|
rus = ''
|
|||
|
fiz = ''
|
|||
|
inf = ''
|
|||
|
inostr = ''
|
|||
|
obsh = ''
|
|||
|
biol = ''
|
|||
|
|
|||
|
math_temp1 = self.cursor.execute('SELECT `math` FROM `allusers` WHERE `user_id` = ?', (user_id,)).fetchall()
|
|||
|
temp1 = math_temp1[0]
|
|||
|
|
|||
|
rus_temp2 = self.cursor.execute('SELECT `rus` FROM `allusers` WHERE `user_id` = ?', (user_id,)).fetchall()
|
|||
|
temp2 = rus_temp2[0]
|
|||
|
|
|||
|
fiz_temp3 = self.cursor.execute('SELECT `fiz` FROM `allusers` WHERE `user_id` = ?', (user_id,)).fetchall()
|
|||
|
temp3 = fiz_temp3[0]
|
|||
|
|
|||
|
inf_temp4 = self.cursor.execute('SELECT `inf` FROM `allusers` WHERE `user_id` = ?', (user_id,)).fetchall()
|
|||
|
temp4 = inf_temp4[0]
|
|||
|
|
|||
|
inostr_temp5 = self.cursor.execute('SELECT `inostr` FROM `allusers` WHERE `user_id` = ?', (user_id,)).fetchall()
|
|||
|
temp5 = inostr_temp5[0]
|
|||
|
|
|||
|
obsh_temp6 = self.cursor.execute('SELECT `obsh` FROM `allusers` WHERE `user_id` = ?', (user_id,)).fetchall()
|
|||
|
temp6 = obsh_temp6[0]
|
|||
|
|
|||
|
biol_temp7 = self.cursor.execute('SELECT `biol` FROM `allusers` WHERE `user_id` = ?', (user_id,)).fetchall()
|
|||
|
temp7 = biol_temp7[0]
|
|||
|
|
|||
|
if temp1[0] == 1:
|
|||
|
math = '\n✅ математика'
|
|||
|
if temp2[0] == 1:
|
|||
|
rus = '\n✅ русский язык'
|
|||
|
if temp3[0] == 1:
|
|||
|
fiz = '\n✅ физика'
|
|||
|
if temp4[0] == 1:
|
|||
|
inf = '\n✅ информатика и ИКТ'
|
|||
|
if temp5[0] == 1:
|
|||
|
inostr = '\n✅ иностранный язык'
|
|||
|
if temp6[0] == 1:
|
|||
|
obsh = '\n✅ обществознание'
|
|||
|
if temp7[0] == 1:
|
|||
|
biol = '\n✅ биология'
|
|||
|
return (f'Выбраны предметы:{math}{rus}{fiz}{inf}{inostr}{obsh}{biol}')
|
|||
|
|
|||
|
|
|||
|
def load_predm(self, user_id):
|
|||
|
"""Выбраные предметы"""
|
|||
|
with self.connection:
|
|||
|
temp_russian = self.cursor.execute('SELECT `russia` FROM `allusers` WHERE `user_id` = ?', (user_id,)).fetchall()
|
|||
|
russian = temp_russian[0]
|
|||
|
math_temp1 = self.cursor.execute('SELECT `math` FROM `allusers` WHERE `user_id` = ?', (user_id,)).fetchall()
|
|||
|
math = math_temp1[0]
|
|||
|
rus_temp2 = self.cursor.execute('SELECT `rus` FROM `allusers` WHERE `user_id` = ?', (user_id,)).fetchall()
|
|||
|
rus = rus_temp2[0]
|
|||
|
fiz_temp3 = self.cursor.execute('SELECT `fiz` FROM `allusers` WHERE `user_id` = ?', (user_id,)).fetchall()
|
|||
|
fiz = fiz_temp3[0]
|
|||
|
inf_temp4 = self.cursor.execute('SELECT `inf` FROM `allusers` WHERE `user_id` = ?', (user_id,)).fetchall()
|
|||
|
inf = inf_temp4[0]
|
|||
|
inostr_temp5 = self.cursor.execute('SELECT `inostr` FROM `allusers` WHERE `user_id` = ?', (user_id,)).fetchall()
|
|||
|
inostr = inostr_temp5[0]
|
|||
|
obsh_temp6 = self.cursor.execute('SELECT `obsh` FROM `allusers` WHERE `user_id` = ?', (user_id,)).fetchall()
|
|||
|
obsh = obsh_temp6[0]
|
|||
|
biol_temp7 = self.cursor.execute('SELECT `biol` FROM `allusers` WHERE `user_id` = ?', (user_id,)).fetchall()
|
|||
|
biol = biol_temp7[0]
|
|||
|
|
|||
|
out0 = 'Ничего не найдено\n'
|
|||
|
out1 = ''
|
|||
|
out2 = ''
|
|||
|
out3 = ''
|
|||
|
out4 = ''
|
|||
|
out5 = ''
|
|||
|
out6 = ''
|
|||
|
out7 = ''
|
|||
|
out8 = ''
|
|||
|
out9 = ''
|
|||
|
out10 = ''
|
|||
|
out11 = ''
|
|||
|
out12 = ''
|
|||
|
out13 = ''
|
|||
|
out14 = ''
|
|||
|
out15 = ''
|
|||
|
out16 = ''
|
|||
|
out17 = ''
|
|||
|
out18 = ''
|
|||
|
out19 = ''
|
|||
|
out20 = ''
|
|||
|
out21 = ''
|
|||
|
out22 = ''
|
|||
|
out23 = ''
|
|||
|
out24 = ''
|
|||
|
out25 = ''
|
|||
|
out26 = ''
|
|||
|
ss0 = 'Ничего не найдено'
|
|||
|
ss1 = ''
|
|||
|
ss2 = ''
|
|||
|
ss3 = ''
|
|||
|
ss4 = ''
|
|||
|
ss5 = ''
|
|||
|
ss6 = ''
|
|||
|
ss7 = ''
|
|||
|
ss8 = ''
|
|||
|
ss9 = ''
|
|||
|
ss10 = ''
|
|||
|
ss11 = ''
|
|||
|
if (russian[0] == 0):
|
|||
|
if (math[0] == 1 and rus[0] == 1 and inf[0] == 1):
|
|||
|
out0 = ''
|
|||
|
out1 = PSEVDO['b1']
|
|||
|
out2 = PSEVDO['b2']
|
|||
|
out3 = PSEVDO['b3']
|
|||
|
out4 = PSEVDO['b4']
|
|||
|
out5 = PSEVDO['b5']
|
|||
|
out6 = PSEVDO['b6']
|
|||
|
ss0 = ''
|
|||
|
ss8 = PSEVDO['s8']
|
|||
|
ss9 = PSEVDO['s9']
|
|||
|
|
|||
|
if (math[0] == 1 and rus[0] == 1 and fiz[0] == 1):
|
|||
|
out0 = ''
|
|||
|
out7 = PSEVDO['b7']
|
|||
|
out8 = PSEVDO['b8']
|
|||
|
out9 = PSEVDO['b9']
|
|||
|
out10 = PSEVDO['b10']
|
|||
|
out11 = PSEVDO['b11']
|
|||
|
out12 = PSEVDO['b12']
|
|||
|
out13 = PSEVDO['b13']
|
|||
|
out14 = PSEVDO['b14']
|
|||
|
out15 = PSEVDO['b15']
|
|||
|
out16 = PSEVDO['b16']
|
|||
|
out17 = PSEVDO['b17']
|
|||
|
out18 = PSEVDO['b18']
|
|||
|
out19 = PSEVDO['b19']
|
|||
|
out20 = PSEVDO['b20']
|
|||
|
out21 = PSEVDO['b21']
|
|||
|
ss0 = ''
|
|||
|
ss1 = PSEVDO['s1']
|
|||
|
ss2 = PSEVDO['s2']
|
|||
|
ss3 = PSEVDO['s3']
|
|||
|
ss4 = PSEVDO['s4']
|
|||
|
ss5 = PSEVDO['s5']
|
|||
|
ss6 = PSEVDO['s6']
|
|||
|
ss7 = PSEVDO['s7']
|
|||
|
if (math[0] == 1 and rus[0] == 1 and biol[0] == 1):
|
|||
|
ss0 = ''
|
|||
|
ss10 = PSEVDO['s10']
|
|||
|
|
|||
|
if (rus[0] == 1 and inostr[0] == 1 and obsh[0] == 1):
|
|||
|
out0 = ''
|
|||
|
out22 = PSEVDO['b22']
|
|||
|
out23 = PSEVDO['b23']
|
|||
|
out24 = PSEVDO['b24']
|
|||
|
out25 = PSEVDO['b25']
|
|||
|
ss0 = ''
|
|||
|
ss11 = PSEVDO['s11']
|
|||
|
|
|||
|
if (math[0] == 1 and rus[0] == 1 and inostr[0] == 1):
|
|||
|
out0 = ''
|
|||
|
out26 = PSEVDO['b26']
|
|||
|
|
|||
|
return (f'📍 Бакалавриат:\n{out0} {out1} {out2} {out3} {out4} {out5} {out6} {out7} {out8} {out9} {out10} {out11} {out12} {out13} {out14} {out15} {out16} {out17} {out18} {out19} {out20} {out21} {out22} {out23} {out24} {out25} {out26}\n📍 Специалитет:\n{ss0} {ss1} {ss2}{ss3} {ss4} {ss5} {ss6} {ss7} {ss8} {ss9} {ss10} {ss11}')
|
|||
|
elif (russian[0] == 1):
|
|||
|
if (math[0] == 1 and rus[0] == 1 and inf[0] == 1):
|
|||
|
out0 = ''
|
|||
|
out2 = PSEVDO['b2']
|
|||
|
out3 = PSEVDO['b3']
|
|||
|
out6 = PSEVDO['b6']
|
|||
|
|
|||
|
if (math[0] == 1 and rus[0] == 1 and fiz[0] == 1):
|
|||
|
out0 = ''
|
|||
|
out12 = PSEVDO['b12']
|
|||
|
out14 = PSEVDO['b14']
|
|||
|
out15 = PSEVDO['b15']
|
|||
|
out20 = PSEVDO['b20']
|
|||
|
out21 = PSEVDO['b21']
|
|||
|
|
|||
|
if (rus[0] == 1 and inostr[0] == 1 and obsh[0] == 1):
|
|||
|
out0 = ''
|
|||
|
out22 = PSEVDO['b22']
|
|||
|
out23 = PSEVDO['b23']
|
|||
|
out25 = PSEVDO['b25']
|
|||
|
|
|||
|
if (math[0] == 1 and rus[0] == 1 and inostr[0] == 1):
|
|||
|
out0 = ''
|
|||
|
out26 = PSEVDO['b26']
|
|||
|
|
|||
|
return (f'📍 Бакалавриат:\n{out0} {out2} {out3} {out6} {out12} {out14} {out15} {out20} {out21} {out22} {out23} {out25} {out26}\n')
|
|||
|
else:
|
|||
|
return (f'error 8')
|
|||
|
|
|||
|
|
|||
|
def close(self):
|
|||
|
"""Закрываем соединение с БД"""
|
|||
|
self.connection.close()
|