class QuizQuestion(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) question_id = db.Column('question_id', db.Integer, db.ForeignKey("question.id"), nullable=False) quiz_id = db.Column('quiz_id', db.Integer, db.ForeignKey("quiz.id"), nullable=False)
class StudentCourse(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) student_id = db.Column('student_id', db.Integer, db.ForeignKey("student.id"), nullable=False) course_id = db.Column('course_id', db.Integer, db.ForeignKey("course.id"), nullable=False) # TODO: Make sure only two values (registered/dropped) can be used. status = db.Column(db.String(20), nullable=True) final_grade = db.Column(db.String(2), nullable=True)
class StudentQuizRunAnswers(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) student_quiz_run_question_attempt_id = db.Column('student_quiz_run_question_attempt_id', db.Integer, db.ForeignKey("student_quiz_run_question_attempt.id"), nullable=False) # This answer id is not a foreign key to answer table because we don't know the exact type (MCQ, Fill in the blank # etc) of question answer_id = db.Column(db.Integer)
class Course(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) course_name = db.Column(db.String(80), nullable=False) course_section = db.Column(db.String(40), nullable=True) professor_id = db.Column('professor_id', db.Integer, db.ForeignKey("professor.id"), nullable=False) join_code = db.Column('join_code', db.Integer, unique=True, nullable=False)
class MCQAnswers(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) option_text = db.Column(db.String(), nullable=False) correct_answer = db.Column(db.Boolean(), nullable=False, default=False) # This is 'MCQ id', not the question id from question table question_id = db.Column('MCQ_id', db.Integer, db.ForeignKey("MCQ.id"), nullable=False)
class MCQ(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) # Making question Id unique ensures one-to-one mapping question_id = db.Column('question_id', db.Integer, db.ForeignKey("question.id"), unique=True, nullable=False) question_text = db.Column(db.String(), nullable=False)
class Quiz(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) quiz_number = db.Column(db.Integer, nullable=False) course_id = db.Column('course_id', db.Integer, db.ForeignKey("course.id"), nullable=False)
class StudentQuizRunQuestionAttempt(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) student_id = db.Column('student_id', db.Integer, db.ForeignKey("student.id"), nullable=False) quiz_run_id = db.Column('quiz_run_id', db.Integer, db.ForeignKey("quiz_run.id"), nullable=False) question_id = db.Column('question_id', db.Integer, db.ForeignKey("question.id"), nullable=False)
class QuizRun(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) run_number = db.Column(db.Integer, nullable=False) quiz_id = db.Column('quiz_id', db.Integer, db.ForeignKey("quiz.id"), nullable=False) quiz_run_start_time = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)