本文整理汇总了Python中models.Question.type_of_quiz方法的典型用法代码示例。如果您正苦于以下问题:Python Question.type_of_quiz方法的具体用法?Python Question.type_of_quiz怎么用?Python Question.type_of_quiz使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Question
的用法示例。
在下文中一共展示了Question.type_of_quiz方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_item
# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import type_of_quiz [as 别名]
def process_item(self, item, spider):
session = self.Session()
question = Question(
question_number=item.get('question_number', ''),
question=item.get('question', ''),
possible_answers=item.get('possible_answers', ''),
correct_answer=item.get('correct_answer', ''),
explanation=item.get('explanation', ''),
section=item.get('section', ''),
type_of_quiz=item.get('type_of_quiz', ''),
)
existing_query = session.query(Question).filter(
Question.question_number == question.question_number).first()
if existing_query:
question = existing_query
question.question_number = item.get('question_number', '')
question.question = item.get('question', '')
question.possible_answers = item.get('possible_answers', '')
question.correct_answer = item.get('correct_answer', '')
question.explanation = item.get('explanation', '')
question.section = item.get('section', '')
question.type_of_quiz = item.get('type_of_quiz', '')
else:
session.add(question)
session.commit()
session.close()
return item