Backend decisions

Question Reactions

In order to implement the reactions feature, we needed to create a new table in the database. The model for this can be found in the /app/models/ folder in the question_reaction.rb file. This table is called question_reactions and it has the following structure:

id [PK] bigint)reaction (string)question_id (bigint)user_enrollment_id (uuid)created_at (timestamp)updated_at (timestamp)
1like108944cff9f-4ef3-4582-ac3e-890ad9a59c812021-06-09 10:11:42.0000002021-06-09 10:11:42.000000

Each time a learner interacts with the reactions widget via the UI (see below), a new record is created in this table.

  • The reaction column is a string that can be either like, love, insightful or confused.
  • The question_id column is a foreign key that references the id column in the questions table.
  • The user_enrollment_id column is a foreign key that references the id column in the user_enrollments table.

Reactions

Question Comments

In order to separate the comments from the reactions, we needed to create a new table in the database. The model for this can be found in the /app/models/ folder in the question_comment.rb file. This table is called question_comments and it has the following structure:

id [PK] bigint)comment (string)question_id (bigint)user_enrollment_id (uuid)created_at (timestamp)updated_at (timestamp)
1This is a comment108944cff9f-4ef3-4582-ac3e-890ad9a59c812021-06-09 10:11:42.0000002021-06-09 10:11:42.000000

Each time a learner interacts with the comments modal via the UI (see below), a new record is created in this table.

  • The comment column is a string that contains the comment that the learner has submitted.
  • The question_id column is a foreign key that references the id column in the questions table.
  • The user_enrollment_id column is a foreign key that references the id column in the user_enrollments table.

A new rake task was created to copy qualifying comments from the user_feedbacks table to the question_comments table. This rake task can be found in the /lib/tasks/ folder in the migrate_comment_data_to_comment_table.rake file.

Reactions Reactions

Running migration and rake task

DB Migration Rake tasks

Question Feedbacks (deprecated)

The above work for reactions and comments was done in order to replace the existing feedback feature. The feedback feature was originally implemented as a single table in the database called user_feedbacks. We have not deleted the table as it may still be used to generate user engagement reports. However, we have deprecated the feature and we are no longer using it in the platform.