The Course Feedback System is designed to allow users to leave feedback on courses. Each course and feedback entry has a unique ID, and feedback can be upvoted or downvoted by users.
- id: A unique identifier for the course.
- title: The title of the course.
- description: A detailed description of the course.
- dateAdded: The date and time the course was added.
- tags: A list of tags associated with the course for categorization and search purposes.
- id: A unique identifier for the feedback.
- courseId: The ID of the course the feedback is associated with.
- userId: The identifier of the user leaving the feedback.
- rating: A numeric rating given to the course.
- message: A textual description of the feedback.
- attachmentURL: Optional URL for any attachments.
- upvotes: The number of upvotes the feedback has received.
- downvotes: The number of downvotes the feedback has received.
- createdAt: The date and time the feedback was created.
- updatedAt: The date and time the feedback was last updated.
-
addCourse(title, description, tags)
- Adds a new course to the system.
- Returns the created course or an error message.
-
getAllCourses()
- Retrieves all courses from the system.
- Returns a list of courses.
-
getCourse(courseId)
- Fetches a specific course based on its
courseId
. - Returns the requested course or an error if not found.
- Fetches a specific course based on its
-
addFeedback(courseId, userId, rating, message)
- Adds feedback to a specific course.
- Returns the created feedback or an error message.
-
getFeedback(feedbackId)
- Fetches a specific feedback based on its
feedbackId
. - Returns the requested feedback or an error if not found.
- Fetches a specific feedback based on its
-
getFeedbackForCourse(courseId)
- Fetches all feedback for a specific course.
- Returns a list of feedback entries or an error if the course is not found.
-
upvoteFeedback(feedbackId)
- Increases the upvote count of a specific feedback by 1.
- Returns the updated feedback or an error if not found.
-
downvoteFeedback(feedbackId)
- Increases the downvote count of a specific feedback by 1.
- Returns the updated feedback or an error if not found.
- This canister uses the
StableBTreeMap
data structure for efficient storage and retrieval of courses and feedback. - Unique identifiers for courses and feedback are generated using the
uuid
package. - The system expects proper handling on the client side to manage user identities for feedback.
-
Clone the Repository
-
Navigate to the Project Directory
-
Install Dependencies
npm install
- Start the ICP Blockchain Locally & Deploy the Canister
dfx start --background --clean
dfx deploy
You can make calls to the canister and its methods. Here are some primary methods available:
addCourse
: Adds a new course.getAllCourses
: Retrieves all courses.getCourse
: Fetches details of a specific course.addFeedback
: Adds feedback to a specific course.getFeedback
: Fetches a specific feedback by ID.getFeedbackForCourse
: Gets all feedback for a specific course.upvoteFeedback
: Increases the upvote count for a specific feedback.downvoteFeedback
: Increases the downvote count for a specific feedback.
- Add a Course
dfx canister call course_feedback addCourse '(record { "title" = "Introduction to Mathematics"; "description" = "A beginner course on basic mathematical concepts."; "tags" = vec { "math"; "beginner"; "theory" } })'
- Get All Courses
dfx canister call course_feedback getAllCourses '()'
- Get a Specific Course
dfx canister call course_feedback getCourse '("2dee4f5d-0055-4143-ad64-265b1af1bde4")'
- Add Feedback
dfx canister call course_feedback addFeedback '(record { "courseId" = "2dee4f5d-0055-4143-ad64-265b1af1bde4"; "userId" = "some_user_id"; "rating" = 5.0; "message" = "This course was excellent!" })'
- Get a Specific Feedback
dfx canister call course_feedback getFeedback '("067de5b2-ab8e-46ac-98a8-12a6133addbe")'
- Get All Feedback for a Course
dfx canister call course_feedback getFeedbackForCourse '("2dee4f5d-0055-4143-ad64-265b1af1bde4")'
- Upvote a Feedback
dfx canister call course_feedback upvoteFeedback '("067de5b2-ab8e-46ac-98a8-12a6133addbe")'
- Downvote a Feedback
dfx canister call course_feedback downvoteFeedback '("067de5b2-ab8e-46ac-98a8-12a6133addbe")'