Esempio n. 1
0
	def user_post(self, *args):
		pagename = args[0]
		if args[0] is None:
			pagename=""

		exercise = Exercise.query().filter("url = ",pagename).get()
		submission = self.request.get('code')
		program = exercise.outside_code.format(submission)
		action = self.request.get('action')


		response = dict()
		if action == 'check':
			response = exercise.checker.checkWork(program, self.username)
			if response['passed']:
				user = User.query().filter('username = '******'test':
			message = ''
			logging.info(self.request.get('input'))
			response = exercise.checker.submit(program, self.username, self.request.get('input'))
			
			if (response['error'] != "OK" or 
				int(response['result']) != 15 or 
				response['output'] is None):
					message = response['error_message']

			response['message'] = message

		self.write_json(response);
Esempio n. 2
0
	def get(self):
		workouts_query = Workout.query(ancestor = PARENT_KEY)
		exercise_query = Exercise.query(ancestor = PARENT_KEY).order( Exercise.order )
		template = jinja_env.get_template("templates/index.html")
		print 'self response'
		print self.response
		self.response.write(template.render( {"workouts_query": workouts_query, "exercise_query" : exercise_query} ))
Esempio n. 3
0
	def user_get(self, *args):
		pagename = args[0]
		if pagename is None:
			exercise_list = Exercise.query().order('name')
			page = {'url':'exercises', 'topic_name':'Practice Exercises'}
			self.render_with_user("exerciseindex.html", {'page':page,
														 'exercises':exercise_list})
		else:
			exercise = Exercise.query().filter("url = ",pagename).get()
			if exercise is None:
				self.write("No Exercise named '%s'" % pagename)
			else:
				logging.info("Serving exercise: " + repr(exercise.name))
				logging.info("Serving exercise: " + repr(exercise.start_code))
				logging.info("Serving exercise: " + repr(exercise.description))
				self.render_with_user("exercise.html", {'page':exercise})