Skip to content

Commit 2a0b1d5

Browse files
Merge branch 'development' into 258-endpoints-from-pracs
2 parents ac21383 + c4ef262 commit 2a0b1d5

26 files changed

+1620
-398
lines changed

_apidoc.js

Lines changed: 241 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,8 +309,189 @@
309309
* @apiSuccess {Date} accreditation.dateofAccreditation Date on which accreditation was issued.
310310
* @apiSuccess {Date} accreditation.dateofExpiry Date till which accreditation is valid.
311311
*/
312+
//------------------------------------------------------------------------------------------
313+
// Tutorials.
314+
// ------------------------------------------------------------------------------------------
315+
316+
/**
317+
* @api {post} /tutorial/add Add Tutorial
318+
* @apiName AddTutorial
319+
* @apiGroup Tutorial
320+
*
321+
* @apiBody {Number} no The number of tutorial.
322+
* @apiBody {String} title The title of tutorial.
323+
* @apiBody {Number} hours The hours required for tutorial .
324+
* @apiBody {String} cognitiveLevel The cognitiveLvel of tutorial.
325+
326+
*
327+
* @apiSuccess {String} res Success message with the ID of the added tutorial.
328+
*
329+
* @apiError (Error 500) DatabaseError Error while inserting in the database.
330+
*
331+
* @apiDescription Adds a new tutorial to the system.
332+
*/
333+
334+
/**
335+
* @api {get} tutorial/list Get Tutorial List
336+
* @apiName GetTutorial
337+
* @apiGroup Tutorial
338+
*
339+
* @apiQuery {Number} [no] Number of Tutorial.
340+
* @apiQuery {String} [title] Title of Tutorial.
341+
* @apiQuery {Number} [hours] Hours required for Tutorial
342+
* @apiQuery {String} [cognitiveLevel] Level of Tutorial.
343+
344+
*
345+
* @apiSuccess {Tutorial[]} res Array of Filtered Tutorial Doc .
346+
* @apiSuccess {String} tutorial._id ID of document given by database.
347+
* @apiSuccess {Number} tutorial.no Number of Tutorial.
348+
* @apiSuccess {String} tutorial.title Title of Tutorial.
349+
* @apiSuccess {String} tutorial.hours Hours of Tutorial.
350+
* @apiSuccess {Number} tutorial.cognitiveLevel CognitiveLevel of Tutorial.
351+
*/
352+
353+
/**
354+
* @api {delete} /tutorial/delete/:tutorialId Delete Tutorial
355+
* @apiName DeleteTutorial,
356+
* @apiGroup Tutorial
357+
*
358+
* @apiParam {String} tutorialId The ID of the tutorial document to delete.
359+
*
360+
* @apiSuccess {String} res Success message indicating the deletion.
361+
*
362+
* @apiError (Error 500) err Error message if there was an error during the deletion.
363+
*
364+
* */
365+
/**
366+
* @api {post} /tutorial/update Update tutorial details
367+
* @apiName UpdateTutorial
368+
* @apiGroup Tutorial
369+
* @apiDescription update Existing Tutorial details
370+
*
371+
* @apiBody {String} id Id of the tutorial to be updated
372+
* @apiBody {Number} [no] The no of tutorial.
373+
* @apiBody {String} [title] The title of tutorial.
374+
* @apiBody {String} [hours] The hours required for the tutorial.
375+
* @apiBody {Number} [cognitiveLevel] The cognitiveLevel of tutorial.
376+
377+
*
378+
* @apiSuccess {String} res tutorial updated.
379+
* @apiError (Error 500) err Error in updating database
380+
*
381+
*/
312382

