Modify Question table and rename to QuestionType
This commit is contained in:
parent
5f84794e24
commit
c450bd36b0
@ -51,14 +51,14 @@ def get_npc_random_answer(npc_id:int, qa_type:int) -> Answer :
|
||||
answers = db.session.query(Answer).filter_by(QA_TYPE=qa_type,NPC_ID=npc_id.NPC_ID).all()
|
||||
return random.choice(answers)
|
||||
|
||||
def get_random_question(qa_type: int) -> Question :
|
||||
def get_random_question(qa_type: int) -> QuestionType :
|
||||
"""
|
||||
Returns a random inspector question from a question type
|
||||
|
||||
:param qa_type: the type of the question
|
||||
:return: a Question object
|
||||
"""
|
||||
answers = db.session.query(Question).filter_by(QUESTION_TYPE=qa_type).all()
|
||||
answers = db.session.query(QuestionType).filter_by(QUESTION_TYPE_ID=qa_type).all()
|
||||
return random.choice(answers)
|
||||
|
||||
def get_trait_from_text(text: str) -> int:
|
||||
|
@ -42,24 +42,22 @@ class Place(Base):
|
||||
return f"{self.PLACE_ID} {self.NAME_LID}"
|
||||
|
||||
|
||||
class Question(Base):
|
||||
class QuestionType(Base):
|
||||
"""
|
||||
Stores questions asked by players
|
||||
Stores questions types that can be asked by players, e.g "where", "with tho"
|
||||
"""
|
||||
|
||||
__tablename__ = "T_QUESTION"
|
||||
QUESTION_ID = Column(Integer, primary_key=True, comment="ID of this question")
|
||||
QUESTION_TYPE = Column(Integer, comment="Question type ID, e.g 'when..', 'where..'")
|
||||
__tablename__ = "T_QUESTION_TYPE"
|
||||
QUESTION_TYPE_ID = Column(Integer, primary_key=True, comment="ID of this question type.")
|
||||
TEXT_LID = Column(Integer, ForeignKey("T_LOCALE.TEXT_ID"), comment="Question text")
|
||||
LOCALE = relationship("Locale")
|
||||
|
||||
def __init__(self, QUESTION_ID, QUESTION_TYPE, TEXT_LID):
|
||||
self.QUESTION_ID = QUESTION_ID
|
||||
self.QUESTION_TYPE = QUESTION_TYPE
|
||||
def __init__(self, QUESTION_TYPE_ID, TEXT_LID):
|
||||
self.QUESTION_ID = QUESTION_TYPE_ID
|
||||
self.TEXT_LID = TEXT_LID
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.QUESTION_ID} {self.QUESTION_TYPE} {self.TEXT_LID}"
|
||||
return f"{self.QUESTION_ID} {self.QUESTION_TYPE_ID}"
|
||||
|
||||
|
||||
class Answer(Base):
|
||||
|
Loading…
Reference in New Issue
Block a user