Skip to content

Commit 8e7afc0

Browse files
Merge branch 'development' into 280-megafeat-semester
2 parents e7d3701 + e21f266 commit 8e7afc0

25 files changed

+1299
-48
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
}
File renamed without changes.

_apidoc.js

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,3 +732,153 @@
732732
*
733733
* @apiError (Error 500) DatabaseError Error message if there was an error during the deletion.
734734
*/
735+
736+
737+
// ------------------------------------------------------------------------------------------
738+
// Activity.
739+
// ------------------------------------------------------------------------------------------
740+
741+
/**
742+
* @api {post} /activity/add Add Activty.
743+
* @apiName AddActivity
744+
* @apiGroup Activity
745+
*
746+
* @apiBody {Date} startTime The startTime of the activity.
747+
* @apiBody {Number} duration The duration of the activity (in minutes).
748+
* @apiBody {ObjectId} course The course of the activity (ObjectId).
749+
* @apiBody {ObjectId} faculty The faculty alloted for the activity(ObjectId).
750+
* @apiBody {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
751+
* @apiBody {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
752+
* @apiBody {ObjectId} group The group of the activity (ObjectId).
753+
* @apiBody {ObjectId} students the students who gonna attend the activity(ObjectId).
754+
*
755+
* @apiSuccess {String} res Response message.
756+
*
757+
* @apiError (Error 500) DatabaseError Error while inserting in the database.
758+
*
759+
* @apiDescription Adds a new Activity to the system.
760+
*/
761+
762+
/**
763+
*
764+
* @apiSuccessExample Success-Response:
765+
* HTTP/1.1 200 OK
766+
* {
767+
* "res": "Added activity"
768+
* }
769+
*
770+
* @apiErrorExample Error-Response:
771+
* HTTP/1.1 500 Internal Server Error
772+
* {
773+
* "err": "Error while inserting in DB"
774+
* }
775+
*/
776+
777+
/**
778+
* @api {delete} /timetable/delete/:timetableId Delete Timetable
779+
* @apiName DeleteTimetable
780+
* @apiGroup Timetable
781+
*
782+
* @apiParam {String} timetableId The ID of the timetable document to delete.
783+
*
784+
* @apiSuccess {String} res Success message indicating the deletion.
785+
*
786+
* @apiError (Error 500) DatabaseError Error message if there was an error during the deletion.
787+
*/
788+
789+
/**
790+
* @api {delete} /activity/delete/:activity Delete Activity.
791+
* @apiName DeleteActivity
792+
* @apiGroup Activity
793+
*
794+
* @apiParam {String} Activity The activity document to delete.
795+
*
796+
* @apiSuccess {String} res Success message indicating the deletion.
797+
*
798+
* @apiError (Error 500) DatabaseError Error message if there was an error during the deletion.
799+
*/
800+
801+
/**
802+
* @api {post} /timetable/update Update Timetable
803+
* @apiName UpdateTimetable
804+
* @apiGroup Timetable
805+
* @apiDescription Update existing timetable data.
806+
*
807+
* @apiBody {Date} startTime The startTime of the activity.
808+
* @apiBody {Number} duration The duration of the activity (in minutes).
809+
* @apiBody {ObjectId} course The course of the activity (ObjectId).
810+
* @apiBody {ObjectId} faculty The faculty alloted for the activity(ObjectId).
811+
* @apiBody {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
812+
* @apiBody {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
813+
* @apiBody {ObjectId} group The group of the activity (ObjectId).
814+
* @apiBody {ObjectId} students the students who gonna attend the activity(ObjectId).
815+
*
816+
* @apiSuccess {String} res Timetable updated.
817+
*/
818+
819+
/**
820+
* @api {post} /activity/update Update Activity.
821+
* @apiName UpdateActivity
822+
* @apiGroup Activity
823+
* @apiDescription Update existing activity data.
824+
*
825+
* @apiBody {Date} startTime The startTime of the activity.
826+
* @apiBody {Number} duration The duration of the activity (in minutes).
827+
* @apiBody {ObjectId} course The course of the activity (ObjectId).
828+
* @apiBody {ObjectId} faculty The faculty alloted for the activity(ObjectId).
829+
* @apiBody {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
830+
* @apiBody {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
831+
* @apiBody {ObjectId} group The group of the activity (ObjectId).
832+
* @apiBody {ObjectId} students the students who gonna attend the activity(ObjectId).
833+
*
834+
* @apiSuccess {String} res Activity updated.
835+
* @apiError (Error 500) DatabaseError Error in updating the database.
836+
*/
837+
838+
/**
839+
* @api {get} /timetable/list Get Timetable List
840+
* @apiName GetTimetableList
841+
* @apiGroup Timetable
842+
*
843+
* @apiQuery {Date} startTime The startTime of the activity.
844+
* @apiQuery {Number} duration The duration of the activity (in minutes).
845+
* @apiQUERY {ObjectId} course The course of the activity (ObjectId).
846+
* @apiQuery {ObjectId} faculty The faculty alloted for the activity(ObjectId).
847+
* @apiQuery {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
848+
* @apiQuery {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
849+
* @apiQuery {ObjectId} group The group of the activity (ObjectId).
850+
* @apiQuery {ObjectId} students the students who gonna attend the activity(ObjectId).
851+
*
852+
* @apiSuccess {Date} startTime The startTime of the activity.
853+
* @apiSuccess {Number} duration The duration of the activity (in minutes).
854+
* @apiSuccess {ObjectId} course The course of the activity (ObjectId).
855+
* @apiSuccess {ObjectId} faculty The faculty alloted for the activity(ObjectId).
856+
* @apiSuccess {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
857+
* @apiSuccess {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
858+
* @apiSuccess {ObjectId} group The group of the activity (ObjectId).
859+
* @apiSucess {ObjectId} students the students who gonna attend the activity(ObjectId).
860+
*/
861+
862+
/**
863+
* @api {get} /activity/list Get Activity List
864+
* @apiName GetActivityList
865+
* @apiGroup Activity
866+
*
867+
* @apiQuery {Date} startTime The startTime of the activity.
868+
* @apiQuery {Number} duration The duration of the activity (in minutes).
869+
* @apiQUERY {ObjectId} course The course of the activity (ObjectId).
870+
* @apiQuery {ObjectId} faculty The faculty alloted for the activity(ObjectId).
871+
* @apiQuery {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
872+
* @apiQuery {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
873+
* @apiQuery {ObjectId} group The group of the activity (ObjectId).
874+
* @apiQuery {ObjectId} students the students who gonna attend the activity(ObjectId).
875+
*
876+
* @apiSuccess {Date} startTime The startTime of the activity.
877+
* @apiSuccess {Number} duration The duration of the activity (in minutes).
878+
* @apiSuccess {ObjectId} course The course of the activity (ObjectId).
879+
* @apiSuccess {ObjectId} faculty The faculty alloted for the activity(ObjectId).
880+
* @apiSuccess {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
881+
* @apiSuccess {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
882+
* @apiSuccess {ObjectId} group The group of the activity (ObjectId).
883+
* @apiSucess {ObjectId} students the students who gonna attend the activity(ObjectId).
884+
*/

app.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ import tutorialRouter from "#routes/tutorial";
1818
import assignmentRouter from "#routes/assignment";
1919
import timetableRouter from "#routes/timetable";
2020
import courseworkRouter from "#routes/coursework";
21+
import activityRouter from "#routes/activity";
2122
import moduleRouter from "#routes/module";
23+
import facultyRouter from "#routes/faculty";
2224
import { identifyUser } from "#middleware/identifyUser";
2325
import departmentRouter from "#routes/department";
2426

@@ -47,12 +49,13 @@ app.use("/department", departmentRouter);
4749
app.use("/practical", practicalRouter);
4850
app.use("/organization", organizationRouter);
4951
app.use("/student", studentRouter);
52+
app.use("/activity", activityRouter);
5053
app.use("/tutorial", tutorialRouter);
5154
app.use("/assignment", assignmentRouter);
5255
app.use("/timetable", timetableRouter);
5356
app.use("/department", departmentRouter);
5457
app.use("/coursework", courseworkRouter);
5558
app.use("/module", moduleRouter);
5659
app.use("/semester", semesterRouter);
57-
60+
app.use("/faculty", facultyRouter);
5861
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)