Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question implementaion #47

Open
YedilSerzhan opened this issue Aug 22, 2023 · 0 comments
Open

Question implementaion #47

YedilSerzhan opened this issue Aug 22, 2023 · 0 comments
Labels
improvment ℹmprovements that can be made if there is spare effort.

Comments

@YedilSerzhan
Copy link
Collaborator

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:
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
@YedilSerzhan YedilSerzhan added the improvment ℹmprovements that can be made if there is spare effort. label Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvment ℹmprovements that can be made if there is spare effort.
Projects
None yet
Development

No branches or pull requests

1 participant