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


Python Question.query方法代码示例

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


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

示例1: flush

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import query [as 别名]
def flush():
    ndb.delete_multi(School.query().fetch(keys_only=True))
    ndb.delete_multi(QuestionInstance.query().fetch(keys_only=True))
    ndb.delete_multi(State_Questions.query().fetch(keys_only=True))
    ndb.delete_multi(Topic_States.query().fetch(keys_only=True))
    ndb.delete_multi(Question.query().fetch(keys_only=True))
    ndb.delete_multi(State.query().fetch(keys_only=True))
    ndb.delete_multi(Address.query().fetch(keys_only=True))
    ndb.delete_multi(Teacher.query().fetch(keys_only=True))
    ndb.delete_multi(Class.query().fetch(keys_only=True))
    ndb.delete_multi(Assessment_Record.query().fetch(keys_only=True))
    ndb.delete_multi(Student.query().fetch(keys_only=True))
    ndb.delete_multi(UserInfo.query().fetch(keys_only=True))
    ndb.delete_multi(Student_Assessments.query().fetch(keys_only=True))
    ndb.delete_multi(Assessment.query().fetch(keys_only=True))
    ndb.delete_multi(Subject.query().fetch(keys_only=True))
    ndb.delete_multi(Topic_Questions.query().fetch(keys_only=True))
    ndb.delete_multi(State_Questions.query().fetch(keys_only=True))
    ndb.delete_multi(Topic_States.query().fetch(keys_only=True))
    ndb.delete_multi(Subject_Topics.query().fetch(keys_only=True))
    ndb.delete_multi(Student_Assessments.query().fetch(keys_only=True))
    ndb.delete_multi(Topic.query().fetch(keys_only=True))
    ndb.delete_multi(User.query().fetch(keys_only=True))
    ndb.delete_multi(Assessment_Record.query().fetch(keys_only=True))
    ndb.delete_multi(State_Types.query().fetch(keys_only=True))
开发者ID:anks315,项目名称:Assesment2,代码行数:27,代码来源:dummydata3.py

示例2: get_question_entries

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import query [as 别名]
def get_question_entries(user, lessons_map):
  """ Gets all of the grade entries for this user.
        Replaces the assignment_key and student_key with an assignment and student. """
  question_entries = Question.query(ancestor=get_parent_key(user)).fetch() # TODO: Query for all QuestionEntries for this user, then fetch()
  for question_entry in question_entries:
    question_entry.lesson = lessons_map[question_entry.lesson_key]
  return question_entries
开发者ID:katyak20,项目名称:kck-answerspace,代码行数:9,代码来源:utils.py

示例3: get

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import query [as 别名]
  def get(self):
    context = []
    qs =  Question.query()
    # import pdb; pdb.set_trace()
    # qs.map_async(lambda x: context.append())

    temp = jinja_env.get_template('templates/popup.html')
    self.response.out.write(temp.render({"qs": qs}))
开发者ID:daonb,项目名称:idontgetit,代码行数:10,代码来源:idontgetit.py

示例4: get_question

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import query [as 别名]
    def get_question(self, request):
        """Retrieve a question."""
        q = Question.query()
        question = q.get()

        if question:
            return question.to_trivia_form()
        else:
            raise endpoints.NotFoundException('No question not found!')
开发者ID:CurtiePi,项目名称:triviagame,代码行数:11,代码来源:api.py

示例5: get

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import query [as 别名]
	def get(self):
		# Delete the album/question by id
		# TODO Support multiple row deletions
		if self.request.GET['album'] == '0':
			question_url = self.request.GET['id']
			question_key = ndb.Key(urlsafe=question_url)
			question_key.delete()
		else:
			album_url = self.request.GET['id']
			album_key = ndb.Key(urlsafe=album_url)
			questions = Question.query(ancestor=album_key).order(-Question.date).fetch()
			for question in questions:
				question.key.delete()
			album_key.delete()
开发者ID:nischalshrestha,项目名称:recognize,代码行数:16,代码来源:recognize.py

