Exemplo n.º 1
0
	def post(self):
		daystr = self.request.get('day')
		dt = datetime.datetime.strptime(daystr, "%Y-%m-%d")
		
		query = DailySummary.all().filter('datetime =', dt)
		
		quizzerkey = self.request.get('quizzer')
		if not quizzerkey:
			query.filter('quizzer =', None)
		else:
			query.filter('quizzer =', getUserFromKey(quizzerkey))
			
		ds = query.fetch(1)[0]
		
		query = DailySummaryCategoryCount.all().ancestor(ds)
		
		d = {}
		d['cols'] = [{'id': 'label', 'label': 'label', 'type': 'string'}, {'id': 'value', 'label': 'value', 'type': 'number'}]
		rows = []
		cat = dict(CATEGORIES)
		for dsc in query:
			rows.append({'c': [{'v': cat[dsc.category]}, {'v': dsc.answeredcount}]})
		d['rows'] = rows
		
		self.response.headers['Content-Type'] = 'text/json'
		self.response.out.write(json.dumps(d))
Exemplo n.º 2
0
	def post(self):
		daystr = self.request.get('day')
		dt = datetime.datetime.strptime(daystr, "%Y-%m-%d")
		
		query = DailySummary.all().filter('datetime =', dt)
		
		quizzerkey = self.request.get('quizzer')
		query.filter('quizzer =', getUserFromKey(quizzerkey))
		
		ds = query.fetch(1)[0]
		
		query = DailySummaryMarker.all().ancestor(ds)
		
		d = {}
		d['cols'] = [{'id': 'qkey', 'label': 'Question Key', 'type': 'string'},
			{'id': 'time', 'label': 'Time', 'type': 'timeofday'},
			{'id': 'category', 'label': 'Category', 'type': 'string'},
			{'id': 'question', 'label': 'Question', 'type': 'string'},
			{'id': 'correct', 'label': 'Correct', 'type': 'boolean'},
			{'id': 'duration', 'label': 'Duration (s)', 'type': 'number'}]
		
		cat = dict(CATEGORIES)
		rows = []
		for dsm in query:
			ans = dsm.session
			dt = ans.datetime.replace(tzinfo=utctz).astimezone(phtz)
			qstring = ans.question.question
			if len(qstring) > 60:
				qstring = qstring[:60] + '...'
			rows.append({'c': [{'v': str(ans.question.key())},
					{'v': [dt.hour, dt.minute, dt.second]},
					{'v': cat[dsm.category]},
					{'v': qstring},
					{'v': ans.correct},
					{'v': ans.duration}
				]})
				
		d['rows'] = rows
		
		self.response.headers['Content-Type'] = 'text/json'
		self.response.out.write(json.dumps(d))
Exemplo n.º 3
0
	def post(self):
		daystr = self.request.get('day')
		dt = datetime.datetime.strptime(daystr, "%Y-%m-%d")
		
		query = DailySummary.all().filter('datetime =', dt)
		
		quizzerkey = self.request.get('quizzer')
		if not quizzerkey:
			query.filter('quizzer =', None)
		else:
			query.filter('quizzer =', getUserFromKey(quizzerkey))
			
		ds = query.fetch(1)[0]
		
		d = {}
		d['cols'] = [{'id': 'label', 'label': 'label', 'type': 'string'}, {'id': 'value', 'label': 'value', 'type': 'number'}]
		rows = []
		rows.append({'c': [{'v': 'Correct'}, {'v': ds.correctcount}]})
		rows.append({'c': [{'v': 'Wrong'}, {'v': ds.answeredcount - ds.correctcount}]})
		d['rows'] = rows
		
		self.response.headers['Content-Type'] = 'text/json'
		self.response.out.write(json.dumps(d))