313383
// ------------------------------------------------------------------------------------------
384+
// Timetable.
385+
// ------------------------------------------------------------------------------------------
386+
387+
/**
388+
* @api {post} /timetable/add Add Timetable
389+
* @apiName AddTimetable
390+
* @apiGroup Timetable
391+
* @apiDescription Add a new timetable entry.
392+
*
393+
* @apiBody {Date} startDate Start date of the timetable.
394+
* @apiBody {Date} endDate End date of the timetable.
395+
* @apiBody {ObjectId} classIncharge ID of the faculty in charge (ObjectId).
396+
* @apiBody {ObjectId} group ID of the group (ObjectId).
397+
* @apiBody {ObjectId} activityBlueprints ID of the activity blueprint (ObjectId).
398+
* @apiBody {String} lunchBreakStartTime Start time of the lunch break.
399+
* @apiBody {Number} lunchBreakDuration Duration of the lunch break (in minutes).
400+
* @apiBody {String} teaBreakStartTime Start time of the tea break.
401+
* @apiBody {Number} teaBreakDuration Duration of the tea break (in minutes).
402+
*
403+
* @apiSuccess {String} res Response message.
404+
* @apiError (Error 500) DatabaseError Error message if there was an error inserting into the database.
405+
*
406+
* @apiSuccessExample Success-Response:
407+
* HTTP/1.1 200 OK
408+
* {
409+
* "res": "Added timetable for <startDate> - <endDate>"
410+
* }
411+
*
412+
* @apiErrorExample Error-Response:
413+
* HTTP/1.1 500 Internal Server Error
414+
* {
415+
* "err": "Error while inserting in DB"
416+
* }
417+
*/
418+
419+
// ------------------------------------------------------------------------------------------
420+
// Department.
421+
// ------------------------------------------------------------------------------------------
422+
423+
/**
424+
* @api {post} /department/create Create Deapartment
425+
* @apiName AddDepartment
426+
* @apiDescription Adds a new Department.
427+
* @apiGroup Department
428+
*
429+
* @apiBody {String} name The name of the Department.
430+
* @apiBody {String} acronym The acronym of the Department.
431+
* @apiBody {Date} yearOfStarting The year of establishment of the Department.
432+
* @apiBody {connector.Schema.Types.ObjectId} accreditations The accreditation which is associated.
433+
* @apiBody {connector.Schema.Types.ObjectId} infrastructure The infrastructure which is associated.
434+
*
435+
* @apiSuccess {String} res added Department successfully.
436+
*
437+
* @apiError (Error 500) DatabaseError Error while inserting in the DB.
438+
*
439+
*/
440+
441+
/**
442+
* @api {get} Department/list Listdown Department
443+
* @apiName GetDepartment
444+
* @apiDescription Listdown the Department.
445+
* @apiGroup Department
446+
*
447+
* @apiBody {String} [name] The name of the Department.
448+
* @apiBody {String} [acronym] The acronym of the Department.
449+
* @apiBody {Date} [yearOfStarting] The year of establishment of the Department.
450+
* @apiBody {connector.Schema.Types.ObjectId} [accreditations] Accreditation which is associated.
451+
* @apiBody {connector.Schema.Types.ObjectId} [infrastructure] Infrastructure which is associated.
452+
*
453+
* @apiSuccess {Department[]} res Array of Filtered Department Doc .
454+
* @apiSuccess {String} department._id ID of document given by database.
455+
* @apiSuccess {String} department.name Name of Infrastructure
456+
* @apiSuccess {String} department.acronym The acronym of the Department.
457+
* @apiSuccess {Date} department.yearOfStarting The year of establishment of the Department.
458+
* @apiSuccess {connector.Schema.Types.ObjectId} department.accreditations associated Accreditation.
459+
* @apiSuccess {connector.Schema.Types.ObjectId} department.infrastructure associatedInfrastructure.
460+
* @apiError (Error 500) err Error while fetching the data.
461+
*/
462+
463+
/**
464+
* @api {delete} /department/delete/:departmentId Delete Department
465+
* @apiName DeleteDepartment
466+
* @apiDescription Remove the existing Department.
467+
* @apiGroup Department
468+
*
469+
* @apiParam {String} departmentId The ID of the department document to delete.
470+
*
471+
* @apiSuccess {String} res "Department deleted successfully.
472+
*
473+
* @apiError (Error 500) err Error while deleting from DB.
474+
*
475+
* */
476+
477+
/**
478+
* @api {post} /department/update Update department
479+
* @apiName UpdateDepartment
480+
* @apiGroup Department
481+
* @apiDescription Update Existing Department details except [yearOfStarting],[acronym]
482+
*
483+
* @apiSuccess {String} department._id ID of document given by database.
484+
* @apiSuccess {String} department.name Name of Infrastructure
485+
* @apiSuccess {String} department.acronym The acronym of the Department.
486+
* @apiSuccess {Date} department.yearOfStarting The year of establishment of the Department.
487+
* @apiSuccess {connector.Schema.Types.ObjectId} department.accreditations associated Accreditation.
488+
* @apiSuccess {connector.Schema.Types.ObjectId} department.infrastructure associatedInfrastructure.
489+
*
490+
* @apiSuccess {String} res updated infrastructure with id.
491+
* @apiError (Error 500) err Error while inserting in DB
492+
*/
493+
494+
//
314495
// Coursework.
315496
// ------------------------------------------------------------------------------------------
316497

