You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the initial implementation, we had only multiple-choice questions, as the level 3 feature was not present at that time. Therefore, the implementation was designed around the Questions and Choices models. Each choice has a question ID and a 'correctness' field, which indicates whether the choice is correct. This way, we can implement multiple-choice questions with either multiple correct answers or single correct answers. To store users' responses, we record the user_id and user-selected choice_id in the answer table. By joining it with the choice table, we can determine whether users have selected the correct choice.
Here are the three database models used for this implementation:
class Question(db.Model):
id = db.Column(db.BigInteger, primary_key=True)
title = db.Column(db.String(), nullable=False)
description = db.Column(db.String())
type = db.Column(db.String(), nullable=False)
hint = db.Column(db.String())
explanation = db.Column(db.String())
image_name = db.Column(db.String())
point = db.Column(db.Integer, nullable=False)
transition_sentence = db.Column(db.String())
chapter_id = db.Column(db.Integer, db.ForeignKey('chapter.id'), nullable=False)
class Choice(db.Model):
id = db.Column(db.BigInteger, primary_key=True)
content = db.Column(db.String(), nullable=False)
correctness = db.Column(db.Boolean(), nullable=False)
question_id = db.Column(db.Integer, db.ForeignKey('question.id'), nullable=False)
class Answer(db.Model):
id = db.Column(db.BigInteger, primary_key=True)
user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)
choice_id = db.Column(db.Integer, nullable=False)
We also have grid questions, as shown in the example image:
These grid questions were implemented by creating one question for each row, with all columns as choices for the question, and the row text as the question description. When displaying these questions, we sort them by their ID, and if we encounter consecutive questions of the grid type with the same title, we group them into a grid for display.
While this approach works, it's not the most elegant solution and introduces redundancy. A potential improvement would be to create a dedicated table for grid cells, like so:
Grid_Cell:
grid_cell_id (Primary Key)
question_id (Foreign Key referencing the Question table for grid questions)
row_label (Text label for the row)
column_label (Text label for the column)
is_correct (Boolean: indicates if the cell is correct for the grid question)
Other relevant fields
The text was updated successfully, but these errors were encountered:
In the initial implementation, we had only multiple-choice questions, as the level 3 feature was not present at that time. Therefore, the implementation was designed around the Questions and Choices models. Each choice has a question ID and a 'correctness' field, which indicates whether the choice is correct. This way, we can implement multiple-choice questions with either multiple correct answers or single correct answers. To store users' responses, we record the user_id and user-selected choice_id in the answer table. By joining it with the choice table, we can determine whether users have selected the correct choice.
Here are the three database models used for this implementation:
We also have grid questions, as shown in the example image:
These grid questions were implemented by creating one question for each row, with all columns as choices for the question, and the row text as the question description. When displaying these questions, we sort them by their ID, and if we encounter consecutive questions of the grid type with the same title, we group them into a grid for display.
While this approach works, it's not the most elegant solution and introduces redundancy. A potential improvement would be to create a dedicated table for grid cells, like so:
The text was updated successfully, but these errors were encountered: