Skip to content

Commit 65ebad8

Browse files
fixed eslint + fixed merge conflict
209 model for activity
2 parents 06e07d1 + caf7403 commit 65ebad8

File tree

10 files changed

+89
-67
lines changed

10 files changed

+89
-67
lines changed

models/activity.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import connector from "#models/databaseUtil";
2+
3+
const activitySchema = {
4+
activityBlueprint: { type: connector.Schema.Types.ObjectId, ref: "ActivityBlueprint", required: true },
5+
startTime: { type: Date, required: true },
6+
duration: { type: Number, required: true },
7+
course: { type: connector.Schema.Types.ObjectId, ref: "Course", required: true },
8+
faculty: { type: connector.Schema.Types.ObjectId, ref: "Faculty", required: true },
9+
type: {
10+
type: String,
11+
required: true,
12+
enum: ["LECTURE", "PRACTICAL", "TUTORIAL"],
13+
},
14+
task: [{
15+
type: connector.Schema.Types.ObjectId,
16+
ref: ["Topic", "Practical", "Tutorial"],
17+
required: true,
18+
}],
19+
group: { type: connector.Schema.Types.ObjectId, ref: "Group", required: true },
20+
students: [{ type: connector.Schema.Types.ObjectId, ref: "Student", required: true }],
21+
};
22+
23+
// eslint-disable-next-line no-unused-vars
24+
const Activity = connector.model("Activity", activitySchema);

models/activityBlueprint.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
import connector from "#models/databaseUtil"
1+
import connector from "#models/databaseUtil";
22

33
const activityBluePrintSchema = {
4-
number : { type: Number, required: true },
5-
academicYearYear: {
6-
type: String,
7-
required: true,
8-
validate: {
9-
validator: function(value) {
10-
return /^2\d{3}$/.test(value); // Matches "2" followed by any 3 digits
11-
},
12-
message: props => `${props.value} is not a valid year format starting with "2"!`
13-
}
14-
},
15-
type : { enum : ['ODD', 'EVEN'] , required : true},
16-
startDate: {type : Date, required : true},
17-
endDate : {type : Date, required : true}
18-
}
4+
number: { type: Number, required: true },
5+
academicYearYear: {
6+
type: String,
7+
required: true,
8+
validate: {
9+
validator: (value) => /^2\d{3}$/.test(value),
10+
message: (props) => `${props.value} is not a valid year format starting with "2"!`,
11+
},
12+
},
13+
type: { enum: ["ODD", "EVEN"], required: true },
14+
startDate: { type: Date, required: true },
15+
endDate: { type: Date, required: true },
16+
};
1917

20-
const ActivityBlueprint = connector.model("ActivityBlueprint", activityBluePrintSchema);
18+
// eslint-disable-next-line no-unused-vars
19+
const ActivityBlueprint = connector.model("ActivityBlueprint", activityBluePrintSchema);

models/assignment.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async function read(filter, limit = 1) {
2323
return assignmentDoc;
2424
}
2525

26-
async function update(filter, updateObject, options = {multi: true}) {
26+
async function update(filter, updateObject, options = { multi: true }) {
2727
const updateResult = await Assignment.updateMany(filter, { $set: updateObject }, options);
2828
return updateResult.acknowledged;
2929
}
@@ -39,4 +39,3 @@ export default {
3939
update,
4040
remove,
4141
};
42-

models/coursework.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import connector from "#models/databaseUtil";
22

33
const courseworkSchema = {
4-
student: { type: mongoose.Schema.Types.ObjectId, ref: 'Student', required: true},
5-
type:{type : String , enum : ['onCampus','offCampus'], required: true},
6-
course:{type:mongoose.Schema.Types.ObjectId, ref: 'Course', required:true},
7-
task: {type: mongoose.Schema.Types.ObjectId, refPath: 'objectID', required: true },
8-
objectID: {type: String, enum: ['Practical', 'Tutorial', 'Assignment'], required: true},
9-
activity:{type:mongoose.Schema.Types.ObjectId, ref: 'Activity',required:true},
10-
marks: {type: Number, required: true},
4+
student: { type: connector.Schema.Types.ObjectId, ref: "Student", required: true },
5+
type: { type: String, enum: ["onCampus", "offCampus"], required: true },
6+
course: { type: connector.Schema.Types.ObjectId, ref: "Course", required: true },
7+
task: { type: connector.Schema.Types.ObjectId, refPath: "objectID", required: true },
8+
objectID: { type: String, enum: ["Practical", "Tutorial", "Assignment"], required: true },
9+
activity: { type: connector.Schema.Types.ObjectId, ref: "Activity", required: true },
10+
marks: { type: Number, required: true },
1111
};
12-
const Coursework = connector.model('Coursework', courseworkSchema);
1312

14-
module.exports = Coursework;
13+
// eslint-disable-next-line no-unused-vars
14+
const Coursework = connector.model("Coursework", courseworkSchema);

models/exam.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ export default {
3737
read,
3838
update,
3939
remove,
40-
};
40+
};

models/paper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ const paperSchema = {
88
mark: { type: Number, required: true },
99
};
1010

11+
// eslint-disable-next-line no-unused-vars
1112
const Paper = connector.model("Paper", paperSchema);