@@ -344,6 +525,18 @@
344525
* }
345526
*/
346527

528+
/**
529+
* @api {delete} /timetable/delete/:timetableId Delete Timetable
530+
* @apiName DeleteTimetable
531+
* @apiGroup Timetable
532+
*
533+
* @apiParam {String} timetableId The ID of the timetable document to delete.
534+
*
535+
* @apiSuccess {String} res Success message indicating the deletion.
536+
*
537+
* @apiError (Error 500) DatabaseError Error message if there was an error during the deletion.
538+
*/
539+
347540
/**
348541
* @api {delete} /coursework/delete/:courseworkId Delete Coursework
349542
* @apiName DeleteCoursework
@@ -356,6 +549,25 @@
356549
* @apiError (Error 500) DatabaseError Error message if there was an error during the deletion.
357550
*/
358551

552+
/**
553+
* @api {post} /timetable/update Update Timetable
554+
* @apiName UpdateTimetable
555+
* @apiGroup Timetable
556+
* @apiDescription Update existing timetable data.
557+
*
558+
* @apiBody {String} id ID of the timetable to be updated.
559+
* @apiBody {Date} [startDate] Start date of the timetable.
560+
* @apiBody {Date} [endDate] End date of the timetable.
561+
* @apiBody {ObjectId} [classIncharge] ID of the faculty in charge (ObjectId).
562+
* @apiBody {ObjectId} [group] ID of the group (ObjectId).
563+
* @apiBody {ObjectId} [activityBlueprints] ID of activity blueprint (ObjectId).
564+
* @apiBody {String} [lunchBreakStartTime] Start time of the lunch break.
565+
* @apiBody {Number} [lunchBreakDuration] Duration of lunch break (in minutes).
566+
* @apiBody {String} [teaBreakStartTime] Start time of tea break.
567+
* @apiBody {Number} [teaBreakDuration] Duration of tea break (in minutes).
568+
*
569+
* @apiSuccess {String} res Timetable updated.
570+
359571
/**
360572
* @api {post} /coursework/update Update Coursework
361573
* @apiName UpdateCoursework
@@ -375,6 +587,33 @@
375587
* @apiError (Error 500) DatabaseError Error in updating the database.
376588
*/
377589

590+
/**
591+
* @api {get} /timetable/list Get Timetable List
592+
* @apiName GetTimetableList
593+
* @apiGroup Timetable
594+
*
595+
* @apiQuery {Date} [startDate] Start date of the timetable.
596+
* @apiQuery {Date} [endDate] End date of the timetable.
597+
* @apiQuery {ObjectId} [classIncharge] ID of the faculty in charge (ObjectId).
598+
* @apiQuery {ObjectId} [group] ID of the group (ObjectId).
599+
* @apiQuery {ObjectId} [activityBlueprints] ID of the activity blueprint (ObjectId).
600+
* @apiQuery {String} [lunchBreakStartTime] Start time of the lunch break.
601+
* @apiQuery {Number} [lunchBreakDuration] Duration of the lunch break (in minutes).
602+
* @apiQuery {String} [lunchBreakStartTime] Start time of the lunch break.
603+
* @apiQuery {Number} [lunchBreakDuration] Duration of the lunch break (in minutes).
604+
*
605+
* @apiSuccess {Timetable[]} res Array of filtered timetable documents.
606+
* @apiSuccess {String} timetable._id ID of the timetable document given by the database.
607+
* @apiSuccess {Date} timetable.startDate Start date of the timetable.
608+
* @apiSuccess {Date} timetable.endDate End date of the timetable.
609+
* @apiSuccess {ObjectId} timetable.classIncharge ID of the faculty in charge (ObjectId).
610+
* @apiSuccess {ObjectId} timetable.group ID of the group (ObjectId).
611+
* @apiSuccess {ObjectId} timetable.activityBlueprints ID of the activity blueprint (ObjectId).
612+
* @apiSuccess {String} timetable.lunchBreakStartTime Start time of the lunch break.
613+
* @apiSuccess {Number} timetable.lunchBreakDuration Duration of the lunch break (in minutes).
614+
* @apiSuccess {String} timetable.teaBreakStartTime Start time of the tea break.
615+
* @apiSuccess {Number} timetable.teaBreakDuration Duration of the tea break (in minutes).
616+
378617
/**
379618
* @api {get} /coursework/list Get Coursework List
380619
* @apiName GetCourseworkList
@@ -398,7 +637,8 @@
398637
* @apiSuccess {ObjectId} coursework.activity Id of the activity in Coursework.
399638
* @apiSuccess {Number} coursework.marks Marks in the Coursework.
400639
*/
401-
=======
640+
641+
// ------------------------------------------------------------------------------------------
402642
// Module.
403643
// ------------------------------------------------------------------------------------------
404644

