Exemplo n.º 1
0
 def get(self):
     cookie = self.get_cookie("user.opros", default=None)
     if cookie == None:
         if self.get_query_argument("err", default=False):
             self.write(page.makepage('newuser', 'incorrectdata'))
         else:
             self.write(page.makepage('newuser'))
     else:
         self.write(page.makepage('continue'))
Exemplo n.º 2
0
	def get(self):
		cookie = self.get_cookie("user.opros",default=None)
		if cookie == None:
			if self.get_query_argument("err", default = False):
				self.write(page.makepage('newuser', 'incorrectdata'))
			else:
				self.write(page.makepage('newuser'))
		else:
			self.write(page.makepage('continue'))
Exemplo n.º 3
0
	def post(self):
		if self.get_query_argument("err", default = False):
			self.write(page.makepage('questions', 'incorrectdata'))
		elif self.get_body_argument("new", default = False):
			self.Start()
		else:
			fio = self.CorrectName()
			if fio == 'ERROR':
				self.redirect('/?err=1')
			else:
				user_id = db.Answer(fio)
				if user_id == False:
					user_id = db.FindAnswer(fio)
					self.set_cookie("user.opros", (str(user_id)))
					self.write(page.makepage('answerexist'))
				else:
					self.set_cookie("user.opros", (str(user_id)))
					self.Start()
Exemplo n.º 4
0
 def post(self):
     if self.get_query_argument("err", default=False):
         self.write(page.makepage('questions', 'incorrectdata'))
     elif self.get_body_argument("new", default=False):
         self.Start()
     else:
         fio = self.CorrectName()
         if fio == 'ERROR':
             self.redirect('/?err=1')
         else:
             user_id = db.Answer(fio)
             if user_id == False:
                 user_id = db.FindAnswer(fio)
                 self.set_cookie("user.opros", (str(user_id)))
                 self.write(page.makepage('answerexist'))
             else:
                 self.set_cookie("user.opros", (str(user_id)))
                 self.Start()
Exemplo n.º 5
0
	def Start(self):
		questlist = db.GetQuestions()
		content = "<p>Начинаем самый бессмысленный тест в твоей жизни!\n<form action='/endtest' method='POST'>\n"
		for question in sorted(questlist):
			content = content + page.makequestion(question, questlist[question])
		content = content + "<br><input type='submit'></form>"
		quest = open(staticdir + "questions", 'w')
		quest.write(content)
		quest.close()
		self.write(page.makepage('questions'))
Exemplo n.º 6
0
 def Start(self):
     questlist = db.GetQuestions()
     content = "<p>Начинаем самый бессмысленный тест в твоей жизни!\n<form action='/endtest' method='POST'>\n"
     for question in sorted(questlist):
         content = content + page.makequestion(question,
                                               questlist[question])
     content = content + "<br><input type='submit'></form>"
     quest = open(staticdir + "questions", 'w')
     quest.write(content)
     quest.close()
     self.write(page.makepage('questions'))
Exemplo n.º 7
0
	def post(self):
		cookie = self.get_cookie("user.opros",default=None)
		user_id = cookie
		data = self.CorrectData()
		if data == 'ERROR':
			self.redirect('/begintest?err=1')
		else:
			printable = db.SetDataInDB(data, user_id)
			result = open(staticdir + "result", 'w')
			result.write(printable)
			result.close()
			self.write(page.makepage('result'))
			self.clear_cookie("user.opros")
Exemplo n.º 8
0
 def post(self):
     cookie = self.get_cookie("user.opros", default=None)
     user_id = cookie
     data = self.CorrectData()
     if data == 'ERROR':
         self.redirect('/begintest?err=1')
     else:
         printable = db.SetDataInDB(data, user_id)
         result = open(staticdir + "result", 'w')
         result.write(printable)
         result.close()
         self.write(page.makepage('result'))
         self.clear_cookie("user.opros")
Exemplo n.º 9
0
	def get(self):
		cookie = self.get_cookie("user.opros",default=None)
		try:
			user_id = int(cookie)
		except:
			self.redirect('/')
		if self.get_argument("results", default=False):
			printable = db.GetResults(user_id)
			results = open(staticdir + "results", 'w')
			results.write(printable)
			results.close()
			self.write(page.makepage('results'))
			self.clear_cookie("user.opros")
		else:
			self.redirect('/')
Exemplo n.º 10
0
 def get(self):
     cookie = self.get_cookie("user.opros", default=None)
     try:
         user_id = int(cookie)
     except:
         self.redirect('/')
     if self.get_argument("results", default=False):
         printable = db.GetResults(user_id)
         results = open(staticdir + "results", 'w')
         results.write(printable)
         results.close()
         self.write(page.makepage('results'))
         self.clear_cookie("user.opros")
     else:
         self.redirect('/')