def show_report(self, report): print("starting") from dbase import DbConnect ttk.Label(report, text="Select Department").grid(row=0, column=0, padx=10, pady=10, ipadx=5, ipady=5) dept_list = ttk.Combobox(report) time_box = ttk.Combobox(report) time_box.grid(row=1, column=1, padx=10, pady=10, ipadx=5, ipady=5) dept_list.grid(row=0, column=1, padx=10, pady=10, ipadx=5, ipady=5) db = DbConnect(self.ip) db.cu.execute('SELECT dept FROM `department`') row = db.cu.fetchall() dept_list['values'] = row # dept = dept_list.get() # row = db.cu.fetchall() db.cu.execute('Select distinct(time) from feedback') row = db.cu.fetchall() time_box['values'] = row ttk.Button(report, text="Generate", command=lambda: self.make_report(dept_list.get(), time_box.get())). \ grid(row=2, column=1, padx=10, pady=10, ipadx=5, ipady=5)
def teacher_save(self, sem, dept): from dbase import DbConnect db = DbConnect(self.ip) stmt = 'insert into teacher(t_id,t_sub,t_div,sem,dept) values(%s,%s,%s,%s,%s)' s_stmt = 'insert into practical(t_id,t_sub,batch,t_div,sem,dept) values(%s,%s,%s,%s,%s,%s)' stmt2 = 'insert into student(s_id,s_div,s_dept,s_sem, batch) values(%s,%s,%s,%s,%s)' stu_id = dept + "_" + sem + "_" print(stu_id) try: batch_list = [] for t in self.teacher_value: data = [t[0], t[2], t[3], sem, dept] db.cu.execute(stmt, data) for t in self.sp_teacher_value: div = t[3][:1] data = [t[0], t[2], t[3], div, sem, dept] db.cu.execute(s_stmt, data) if batch_list.count(t[3]) == 0: batch_list.append(t[3]) if batch_list: for t in batch_list: s_id = stu_id + t check = 0 try: check = db.cu.execute( 'select s_id from student where s_id = "{}" '. format(s_id)) print(check) except pm.InternalError: print(check) if check == 0: div = t[:1] data = [s_id, div, dept, sem, t] db.cu.execute(stmt2, data) print("batch student") db.db.commit() messagebox.showinfo(title='Success', message='Teachers added successfully') else: for t in self.teacher_value: s_id = stu_id + t[3] check = 0 try: check = db.cu.execute( 'select s_id from student where s_id = "{}" '. format(s_id)) print(check) except pm.InternalError: print(check) if check == 0: data = [s_id, t[3], dept, sem, ''] db.cu.execute(stmt2, data) print("student") db.db.commit() messagebox.showinfo(title='Success', message='Teachers added successfully') except pm.err: db.db.rollback() messagebox.showerror()
def eval_quest(self, i): from dbase import DbConnect db = DbConnect(self.ip) stmt = 'select t_id,t_sub from teacher where dept="' + str( self.dept) + '" and t_div="' + str(self.div) + '" and sem=' + str( self.sem) db.cu.execute(stmt) res = db.cu.rowcount if self.inc <= res: if self.marks.get() != 0: db.cu.execute('select * from mt_question') q_count = db.cu.rowcount if i <= q_count: self.eval() self.question_loop() else: self.eval() self.tent.append(self.ent) print(self.tent) self.ent = [] self.count = 1 self.question_loop() self.show_teacher() else: messagebox.showwarning('Pynalyze', 'Select an option')
def eval_quest(self, i): from dbase import DbConnect db = DbConnect(self.ip) stmt = 'select t_id,t_sub from teacher where dept="' + str( self.dept) + '" and t_div="' + str(self.div) + '" and sem=' + str( self.sem) # print(stmt) db.cu.execute(stmt) res = db.cu.rowcount if res != 0: res += db.cu.execute( 'select t_id,t_sub from practical where dept=%s and batch=%s and sem=%s', (str(self.dept), self.batch, str(self.sem))) if self.inc <= res: if self.marks.get() != 0: db.cu.execute('select * from mt_question') q_count = db.cu.rowcount if i <= q_count: self.eval() self.question_loop() else: self.eval() self.tent.append(self.ent) # print("inputs "+str(len(self.tent))) self.ent = [] self.count = 1 self.question_loop() # print("i am here") self.text_rev() # self.show_teacher() else: messagebox.showwarning('Pynalyze', 'Select an option') else: messagebox.showerror("MCT's RGIT", "Teachers for the student does not exists")
def tg1(): db = DbConnect() db.cu.execute('select distinct t_id from feedback') res = db.cu.fetchall() print(res[0]) r = [] x = [] for t in res: db.cu.execute('select sum(sum) from feedback where t_id=' + str(t[0])) row = db.cu.fetchone() x.append(int(float(row[0]))) r.append(row) print(x) db.cu.execute('select distinct t_id from feedback') res = db.cu.fetchall() objects = [int(i[0]) for i in res] print(objects) # objects = ('TIME SENSE', 'SUBJ COMMND', 'TEACHNG METHDS', 'HELPING ATT.', 'INTERACTION', 'COMM SKILLS', 'OTHERS') na = [] for i in objects: db.cu.execute('select t_name from mt_teacher where t_id=' + str(i)) res = db.cu.fetchone() na.append(res[0]) print(na) plt.bar(objects, x, align='center', alpha=1.0) plt.xticks(objects, na) plt.ylabel('Ratings') plt.title('Teachers - March 2017') figtext(.03, .03, "The highest value is " + str(max(x))) plt.show()
def add_teacher_list(self, teacher, subject, div, selection_top, flag): from dbase import DbConnect label_list = [] button_list = [] if teacher == '' or subject == '' or div == '': messagebox.showerror(title="Missing Values", message="Please enter values correctly") return db = DbConnect(self.ip) stmt = 'select t_name from mt_teacher where t_id=%s' num = db.cu.execute(stmt, teacher) if num == 0: messagebox.showerror(title="Invalid", message="Teacher does not exist") return res = db.cu.fetchone() teacher_name = res[0] if flag == 0: self.teacher_value.append( [teacher, teacher_name, subject, div.upper()]) if flag == 1: self.sp_teacher_value.append( [teacher, teacher_name, subject, div.upper()]) teacher_box = Canvas(selection_top) teacher_box.grid(row=3, column=0, sticky=(N, S, E, W)) self.teacher_refresh(teacher_box, label_list, button_list) '''for t in teacher_values:
def add_teacher(self, add_teacher): from dbase import DbConnect print("adding") ttk.Label(add_teacher, text="Select Department").grid(row=0, column=0, padx=10, pady=10, ipadx=5, ipady=5) ttk.Label(add_teacher, text='Select Sem').grid(row=1, column=0, padx=10, pady=10, ipadx=5, ipady=5) ttk.Button(add_teacher, text="Next", command=lambda: self.select_teacher(sem_list.get(), dept_list.get(), add_teacher)) \ .grid(row=2, column=2, padx=10, pady=10, ipadx=5, ipady=5) dept_list = ttk.Combobox(add_teacher) sem_list = ttk.Combobox(add_teacher) dept_list.grid(row=0, column=1, padx=10, pady=10, ipadx=5, ipady=5) sem_list.grid(row=1, column=1, padx=10, pady=10, ipadx=5, ipady=5) db = DbConnect(self.ip) db.cu.execute('Select dept from department') res = db.cu.fetchall() dept_list['values'] = res sem = [1, 2, 3, 4, 5, 6, 7, 8] sem_list['values'] = sem
def adm_check(self, parent, controller): from dbase import DbConnect from adminpanel import AdminPanel db_con = DbConnect(self.ip.get()) c = db_con.db_admin_call(self.admin, self.password) ap = AdminPanel(parent, controller, self.ip.get()) ap.winfo_toplevel().geometry('500x400') if c == 1: controller.remove_frame() ap.grid() elif c == 0: messagebox.showerror('Pynalyze', 'Please check your user name and password') self.password.set("") else: messagebox.showerror('Pynalyze', 'Multiple administrators are not allowed')
def student_check(self, parent, controller): from dbase import DbConnect from studentform import StudentForm try: db_con = DbConnect(self.ip.get()) sf = StudentForm(parent, controller, self.ip.get()) c = db_con.db_stu_call(self.std_id, sf) if c == 1: print(self.ip.get()) controller.remove_frame() sf.grid() elif c == 0: messagebox.showerror('Pynalyze', 'Select your correct student id please') else: messagebox.showwarning( 'Pynalyze', 'Sorry!! you are not allowed to proceed') except: messagebox.showerror('Pynalyze', 'Server not reachable')
def show_teacher(self): from dbase import DbConnect self.inc += 1 top_list = ttk.Frame(self, height=200, width=100, borderwidth=2, relief=GROOVE) top_list.grid(row=0, column=0, rowspan=3, sticky=(N, W), padx=6, pady=6) top_list.grid_propagate(0) db = DbConnect(self.ip) stmt = 'select t_id,t_sub from teacher where dept="'+str(self.dept)+'" and t_div="'+str(self.div)+'" and sem='\ + str(self.sem) db.cu.execute(stmt) res = db.cu.fetchall() name = [] sub = [] for t in res: db.cu.execute('select t_name from mt_teacher where t_id=' + str(t[0])) row = db.cu.fetchall() name.append(row[0]) sub.append(t[1]) for t in name: ttk.Label(top_list, text=t).grid(padx=6, pady=6) info = ttk.Frame(self, height=100, width=400, borderwidth=2, relief=GROOVE) info.grid(row=0, column=1, columnspan=3, sticky=(N, W), padx=6, pady=6) try: n = ''.join(name[self.inc - 1]) s = ''.join(sub[self.inc - 1]) self.t.set('Name: ' + n + ' Dept: ' + str(self.dept) + ' Subject: ' + s) ttk.Label(info, textvariable=self.t).grid(row=0, column=0, ipadx=25, ipady=20, sticky=E) except db: self.grid_remove() messagebox.showinfo('Pynalyze', 'Thank You') # update to database self.controller.destroy()
def student_check(self, parent, controller): from dbase import DbConnect from studentform import StudentForm try: db_con = DbConnect(self.ip.get()) sf = StudentForm(parent, controller, self.ip.get()) c = db_con.db_stu_call(self.std_id, sf) if c == 1: # print(self.ip.get()) controller.remove_frame() sf.grid() elif c == 0: messagebox.showerror("MCT's RGIT", 'Select your correct student id please') else: messagebox.showwarning( "MCT's RGIT", 'Sorry!! you are not allowed to proceed') except pm.err.OperationalError: # DbConnect: messagebox.showerror("MCT's RGIT", 'Server not reachable') except IndexError: messagebox.showerror("MCT's RGIT", "No Teacher for current ID exists") '''db_con = DbConnect(self.ip.get())
def question_loop(self): from dbase import DbConnect db = DbConnect(self.ip) # db.cu.execute('select i from con') # row = db.cu.fetchone() # if row[0]: db.cu.execute('select q_text,q_options from mt_question where q_id=' + str(self.count)) res = db.cu.fetchone() self.q.set(str(self.count) + "." + res[0]) self.count += 1 opt = res[1].split(',') for r in range(5): self.rb[r].config(text=opt[r])
def tg1(t1): db = DbConnect() db.cu.execute('select * from feedback where t_id=' + str(t1)) row = db.cu.fetchall() print(row) t = [2008, 2009, 2010, 2011, 2012, 2013, 2014] s = [6.2, 7.1, 7.2, 8.3, 8.2, 8.3, 8.0] s2 = [7.5, 7.6, 8.0, 7, 7.6, 8.2, 7.9] plot(t, s, label='Teacher XYZ') plot(t, s2, label='Teacher PQR') pylab.legend(loc='upper right') xlabel('YEARS') ylabel('Ratings') title('XYZ v/s PQR') grid(True) show()
def make_report(ip, tid): from dbase import DbConnect db = DbConnect(ip) # ---------------------------COLLECTING VARIABLES------------------------------ # cursor.execute("INSERT INTO table VALUES (%s, %s, %s)", (var1, var2, var3)) db.cu.execute("Select t_name from mt_teacher where t_id={}".format(tid)) r1 = db.cu.fetchone() t_name = r1[0] # print(t_name) # f=open("%s.txt"%t_name,"w+") # print t_name db.cu.execute("Select dept from teacher where t_id={}".format(tid)) r1 = db.cu.fetchone() t_dept = r1[0] # print(t_dept) # print t_dept db.cu.execute("Select t_sub from teacher where t_id={}".format(tid)) r1 = db.cu.fetchone() t_sub = r1[0] # print(t_sub) # print t_sub db.cu.execute("Select rating from finalfeedback where t_id=(%s)", tid) r1 = db.cu.fetchone() final_rating = r1[0] # print(final_rating) # print final_rating # ---------------------------WRITING IN FILE--------------------------------------------- filename = t_name + "_" + t_dept f = open("%s.txt" % filename, "w+") # f.write(" \t\t\t\t\t\t\t\t\t%s\n\n"%t_name) f.write("==>Teacher name : %s\n" % t_name) f.write("==>Subject : %s\n==>Department : %s\n\n" % (t_sub, t_dept)) f.write("\t\t-----------------SCORE---------------------\n\n") db.cu.execute("Select avg from feedback where t_id=(%s)", tid) avg = db.cu.fetchall() num_rows = db.cu.rowcount db.cu.execute("Select q_text from mt_question") q_text = db.cu.fetchall() for x in range(0, num_rows): # f.write("%s)" % (x+1)+"%s" % str(q_text[0])+" - %s/5" % str(avg[0])+"\n\n") f.write("{}) {}/5 \t\t\t|| {}\n\n".format(x+1, round(avg[x][0], 2), q_text[x][0])) f.write("\n\n\t\t-------------OVER ALL SCORE-----------------\n\n") f.write("\t\t\t\t----------\n\t\t\t %s percent" % final_rating+"\n\t\t\t\t----------\n\n\n\n\n\n\n") f.write(" \t\t\t\t\t\t\t\t\t_________________\n") f.write(" \t\t\t\t\t\t\t\t\t SIGNATURE") f.close()
def question_loop(self): from dbase import DbConnect db = DbConnect(self.ip) db.cu.execute('select i from con') row = db.cu.fetchone() if row[0]: db.cu.execute('select q_text from mt_question where q_id=' + str(self.count)) res = db.cu.fetchone() self.count += 1 self.q.set(res[0]) else: db.cu.execute('select q_text from mt_question where q_id=' + str(33 + self.count) + '') res = db.cu.fetchone() self.count += 1 try: self.q.set(res[0]) except self.q: self.show_teacher()
def create_entries(self): from dbase import DbConnect import datetime db = DbConnect(self.ip) time_input = datetime.date.today().strftime("%B %Y") # stmt = 'select t_id from mt_teacher' # db.cu.execute(stmt) db.cu.execute('select t_id,t_sub,t_div from teacher') res = db.cu.fetchall() stmt = 'select t_id from feedback where time="' + time_input + '"' db.cu.execute(stmt) check = db.cu.fetchall() stmt = 'select count(q_id) from mt_question' db.cu.execute(stmt) c = db.cu.fetchone() db.cu.execute('select t_id, t_sub, batch from practical') prac = db.cu.fetchall() res = res + prac try: if len(check) != 0: messagebox.showerror("Pynalyze", "Data table already exists !") else: for i in range(len(res)): for j in range(c[0]): # stmt = ("INSERT INTO feedback " # "(t_id, q_id, time) " # "values (%s, %s, %s);") # data = (res[i], j+1, time_input) stmt = ("INSERT INTO feedback " "(t_id, q_id, time, t_sub, t_div) " "value (%s, %s, %s, %s, %s);") data = (res[i][0], j + 1, time_input, res[i][1], res[i][2]) db.cu.execute(stmt, data) messagebox.showinfo("Pynalyze", "Table Created Successfully") db.db.commit() except pm.err: db.db.rollback()
import datetime import os from dbase import DbConnect db = DbConnect("") dept = 'MECH' db.cu.execute("SELECT t_id, t_sub, batch from practical where dept=%s", dept) t_res = db.cu.fetchall() print(t_res) time_input = datetime.date.today().strftime("%B %Y") db.cu.execute("select distinct(time) from feedback") time_in = db.cu.fetchone() time_in = time_in[0] for detail in t_res: tid = detail[0] print(tid) # ---------------------------COLLECTING VARIABLES------------------------------ db.cu.execute("Select t_name from mt_teacher where t_id={}".format(tid)) r1 = db.cu.fetchone() t_name = r1[0] db.cu.execute("Select dept from practical where t_id={}".format(tid)) r1 = db.cu.fetchone() t_dept = r1[0] t_sub = detail[1] t_div = detail[2] # print(t_sub) # print t_sub print(tid,time_in,t_sub,t_div) db.cu.execute("Select AVG(avg) from feedback where t_id=(%s) and time=(%s) and t_sub=%s and t_div=%s",
def __init__(self, parent, controller, host): from dbase import DbConnect ttk.Frame.__init__(self, parent) menu_bar = Menu(controller) controller['menu'] = menu_bar menu_file = Menu(menu_bar) menu_edit = Menu(menu_bar) menu_setting = Menu(menu_bar) menu_bar.add_cascade(menu=menu_file, label='File') menu_bar.add_cascade(menu=menu_edit, label='Edit') menu_setting.add_cascade(menu=menu_edit, label='setting') self.percent = DoubleVar() self.fb = StringVar() self.ip = host self.db = DbConnect(self.ip) self.teacher_value = [] self.sp_teacher_value = [] n = ttk.Notebook(self) # general = ttk.Frame(n) # first page, which would get widgets gridded into it tools = ttk.Frame(n) # second page stats = ttk.Frame(n) # graph page graph = ttk.Combobox(stats) graph['values'] = ('', 'All teachers') graph.current(0) graph.grid(row=0, column=0, padx=10, pady=10) # ttk.Button(stats, text='Generate graph', command=lambda: tg1(host)).grid(row=0, column=1, padx=10, pady=10) mail = ttk.Combobox(stats) db = DbConnect(self.ip) db.cu.execute('select t_name from mt_teacher') row = db.cu.fetchall() # print(row) mail['values'] = row mail.grid(row=1, column=0) ttk.Button(stats, text="Send Mail", command=lambda: messagebox.showinfo( 'Pynalyze', 'Message sent successfully')).grid(row=1, column=1) # sel = ttk.LabelFrame(general, text='Selection') # sel.grid(row=0, column=0, padx=10, pady=10) # ttk.Label(sel, text='Select Department code').grid(row=0, column=0, padx=10, pady=10, sticky=W) # self.dept = ttk.Combobox(sel) # self.dept.grid(row=0, column=1, sticky=W) # self.db.cu.execute('select distinct s_dept from student') # self.dept['values'] = self.db.cu.fetchall() # ttk.Entry(sel, textvariable=self.percent).grid(row=1, column=1, sticky=W) # ttk.Label(sel, text='Minimum Percentage : ').grid(row=1, column=0, padx=10, pady=10, sticky=W) # ttk.Label(sel, text='Select Semester').grid(row=2, column=0, padx=10, pady=10, sticky=W) # self.sem = ttk.Combobox(sel) # self.sem.grid(row=2, column=1, sticky=W) self.db.cu.execute('select distinct s_sem from student') # self.sem['values'] = self.db.cu.fetchall() # ttk.Label(sel, text='Select Division').grid(row=3, column=0, padx=10, pady=10, sticky=W) # self.div = ttk.Combobox(sel) # self.div.grid(row=3, column=1, sticky=W) # self.db.cu.execute('select distinct s_div from student') # self.div['values'] = self.db.cu.fetchall() # ttk.Label(sel, text='Type of Feedback').grid(row=4, column=0, padx=10, pady=10, sticky=W) # sf = ttk.Frame(sel, borderwidth=2, relief=GROOVE) # sf.grid(row=4, column=1, sticky=E) # ttk.Radiobutton(sf, variable=self.fb, text='Standard', value='0').grid(row=0, column=0) # ttk.Radiobutton(sf, variable=self.fb, text='Behavioral', value='1').grid(row=0, column=1) # ttk.Button(sel, text='Start', command=lambda: self.update_all()).grid(row=5, column=2) self.db.db.close() # n.add(general, text='General') n.add(tools, text='Tools') n.add(stats, text='Stats') n.grid() tools_notebook = ttk.Notebook(tools) add_user = ttk.Frame(tools_notebook) report = ttk.Frame(tools_notebook) add_teacher = ttk.Frame(tools_notebook) tools_notebook.grid() tools_notebook.add(report, text='Report') tools_notebook.add(add_teacher, text='Add teacher') tools_notebook.add(add_user, text='Add user') ttk.Separator(tools).grid(row=3) ttk.Button(report, text="Generate Table", command=lambda: self.create_entries()) \ .grid(row=4, column=0, padx=10, pady=10, sticky=W) self.show_report(report) self.add_teacher(add_teacher) for child in self.winfo_children(): child.grid_configure(padx=5, pady=5)
def update_all(self): from dbase import DbConnect db = DbConnect(self.ip) db.cu.execute('update con set i=' + str(self.fb.get()) + ' where p=1') db.db.commit() messagebox.showinfo("Pynalyze", "feedback session has started")
def make_report(self, dept, time_in): print("initializing") time_in = time_in[1:-1] # import datetime from dbase import DbConnect db = DbConnect(self.ip) dept = str(dept) db.cu.execute("SELECT t_id, t_sub, t_div from teacher where dept=%s", dept) t_res = db.cu.fetchall() db.cu.execute('Select t_id, t_sub, batch from practical where dept=%s', dept) t_res = t_res + db.cu.fetchall() # db.cu.execute("SELECT t_id, t_sub, batch from practical where dept=%s", dept) # t_res.append(db.cu.fetchall()) # print # time_input = datetime.date.today().strftime("%B %Y") # db.cu.execute("select distinct(time) from feedback") # time_in = db.cu.fetchone() # time_in = time_in[0] for detail in t_res: tid = detail[0] t_sub = detail[1] t_div = detail[2] # print(tid) # ---------------------------COLLECTING VARIABLES------------------------------ db.cu.execute( "Select t_name from mt_teacher where t_id={}".format(tid)) r1 = db.cu.fetchone() t_name = r1[0] try: db.cu.execute( "Select dept from teacher where t_id=%s and t_sub=%s and t_div=%s", (tid, t_sub, t_div)) print((tid, t_sub, t_div)) r1 = db.cu.fetchone() t_dept = r1[0] except TypeError: db.cu.execute( "Select dept from practical where t_id=%s and t_sub=%s and batch=%s", (tid, t_sub, t_div)) r1 = db.cu.fetchone() t_dept = r1[0] db.cu.execute( "select sem from subjects where subject_name=%s and dept=%s", (t_sub, dept)) r1 = db.cu.fetchone() t_sem = r1[0] # print(t_sub) # print t_sub db.cu.execute( "Select AVG(avg) from feedback where t_id=(%s) and time=(%s) and t_sub=%s and t_div=%s", (tid, time_in, t_sub, t_div)) r1 = db.cu.fetchone() final_rating = r1[0] # print((tid, time_in, t_sub, t_div)) final_rating = round(final_rating, 3) # ---------------------------WRITING IN FILE--------------------------------------------- filepath = t_dept + "_" + time_in + "/" + str(t_sem) print(filepath, tid) if not os.path.exists(filepath): os.makedirs(filepath) filename = t_name + "_" + t_sub + "_" + t_div # print(filename) f = open("{}/{}.txt".format(filepath, filename), "w+") f.write("==>Teacher name \t: {}\n".format(t_name)) f.write("==>Subject \t\t: {}\n==>Department \t\t: {}\n".format( t_sub, t_dept)) f.write("==>Division \t\t: {}\n".format(t_div)) f.write("\n\t\t-----------------SCORE-----------------\n") db.cu.execute( "Select avg from feedback where t_id=(%s) and time=(%s) and t_sub=(%s) and t_div=%s", (tid, time_in, t_sub, t_div)) avg = db.cu.fetchall() db.cu.execute("Select q_tag from mt_question") num_rows = db.cu.rowcount q_text = db.cu.fetchall() final_pct = (final_rating / 5) * 100 #print(q_text.__len__()) print(q_text) for x in range(0, num_rows): pct = (avg[x][0] / 5) * 100 # f.write("%s)" % (x+1)+"%s" % str(q_text[0])+" - %s/5" % str(avg[0])+"\n\n") #print(q_text[x][0]) print(num_rows) f.write("{}) {} % \t\t||{}\n\n".format(x + 1, round(pct, 2), q_text[x][0])) f.write("\n\t\t--------------TOTAL SCORE--------------\n") f.write( "\t\t\t-----------------------\n\t\t\t {} %\n\t\t\t-----------------------\n\n" .format(round(final_pct, 3))) f.write("_________________\n") f.write(" SIGNATURE") # self.make_graph(tid) db.cu.execute( "select review from teacher_review " "where t_id=%s and time=%s and t_sub=%s and t_div=%s", (tid, time_in, t_sub, t_div)) rev = db.cu.fetchall() f.write("\n\n\n\n\n\n\n\n\n\n\n\n\t--------Reviews--------\n\n") for i in rev: f.write("\n{} \n".format(i[0])) print(rev) # self.make_graph(tid, filepath) f.close() messagebox.showinfo("Pynalyze", "Report Generated")
def show_teacher(self): from dbase import DbConnect self.inc += 1 top_list = ttk.Frame(self, height=200, width=160, borderwidth=2, relief=GROOVE) top_list.grid(row=0, column=0, rowspan=3, sticky=(N, W), padx=6, pady=6, ipadx=5, ipady=5) top_list.grid_propagate(0) db = DbConnect(self.ip) stmt = 'select t_id,t_sub from teacher where dept="'+str(self.dept)+'" and t_div="'+str(self.div)+'" and sem='\ + str(self.sem) db.cu.execute(stmt) res = db.cu.fetchall() name = [] sub = [] tid_list = [] # print(res) for t in res: db.cu.execute('select t_name from mt_teacher where t_id=' + str(t[0])) # print(str(t[0])) row = db.cu.fetchall() name.append(row[0]) sub.append(t[1]) tid_list.append(t[0]) stmt = "select t_id,t_sub from practical where dept=%s and batch=%s and sem=%s" batch_data = (str(self.dept), self.batch, str(self.sem)) db.cu.execute(stmt, batch_data) bat = db.cu.fetchone() res = res + (bat, ) if bat is not None: db.cu.execute('select t_name from mt_teacher where t_id=' + str(bat[0])) bat_t = db.cu.fetchall() name.append(bat_t[0]) sub.append(bat[1]) tid_list.append(bat[0]) for t in name: ttk.Label(top_list, text=t).grid(padx=6, pady=6) info = ttk.Frame(self, height=100, width=400, borderwidth=2, relief=GROOVE) info.grid(row=0, column=1, columnspan=3, sticky=(N, W), padx=6, pady=6) try: n = ''.join(name[self.inc - 1]) self.current_tid = tid_list[self.inc - 1] s = ''.join(sub[self.inc - 1]) self.t.set('Name: ' + n + ' Dept: ' + str(self.dept) + ' Subject: ' + s) ttk.Label(info, textvariable=self.t).grid(row=0, column=0, ipadx=25, ipady=20, sticky=E) except IndexError: self.grid_remove() # update to database time_input = datetime.date.today().strftime("%B %Y") k = -1 stmt = 'select count(q_id) from mt_question' db.cu.execute(stmt) c = db.cu.fetchone() db.cu.execute('lock tables feedback write, teacher_review write') for t in res: k += 1 count_review = 0 # print(self.review) '''if k < len(self.review): if len(self.review[k]) != 0: stmt = ("INSERT INTO teacher_review " "(t_id, review, time) " "values (%s, %s, %s);") data = (t[0], self.review[k], time_input) # print(data) stmt = ("INSERT INTO teacher_review " "(t_id, review, time, t_sub, t_div) " "values (%s, %s, %s, %s, %s);") print(s) data = (t[0], self.review[k], time_input, s, self.div) db.cu.execute(stmt, data)''' for i in range(c[0]): # stmt = ("INSERT INTO feedback " # "(t_id, q_id, time) " # "values (%s, %s, %s);") # data = (t[0], i+1, time_input) # db.cu.execute(stmt, data) # db.db.commit() for j in range(len(self.tent)): # stmt = "update feedback " \ # "set `%s` = `%s` + 1 " \ # "where t_id=%s and q_id=%s and time=%s ; " stmt = ( 'update feedback ' 'set `%s` = `%s` + 1 ' 'where t_id=%s and q_id=%s and time=%s and t_sub=%s and (t_div=%s or t_div=%s);' ) if j == k: # print("normal") # data = (self.tent[j][i], self.tent[j][i], t[0], i+1, time_input) data = (self.tent[j][i], self.tent[j][i], t[0], i + 1, time_input, sub[j], str(self.div), self.batch) db.cu.execute(stmt, data) if count_review == 0: if k < len(self.review): if len(self.review[k]) != 0: '''stmt = ("INSERT INTO teacher_review " "(t_id, review, time) " "values (%s, %s, %s);") data = (t[0], self.review[k], time_input)''' # print(data) stmt = ( "INSERT INTO teacher_review " "(t_id, review, time, t_sub, t_div) " "values (%s, %s, %s, %s, %s);") print(sub[j]) data = (t[0], self.review[k], time_input, sub[j], self.div) db.cu.execute(stmt, data) count_review = 1 messagebox.showinfo('Pynalyze', 'Thank You') self.controller.destroy() db.db.commit() db.cu.execute('unlock tables')
def select_teacher(self, sem, dept, add_top): from dbase import DbConnect if sem == '' or dept == '': messagebox.showerror( title='Missing Value', message='department/sem values cannot be empty') add_top.lift() return if int(sem) > 2 and dept == 'AS&H': messagebox.showerror(title='Invalid Value', message='Error in department/sem values') add_top.lift() return elif int(sem) < 3 and dept != 'AS&H': messagebox.showerror(title='Invalid Value', message='Error in department/sem values') add_top.lift() return teacher_select = Toplevel(self) teacher_select.lift() teacher_type = ttk.Notebook(teacher_select) selection_top = ttk.Frame(teacher_select) selection_sp = ttk.Frame(teacher_select) teacher_type.add(selection_top, text="Normal") teacher_type.add(selection_sp, text="Special") teacher_type.grid() ttk.Label(selection_top, text="Teacher").grid(row=0, column=0, padx=10, pady=10, ipadx=5, ipady=5) teacher = ttk.Entry(selection_top) teacher.grid(row=1, column=0, ipadx=5, ipady=5) ttk.Label(selection_top, text='Subject').grid(row=0, column=1, padx=10, pady=10, ipadx=5, ipady=5) subject = ttk.Combobox(selection_top) db = DbConnect(self.ip) stmt = "select subject_name from subjects where sem=%s and dept=%s" data = (sem, dept) db.cu.execute(stmt, data) res = db.cu.fetchall() subject['values'] = res subject.grid(row=1, column=1, ipadx=5, ipady=5) ttk.Label(selection_top, text='Div').grid(row=0, column=2, padx=10, pady=10, ipadx=5, ipady=5) div = ttk.Entry(selection_top) div.grid(row=1, column=2, ipadx=5, ipady=5) ttk.Button(selection_top, text='Add', command=lambda: self.add_teacher_list(teacher.get(), subject.get(), div.get(), teacher_select, 0)) \ .grid(row=1, column=4, padx=10, pady=10, ipadx=5, ipady=5) ttk.Label(selection_sp, text="Teacher").grid(row=0, column=0, padx=10, pady=10, ipadx=5, ipady=5) s_teacher = ttk.Entry(selection_sp) s_teacher.grid(row=1, column=0, ipadx=5, ipady=5) ttk.Label(selection_sp, text='Subject').grid(row=0, column=1, padx=10, pady=10, ipadx=5, ipady=5) s_subject = ttk.Combobox(selection_sp) s_subject['values'] = res s_subject.grid(row=1, column=1, ipadx=5, ipady=5) ttk.Label(selection_sp, text='Batch').grid(row=0, column=2, padx=10, pady=10, ipadx=5, ipady=5) s_div = ttk.Entry(selection_sp) s_div.grid(row=1, column=2, ipadx=5, ipady=5) ttk.Button(selection_sp, text='Add', command=lambda: self.add_teacher_list(s_teacher.get(), s_subject.get(), s_div.get(), teacher_select, 1)) \ .grid(row=1, column=4, padx=10, pady=10, ipadx=5, ipady=5) ttk.Button(teacher_select, text='Save', command=lambda: self.teacher_save(sem, dept)) \ .grid(row=4, column=3, padx=10, pady=10, ipadx=5, ipady=5)