示例6: albums_list

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import query [as 别名]
 def albums_list(self, request):
   current_user = endpoints.get_current_user()
   album_type = request.type
   email = (current_user.email() if current_user is not None
          else 'Anonymous')
   albums = Album.query(Album.album_type == album_type).order(-Album.date)
   items = []
   for album in albums:
     a = AlbumMessage(album_id=album.album_id,
                       title=album.title, 
                       category=album.category, 
                       album_type=album.album_type, 
                       date=str(album.date.date()))
     questions = Question.query(ancestor=album.key).order(-Question.date).fetch()
     for q in questions:
       q_msg = QuestionMessage(question_id=q.question_id, title=q.title, fact=q.fact)
       q_images = q.images
       for image in q_images:
         q_msg.images.append(ImageMessage(title=image.title, correct=image.correct, image_url=image.image))
       a.questions.append(q_msg)
     items.append(a)
   return AlbumCollection(albums=items)
开发者ID:nischalshrestha,项目名称:recognize,代码行数:24,代码来源:recognize_api.py

示例7: post

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import query [as 别名]
    def post(self):
		# Grab album from url
		urlstring = self.request.POST['album']
		album_key = ndb.Key(urlsafe=urlstring)
		album = album_key.get()
		# Check whether we're storing a album or a Question
		if self.request.GET['album'] == '1':
			album.title = self.request.POST['albumTitle']
			album.category = self.request.POST['categoryTitle']
			album.put()
			time.sleep(0.1)
			# Save album and redirect to edit if the user clicks on 'Save and continue editing'
			# Else, save album and go back to the main page which lists all albums
			if self.request.POST.get('stay') == '1':
				self.redirect('/edit?album=1&id='+urlstring)
			else:
				if album.album_type == 'match':
					self.redirect('/match')
				elif album.album_type == 'correlate':
					self.redirect('/correlate')
				else:
					self.redirect('/oddmanout')
		else:
			# Create Question with the album as parent for strong consistency
			question = ""
			new = "1"
			if self.request.POST['question'] == "":
				question = Question(parent=album_key)
				question.question_id = question.put().id()
			else:
				new = "0"
				question_url = self.request.POST['question']
				question_key = ndb.Key(urlsafe=question_url)
				question = question_key.get()
			question.title = self.request.get('title')
			question.fact = self.request.get('fact')
			question.effect = self.request.get('revealEffect')
			question.difficulty = self.request.get('difficulty')
			# Create answer choices
			answer = int(self.request.get('correct_answer'))
			input_images = self.request.get('image', allow_multiple=True)
			num_images = 4
			if album.album_type == 'correlate':
				num_images = 5
			image_list = []
			for i in range(num_images):
				img = ""
				input_img = input_images[i]
				# If old retrieve the Image
				if new == "0":
					img = question.images[i]
				else:
					img = Image()
				# Resize image
				if input_img:
					op_img = images.Image(input_img)
					op_img.resize(width=256, height=256, crop_to_fit=True)
					result_img = op_img.execute_transforms(output_encoding=images.JPEG)
					img.image = result_img
				# Set the title and correct fields
				if answer == i:
					img.title = "correct_answer_"+str(i)
					img.correct = True
				elif num_images == 5 and i == 0: # This is if the album is of type Correlate
					img.title = "main_image_"+str(i)
					img.correct = False
				else:
					img.title = "incorrect_answer_"+str(i)
					img.correct = False
			 	# If old Question, free up the old Image and put in new Image 
				if new == "0":
					question.images.pop(i)
					question.images.insert(i, img)
				else:
					question.images.append(img)

			question.put()
			# Query all Question(s) for the album in recently added order for /create
			# Retrieve previously input values, and indicate whether this is a new album (edit)
			questions = Question.query(ancestor=album_key).order(-Question.date).fetch()
			retrieve = 1
			edit = self.request.GET['edit']
			template_values = {
				'album': album,
				'album_type': album.album_type,
				'questions': questions,
				'edit': edit,
				'retrieve': retrieve
			}
			template = JINJA_ENVIRONMENT.get_template('create.html')
			self.response.write(template.render(template_values))
开发者ID:nischalshrestha,项目名称:recognize,代码行数:93,代码来源:recognize.py

示例8: _getQuestions

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import query [as 别名]
	def _getQuestions(self):
		ques = Question.query()
		return self._copyQuestiontoForm(ques)
开发者ID:codegress,项目名称:code-gress,代码行数:5,代码来源:main.py

示例9: get_questions

# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import query [as 别名]
def get_questions(user,  Lesson):
  questions = Question.query(ancestor=get_parent_key(user)).order(Question.question_order).fetch()
  questions_map = {}
  for question in questions:
    questions_map[question.key()] = question
  return questions, questions_map
开发者ID:katyak20,项目名称:kck-answerspace,代码行数:8,代码来源:utils.py


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