stephenneale / seng371-group16

Contains Group 16's work for SENG371 A02 - Group 16, Spring 2023
0 stars 1 forks source link

Implement ability for profs to create new courses #56

Closed matt-lebl closed 1 year ago

matt-lebl commented 1 year ago

Frontend

Provide a button on the homepage to create a new course. This will prompt the user for the following information:

  1. Course name
  2. Course code (e.g. SENG 371)
  3. Professor name

That information should be sent via POST request to an API endpoint, which will then return the course ID. The frontend should immediately navigate to the new course. Since this new course will have no content, there should be a user-friendly message displayed, something like "No announcements at the moment. Announcements will appear here as they are posted."

At this stage, we don't need to implement creation of new course content—empty courses are fine.

Backend

Expand static course serving to be more dynamic. At this stage we still won't use a database, but some ephemeral datastructure to hold new added courses should be implemented. Upon receiving a POST request to create a new course with the info above, create records for the new course and add them to this datastructure, and return the generated course ID.

matt-lebl commented 1 year ago

Okay so essentially this adds a new POST endpoint to add new courses. You can send the code, name, and instructor values to /courses and it'll add a new course which will be reflected in the /courses and /courses/<id> endpoints.

curl -X POST \
     -H "Content-Type: application/json" \
     -d '{"code": "SENG 321", "name": "Requirements Engineering", "instructor": "Neil Ernst"}' \
     http://localhost:8080/courses

the API will return the normal course response to indicate the course was added:

{
    "code": "SENG 321",
    "id": 2,
    "instructor": "Neil Ernst",
    "name": "Requirements Engineering"
}

…and then when you query the courses:

curl http://localhost:8080/courses

[
    {
        "code": "EE 120",
        "id": 1
    },
    {
        "code": "SENG 321",
        "id": 2
    }
]

curl http://localhost:8080/courses/2

{
    "code": "SENG 321",
    "id": 2,
    "instructor": "Neil Ernst",
    "name": "Requirements Engineering"
}

On to you, @stephenneale ! 😃

stephenneale commented 1 year ago

Looks great, I'll give you a shout if anything else comes up!

stephenneale commented 1 year ago

Ok! My implementation is done. Check it out in the following PR.