Skip to content

Consistency issue with Quiz Questions in yaml files and database #48

@YedilSerzhan

Description

@YedilSerzhan

Background:
Originally, DNAnalyzer utilized Jekyll with Google Docs embeds for quiz questions. As the need for advanced functionalities arose (e.g., storing questions, showing scores, user authentication), Flask and Jinja templates were adopted. To accommodate non-technical contributors, quiz questions are kept in YAML files. The init_yaml_to_db.py script was introduced to transition quiz data from these YAML files into our PostgreSQL database.

Working of the Script:

  • Reads data from YAML files.
  • Converts this data into delimiter-separated files suitable for various database tables (e.g., question, choice, chapter, level).
  • Deletes existing questions and choices in the database, then repopulates from the new data.
  • To facilitate this approach, foreign keys in models related to questions were dropped.

Identified Issues:

  1. Model Adaptability: Whenever there are changes in the question models, the script necessitates minor modifications to be compatible.
  2. Database Consistency:
    • Modifying just the text of a question doesn't jeopardize consistency.
    • However, adding or removing questions/choices modifies part of their IDs. This alteration impacts the (user_id, choice_id) pairing in the answer table and the computation of the chapter score.
  3. Library Inconsistency: The script is built on the psycopg2 library, whereas the backend predominantly uses SQLalchemy.

Current Solutions:

  • Stable Questions: Ensure that all quiz questions are finalized and require no modifications before being pushed to production.

Improvement:

  • Script Enhancement: A more sophisticated improvement to the script can be made. This might involve creating a mechanism that can handle database updates without disrupting user data or requiring manual modifications each time the question models change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    improvmentℹmprovements that can be made if there is spare effort.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions