From e0c756fb361ab0fd3e18a50ee0c8bbe4fb07c52e Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Wed, 26 Feb 2025 14:17:21 +0100 Subject: [PATCH 1/8] feat: /teacher endpoint met dummy JSON voor #48 --- backend/src/routes/teacher.ts | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 backend/src/routes/teacher.ts diff --git a/backend/src/routes/teacher.ts b/backend/src/routes/teacher.ts new file mode 100644 index 00000000..a004ce8c --- /dev/null +++ b/backend/src/routes/teacher.ts @@ -0,0 +1,44 @@ +import express from 'express' +const router = express.Router(); + +// information about an question with id 'id' +router.get('/:id/', (req, res) => { + res.json({ + id: req.params.id, + firstName: 'John', + lastName: 'Doe', + username: 'JohnDoe1', + endpoints: { + classes: `/teacher/${req.params.id}/classes`, + questions: `/teacher/${req.params.id}/questions`, + invitations: `/teacher/${req.params.id}/invitations`, + }, + }); +}) + +router.get('/:id/questions', (req, res) => { + res.json({ + questions: [ + '0' + ], + }); +}); + +router.get('/:id/invitations', (req, res) => { + res.json({ + invitations: [ + '0' + ], + }); +}); + +router.get('/:id/classes', (req, res) => { + res.json({ + classes: [ + '0' + ], + }); +}); + + +export default router \ No newline at end of file From bb41fd848c2ea903f374e457b9c9ee96d67ca4fb Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Wed, 26 Feb 2025 14:18:48 +0100 Subject: [PATCH 2/8] feat: commentaar toegevoegd voor de verschillende endpoints in /teacher --- backend/src/routes/teacher.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/routes/teacher.ts b/backend/src/routes/teacher.ts index a004ce8c..851da986 100644 --- a/backend/src/routes/teacher.ts +++ b/backend/src/routes/teacher.ts @@ -1,7 +1,7 @@ import express from 'express' const router = express.Router(); -// information about an question with id 'id' +// information about a teacher router.get('/:id/', (req, res) => { res.json({ id: req.params.id, @@ -16,6 +16,7 @@ router.get('/:id/', (req, res) => { }); }) +// the questions students asked a teacher router.get('/:id/questions', (req, res) => { res.json({ questions: [ @@ -24,6 +25,7 @@ router.get('/:id/questions', (req, res) => { }); }); +// invitations to other classes a teacher received router.get('/:id/invitations', (req, res) => { res.json({ invitations: [ @@ -32,6 +34,7 @@ router.get('/:id/invitations', (req, res) => { }); }); +// a list with ids of classes a teacher is in router.get('/:id/classes', (req, res) => { res.json({ classes: [ From 62d4e3bc224d4fe52fa3af8cc5f9d25dab055cab Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Wed, 26 Feb 2025 14:20:58 +0100 Subject: [PATCH 3/8] feat: profiel endpoint van een student toegevoegd --- backend/src/routes/student.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/backend/src/routes/student.ts b/backend/src/routes/student.ts index 3c8cd16c..b799e6aa 100644 --- a/backend/src/routes/student.ts +++ b/backend/src/routes/student.ts @@ -1,6 +1,22 @@ import express from 'express' const router = express.Router(); +// information about a student's profile +router.get('/:id', (req, res) => { + res.json({ + id: req.params.id, + firstName: 'Jimmy', + lastName: 'Faster', + username: 'JimmyFaster2', + endpoints: { + classes: `/student/${req.params.id}/classes`, + questions: `/student/${req.params.id}/submissions`, + invitations: `/student/${req.params.id}/assignments`, + groups: `/student/${req.params.id}/groups`, + }, + }); +}); + // the list of classes a student is in router.get('/:id/classes', (req, res) => { res.json({ From 08e54dbcb1847d1d0b93bf60c7e91023e069572d Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Wed, 26 Feb 2025 14:35:42 +0100 Subject: [PATCH 4/8] feat+fix: extra endpoints in /class toegevoegd, links in responses naar zuster endpoints toegevoegd --- backend/src/routes/class.ts | 32 ++++++++++++++++++++++++++++++-- backend/src/routes/teacher.ts | 9 +++++---- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/backend/src/routes/class.ts b/backend/src/routes/class.ts index c9fe4259..4d031587 100644 --- a/backend/src/routes/class.ts +++ b/backend/src/routes/class.ts @@ -8,9 +8,37 @@ router.get('/:id', (req, res) => { displayName: 'Klas 4B', teachers: [ '0' ], students: [ '0' ], - assignments: [ '0' ], joinRequests: [ '0' ], - invitations: [ '0' ], + links: { + self: `${req.baseUrl}/${req.params.id}`, + classes: `${req.baseUrl}/${req.params.id}/invitations`, + questions: `${req.baseUrl}/${req.params.id}/assignments`, + students: `${req.baseUrl}/${req.params.id}/students`, + } + }); +}) + +router.get('/:id/invitations', (req, res) => { + res.json({ + invitations: [ + '0' + ], + }); +}) + +router.get('/:id/assignments', (req, res) => { + res.json({ + assignments: [ + '0' + ], + }); +}) + +router.get('/:id/students', (req, res) => { + res.json({ + students: [ + '0' + ], }); }) diff --git a/backend/src/routes/teacher.ts b/backend/src/routes/teacher.ts index 851da986..06ab320b 100644 --- a/backend/src/routes/teacher.ts +++ b/backend/src/routes/teacher.ts @@ -8,10 +8,11 @@ router.get('/:id/', (req, res) => { firstName: 'John', lastName: 'Doe', username: 'JohnDoe1', - endpoints: { - classes: `/teacher/${req.params.id}/classes`, - questions: `/teacher/${req.params.id}/questions`, - invitations: `/teacher/${req.params.id}/invitations`, + links: { + self: `${req.baseUrl}/${req.params.id}`, + classes: `${req.baseUrl}/${req.params.id}/classes`, + questions: `${req.baseUrl}/${req.params.id}/questions`, + invitations: `${req.baseUrl}/${req.params.id}/invitations`, }, }); }) From a7d4868e63e012bf750395b5404769a55ca5a9a5 Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Wed, 26 Feb 2025 14:40:32 +0100 Subject: [PATCH 5/8] feat: extra endpoints toegevoegd voor /assignment --- backend/src/routes/assignment.ts | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/backend/src/routes/assignment.ts b/backend/src/routes/assignment.ts index 95116243..38fffe29 100644 --- a/backend/src/routes/assignment.ts +++ b/backend/src/routes/assignment.ts @@ -9,8 +9,36 @@ router.get('/:id', (req, res) => { description: 'Een korte beschrijving', groups: [ '0' ], learningPath: '0', - class: '0' + class: '0', + links: { + self: `${req.baseUrl}/${req.params.id}`, + submissions: `${req.baseUrl}/${req.params.id}`, + }, }); }) +router.get('/:id/submissions', (req, res) => { + res.json({ + submissions: [ + '0' + ], + }); +}); + +router.get('/:id/groups', (req, res) => { + res.json({ + groups: [ + '0' + ], + }); +}); + +router.get('/:id/questions', (req, res) => { + res.json({ + questions: [ + '0' + ], + }); +}); + export default router \ No newline at end of file From 2e87710fe662af39aedb1e69ffecfeefb76e7bcf Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Wed, 26 Feb 2025 14:42:38 +0100 Subject: [PATCH 6/8] feat: extra endpoints voor /question toegevoegd --- backend/src/routes/question.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/backend/src/routes/question.ts b/backend/src/routes/question.ts index 2218abf9..16b1a484 100644 --- a/backend/src/routes/question.ts +++ b/backend/src/routes/question.ts @@ -9,9 +9,20 @@ router.get('/:id', (req, res) => { group: '0', time: new Date(2025, 1, 1), content: 'Zijn alle gehele getallen groter dan 2 gelijk aan de som van 2 priemgetallen????', - answers: [ '0' ], - learningObject: [ '0' ], + learningObject: '0', + links: { + self: `${req.baseUrl}/${req.params.id}`, + answers: `${req.baseUrl}/${req.params.id}/answers`, + } }); }) +router.get('/:id/answers', (req, res) => { + res.json({ + answers: [ + '0' + ], + }) +}) + export default router \ No newline at end of file From b85374afa8f59f8749ae966d472b69fb918f22cd Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Thu, 27 Feb 2025 16:30:55 +0100 Subject: [PATCH 7/8] feat: root paden toegevoegd aan endpoints --- backend/src/routes/assignment.ts | 10 ++++++++++ backend/src/routes/class.ts | 10 ++++++++++ backend/src/routes/group.ts | 10 ++++++++++ backend/src/routes/question.ts | 10 ++++++++++ backend/src/routes/student.ts | 10 ++++++++++ backend/src/routes/submission.ts | 10 ++++++++++ backend/src/routes/teacher.ts | 12 +++++++++++- 7 files changed, 71 insertions(+), 1 deletion(-) diff --git a/backend/src/routes/assignment.ts b/backend/src/routes/assignment.ts index 38fffe29..fcb6e9da 100644 --- a/backend/src/routes/assignment.ts +++ b/backend/src/routes/assignment.ts @@ -1,6 +1,16 @@ import express from 'express' const router = express.Router(); +// root endpoint used to search objects +router.get('/', (req, res) => { + res.json({ + assignments: [ + '0', + '1', + ] + }); +}); + // information about an assignment with id 'id' router.get('/:id', (req, res) => { res.json({ diff --git a/backend/src/routes/class.ts b/backend/src/routes/class.ts index 4d031587..e554a7f2 100644 --- a/backend/src/routes/class.ts +++ b/backend/src/routes/class.ts @@ -1,6 +1,16 @@ import express from 'express' const router = express.Router(); +// root endpoint used to search objects +router.get('/', (req, res) => { + res.json({ + classes: [ + '0', + '1', + ] + }); +}); + // information about an class with id 'id' router.get('/:id', (req, res) => { res.json({ diff --git a/backend/src/routes/group.ts b/backend/src/routes/group.ts index bca20889..e55dddd1 100644 --- a/backend/src/routes/group.ts +++ b/backend/src/routes/group.ts @@ -1,6 +1,16 @@ import express from 'express' const router = express.Router(); +// root endpoint used to search objects +router.get('/', (req, res) => { + res.json({ + groups: [ + '0', + '1', + ] + }); +}); + // information about a group (members, ... [TODO DOC]) router.get('/:id', (req, res) => { res.json({ diff --git a/backend/src/routes/question.ts b/backend/src/routes/question.ts index 16b1a484..25d168b7 100644 --- a/backend/src/routes/question.ts +++ b/backend/src/routes/question.ts @@ -1,6 +1,16 @@ import express from 'express' const router = express.Router(); +// root endpoint used to search objects +router.get('/', (req, res) => { + res.json({ + questions: [ + '0', + '1', + ] + }); +}); + // information about an question with id 'id' router.get('/:id', (req, res) => { res.json({ diff --git a/backend/src/routes/student.ts b/backend/src/routes/student.ts index b799e6aa..a11c1fbc 100644 --- a/backend/src/routes/student.ts +++ b/backend/src/routes/student.ts @@ -1,6 +1,16 @@ import express from 'express' const router = express.Router(); +// root endpoint used to search objects +router.get('/', (req, res) => { + res.json({ + students: [ + '0', + '1', + ] + }); +}); + // information about a student's profile router.get('/:id', (req, res) => { res.json({ diff --git a/backend/src/routes/submission.ts b/backend/src/routes/submission.ts index b830af8b..8d09cf8e 100644 --- a/backend/src/routes/submission.ts +++ b/backend/src/routes/submission.ts @@ -1,6 +1,16 @@ import express from 'express' const router = express.Router(); +// root endpoint used to search objects +router.get('/', (req, res) => { + res.json({ + submissions: [ + '0', + '1', + ] + }); +}); + // information about an submission with id 'id' router.get('/:id', (req, res) => { res.json({ diff --git a/backend/src/routes/teacher.ts b/backend/src/routes/teacher.ts index 06ab320b..37b3b04b 100644 --- a/backend/src/routes/teacher.ts +++ b/backend/src/routes/teacher.ts @@ -1,8 +1,18 @@ import express from 'express' const router = express.Router(); +// root endpoint used to search objects +router.get('/', (req, res) => { + res.json({ + teachers: [ + '0', + '1', + ] + }); +}); + // information about a teacher -router.get('/:id/', (req, res) => { +router.get('/:id', (req, res) => { res.json({ id: req.params.id, firstName: 'John', From 09923202f3acedd01ea19ced6daf81843e6bd79f Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Thu, 27 Feb 2025 16:31:41 +0100 Subject: [PATCH 8/8] fix: routes/themes.ts bestand verwijderd om conflicten te vermijden --- backend/src/routes/themes.ts | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 backend/src/routes/themes.ts diff --git a/backend/src/routes/themes.ts b/backend/src/routes/themes.ts deleted file mode 100644 index 99f4dd0c..00000000 --- a/backend/src/routes/themes.ts +++ /dev/null @@ -1,10 +0,0 @@ -import express from 'express' -const router = express.Router(); - -// I'm not sure what's supposed to be here -// https://github.com/SELab-2/Dwengo-1/issues/24 -router.get('/', (req, res) => { - res.send('themes route'); -}) - -export default router \ No newline at end of file