app.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@ import authRouter from "#routes/auth";
1111
import accreditationRouter from "#routes/accreditation";
1212
import infrastructureRouter from "#routes/infrastructure";
1313
import practicalRouter from "#routes/practical";
14+
import organizationRouter from "#routes/organization";
15+
import studentRouter from "#routes/student";
16+
import tutorialRouter from "#routes/tutorial";
17+
import assignmentRouter from "#routes/assignment";
18+
import timetableRouter from "#routes/timetable";
1419
import courseworkRouter from "#routes/coursework";
1520
import moduleRouter from "#routes/module";
1621
import { identifyUser } from "#middleware/identifyUser";
22+
import departmentRouter from "#routes/department";
1723

1824

1925
const app = express();
@@ -38,6 +44,12 @@ app.use("/auth", authRouter);
3844
app.use("/accreditation", accreditationRouter);
3945
app.use("/infrastructure", infrastructureRouter);
4046
app.use("/practical", practicalRouter);
47+
app.use("/organization", organizationRouter);
48+
app.use("/student", studentRouter);
49+
app.use("/tutorial", tutorialRouter);
50+
app.use("/assignment", assignmentRouter);
51+
app.use("/timetable", timetableRouter);
52+
app.use("/department", departmentRouter);
4153
app.use("/coursework", courseworkRouter);
4254
app.use("/module", moduleRouter);
4355

controller/assignment.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import {
2+
createAssignment, deleteAssignmentById, assignmentList, updateAssignmentById,
3+
} from "#services/assignment";
4+
import { logger } from "#util";
5+
6+
async function addAssignment(req, res) {
7+
const {
8+
no, title, type, marks,
9+
} = req.body;
10+
try {
11+
const newAssignment = await createAssignment(no, title, type, marks);
12+
res.json({ res: `added user ${newAssignment.id}` });
13+
} catch (error) {
14+
logger.error("Error while inserting", error);
15+
res.status(500);
16+
res.json({ err: "Error while inserting in DB" });
17+
}
18+
}
19+
20+
async function updateAssignment(req, res) {
21+
const {
22+
id, ...data
23+
} = req.body;
24+
try {
25+
await updateAssignmentById(id, data);
26+
res.json({ res: `updated assignment with id ${id}` });
27+
} catch (error) {
28+
logger.error("Error while updating", error);
29+
res.status(500);
30+
res.json({ err: "Error while updaing in DB" });
31+
}
32+
}
33+
34+
async function getAssignment(req, res) {
35+
const filter = req.query;
36+
const assingmentlist = await assignmentList(filter);
37+
res.json({ res: assingmentlist });
38+
}
39+
40+
async function deleteAssignment(req, res) {
41+
const { assignmentId } = req.params;
42+
try {
43+
await deleteAssignmentById(assignmentId);
44+
45+
res.json({ res: `Deleted assignment with ID ${assignmentId}` });
46+
} catch (error) {
47+
logger.error("Error while deleting", error);
48+
res.status(500).json({ error: "Error while deleting from DB" });
49+
}
50+
}
51+
export default {
52+
addAssignment, deleteAssignment, getAssignment, updateAssignment,
53+
};

0 commit comments

Comments
 (0)