当前位置: 首页>>代码示例>>Python>>正文


Python Exercise.query方法代码示例

本文整理汇总了Python中models.Exercise.query方法的典型用法代码示例。如果您正苦于以下问题:Python Exercise.query方法的具体用法?Python Exercise.query怎么用?Python Exercise.query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Exercise的用法示例。


在下文中一共展示了Exercise.query方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: user_post

# 需要导入模块: from models import Exercise [as 别名]
# 或者: from models.Exercise import query [as 别名]
	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 = ', self.username).get()
				if user and (not exercise.key() in user.exercises_completed):
					user.exercises_completed.append(exercise.key())
					user.put()

		elif action == '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);
开发者ID:chrisuehlinger,项目名称:sg-study-c,代码行数:35,代码来源:views.py

示例2: get

# 需要导入模块: from models import Exercise [as 别名]
# 或者: from models.Exercise import query [as 别名]
	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} ))
开发者ID:samoretc,项目名称:Workout-Timer,代码行数:9,代码来源:main.py

示例3: user_get

# 需要导入模块: from models import Exercise [as 别名]
# 或者: from models.Exercise import query [as 别名]
	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})
开发者ID:chrisuehlinger,项目名称:sg-study-c,代码行数:18,代码来源:views.py


注:本文中的models.Exercise.query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。