Discussions in edX are stored in a MongoDB database as collections of JSON documents.
The primary collection holding all posts and comments written by users is contents. There are two types of objects stored here, though they share much of the same structure. A CommentThread represents a comment that opens a new thread – usually a student question of some sort. A Comment is a reply in the conversation started by a CommentThread.
The following fields are specific to CommentThread objects. Each thread in the forums is represented by one CommentThread.
If true, this thread was closed by a forum moderator/admin.
The number of comment replies in this thread. This includes all replies to replies, but does not include the original comment that started the thread. So if we had:
CommentThread: "What's a good breakfast?" * Comment: "Just eat cereal!" * Comment: "Try a Loco Moco, it's amazing!" * Comment: "A Loco Moco? Only if you want a heart attack!" * Comment: "But it's worth it! Just get a spam musubi on the side."In that exchange, the comment_count for the CommentThread is 4.
We can attach a discussion to any piece of content in the course, or to top level categories like “General” and “Troubleshooting”. When the commentable_id is a high level category, it’s specified in the course’s policy file. When it’s a specific content piece (e.g. 600x_l5_p8, meaning 6.00x, Lecture Sequence 5, Problem 8), it’s taken from a discussion module in the course.
Timestamp in UTC indicating the last time there was activity in the thread (new posts, edits, etc). Closing the thread does not affect the value in this field.
Meant to be a list of tags that were user definable, but no longer used.
Title of the thread, UTF-8 string.
The following fields are specific to Comment objects. A Comment is a reply to a CommentThread (so an answer to the question), or a reply to another Comment (a comment about somebody’s answer). It used to be the case that Comment replies could nest much more deeply, but we later capped it at just these three levels (question, answer, comment) much in the way that StackOverflow does.
Boolean value, true if a forum moderator or instructor has marked that this Comment is a correct answer for whatever question the thread was asking. Exists for Comments that are replies to other Comments, but in that case endorsed is always false because there’s no way to endorse such comments through the UI.
What CommentThread are we a part of? All Comment objects have this.
The parent_id is the _id of the Comment that this comment was made in reply to. Note that this only occurs in a Comment that is a reply to another Comment; it does not appear in a Comment that is a reply to a CommentThread.
The parent_ids attribute appears in all Comment objects, and contains the _id of all ancestor comments. Since the UI now prevents comments from being nested more than one layer deep, it will only ever have at most one element in it. If a Comment has no parent, it’s an empty list.