Skip to content

Commit c0ba710

Browse files
committed
fixed all eslint problems, testcase problems, and apidoc issues, and all merge conflicts
1 parent 7840828 commit c0ba710

24 files changed

+422
-337
lines changed

_apidoc.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,8 @@
320320
*
321321
* @apiBody {Number} no The number of tutorial.
322322
* @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-
323+
* @apiBody {Number} hours The hours required for tutorial.
324+
* @apiBody {String} cognitiveLevel The cognitiveLevel of tutorial.
326325
*
327326
* @apiSuccess {String} res Success message with the ID of the added tutorial.
328327
*
@@ -340,7 +339,6 @@
340339
* @apiQuery {String} [title] Title of Tutorial.
341340
* @apiQuery {Number} [hours] Hours required for Tutorial
342341
* @apiQuery {String} [cognitiveLevel] Level of Tutorial.
343-
344342
*
345343
* @apiSuccess {Tutorial[]} res Array of Filtered Tutorial Doc .
346344
* @apiSuccess {String} tutorial._id ID of document given by database.
@@ -401,7 +399,7 @@
401399
* @apiBody {Number} teaBreakDuration Duration of the tea break (in minutes).
402400
*
403401
* @apiSuccess {String} res Response message.
404-
* @apiError (Error 500) DatabaseError Error message if there was an error inserting into the database.
402+
* @apiError (Error 500) DatabaseError Error if there was an error inserting into the database.
405403
*
406404
* @apiSuccessExample Success-Response:
407405
* HTTP/1.1 200 OK
@@ -490,9 +488,9 @@
490488
* @apiSuccess {String} res updated infrastructure with id.
491489
* @apiError (Error 500) err Error while inserting in DB
492490
*/
493-
494-
//
495-
// Coursework.
491+
492+
// ------------------------------------------------------------------------------------------
493+
// Coursework
496494
// ------------------------------------------------------------------------------------------
497495

498496
/**
@@ -567,7 +565,8 @@
567565
* @apiBody {Number} [teaBreakDuration] Duration of tea break (in minutes).
568566
*
569567
* @apiSuccess {String} res Timetable updated.
570-
568+
*/
569+
571570
/**
572571
* @api {post} /coursework/update Update Coursework
573572
* @apiName UpdateCoursework
@@ -613,7 +612,8 @@
613612
* @apiSuccess {Number} timetable.lunchBreakDuration Duration of the lunch break (in minutes).
614613
* @apiSuccess {String} timetable.teaBreakStartTime Start time of the tea break.
615614
* @apiSuccess {Number} timetable.teaBreakDuration Duration of the tea break (in minutes).
616-
615+
*/
616+
617617
/**
618618
* @api {get} /coursework/list Get Coursework List
619619
* @apiName GetCourseworkList
@@ -652,7 +652,8 @@
652652
* @apiQuery {String} [outcome] Module outcome.
653653
* @apiQuery {String[]} [contents] Array of contents of the module.
654654
* @apiQuery {Number} [hrsPerModule] Number of hours required per module.
655-
* @apiQuery {String[]} [cognitiveLevels] Array of cognitive levels of attainment as per Bloom's Taxanomy (L1-L6).
655+
* @apiQuery {String[]} [cognitiveLevels] Array of cognitive levels
656+
* of attainment as per Bloom's Taxanomy (L1-L6).
656657
*
657658
* @apiSuccess {module[]} res Array of Filtered module Doc.
658659
* @apiSuccess {String} module._id ID of document given by database.
@@ -661,5 +662,6 @@
661662
* @apiSuccess {String} module.outcome Module outcome.
662663
* @apiSuccess {String[]} module.contents Array of contents of the module.
663664
* @apiSuccess {Number} module.hrsPerModule Number of hours required per module.
664-
* @apiSuccess {String[]} module.cognitiveLevels Array of cognitive levels of attainment as per Bloom's Taxanomy (L1-L6).
665+
* @apiSuccess {String[]} module.cognitiveLevels Array of cognitive levels of
666+
* attainment as per Bloom's Taxanomy (L1-L6).
665667
*/

controller/auth.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ async function login(req, res) {
2828
}
2929

3030
function validateUser(req, res) {
31-
if(req.user){
32-
res.json({ res: req.user, msg: "user validated", err: null });
33-
}
34-
else{
35-
res.status(401).json({res:null, msg:"unauthorised", err:"User not authorised"})
36-
}
31+
if (req.user) {
32+
res.json({ res: req.user, msg: "user validated", err: null });
33+
} else {
34+
res.status(401).json({ res: null, msg: "unauthorised", err: "User not authorised" });
35+
}
3736
}
3837

3938
async function sendOTP(req, res) {

controller/department.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async function showdepartments(req, res) {
5959

6060
async function updatedDepartment(req, res) {
6161
const {
62-
id, data,
62+
id, ...data
6363
} = req.body;
6464
try {
6565
await updateDepartmentbyid(id, data);

controller/module.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getModule } from "#services/module";
1+
import { getModule, addNewModule } from "#services/module";
22
import { logger } from "#util";
33

44
async function showModule(req, res) {
@@ -12,6 +12,20 @@ async function showModule(req, res) {
1212
}
1313
}
1414

15-
export default {
16-
showModule,
15+
async function addModule(req, res) {
16+
const {
17+
no, name, outcome, contents, hrsPerModule, cognitiveLevels,
18+
} = req.body;
19+
try {
20+
const newModule = await addNewModule(no, name, outcome, contents, hrsPerModule, cognitiveLevels);
21+
res.json({ res: `added module ${newModule.name}` });
22+
} catch (error) {
23+
logger.error("Error while inserting", error);
24+
res.status(500);
25+
res.json({ err: "Error while inserting in DB" });
26+
}
1727
}
28+
29+
export default {
30+
showModule, addModule
31+
};

controller/organization.js

Lines changed: 54 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,59 @@
11
import {
2-
addNewOrganization, deleteOrganizationById, updateOrganizationById, getOrganizations,
3-
} from "#services/organization";
4-
import { logger } from "#util";
5-
6-
async function addOrganization(req, res) {
7-
const {
8-
parent, startDate, name, accreditation,
9-
} = req.body;
10-
try {
11-
const organization = await addNewOrganization( parent, startDate, name, accreditation,);
12-
res.json({ res: `added organization${organization.name}` });
13-
} catch (error) {
14-
logger.error("Error while inserting", error);
15-
res.status(500);
16-
res.json({ err: "Error while inserting in DB" });
17-
}
2+
addNewOrganization, deleteOrganizationById, updateOrganizationById, getOrganizations,
3+
} from "#services/organization";
4+
import { logger } from "#util";
5+
6+
async function addOrganization(req, res) {
7+
const {
8+
parent, startDate, name, accreditation,
9+
} = req.body;
10+
try {
11+
const organization = await addNewOrganization(parent, startDate, name, accreditation);
12+
res.json({ res: `added organization${organization.name}` });
13+
} catch (error) {
14+
logger.error("Error while inserting", error);
15+
res.status(500);
16+
res.json({ err: "Error while inserting in DB" });
1817
}
19-
async function deleteOrganization(req, res) {
20-
const { organizationId } = req.params;
21-
try {
22-
await deleteOrganizationById(organizationId);
23-
res.json({ res: "Organization deleted successfully" });
24-
} catch (error) {
25-
logger.error("Error while deleting", error);
26-
res.status(500);
27-
res.json({ err: "Error while deleting from DB" });
28-
}
18+
}
19+
async function deleteOrganization(req, res) {
20+
const { organizationId } = req.params;
21+
try {
22+
await deleteOrganizationById(organizationId);
23+
res.json({ res: "Organization deleted successfully" });
24+
} catch (error) {
25+
logger.error("Error while deleting", error);
26+
res.status(500);
27+
res.json({ err: "Error while deleting from DB" });
2928
}
30-
31-
async function updateOrganization(req, res) {
32-
const {
33-
id, ...data
34-
} = req.body;
35-
36-
try {
37-
await updateOrganizationById(id, data);
38-
res.json({ res: "organization updated" });
39-
} catch (error) {
40-
logger.error("Error while inserting", error);
41-
res.status(500);
42-
res.json({ err: "Error while inserting in DB" });
43-
}
29+
}
30+
31+
async function updateOrganization(req, res) {
32+
const {
33+
id, ...data
34+
} = req.body;
35+
36+
try {
37+
await updateOrganizationById(id, data);
38+
res.json({ res: "organization updated" });
39+
} catch (error) {
40+
logger.error("Error while inserting", error);
41+
res.status(500);
42+
res.json({ err: "Error while inserting in DB" });
4443
}
45-
46-
async function showOrganization(req, res) {
47-
try {
48-
const organization = await getOrganizations(req.query);
49-
return res.json({ res: organization });
50-
} catch (error) {
51-
logger.error("Error while fetching", error);
52-
res.status(500);
53-
return res.json({ err: "Error while fetching the data" });
54-
}
44+
}
45+
46+
async function showOrganization(req, res) {
47+
try {
48+
const organization = await getOrganizations(req.query);
49+
return res.json({ res: organization });
50+
} catch (error) {
51+
logger.error("Error while fetching", error);
52+
res.status(500);
53+
return res.json({ err: "Error while fetching the data" });
5554
}
56-
57-
export default {
58-
addOrganization, updateOrganization, deleteOrganization, showOrganization,
59-
};
60-
55+
}
56+
57+
export default {
58+
addOrganization, updateOrganization, deleteOrganization, showOrganization,
59+
};

controller/practical.js

Lines changed: 61 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,67 @@
11
// Import Practical-related services and utilities
22
import {
3-
createPractical,
4-
deletePracticalById,
5-
listPractical,
6-
updatePracticalById,
7-
} from "#services/practical";
8-
9-
import { logger } from "#util"; // Import the logger utility
10-
11-
// Controller function to add a new Practical entity
12-
async function addPractical(req, res) {
13-
const {
3+
createPractical,
4+
deletePracticalById,
5+
listPractical,
6+
updatePracticalById,
7+
} from "#services/practical";
8+
9+
import { logger } from "#util"; // Import the logger utility
10+
11+
// Controller function to add a new Practical entity
12+
async function addPractical(req, res) {
13+
const {
14+
no, title, type, hours, cognitiveLevels,
15+
} = req.body;
16+
try {
17+
const newPractical = await createPractical({
1418
no, title, type, hours, cognitiveLevels,
15-
} = req.body;
16-
try {
17-
const newPractical = await createPractical({
18-
no, title, type, hours, cognitiveLevels,
19-
});
20-
res.json({ res: `Added Practical with ID ${newPractical.id}` });
21-
} catch (error) {
22-
logger.error("Error while inserting Practical", error);
23-
res.status(500);
24-
res.json({ err: "Error while inserting Practical in DB" });
25-
}
19+
});
20+
res.json({ res: `Added Practical with ID ${newPractical.id}` });
21+
} catch (error) {
22+
logger.error("Error while inserting Practical", error);
23+
res.status(500);
24+
res.json({ err: "Error while inserting Practical in DB" });
2625
}
27-
28-
// Controller function to update a Practical entity
29-
async function updatePractical(req, res) {
30-
const {
31-
id, ...data
32-
} = req.body;
33-
try {
34-
await updatePracticalById(id, data);
35-
res.json({ res: `Updated Practical with ID ${id}` });
36-
} catch (error) {
37-
logger.error("Error while updating Practical", error);
38-
res.status(500);
39-
res.json({ err: "Error while updating Practical in DB" });
40-
}
26+
}
27+
28+
// Controller function to update a Practical entity
29+
async function updatePractical(req, res) {
30+
const {
31+
id, ...data
32+
} = req.body;
33+
try {
34+
await updatePracticalById(id, data);
35+
res.json({ res: `Updated Practical with ID ${id}` });
36+
} catch (error) {
37+
logger.error("Error while updating Practical", error);
38+
res.status(500);
39+
res.json({ err: "Error while updating Practical in DB" });
4140
}
42-
43-
// Controller function to get a list of Practical entities
44-
async function getPractical(req, res) {
45-
const filter = req.query;
46-
const practicalList = await listPractical(filter);
47-
res.json({ res: practicalList });
41+
}
42+
43+
// Controller function to get a list of Practical entities
44+
async function getPractical(req, res) {
45+
const filter = req.query;
46+
const practicalList = await listPractical(filter);
47+
res.json({ res: practicalList });
48+
}
49+
50+
// Controller function to delete a Practical entity
51+
async function deletePractical(req, res) {
52+
const { practicalId } = req.params;
53+
try {
54+
await deletePracticalById(practicalId);
55+
res.json({ res: `Deleted Practical with ID ${practicalId}` });
56+
} catch (error) {
57+
logger.error("Error while deleting Practical", error);
58+
res.status(500).json({ error: "Error while deleting Practical from DB" });
4859
}
49-
50-
// Controller function to delete a Practical entity
51-
async function deletePractical(req, res) {
52-
const { practicalId } = req.params;
53-
try {
54-
await deletePracticalById(practicalId);
55-
res.json({ res: `Deleted Practical with ID ${practicalId}` });
56-
} catch (error) {
57-
logger.error("Error while deleting Practical", error);
58-
res.status(500).json({ error: "Error while deleting Practical from DB" });
59-
}
60-
}
61-
62-
export default {
63-
addPractical,
64-
deletePractical,
65-
getPractical,
66-
updatePractical,
67-
};
68-
60+
}
61+
62+
export default {
63+
addPractical,
64+
deletePractical,
65+
getPractical,
66+
updatePractical,
67+
};

0 commit comments

Comments
 (0)