-
Notifications
You must be signed in to change notification settings - Fork 0
/
decisionTree.py
169 lines (152 loc) · 6.8 KB
/
decisionTree.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
from pymongo import MongoClient
import random
def fetchData():
MONGODB_URI = "mongodb://Debangshu:[email protected]:39055/studmenu"
client = MongoClient(MONGODB_URI, connectTimeoutMS=30000)
db = client.get_database("studmenu")
col = db["questionAnswers"]
cursor = col.find()
# p.pprint(cursor[0])
userInfo = cursor[0]
return(userInfo)
def updateUsersInformation(ID, **kwargs):
MONGODB_URI = "mongodb://Debangshu:[email protected]:39055/studmenu"
client = MongoClient(MONGODB_URI, connectTimeoutMS=30000)
db = client.get_database("studmenu")
for key in kwargs:
db.userInfo.update({"_id" : "5c4e064ffb6fc05326ad8c57"}, {"$set":{str(ID)+"."+str(key): kwargs[key]}},upsert=True);
return(0)
def listOfExams(supertopic):
if supertopic=='jobPrep':
return ['aptitude','generalknowledge','verbalability']
if supertopic=='class10':
return ['physics','biology','chemistry','math']
def decision(input):
if input=='Call Waiter':
msg=['Calling waiter! what do you want?']
listitems=['Napkin','Spoons',"Water","Talk to waiter"]
return msg,listitems
if input=='biology':
msg=['Okay so biology it is! I will continue giving you some random questions from biology ',' Untill you decide its enough','biology']
listitems=['Okay Sure','Go Back']
return msg,listitems
if input=='aptitude':
msg=['Okay so aptitude it is! I will continue giving you some random questions from aptitude ',' Untill you decide its enough','aptitude']
listitems=['Okay Sure','Go Back']
return msg,listitems
if input=='math':
msg=['Okay so math it is! I will continue giving you some random questions from math ',' Untill you decide its enough','math']
listitems=['Okay Sure','Go Back']
return msg,listitems
if input=='chemistry':
msg=['Okay so chemistry it is! I continue giving you some random questions from chemistry ',' Untill you decide its enough','chemistry']
listitems=['Okay Sure','Go Back']
return msg,listitems
if input=='physics':
msg=['Okay so physics it is! I will continue giving you some random questions from physics ',' Untill you decide its enough','physics']
listitems=['Okay Sure','Go Back']
return msg,listitems
if input=='Lets test':
msg=['Okay, lets test your knowledge! ','Choose a topic from below','biology']
listitems=['checkcurrenttopics']
return msg,listitems
if input=='Go Back':
msg=['Going back,which topic would you like to practice']
listitems=['checkcurrenttopics']
return msg, listitems
if input=='Another Level':
msg=['Another Level']
listitems=['Another Level']
return msg, listitems
if input=='Okay Sure':
msg=['okay,Lets start']
listitems=['Go Back']
return msg,listitems
if input=='Try Another':
msg=['okay,Lets start again']
listitems=['Go Back']
return msg,listitems
if input=='Another One':
msg=['okay,Lets start again']
listitems=['Go Back']
return msg,listitems
if input=='Results':
msg=['Results','Okay let me check your results!!']
listitems=['Details','Go Back','Continue']
return msg,listitems
if input=='Continue':
msg=['okay,Lets start']
listitems=['Go Back']
return msg,listitems
if input=='I am Bored!':
msg=['I am Bored!']
listitems=['Go Back','Lets test','Continue','Tell me a joke']
return msg,listitems
def decisionRightWrong(rightwrong,numberofrightwrong):
if rightwrong=='right':
if numberofrightwrong==0:
Arr=['Thats right! :)','Yup, thats right','You got it right!','Your answer is correct :)']
return random.choice(Arr)
if numberofrightwrong==1:
Arr=['Right again!','Yay! right again! :D','Absolutely right again!','You got it right again! :D']
return random.choice(Arr)
if numberofrightwrong>=2:
Arr=['You are on fire :D , Thats right!','Guess what :D , THATS RIGHT....AGAIN','bravo!! Right again',
'Wow I am so proud of you,Right AGAIN!! :D','You are a genius!,RIGHT AGAIN :D']
return random.choice(Arr)
if rightwrong=='wrong':
if numberofrightwrong==0:
Arr=['Thats wrong !','Its wrong ','That answer is wrong','Sorry but its incorrect']
return random.choice(Arr)
if numberofrightwrong==1:
Arr=['OOPS! wrong again!','Its wrong again!!','You got it wrong again','thats incorrect again :)']
return random.choice(Arr)
if numberofrightwrong>=2:
Arr=['Well it is wrong again. You should try harder may be :)','Think hard!!','Sorry to say but WRONG AGAIN!!!!' ]
return random.choice(Arr)
def handleResults(total,right):
percent=(right*100.0/total)
if percent<=50:
return 'nice'
if percent<=80 and percent>50:
return 'fantastic'
if percent<=100 and percent>80:
return 'awesome'
"""def resultOfQuickreply(message):
if message['message'].get('quick_reply'):
if message['message']['quick_reply']['payload']=='right':
return('Thats right',['Another one','Go Back'],True)
if message['message']['quick_reply']['payload']=='wrong':
return ('sorry thats wrong!',['Try again','Go Back'],True)
else:
return 'sorry thats wrong!',['Try again','Go Back'],False"""
def askQuestion(topic):
question="Who is the father of the nation?"
options=[' A ',' B ',' C ',' D ']
right='gandhi'
questionanswer=fetchQuestionanswer(topic)
question= questionanswer['question']
options=questionanswer['options']
right=questionanswer['right']
try:
hint=questionanswer['hint']
except:
hint='noHint'
try:
solution=questionanswer['solution']
except:
solution=''
print(solution)
exceeded=False
for option in options:
if len(option)>19:
exceeded=True
return question,options,right,hint,solution,exceeded
def fetchQuestionanswer(topic):
MONGODB_URI = "mongodb://Debangshu:[email protected]:63694/brilu"
client = MongoClient(MONGODB_URI, connectTimeoutMS=30000)
db = client.get_database("brilu")
col = db["questionAnswers"]
cursor = col.find()
questionAnswers = cursor[0]
return(random.choice(questionAnswers[topic]))