Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create contoller for lessons under courses #6

Open
Musoye opened this issue Oct 18, 2023 · 4 comments
Open

create contoller for lessons under courses #6

Musoye opened this issue Oct 18, 2023 · 4 comments
Assignees

Comments

@Musoye
Copy link
Collaborator

Musoye commented Oct 18, 2023

create lesson controller

The file should be under controller/lesson.js

The schema contain - lesson_id, course_id, title, content

  • create a function createLesson that creates a new
    This function will accept the request object and every rows must be
    Present else return the missing object with status code 400. if the course_id does not signify any course return 404 with error course not found. If everything is okay, Create the new lesson with new id(lesson_id) and return status code 201 with new object created.

  • create a function getLessons that get all Lessons in the database. return status code 200 with all the Lessons.

  • create a function getLesson that get a Lesson with a particular ID. The ID will be part of the url(params). If Lesson not found return 404 with error Lesson not found. If okay, return the Lesson with 200 statuscode

  • create a function updateLesson that get a Lesson with a particular ID. The ID will be part of the url(params). If Lesson not found return 404 with error Lesson not found. If found take the request object and update it accordingly and return the new record with status code 200

  • create a function deleteLesson that get a user with a particular ID. The ID will be part of the url(params). If Lesson not found return 404 with error Lesson not found. Then delete this Lesson and return 200 with details of Lesson deleted

POST - createLesson, updateLesson
GET - getLessons, getLesson , deleteLesson

routes

/lessons -> creatLesson, getLesson
/lessonss/:lesson_id -> getLesson, deleteLesson, updateLesson

Import this into and include the routes in routes/lesson.js then include it in sever.js.
Test everything if possible.(Optional: Write an automated testing for testing each endpoints in lesson_test.py/.js)

@vihar-s1
Copy link
Contributor

I would like to work on this issue

@vihar-s1
Copy link
Contributor

This requires me to have a course model in backend which refers to a different issue #4. Should I work on that issue first and then focus on this one?

@Musoye
Copy link
Collaborator Author

Musoye commented Oct 25, 2023

Work on that issues first before this one

@vihar-s1
Copy link
Contributor

vihar-s1 commented Oct 25, 2023

Please assign that issue to me instead of this then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants