Skip to content

Commit fc93dc6

Browse files
Merge branch 'development' into 252-apidoc-for-organization
2 parents 75aa9ec + e21f266 commit fc93dc6

File tree

19 files changed

+1122
-39
lines changed

19 files changed

+1122
-39
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = {
44
es2021: true,
55
jest: true
66
},
7-
extends: "airbnb-base",
7+
extends: ["airbnb-base", "prettier"],
88
overrides: [],
99
parserOptions: {
1010
ecmaVersion: "latest",

.prettierignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
**/node_modules
2+
**/apidoc
3+
**/.git
4+
**/_apidoc.js
5+
**/*.json
6+
**/*.css
7+
Dockerfile

.prettierrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2-
"singleQuote": true,
3-
"tabWidth": 2
2+
"singleQuote": false,
3+
"tabWidth": 2,
4+
"semi": true
45
}

_apidoc.js

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,58 @@
713713
* @apiError (Error 500) DatabaseError Error message if there was an error during the deletion.
714714
*/
715715

716+
// ------------------------------------------------------------------------------------------
717+
// Activity.
718+
// ------------------------------------------------------------------------------------------
719+
720+
/**
721+
* @api {post} /activity/add Add Activty.
722+
* @apiName AddActivity
723+
* @apiGroup Activity
724+
*
725+
* @apiBody {Date} startTime The startTime of the activity.
726+
* @apiBody {Number} duration The duration of the activity (in minutes).
727+
* @apiBody {ObjectId} course The course of the activity (ObjectId).
728+
* @apiBody {ObjectId} faculty The faculty alloted for the activity(ObjectId).
729+
* @apiBody {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
730+
* @apiBody {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
731+
* @apiBody {ObjectId} group The group of the activity (ObjectId).
732+
* @apiBody {ObjectId} students the students who gonna attend the activity(ObjectId).
733+
*
734+
* @apiSuccess {String} res Response message.
735+
*
736+
* @apiError (Error 500) DatabaseError Error while inserting in the database.
737+
*
738+
* @apiDescription Adds a new Activity to the system.
739+
*/
740+
741+
/**
742+
*
743+
* @apiSuccessExample Success-Response:
744+
* HTTP/1.1 200 OK
745+
* {
746+
* "res": "Added activity"
747+
* }
748+
*
749+
* @apiErrorExample Error-Response:
750+
* HTTP/1.1 500 Internal Server Error
751+
* {
752+
* "err": "Error while inserting in DB"
753+
* }
754+
*/
755+
756+
/**
757+
* @api {delete} /timetable/delete/:timetableId Delete Timetable
758+
* @apiName DeleteTimetable
759+
* @apiGroup Timetable
760+
*
761+
* @apiParam {String} timetableId The ID of the timetable document to delete.
762+
*
763+
* @apiSuccess {String} res Success message indicating the deletion.
764+
*
765+
* @apiError (Error 500) DatabaseError Error message if there was an error during the deletion.
766+
*/
767+
716768
/**
717769
* @api {post} /organization/update/:organizationId Update Organisation
718770
* @apiName UpdateOrganization
@@ -727,3 +779,100 @@
727779
* @apiSuccess {String} res organization updated
728780
* @apiError (Error 500) Error while inserting in DB
729781
*/
782+
783+
/**
784+
* @api {delete} /activity/delete/:activity Delete Activity.
785+
* @apiName DeleteActivity
786+
* @apiGroup Activity
787+
*
788+
* @apiParam {String} Activity The activity document to delete.
789+
*
790+
* @apiSuccess {String} res Success message indicating the deletion.
791+
*
792+
* @apiError (Error 500) DatabaseError Error message if there was an error during the deletion.
793+
*/
794+
795+
/**
796+
* @api {post} /timetable/update Update Timetable
797+
* @apiName UpdateTimetable
798+
* @apiGroup Timetable
799+
* @apiDescription Update existing timetable data.
800+
*
801+
* @apiBody {Date} startTime The startTime of the activity.
802+
* @apiBody {Number} duration The duration of the activity (in minutes).
803+
* @apiBody {ObjectId} course The course of the activity (ObjectId).
804+
* @apiBody {ObjectId} faculty The faculty alloted for the activity(ObjectId).
805+
* @apiBody {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
806+
* @apiBody {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
807+
* @apiBody {ObjectId} group The group of the activity (ObjectId).
808+
* @apiBody {ObjectId} students the students who gonna attend the activity(ObjectId).
809+
*
810+
* @apiSuccess {String} res Timetable updated.
811+
*/
812+
813+
/**
814+
* @api {post} /activity/update Update Activity.
815+
* @apiName UpdateActivity
816+
* @apiGroup Activity
817+
* @apiDescription Update existing activity data.
818+
*
819+
* @apiBody {Date} startTime The startTime of the activity.
820+
* @apiBody {Number} duration The duration of the activity (in minutes).
821+
* @apiBody {ObjectId} course The course of the activity (ObjectId).
822+
* @apiBody {ObjectId} faculty The faculty alloted for the activity(ObjectId).
823+
* @apiBody {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
824+
* @apiBody {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
825+
* @apiBody {ObjectId} group The group of the activity (ObjectId).
826+
* @apiBody {ObjectId} students the students who gonna attend the activity(ObjectId).
827+
*
828+
* @apiSuccess {String} res Activity updated.
829+
* @apiError (Error 500) DatabaseError Error in updating the database.
830+
*/
831+
832+
/**
833+
* @api {get} /timetable/list Get Timetable List
834+
* @apiName GetTimetableList
835+
* @apiGroup Timetable
836+
*
837+
* @apiQuery {Date} startTime The startTime of the activity.
838+
* @apiQuery {Number} duration The duration of the activity (in minutes).
839+
* @apiQUERY {ObjectId} course The course of the activity (ObjectId).
840+
* @apiQuery {ObjectId} faculty The faculty alloted for the activity(ObjectId).
841+
* @apiQuery {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
842+
* @apiQuery {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
843+
* @apiQuery {ObjectId} group The group of the activity (ObjectId).
844+
* @apiQuery {ObjectId} students the students who gonna attend the activity(ObjectId).
845+
*
846+
* @apiSuccess {Date} startTime The startTime of the activity.
847+
* @apiSuccess {Number} duration The duration of the activity (in minutes).
848+
* @apiSuccess {ObjectId} course The course of the activity (ObjectId).
849+
* @apiSuccess {ObjectId} faculty The faculty alloted for the activity(ObjectId).
850+
* @apiSuccess {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
851+
* @apiSuccess {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
852+
* @apiSuccess {ObjectId} group The group of the activity (ObjectId).
853+
* @apiSucess {ObjectId} students the students who gonna attend the activity(ObjectId).
854+
*/
855+
856+
/**
857+
* @api {get} /activity/list Get Activity List
858+
* @apiName GetActivityList
859+
* @apiGroup Activity
860+
*
861+
* @apiQuery {Date} startTime The startTime of the activity.
862+
* @apiQuery {Number} duration The duration of the activity (in minutes).
863+
* @apiQUERY {ObjectId} course The course of the activity (ObjectId).
864+
* @apiQuery {ObjectId} faculty The faculty alloted for the activity(ObjectId).
865+
* @apiQuery {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
866+
* @apiQuery {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
867+
* @apiQuery {ObjectId} group The group of the activity (ObjectId).
868+
* @apiQuery {ObjectId} students the students who gonna attend the activity(ObjectId).
869+
*
870+
* @apiSuccess {Date} startTime The startTime of the activity.
871+
* @apiSuccess {Number} duration The duration of the activity (in minutes).
872+
* @apiSuccess {ObjectId} course The course of the activity (ObjectId).
873+
* @apiSuccess {ObjectId} faculty The faculty alloted for the activity(ObjectId).
874+
* @apiSuccess {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
875+
* @apiSuccess {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
876+
* @apiSuccess {ObjectId} group The group of the activity (ObjectId).
877+
* @apiSucess {ObjectId} students the students who gonna attend the activity(ObjectId).
878+
*/

