def chatty(user_input, email): # create_history() chat = ChatChild(pairs, reflections) output_response = chat.converse(user_input, email) # Create CSV for user transcripts line_1 = email + ":" + user_input line_2 = "George" + ":" + output_response print(line_1) print(line_2) with open('user_transcript.csv', 'a+', newline='') as f: writer = csv.writer(f) writer.writerow([line_1]) writer.writerow([line_2]) if user_input == "quit": f.close() sub = "Chat Transcript from the MSIST Chatbot" emailAdmin( email, sub, "user_transcript.csv", "Hi User,\n\n Please find attached your chat trasnscript.\n\nBest Regards\nTeam ChatBot George" ) os.remove('user_transcript.csv') return output_response
def unansweredDaily(): db_csv( "select hs_question, hs_studentID from history where strftime('%Y-%m-%d', hs_datestamp) = strftime('%Y-%m-%d','now','localtime') and hs_answer in ('Sorry, Can you be more specific?','Sorry I dint get you')", "AnalyticalReports/UnansweredQuestions.csv") emailAdmin( "*****@*****.**", "Unanswered Questions for the Day", "AnalyticalReports/UnansweredQuestions.csv", "Hi Team,\n\n The report for unanswered questions is attached here.\nReport includes email-id and the question from the student. \n\n Best Regards, \n Team ChatBot George" )
def happy_Meter(): conn = sqlite3.connect('tablessss.db', check_same_thread=False) c = conn.cursor() c.execute( "select count(*), hm_rating from happymeter where hm_rating!='' group by hm_rating order by hm_rating" ) rows = c.fetchall() count1 = rows[0][0] count2 = rows[1][0] count3 = rows[2][0] count4 = rows[3][0] count5 = 0 N = 5 menMeans = (count1, count2, count3, count4, count5) ind = np.arange(N) # the x locations for the groups width = 0.4 # the width of the bars: can also be len(x) sequence plt.figure(figsize=(12, 8)) p1 = plt.bar(ind, menMeans, width, color='lightgreen') #p2 = plt.bar(ind, womenMeans, width, #bottom=menMeans, yerr=womenStd) plt.ylabel('No.Of Students') plt.xlabel('Rating Scale') plt.title('Feedback Ratings') plt.xticks(ind, (1, 2, 3, 4, 5)) plt.yticks(np.arange(0, 25, 5)) p1[1].set_color('lightblue') p1[2].set_color('orange') p1[3].set_color('lightpink') p1[4].set_color('violet') plt.legend((p1[0], p1[1], p1[2], p1[3], p1[4]), ('Loved It', 'Liked It', 'Satisfied', 'Unsatisfied', 'Extremely Unsatisfied')) #plt.show() plt.savefig('AnalyticsImages/HappyMeter.png') emailAdmin( "*****@*****.**", "Chatbot George Feedback", "AnalyticsImages/HappyMeter.png", "Hi Team,\n\n The pictorial report of student experince with the Chatbot is attached below.\n\n Best Regards, \n Team ChatBot George" ) conn.close()
def piechart_report2(): conn = sqlite3.connect('tablessss.db', check_same_thread=False) c = conn.cursor() c.execute("select count(distinct(hs_studentID)) as Number,st_level from history left join student on ( history.hs_studentID=student.st_email) group by st_level") rows = c.fetchall() #for row in rows: #print(row) labels = ['Under Graduate', 'Graduate','Others'] sizes = [rows[2][0], rows[1][0], rows[0][0]] colors = ['yellowgreen','lightskyblue','orange'] patches, texts = plt.pie(sizes, colors=colors, shadow=True, startangle=90) plt.legend(patches, labels, loc="best") plt.axis('equal') plt.tight_layout() plt.savefig('AnalyticsImages/PieChart_StudentFootPrint.png') emailAdmin("*****@*****.**","Report Student Foot Print till date","AnalyticsImages/PieChart_StudentFootPrint.png"," Hi Team,\n\n Please find attached Student footprint.\n\nBest Regards\nTeam ChatBot George") conn.close()
def onOffFootPrint(): conn = sqlite3.connect('tablessss.db', check_same_thread=False) c = conn.cursor() c.execute( "select count(distinct hs_studentID) as on_campus from history left join student on ( history.hs_studentID=student.st_email) where lower(st_location) like '%washington%' or lower(st_location) like '%dc%'" ) rows = c.fetchall() oncampus = rows[0][0] c.execute( "select count(distinct hs_studentID) as off_campus from history left join student on ( history.hs_studentID=student.st_email) where lower(st_location) not like '%washington%' and lower(st_location) not like '%dc%'" ) rows = c.fetchall() offcampus = rows[0][0] N = 2 menMeans = (oncampus, offcampus) ind = np.arange(N) # the x locations for the groups width = 0.4 # the width of the bars: can also be len(x) sequence p1 = plt.bar(ind, menMeans, width, color='orange') #p2 = plt.bar(ind, womenMeans, width, #bottom=menMeans, yerr=womenStd) plt.ylabel('No.Of Students') plt.title('On-Campus vs Off-Campus') plt.xticks(ind, ('On-Campus', 'Off-Campus')) plt.yticks(np.arange(0, 25, 5)) p1[1].set_color('lightblue') plt.legend((p1[0], p1[1]), ('On-Campus', 'Off-Campus')) plt.savefig('AnalyticsImages/BarGraph_OnOffCampus.png') emailAdmin( "*****@*****.**", "On Campus vs Off Campus foot print", "AnalyticsImages/BarGraph_OnOffCampus.png", "Hi Team,\n\n The pictorial report for On campus vs Off-campus student log ins are attached below.\n\n Best Regards, \n Team ChatBot George" ) conn.close()