class AnswerGiven(db.Model): __tablename__ = 'answergiven' id = db.Column(db.Integer, primary_key=True) question_id = db.Column(db.Integer, db.ForeignKey('question.id'), nullable=False) question = db.relationship('Question') team_id = db.Column(db.Integer, db.ForeignKey('team.id'), nullable=False) answered_by = db.relationship('Team') subanswersgiven = db.relationship('SubAnswerGiven')
class Question(db.Model): __tablename__ = 'question' id = db.Column(db.Integer, primary_key=True) questionnumber = db.Column(db.Integer) person_id = db.Column(db.Integer, db.ForeignKey('person.id')) createdby = db.relationship('Person') category_id = db.Column(db.Integer, db.ForeignKey('category.id')) questioncategory = db.relationship('Category') type_id = db.Column(db.Integer, db.ForeignKey('type.id')) questiontype = db.relationship('Type') question = db.Column(db.String(255)) subanswers = db.relationship('SubAnswer') active = db.Column(db.Boolean) def get_question(self): return self.question
class Line(db.Model): """ A line object, corresponding to an answersheet line """ __tablename__ = 'line' id = db.Column(db.Integer, primary_key=True) answersheet_id = db.Column(db.Integer, db.ForeignKey('answersheet.id')) line_image = db.Column(db.LargeBinary) image_width = db.Column(db.Integer) image_height = db.Column(db.Integer)
class Word(db.Model): """ A word object, corresponding to words in a line. """ __tablename__ = 'word' id = db.Column(db.Integer, primary_key=True) line_id = db.Column(db.Integer, db.ForeignKey('line.id')) word_recognised = db.Column(db.String(255)) word_image = db.Column(db.LargeBinary) image_width = db.Column(db.Integer) image_height = db.Column(db.Integer)
class Variant(db.Model): """ for some questions, multiple answers (variants) are correct """ __tablename__ = 'variant' id = db.Column(db.Integer, primary_key=True) subanswer_id = db.Column(db.Integer, db.ForeignKey('subanswer.id')) answer = db.Column(db.String(255)) isNumber = db.Column(db.Boolean) def get_answer(self): return self.answer
class SubAnswerGiven(db.Model): """ A answer can consist of multiple lines, this indicates a single line of an answer. """ __tablename__ = 'subanswergiven' id = db.Column(db.Integer, primary_key=True) corr_answer_id = db.Column(db.Integer, db.ForeignKey('subanswer.id'), nullable=False) corr_answer = db.relationship('SubAnswer') read_answer = db.Column(db.String(255)) correct = db.Column(db.Boolean) confidence = db.Column(db.Float) person_id = db.Column(db.Integer, db.ForeignKey('person.id'), nullable=False) checkedby = db.relationship('Person') line_id = db.Column(db.Integer, db.ForeignKey('line.id'), nullable=False) line = db.relationship('Line') answergiven_id = db.Column(db.Integer, db.ForeignKey('answergiven.id'), nullable=False)
class Answersheet(db.Model): """ image of complete answersheet (handwritten) """ __tablename__ = 'answersheet' id = db.Column(db.Integer, primary_key=True) team_id = db.Column(db.Integer, db.ForeignKey('team.id'), nullable=True) answersheet_image = db.Column(db.LargeBinary) image_width = db.Column(db.Integer) image_height = db.Column(db.Integer) def set_team_id(self, team_id): self.team_id = team_id def get_team_id(self): return self.team_id
class SubAnswer(db.Model): """ question can have multiple subquestions, each subquestion has a subanswer """ __tablename__ = 'subanswer' id = db.Column(db.Integer, primary_key=True) question_id = db.Column(db.Integer, db.ForeignKey('question.id')) variants = db.relationship('Variant')
class AnswerSheetQuestion(db.Model): """ answersheet corresponding to a question """ __tablename__ = 'answersheetquestion' id = db.Column(db.Integer, primary_key=True) answersheet_id = db.Column(db.Integer, db.ForeignKey('answersheet.id')) question_id = db.Column(db.Integer, db.ForeignKey('question.id'))