app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ import tutorialRouter from "#routes/tutorial";
1717
import assignmentRouter from "#routes/assignment";
1818
import timetableRouter from "#routes/timetable";
1919
import courseworkRouter from "#routes/coursework";
20+
import activityRouter from "#routes/activity";
2021
import moduleRouter from "#routes/module";
22+
import facultyRouter from "#routes/faculty";
2123
import { identifyUser } from "#middleware/identifyUser";
2224
import departmentRouter from "#routes/department";
2325

@@ -46,10 +48,12 @@ app.use("/department", departmentRouter);
4648
app.use("/practical", practicalRouter);
4749
app.use("/organization", organizationRouter);
4850
app.use("/student", studentRouter);
51+
app.use("/activity", activityRouter);
4952
app.use("/tutorial", tutorialRouter);
5053
app.use("/assignment", assignmentRouter);
5154
app.use("/timetable", timetableRouter);
5255
app.use("/department", departmentRouter);
5356
app.use("/coursework", courseworkRouter);
5457
app.use("/module", moduleRouter);
58+
app.use("/faculty", facultyRouter);
5559
export default app;

controller/activity.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import {
2+
createActivity,deleteActivityById, activityList ,updateActivityById,
3+
}from "#services/activity";
4+
import {logger} from "#util" ;
5+
6+
async function addActivity(req,res) {
7+
const{
8+
activityBlueprint,
9+
startTime,
10+
duration,
11+
course,
12+
faculty,
13+
type,
14+
task,
15+
group,
16+
students,
17+
}=req.body;
18+
try{
19+
const newActivity = await createActivity(activityBlueprint,startTime,duration,course,faculty,type,task,group,students);
20+
res.json ({res: `added activity ${newActivity.id}`, id: newActivity.id});
21+
} catch (error){
22+
logger.error ("Error while inserting",error);
23+
res.status(500);
24+
res.json({err:"Error while inserting in DB"});
25+
}
26+
}
27+
28+
async function updateActivity(req,res){
29+
const { id }=req.params;
30+
const {
31+
...data
32+
}=req.body;
33+
try {
34+
await updateActivityById(id,data);
35+
res.json({res:`updated activity with id ${id}`});
36+
}catch (error){
37+
logger.error("Error while updating",error);
38+
res.status(500);
39+
res.json({err:"Error while updating in DB"});
40+
}
41+
}
42+
43+
async function getActivity(req,res){
44+
const filter = req.query;
45+
const activitylist =await activityList(filter);
46+
res.json({res:activitylist});
47+
}
48+
49+
50+
async function deleteActivity(res,req){
51+
const { id }=req.params;
52+
try{
53+
await deleteActivityById(id);
54+
55+
res.json({res:`Deleted activity with ID ${id}`});
56+
}catch(error){
57+
logger.error ("Error while deleting",error);
58+
res.status(500).json({error:"Error while deleting from DB"});
59+
}
60+
}
61+
62+
export default {
63+
addActivity, deleteActivity ,getActivity ,updateActivity,
64+
};

