Skip to content

Commit c84b762

Browse files
Merge branch 'development' into 314-all-endpoints-for-group
2 parents 79f3ad9 + 692065c commit c84b762

30 files changed

+1562
-49
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: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,111 @@
695695
* }
696696
*/
697697

698+
// ------------------------------------------------------------------------------------------
699+
// Semester
700+
// ------------------------------------------------------------------------------------------
701+
/**
702+
* @api {post} /semester/add Request to add Semester information
703+
* @apiName Addsemester
704+
* @apiGroup Semester
705+
*
706+
* @apiQuery {Number} [number] Number of semester
707+
* @apiQuery {String} [academicYear] To show the current academic year
708+
* @apiQuery {String} [type] Stores the enum ODD or EVEN for semester
709+
* @apiQuery {Date} [startDate] Start date of the semester
710+
* @apiQuery {Date} [endDate] End date of the semester
711+
*
712+
* @apiSuccess {String} res Response message .
713+
* @apiError (Error 500) DatabaseError Err message if there is an error inserting into the database.
714+
*
715+
*/
716+
717+
/**
718+
* @api {get} /semester/list Request to list Semester information
719+
* @apiName semesterlist
720+
* @apiGroup Semester
721+
*
722+
* @apiQuery {Number} [number] Number of semester
723+
* @apiQuery {String} [academicYear] To show the current academic year
724+
* @apiQuery {String} [type] Stores the enum ODD or EVEN for semester
725+
* @apiQuery {Date} [startDate] Start date of the semester
726+
* @apiQuery {Date} [endDate] End date of the semester
727+
*
728+
* @apiSuccess {semester[]} res Array of Filtered semester Doc.
729+
* @apiSuccess {Number} semester.number Number of semester
730+
* @apiSuccess {String} semester.academicYear To show the current academic year of the semester
731+
* @apiSuccess {String} semester.type Stores the enum ODD or EVEN for semester
732+
* @apiSuccess {Date} semester.startDate Start date of the semester
733+
* @apiSuccess {Date} semester.endDate End date of the semester
734+
*
735+
*/
736+
737+
/**
738+
* @api {update} /semester/update/:id Request to list Semester information
739+
* @apiName Updatesemester
740+
* @apiGroup Semester
741+
*
742+
* @apiBody {Number} [number] Number of semester
743+
* @apiBody {String} [academicYear] To show the current academic year
744+
* @apiBody {String} [type] Stores the enum ODD or EVEN for semester
745+
* @apiBody {Date} [startDate] Start date of the semester
746+
* @apiBody {Date} [endDate] End date of the semester
747+
*
748+
*@apiSuccess {String} res Semester updated.
749+
* @apiError (Error 500) DatabaseError Error in updating the database.
750+
*
751+
*/
752+
753+
/**
754+
* @api {delete} /semester/delete/:id Request to list Semester information
755+
* @apiName Deletesemester
756+
* @apiGroup Semester
757+
*
758+
* @apiParam {String} id The ID of the Semester document to delete.
759+
*
760+
* @apiSuccess {String} res Success message indicating the deletion.
761+
*
762+
* @apiError (Error 500) DatabaseError Error message if there was an error during the deletion.
763+
*/
764+
765+
766+
// ------------------------------------------------------------------------------------------
767+
// Activity.
768+
// ------------------------------------------------------------------------------------------
769+
770+
/**
771+
* @api {post} /activity/add Add Activty.
772+
* @apiName AddActivity
773+
* @apiGroup Activity
774+
*
775+
* @apiBody {Date} startTime The startTime of the activity.
776+
* @apiBody {Number} duration The duration of the activity (in minutes).
777+
* @apiBody {ObjectId} course The course of the activity (ObjectId).
778+
* @apiBody {ObjectId} faculty The faculty alloted for the activity(ObjectId).
779+
* @apiBody {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
780+
* @apiBody {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
781+
* @apiBody {ObjectId} group The group of the activity (ObjectId).
782+
* @apiBody {ObjectId} students the students who gonna attend the activity(ObjectId).
783+
*
784+
* @apiSuccess {String} res Response message.
785+
*
786+
* @apiError (Error 500) DatabaseError Error while inserting in the database.
787+
*
788+
* @apiDescription Adds a new Activity to the system.
789+
*
790+
* @apiSuccessExample Success-Response:
791+
* HTTP/1.1 200 OK
792+
* {
793+
* "res": "Added activity"
794+
* }
795+
*
796+
* @apiErrorExample Error-Response:
797+
* HTTP/1.1 500 Internal Server Error
798+
* {
799+
* "err": "Error while inserting in DB"
800+
* }
801+
*/
802+
698803
/**
699804
* @api {delete} /group/delete/:id Delete Group
700805
* @apiName DeleteGroup
@@ -734,3 +839,111 @@
734839
* @apiSuccess {String} group.title Title of the group.
735840
* @apiSuccess {ObjectId[]} group.students Array of student ObjectIDs in the group.
736841
*/
842+
/**
843+
* @api {delete} /timetable/delete/:timetableId Delete Timetable
844+
* @apiName DeleteTimetable
845+
* @apiGroup Timetable
846+
*
847+
* @apiParam {String} timetableId The ID of the timetable document to delete.
848+
*
849+
* @apiSuccess {String} res Success message indicating the deletion.
850+
*
851+
* @apiError (Error 500) DatabaseError Error message if there was an error during the deletion.
852+
*/
853+
854+
/**
855+
* @api {delete} /activity/delete/:activity Delete Activity.
856+
* @apiName DeleteActivity
857+
* @apiGroup Activity
858+
*
859+
* @apiParam {String} Activity The activity document to delete.
860+
*
861+
* @apiSuccess {String} res Success message indicating the deletion.
862+
*
863+
* @apiError (Error 500) DatabaseError Error message if there was an error during the deletion.
864+
*/
865+
866+
/**
867+
* @api {post} /timetable/update Update Timetable
868+
* @apiName UpdateTimetable
869+
* @apiGroup Timetable
870+
* @apiDescription Update existing timetable data.
871+
*
872+
* @apiBody {Date} startTime The startTime of the activity.
873+
* @apiBody {Number} duration The duration of the activity (in minutes).
874+
* @apiBody {ObjectId} course The course of the activity (ObjectId).
875+
* @apiBody {ObjectId} faculty The faculty alloted for the activity(ObjectId).
876+
* @apiBody {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
877+
* @apiBody {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
878+
* @apiBody {ObjectId} group The group of the activity (ObjectId).
879+
* @apiBody {ObjectId} students the students who gonna attend the activity(ObjectId).
880+
*
881+
* @apiSuccess {String} res Timetable updated.
882+
*/
883+
884+
/**
885+
* @api {post} /activity/update Update Activity.
886+
* @apiName UpdateActivity
887+
* @apiGroup Activity
888+
* @apiDescription Update existing activity data.
889+
*
890+
* @apiBody {Date} startTime The startTime of the activity.
891+
* @apiBody {Number} duration The duration of the activity (in minutes).
892+
* @apiBody {ObjectId} course The course of the activity (ObjectId).
893+
* @apiBody {ObjectId} faculty The faculty alloted for the activity(ObjectId).
894+
* @apiBody {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
895+
* @apiBody {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
896+
* @apiBody {ObjectId} group The group of the activity (ObjectId).
897+
* @apiBody {ObjectId} students the students who gonna attend the activity(ObjectId).
898+
*
899+
* @apiSuccess {String} res Activity updated.
900+
* @apiError (Error 500) DatabaseError Error in updating the database.
901+
*/
902+
903+
/**
904+
* @api {get} /timetable/list Get Timetable List
905+
* @apiName GetTimetableList
906+
* @apiGroup Timetable
907+
*
908+
* @apiQuery {Date} startTime The startTime of the activity.
909+
* @apiQuery {Number} duration The duration of the activity (in minutes).
910+
* @apiQUERY {ObjectId} course The course of the activity (ObjectId).
911+
* @apiQuery {ObjectId} faculty The faculty alloted for the activity(ObjectId).
912+
* @apiQuery {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
913+
* @apiQuery {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
914+
* @apiQuery {ObjectId} group The group of the activity (ObjectId).
915+
* @apiQuery {ObjectId} students the students who gonna attend the activity(ObjectId).
916+
*
917+
* @apiSuccess {Date} startTime The startTime of the activity.
918+
* @apiSuccess {Number} duration The duration of the activity (in minutes).
919+
* @apiSuccess {ObjectId} course The course of the activity (ObjectId).
920+
* @apiSuccess {ObjectId} faculty The faculty alloted for the activity(ObjectId).
921+
* @apiSuccess {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
922+
* @apiSuccess {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
923+
* @apiSuccess {ObjectId} group The group of the activity (ObjectId).
924+
* @apiSucess {ObjectId} students the students who gonna attend the activity(ObjectId).
925+
*/
926+
927+
/**
928+
* @api {get} /activity/list Get Activity List
929+
* @apiName GetActivityList
930+
* @apiGroup Activity
931+
*
932+
* @apiQuery {Date} startTime The startTime of the activity.
933+
* @apiQuery {Number} duration The duration of the activity (in minutes).
934+
* @apiQUERY {ObjectId} course The course of the activity (ObjectId).
935+
* @apiQuery {ObjectId} faculty The faculty alloted for the activity(ObjectId).
936+
* @apiQuery {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
937+
* @apiQuery {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
938+
* @apiQuery {ObjectId} group The group of the activity (ObjectId).
939+
* @apiQuery {ObjectId} students the students who gonna attend the activity(ObjectId).
940+
*
941+
* @apiSuccess {Date} startTime The startTime of the activity.
942+
* @apiSuccess {Number} duration The duration of the activity (in minutes).
943+
* @apiSuccess {ObjectId} course The course of the activity (ObjectId).
944+
* @apiSuccess {ObjectId} faculty The faculty alloted for the activity(ObjectId).
945+
* @apiSuccess {String} type The type of activity.One of possible LECTURE, PRACTICAL, TUTORIAL.
946+
* @apiSuccess {ObjectId} task The task of the activity (ObjectId).One of possible Topic,Practical,Tutorial.
947+
* @apiSuccess {ObjectId} group The group of the activity (ObjectId).
948+
* @apiSucess {ObjectId} students the students who gonna attend the activity(ObjectId).
949+
*/

