Ejemplo n.º 1
0
	def get(self):
		for x in range(0, 110):
			user=users.get_current_user()
			q=Question()
			#get the key of the question
			q.question='Question Number %d ?'%(x+1)
			#initialize a, b, c
			
			#q.a an important parameter
			#q.a=1.0 Rasch Case
			q.a=randint(50,200)/100.0 # this is real case, should be properly estimated
			q.b=(x+1)/10.0
			q.c=0.25
			if user:
				#create/find out the User class
				q.poster=user
			else:
				self.redirect(users.create_login_url(self.request.uri))
			putQ=None
			try:
				putQ=q.put()
				self.response.out.write("S")
			except TransactionFailedError:
				self.response.out.write("F")
			ans=[]
			#currentAnswer can also be randomised atm, its always the first one
			#currentAnswer=randint(0,3)
			currentAnswer=0
			for i in range(4): #four answers at present
				a=Answer()
				#get the numbered variable which hold the flag of it being correct
				a.answer='Option %d-%d'%(x+1,i+1)
				if i==currentAnswer: #check for correctness, set by true
					a.correct=True
				else:
					a.correct=False
				a.question=putQ
				ans.append(a)
			try:
				putQ=q.put()
				for i in range(4):
					ans[i].put()
				self.response.out.write("S")
			except TransactionFailedError:
				self.response.out.write("F")
		
		#temp test for score :P
		#user=users.get_current_user()
		#DisplayResultPg85(self,getThetaResult(user))
Ejemplo n.º 2
0
	def post(self):
		user=users.get_current_user()
		q=Question()
		#get the key of the question
		q.question=self.request.get('q')
		#initialize a, b, c
		q.b=0.0
		q.a=1.0
		q.c=0.25
		if user:
			#create/find out the User class
			q.poster=user
		else:
			self.redirect(users.create_login_url(self.request.uri))
		putQ=None
		try:
			putQ=q.put()
		except TransactionFailedError:
			self.response.out.write("F")
			return
		
		ans=[]
		for i in range(4): #four answers at present
			a=Answer()
			#get the numbered variable which hold the flag of it being correct
			a.answer=self.request.get('a'+str(i+1))
			checked=self.request.get('c'+str(i+1))
			if checked=="true": #check for correctness, set by true
				a.correct=True
			else:
				a.correct=False
			a.question=putQ
			ans.append(a)
		try:
			for i in range(4):
				ans[i].put()
			self.response.out.write("S")
		except TransactionFailedError:
			self.response.out.write("F")