controller/assignment.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ async function addAssignment(req, res) {
99
} = req.body;
1010
try {
1111
const newAssignment = await createAssignment(no, title, type, marks);
12-
res.json({ res: `added user ${newAssignment.id}`, id: newAssignment.id });
12+
res.json({ res: `added assignment ${newAssignment.id}`, id: newAssignment.id });
1313
} catch (error) {
1414
logger.error("Error while inserting", error);
1515
res.status(500);
@@ -24,7 +24,7 @@ async function updateAssignment(req, res) {
2424
} = req.body;
2525
try {
2626
await updateAssignmentById(id, data);
27-
res.json({ res: `updated assignment with id ${id}` });
27+
res.json({ res: `updated assignment ${id}` });
2828
} catch (error) {
2929
logger.error("Error while updating", error);
3030
res.status(500);

controller/faculty.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import {
2+
createFaculty, facultyList, deleteFacultyById, updateFacultyById,
3+
} from "#services/faculty";
4+
import { logger } from "#util";
5+
6+
async function addFaculty(req, res) {
7+
const {
8+
ERPID,
9+
dateOfJoining,
10+
dateOfLeaving,
11+
profileLink,
12+
qualifications,
13+
totalExperience,
14+
achievements,
15+
areaOfSpecialization,
16+
papersPublishedPG,
17+
papersPublishedUG,
18+
department,
19+
preferredSubjects,
20+
designation,
21+
natureOfAssociation,
22+
additionalResponsibilities,
23+
} = req.body;
24+
try {
25+
const newFaculty = await createFaculty(
26+
ERPID,
27+
dateOfJoining,
28+
dateOfLeaving,
29+
profileLink,
30+
qualifications,
31+
totalExperience,
32+
achievements,
33+
areaOfSpecialization,
34+
papersPublishedPG,
35+
papersPublishedUG,
36+
department,
37+
preferredSubjects,
38+
designation,
39+
natureOfAssociation,
40+
additionalResponsibilities,
41+
);
42+
res.json({ res: `added faculty ${newFaculty.ERPID}` });
43+
} catch (error) {
44+
logger.error("Error while inserting", error);
45+
res.status(500);
46+
res.json({ err: "Error while inserting in DB" });
47+
}
48+
}
49+
50+
async function getFaculty(req, res) {
51+
const filter = req.query;
52+
const facultylist = await facultyList(filter);
53+
res.json({ res: facultylist });
54+
}
55+
56+
async function deleteFaculty(req, res) {
57+
const { facultyId } = req.params;
58+
try {
59+
await deleteFacultyById(facultyId);
60+
res.json({ res: "Faculty deleted successfully" });
61+
} catch (error) {
62+
logger.error("Error while deleting", error);
63+
res.status(500);
64+
res.json({ err: "Error while deleting from DB" });
65+
}
66+
}
67+
68+
async function updateFaculty(req, res) {
69+
const {
70+
id, ...data
71+
} = req.body;
72+
try {
73+
await updateFacultyById(id, data);
74+
res.json({ res: `updated faculty with id ${id}` });
75+
} catch (error) {
76+
logger.error("Error while updating", error);
77+
res.status(500);
78+
res.json({ err: "Error while updating in DB" });
79+
}
80+
}
81+
82+
export default {
83+
addFaculty, getFaculty, deleteFaculty, updateFaculty,
84+
};

hooks/pre-commit

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ do
99
# Get staged content of the file
1010
staged_content=$(git show ":$file")
1111

12+
# Format staged files
13+
npx prettier --write $file
14+
1215
# Run ESLint with the staged content and filename
1316
# echo "$staged_content" | npm run eslint -- --stdin
1417
npx eslint $file
@@ -20,4 +23,4 @@ done
2023

2124
if [ $flag -eq 1 ]; then
2225
exit 1
23-
fi
26+
fi

0 commit comments

Comments
 (0)