app.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { logger } from "#util";
88
import indexRouter from "#routes/index";
99
import usersRouter from "#routes/users";
1010
import authRouter from "#routes/auth";
11+
import semesterRouter from "#routes/semester";
1112
import accreditationRouter from "#routes/accreditation";
1213
import infrastructureRouter from "#routes/infrastructure";
1314
import practicalRouter from "#routes/practical";
@@ -17,7 +18,10 @@ import tutorialRouter from "#routes/tutorial";
1718
import assignmentRouter from "#routes/assignment";
1819
import timetableRouter from "#routes/timetable";
1920
import courseworkRouter from "#routes/coursework";
21+
import activityRouter from "#routes/activity";
2022
import moduleRouter from "#routes/module";
23+
import facultyRouter from "#routes/faculty";
24+
import { identifyUser } from "#middleware/identifyUser";
2125
import departmentRouter from "#routes/department";
2226
import groupRouter from "#routes/group";
2327

@@ -48,12 +52,14 @@ app.use("/department", departmentRouter);
4852
app.use("/practical", practicalRouter);
4953
app.use("/organization", organizationRouter);
5054
app.use("/student", studentRouter);
55+
app.use("/activity", activityRouter);
5156
app.use("/tutorial", tutorialRouter);
5257
app.use("/assignment", assignmentRouter);
5358
app.use("/timetable", timetableRouter);
5459
app.use("/department", departmentRouter);
5560
app.use("/coursework", courseworkRouter);
5661
app.use("/module", moduleRouter);
5762
app.use("/group", groupRouter);
58-
63+
app.use("/semester", semesterRouter);
64+
app.use("/faculty", facultyRouter);
5965
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);

0 commit comments

Comments
 (0)