-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #366 from tcet-opensource/development
Biweekly Merge
- Loading branch information
Showing
85 changed files
with
4,979 additions
and
494 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
**/node_modules | ||
**/apidoc | ||
**/.git | ||
**/_apidoc.js | ||
**/*.json | ||
**/*.css | ||
Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"tabWidth": 2 | ||
"singleQuote": false, | ||
"tabWidth": 2, | ||
"semi": true | ||
} |
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { | ||
createActivity,deleteActivityById, activityList ,updateActivityById, | ||
}from "#services/activity"; | ||
import {logger} from "#util" ; | ||
|
||
async function addActivity(req,res) { | ||
const{ | ||
activityBlueprint, | ||
startTime, | ||
duration, | ||
course, | ||
faculty, | ||
type, | ||
task, | ||
group, | ||
students, | ||
}=req.body; | ||
try{ | ||
const newActivity = await createActivity(activityBlueprint,startTime,duration,course,faculty,type,task,group,students); | ||
res.json ({res: `added activity ${newActivity.id}`, id: newActivity.id}); | ||
} catch (error){ | ||
logger.error ("Error while inserting",error); | ||
res.status(500); | ||
res.json({err:"Error while inserting in DB"}); | ||
} | ||
} | ||
|
||
async function updateActivity(req,res){ | ||
const { id }=req.params; | ||
const { | ||
...data | ||
}=req.body; | ||
try { | ||
await updateActivityById(id,data); | ||
res.json({res:`updated activity with id ${id}`}); | ||
}catch (error){ | ||
logger.error("Error while updating",error); | ||
res.status(500); | ||
res.json({err:"Error while updating in DB"}); | ||
} | ||
} | ||
|
||
async function getActivity(req,res){ | ||
const filter = req.query; | ||
const activitylist =await activityList(filter); | ||
res.json({res:activitylist}); | ||
} | ||
|
||
|
||
async function deleteActivity(res,req){ | ||
const { id }=req.params; | ||
try{ | ||
await deleteActivityById(id); | ||
|
||
res.json({res:`Deleted activity with ID ${id}`}); | ||
}catch(error){ | ||
logger.error ("Error while deleting",error); | ||
res.status(500).json({error:"Error while deleting from DB"}); | ||
} | ||
} | ||
|
||
export default { | ||
addActivity, deleteActivity ,getActivity ,updateActivity, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { | ||
createAssignment, deleteAssignmentById, assignmentList, updateAssignmentById, | ||
} from "#services/assignment"; | ||
import { logger } from "#util"; | ||
|
||
async function addAssignment(req, res) { | ||
const { | ||
no, title, type, marks, | ||
} = req.body; | ||
try { | ||
const newAssignment = await createAssignment(no, title, type, marks); | ||
res.json({ res: `added assignment ${newAssignment.id}`, id: newAssignment.id }); | ||
} catch (error) { | ||
logger.error("Error while inserting", error); | ||
res.status(500); | ||
res.json({ err: "Error while inserting in DB" }); | ||
} | ||
} | ||
|
||
async function updateAssignment(req, res) { | ||
const { id } = req.params; | ||
const { | ||
...data | ||
} = req.body; | ||
try { | ||
await updateAssignmentById(id, data); | ||
res.json({ res: `updated assignment ${id}` }); | ||
} catch (error) { | ||
logger.error("Error while updating", error); | ||
res.status(500); | ||
res.json({ err: "Error while updaing in DB" }); | ||
} | ||
} | ||
|
||
async function getAssignment(req, res) { | ||
const filter = req.query; | ||
const assingmentlist = await assignmentList(filter); | ||
res.json({ res: assingmentlist }); | ||
} | ||
|
||
async function deleteAssignment(req, res) { | ||
const { id } = req.params; | ||
try { | ||
await deleteAssignmentById(id); | ||
|
||
res.json({ res: `Deleted assignment with ID ${id}` }); | ||
} catch (error) { | ||
logger.error("Error while deleting", error); | ||
res.status(500).json({ error: "Error while deleting from DB" }); | ||
} | ||
} | ||
export default { | ||
addAssignment, deleteAssignment, getAssignment, updateAssignment, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Import Coursework-related services and utilities | ||
import { | ||
createCoursework, | ||
deleteCourseworkById, | ||
listCoursework, | ||
updateCourseworkById, | ||
} from "#services/coursework"; | ||
|
||
import { logger } from "#util"; // Import the logger utility | ||
|
||
// Controller function to add a new Coursework entity | ||
async function addCoursework(req, res) { | ||
const { | ||
student, type, course, task, objectID, activity, marks, | ||
} = req.body; | ||
try { | ||
const newCoursework = await createCoursework({ | ||
student, type, course, task, objectID, activity, marks, | ||
}); | ||
res.json({ res: `Added Coursework with ID ${newCoursework.id}`, id: newCoursework.id }); | ||
} catch (error) { | ||
logger.error("Error while inserting Coursework", error); | ||
res.status(500); | ||
res.json({ err: "Error while inserting Coursework in DB" }); | ||
} | ||
} | ||
|
||
// Controller function to update a Coursework entity | ||
async function updateCoursework(req, res) { | ||
const { id } = req.params; | ||
const { | ||
...data | ||
} = req.body; | ||
try { | ||
await updateCourseworkById(id, data); | ||
res.json({ res: "/Updated Coursework/" }); | ||
} catch (error) { | ||
logger.error("Error while updating Coursework", error); | ||
res.status(500); | ||
res.json({ err: "Error while updating Coursework in DB" }); | ||
} | ||
} | ||
|
||
// Controller function to get a list of Coursework entities | ||
async function getCoursework(req, res) { | ||
const filter = req.query; | ||
const courseworkList = await listCoursework(filter); | ||
res.json({ res: courseworkList }); | ||
} | ||
|
||
// Controller function to delete a Coursework entity | ||
async function deleteCoursework(req, res) { | ||
const { id } = req.params; | ||
try { | ||
await deleteCourseworkById(id); | ||
res.json({ res: `Deleted Coursework with ID ${id}` }); | ||
} catch (error) { | ||
logger.error("Error while deleting Coursework", error); | ||
res.status(500).json({ error: "Error while deleting Coursework from DB" }); | ||
} | ||
} | ||
|
||
export default { | ||
addCoursework, | ||
deleteCoursework, | ||
getCoursework, | ||
updateCoursework, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { | ||
updateDepartmentbyid, createnewdepartment, listdepartment, deletedepartment, | ||
} from "#services/department"; | ||
|
||
import { logger } from "#util"; | ||
|
||
async function addDepartment(req, res) { | ||
const { | ||
name, | ||
acronym, | ||
yearOfStarting, | ||
accreditations, | ||
infrastructures, | ||
} = req.body; | ||
try { | ||
const department = await createnewdepartment( | ||
name, | ||
acronym, | ||
yearOfStarting, | ||
accreditations, | ||
infrastructures, | ||
); | ||
res.json({ | ||
res: `added Department successfully ${department.name}`, | ||
id: department.id, | ||
}); | ||
} catch (error) { | ||
logger.error("Error while inserting", error); | ||
res.status(500); | ||
res.json({ err: "Error while inserting in DB" }); | ||
} | ||
} | ||
|
||
async function removedepartmentbyid(req, res) { | ||
const { departmentId } = req.params; | ||
try { | ||
await deletedepartment(departmentId); | ||
res.json({ | ||
res: "Department deleted successfully", | ||
}); | ||
} catch (error) { | ||
logger.error("Error while deleting", error); | ||
res.status(500); | ||
res.json({ err: "Error while deleting from DB" }); | ||
} | ||
} | ||
|
||
async function showdepartments(req, res) { | ||
try { | ||
const departments = await listdepartment(req.query); | ||
return res.json({ | ||
res: departments, | ||
}); | ||
} catch (error) { | ||
logger.error("Error while fetching", error); | ||
res.status(500); | ||
return res.json({ err: "Error while fetching the data" }); | ||
} | ||
} | ||
|
||
async function updatedDepartment(req, res) { | ||
const { id } = req.params; | ||
const { | ||
...data | ||
} = req.body; | ||
try { | ||
await updateDepartmentbyid(id, data); | ||
res.json({ | ||
res: "department updated successfully", | ||
}); | ||
} catch (error) { | ||
logger.error("Error while inserting", error); | ||
res.status(500); | ||
res.json({ err: "Error while inserting in DB" }); | ||
} | ||
} | ||
|
||
export default { | ||
updatedDepartment, showdepartments, removedepartmentbyid, addDepartment, | ||
}; |
Oops, something went wrong.