models/practical.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const practicalSchema = {
1515
// eslint-disable-next-line no-unused-vars
1616
const Practical = connector.model("Practical", practicalSchema);
1717

18-
//CRUD operations
18+
// CRUD operations
1919
async function remove(filter) {
2020
const deleteResult = await Practical.deleteMany(filter);
2121
return deleteResult.acknowledged;
@@ -48,4 +48,4 @@ async function update(filter, updateObject, options = { multi: true }) {
4848

4949
export default {
5050
create, read, update, remove,
51-
};
51+
};

models/topic.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ const topicSchema = {
44
title: { type: String, required: true },
55
};
66
// eslint-disable-next-line no-unused-vars
7-
const Topic = connector.model("topic", topicSchema);
7+
const Topic = connector.model("Topic", topicSchema);
88

9-
//CURD operations
9+
// CURD operations
1010
async function create(topicData) {
11-
const{
12-
title
13-
}=topicData;
11+
const {
12+
title,
13+
} = topicData;
1414
const topic = new Topic({
1515
title,
1616
});

models/tutorial.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,3 @@ export default {
4848
update,
4949
remove,
5050
};
51-

test/routes/accreditation.test.js

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
import request from 'supertest';
2-
import { jest } from '@jest/globals'; // eslint-disable-line import/no-extraneous-dependencies
3-
import app from '#app';
4-
import accreditationModel from '#models/accreditation';
5-
import connector from '#models/databaseUtil';
1+
import request from "supertest";
2+
import { jest } from "@jest/globals"; // eslint-disable-line import/no-extraneous-dependencies
3+
import app from "#app";
4+
import accreditationModel from "#models/accreditation";
5+
import connector from "#models/databaseUtil";
66

7-
jest.mock('#util');
7+
jest.mock("#util");
88

99
let server;
1010
let agent;
1111
beforeAll((done) => {
1212
server = app.listen(5000, () => {
1313
agent = request.agent(server);
14-
connector.set('debug', false);
14+
connector.set("debug", false);
1515
done();
1616
});
1717
});
1818

1919
function cleanUp(callback) {
20-
accreditationModel.remove({ name: 'xyz' }).then(() => {
20+
accreditationModel.remove({ name: "xyz" }).then(() => {
2121
connector.disconnect((DBerr) => {
22-
if (DBerr) console.log('Database dissconnnect error: ', DBerr);
22+
if (DBerr) console.log("Database dissconnnect error: ", DBerr);
2323
server.close((serverErr) => {
2424
if (serverErr) console.log(serverErr);
2525
callback();
@@ -32,44 +32,44 @@ afterAll((done) => {
3232
cleanUp(done);
3333
});
3434

35-
describe('checking accreditation functions', () => {
36-
it('create accreditation', async () => {
37-
const response = await agent.post('/accreditation/add').send({
38-
name: 'xyz',
39-
agencyName: 'abc',
40-
dateofAccreditation: '2023-06-18T14:11:30Z',
41-
dateofExpiry: '2023-05-28T14:10:30Z',
35+
describe("checking accreditation functions", () => {
36+
it("create accreditation", async () => {
37+
const response = await agent.post("/accreditation/add").send({
38+
name: "xyz",
39+
agencyName: "abc",
40+
dateofAccreditation: "2023-06-18T14:11:30Z",
41+
dateofExpiry: "2023-05-28T14:10:30Z",
4242
});
43-
expect(response.headers['content-type']).toMatch(/json/);
43+
expect(response.headers["content-type"]).toMatch(/json/);
4444
expect(response.status).toBe(200);
4545
expect(response.body.res).toMatch(/added accreditation/);
4646
});
4747

4848
beforeEach(async () => {
49-
agent.post('/accreditation/add').send({
50-
name: 'xyz',
51-
agencyName: 'abc',
52-
dateofAccreditation: '2023-06-18T14:11:30Z',
53-
dateofExpiry: '2023-05-28T14:10:30Z',
49+
agent.post("/accreditation/add").send({
50+
name: "xyz",
51+
agencyName: "abc",
52+
dateofAccreditation: "2023-06-18T14:11:30Z",
53+
dateofExpiry: "2023-05-28T14:10:30Z",
5454
});
5555
});
5656

5757
afterEach(async () => {
58-
await accreditationModel.remove({ name: 'xyz' });
58+
await accreditationModel.remove({ name: "xyz" });
5959
});
6060

61-
it('read accreditation', async () => {
61+
it("read accreditation", async () => {
6262
const response = await agent
63-
.post('/accreditation/list')
64-
.send({ name: 'xyz' });
63+
.post("/accreditation/list")
64+
.send({ name: "xyz" });
6565
expect(response.body.res).not.toBeNull();
6666
});
6767

68-
it('update accreditation', async () => {
68+
it("update accreditation", async () => {
6969
const response = await agent
70-
.post('/accreditation/update')
71-
.send({ name: 'xyz' }, { name: '123' });
72-
expect(response.headers['content-type']).toMatch(/json/);
70+
.post("/accreditation/update")
71+
.send({ name: "xyz" }, { name: "123" });
72+
expect(response.headers["content-type"]).toMatch(/json/);
7373
expect(response.status).toBe(200);
7474
expect(response.body.res).toMatch(/accreditation updated/);
7575
});

0 commit comments

Comments
 (0)