@@ -17,7 +17,7 @@ async function addCoursework(req, res) {
1717 const newCoursework = await createCoursework ( {
1818 student, type, course, task, objectID, activity, marks,
1919 } ) ;
20- res . json ( { res : `Added Coursework with ID ${ newCoursework . id } ` } ) ;
20+ res . json ( { res : `Added Coursework with ID ${ newCoursework . id } ` , id : newCoursework . id } ) ;
2121 } catch ( error ) {
2222 logger . error ( "Error while inserting Coursework" , error ) ;
2323 res . status ( 500 ) ;
@@ -27,8 +27,9 @@ async function addCoursework(req, res) {
2727
2828// Controller function to update a Coursework entity
2929async function updateCoursework ( req , res ) {
30+ const { id } = req . params ;
3031 const {
31- id , ...data
32+ ...data
3233 } = req . body ;
3334 try {
3435 await updateCourseworkById ( id , data ) ;
@@ -49,10 +50,10 @@ async function getCoursework(req, res) {
4950
5051// Controller function to delete a Coursework entity
5152async function deleteCoursework ( req , res ) {
52- const { courseworkId } = req . params ;
53+ const { id } = req . params ;
5354 try {
54- await deleteCourseworkById ( courseworkId ) ;
55- res . json ( { res : `Deleted Coursework with ID ${ courseworkId } ` } ) ;
55+ await deleteCourseworkById ( id ) ;
56+ res . json ( { res : `Deleted Coursework with ID ${ id } ` } ) ;
5657 } catch ( error ) {
5758 logger . error ( "Error while deleting Coursework" , error ) ;
5859 res . status ( 500 ) . json ( { error : "Error while deleting Coursework from DB" } ) ;
0 commit comments