forked from k4rtik/beastie
-
Notifications
You must be signed in to change notification settings - Fork 7
/
questiondb.py
42 lines (39 loc) · 1.37 KB
/
questiondb.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
# Model Defining Questions Database
import string
from google.appengine.ext import db
class questionm(db.Model):
questionNumber = db.IntegerProperty(required=True)
question = db.StringProperty(required=True, multiline=True)
qimage = db.StringProperty()
opt1 = db.StringProperty(required=True, multiline=True)
opt2 = db.StringProperty(required=True, multiline=True)
opt3 = db.StringProperty(required=True, multiline=True)
opt4 = db.StringProperty(required=True, multiline=True)
ans = db.StringProperty(required=True)
def getQuestion(num,var):
query = questionm.all()
q = query.filter('questionNumber =',num).get()
if q:
return ("{"+
"\"num\" : " + "\""+str(var)+"\""+","+
"\"question\" : "+"\""+q.question.replace('\r\n','<br />')+"\""+","+
"\"image\" : "+"\""+q.qimage+"\""+","+
"\"options\" : " + "["+
"\""+q.opt1.replace('\r\n','<br />')+"\""+","+
"\""+q.opt2.replace('\r\n','<br />')+"\""+","+
"\""+q.opt3.replace('\r\n','<br />')+"\""+","+
"\""+q.opt4.replace('\r\n','<br />')+"\""+
"]"+
"}")
else:
return ("{"+
"\"num\" : " + "\""+"1"+"\""+","+
"\"question\" : "+"\""+"Sorry question not found. We'll fix it Soon"+"\""+","+
"\"image\" : "+"\""+"\""+","+
"\"options\" : " + "["+
"\""+""+"\""+","+
"\""+""+"\""+","+
"\""+""+"\""+","+
"\""+""+"\""+
"]"+
"}")