-
Notifications
You must be signed in to change notification settings - Fork 70
Description
Related to issue #2252
This relates to C0D3 DOJO Design doc #1192 and includes a more detailed documentation of the implementation of the discussion component.
Intro
Current UI design for discussions in Figma(unfinalized): https://www.figma.com/file/f9xRyl1bJOjtBRd8zFORzg/c0d3?node-id=404%3A13721
Current Component Design in Codebase:
https://deploy-preview-2339--youthful-thompson-448332.netlify.app/?path=/story/components-discussionscard--discussions-card-main
Goals
Students can benefit immensely from communicating with mentors and fellow students while working on lessons, exercises, and challenges.
Problem
While students can currently discuss topics on Discord, conversations can drift towards different topics, older messages that have valuable information get buried and become hard to track down over time.
Solution
Having a discussion forum within C0D3 can serve as a valuable tool to discuss topics, concepts, projects, exercises, etc. It allows for better organization of the lesson/exercise being discussed. It can also serve as a lasting reference for future students who run into similar questions or issues.
Sample Discussion Flow
Implementation
A model in Prisma and typeDef in GraphQL called 'ExerciseComments' should be created with the following properties(assumes id, createdAt, and updatedAt are always present):
ExerciseComment{
authorId: Int (foreign key to refer to user who posted)
exerciseId: Int (foreign key to refer to exercise being discussed)
userPic: String? (url to user profile picture)
content: String (body of post)
parentId: Int?
exercise: Exercise
author: User
parent: ExerciseComment?
replies: ExerciseComment[]
}
In addition, exerciseComments: ExerciseComment[] should be added as a property to the Exercise and Usermodel and typeDefs. This way Discussions are linked to a specific exercise and the user who created the comment in the backend.
For use with DOJO exercise
On the frontend for DOJO exercises, our DiscussionsCard component should accept the following props:
type DiscussionsCardProps = {
isMain: boolean
username: string
userPic: string
timeStamp: string
content: string
editAndDeletePermission: boolean
deleteClick: Function
saveClick: Function
sendClick: Function
replies?: DiscussionsCardProps[]
}
Each comment section will be tied to an exercise page, and upon page load, a query will be sent to the backend to check for any ExerciseComment with an exerciseId that matches the exerciseId of the relevant exercise page. These exercises will then be loaded into the page.
If isMain is true, the post is considered the original/main post and will be styled like the following:

If isMain is false, it is considered a response to a main topic, and will be styled like the below:

The userPic should refer to a link that displays the user's profile picture. As of right now, users cannot upload their own profile picture. The students who do have a profile picture, are ones who linked their Discord account, and the image url is taken from a third party Discord link. If the profile picture cannot be obtained from Discord, we will use https://www.gravatar.com/avatar/${ hash } as a default placeholder.
The userPic, username and timeStamp is displayed on the header and content will fill the body of the post.
editAndDeletePermission determines if the user has access to the delete and edit buttons. Users can only delete or edit their own posts.
deleteClick, saveClick, sendClick, are all functions that will alter backend data.
When the user hits 'reply', or the 'edit' button, the click functionality will be handled within the component, rather than use a prop, as these buttons will affect the layout and functionality of the component, but will not send any data to the backend.
Displaying longer threads and pagination
If students create a comment chain with a ton of back and forth discussion and the thread becomes very large, we can only display a certain number of posts at a time. This will be handled with pagination, and users will need to click comments to expand them, and read replies that are further down the chain.
DiscussionCard Component Integration with Prisma ExerciseComment Table
isMain can be determined based on whether the comment has a parentId. If it has one, then we know it is a reply and not a main card.
username can be obtained from the comment's author, as it points to a User table, which will have the author's username
timeStamp will be based on createdAt or updatedAt if the user ends up editing the comment.
GraphQL Queries
On the exercise discussion page, there should be an initial query to load all Discussions relevant to that exercise and display them on the page.
User Interactions
When a user clicks on 'Save' after editing a post, there should be a query that changes the content of the post.
When a user clicks on 'Send' after replying to a post, there should be a query that saves the response data in the array of the replies property.
When a user clicks on 'Delete', there should be a query that replaces the content of the post with 'message deleted by user'
Action Items:
- Create initial design for 'main' and 'sub' DiscussionCards(completed)
- Create
ExerciseCommenttype in prisma and GraphQL - Add
exerciseCommentsproperty toExerciseandUsertype in prisma and GraphQL - Incorporate relational database structure between
ExerciseCommentandExercises - Queries and Resolvers for responding, adding, editing, and deleting a post
- Add UI frontend functionality for edit and delete functions
- Design and create layout for how replies and responses to replies will be displayed
- Create page layout of Discussions
- Integrate frontend and backend with
Exercises. - Add UI frontend functionality for saving edits, and sending replies.
Notes
Version 1 of the discussion component won't have a 'like' button feature.
Version 2, after the discussion feature has gone into production, we may incorporate frontend and backend functionality for a 'like' button.
Distinction between Discussions and Submission Comments
We currently have an existing feature that allows students and reviewers to discuss the student submissions for each challenge. It is initiated by clicking on a single line, and writing a comment pertaining to that line. This feature currently allows replies, but does not create sub-threads that continue to expand, thus does not require pagination.
This is appropriate for it's purpose, as the discussion revolves around a single line, and students are for the most part very receptive to advice, so there isn't as much back and forth. The Discussions feature is meant to allow discourse over a whole exercise, rather than a single line, thus allowing for longer conversations. Having the option to reply to sub-threads is more appropriate for the latter feature




