@neutron.co.id/pendidikan-operation 1.27.2 → 1.27.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/actions/akademik/studentReport/syncStudentReport.action.cjs +24 -17
- package/build/actions/akademik/studentReport/syncStudentReport.action.mjs +24 -17
- package/build/actions/jadwal/index.d.ts +1 -0
- package/build/actions/jadwal/setAksesModulSiswaDiClassGroup/index.d.ts +2 -0
- package/build/actions/jadwal/setAksesModulSiswaDiClassGroup/setAksesModulSiswaDiClassGroup.action.cjs +154 -0
- package/build/actions/jadwal/setAksesModulSiswaDiClassGroup/setAksesModulSiswaDiClassGroup.action.d.ts +16 -0
- package/build/actions/jadwal/setAksesModulSiswaDiClassGroup/setAksesModulSiswaDiClassGroup.action.mjs +152 -0
- package/build/actions/jadwal/setAksesModulSiswaDiClassGroup/setAksesModulSiswaDiClassGroup.schema.cjs +17 -0
- package/build/actions/jadwal/setAksesModulSiswaDiClassGroup/setAksesModulSiswaDiClassGroup.schema.d.ts +14 -0
- package/build/actions/jadwal/setAksesModulSiswaDiClassGroup/setAksesModulSiswaDiClassGroup.schema.mjs +15 -0
- package/build/index.cjs +5 -0
- package/build/index.d.ts +5 -0
- package/build/index.mjs +4 -1
- package/package.json +8 -8
|
@@ -18,8 +18,8 @@ const syncStudentReport = operation.Action.define({
|
|
|
18
18
|
const sessionIds = [];
|
|
19
19
|
const actions = stream.actions.data;
|
|
20
20
|
if (input.groupId !== null) {
|
|
21
|
-
const dbSession = stream.core.dbs["neu-jadwal"].models["neu:jadwal:
|
|
22
|
-
const findSession = await dbSession.find({ groupIds: { $in: [input.groupId] } }).select(["_id"]);
|
|
21
|
+
const dbSession = stream.core.dbs["neu-jadwal"].models["neu:jadwal:classSession"];
|
|
22
|
+
const findSession = (await dbSession.find({ groupIds: { $in: [input.groupId] } }).select(["_id"])).map((s) => s.id);
|
|
23
23
|
sessionIds.push(findSession);
|
|
24
24
|
}
|
|
25
25
|
const dbs = stream.core.dbs;
|
|
@@ -57,6 +57,15 @@ const syncStudentReport = operation.Action.define({
|
|
|
57
57
|
}
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
|
+
const filterPresensi = {
|
|
61
|
+
studentId: input.studentId,
|
|
62
|
+
presenceAt: {
|
|
63
|
+
$gte: input.startedAt,
|
|
64
|
+
$lte: input.endedAt
|
|
65
|
+
},
|
|
66
|
+
deletedAt: { $exists: false },
|
|
67
|
+
...input.groupId && { classSessionBranchIds: { $in: input.branchIds } }
|
|
68
|
+
};
|
|
60
69
|
const dataAttendance = await actions.getMany.execute(
|
|
61
70
|
{
|
|
62
71
|
model: "neu:jadwal:classAttendance",
|
|
@@ -66,16 +75,9 @@ const syncStudentReport = operation.Action.define({
|
|
|
66
75
|
presenceAt: 1,
|
|
67
76
|
sessionType: 1
|
|
68
77
|
},
|
|
69
|
-
filter:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
$gte: input.startedAt,
|
|
73
|
-
$lte: input.endedAt
|
|
74
|
-
},
|
|
75
|
-
deletedAt: { $exists: false },
|
|
76
|
-
...input.groupId && { classSessionBranchIds: { $in: input.branchIds } }
|
|
77
|
-
},
|
|
78
|
-
sort: { createdAt: -1 }
|
|
78
|
+
filter: filterPresensi,
|
|
79
|
+
sort: { createdAt: -1 },
|
|
80
|
+
limit: 99999
|
|
79
81
|
})
|
|
80
82
|
},
|
|
81
83
|
stream
|
|
@@ -203,7 +205,8 @@ const syncStudentReport = operation.Action.define({
|
|
|
203
205
|
startedAt: { $gte: input.startedAt, $lte: input.endedAt },
|
|
204
206
|
branchIds: { $in: input.branchIds },
|
|
205
207
|
studentIds: { $in: [input.studentId] }
|
|
206
|
-
}
|
|
208
|
+
},
|
|
209
|
+
limit: 99999
|
|
207
210
|
})
|
|
208
211
|
}, stream);
|
|
209
212
|
const sessionCount = resultSession.payload?.data?.total || 0;
|
|
@@ -237,7 +240,8 @@ const syncStudentReport = operation.Action.define({
|
|
|
237
240
|
branchIds: { $in: input.branchIds },
|
|
238
241
|
studentIds: { $in: [input.studentId] },
|
|
239
242
|
type: "offline"
|
|
240
|
-
}
|
|
243
|
+
},
|
|
244
|
+
limit: 99999
|
|
241
245
|
})
|
|
242
246
|
}, stream);
|
|
243
247
|
const totalOffline = sessionOffline.payload?.data?.total || 0;
|
|
@@ -249,7 +253,8 @@ const syncStudentReport = operation.Action.define({
|
|
|
249
253
|
branchIds: { $in: input.branchIds },
|
|
250
254
|
studentIds: { $in: [input.studentId] },
|
|
251
255
|
type: "online"
|
|
252
|
-
}
|
|
256
|
+
},
|
|
257
|
+
limit: 99999
|
|
253
258
|
})
|
|
254
259
|
}, stream);
|
|
255
260
|
const totalOnline = sessionOnline.payload?.data?.total || 0;
|
|
@@ -261,7 +266,8 @@ const syncStudentReport = operation.Action.define({
|
|
|
261
266
|
branchIds: { $in: input.branchIds },
|
|
262
267
|
studentIds: { $in: [input.studentId] },
|
|
263
268
|
type: "hybrid"
|
|
264
|
-
}
|
|
269
|
+
},
|
|
270
|
+
limit: 99999
|
|
265
271
|
})
|
|
266
272
|
}, stream);
|
|
267
273
|
const totalHybrid = sessionHybrid.payload?.data?.total || 0;
|
|
@@ -312,7 +318,8 @@ const syncStudentReport = operation.Action.define({
|
|
|
312
318
|
type: 1,
|
|
313
319
|
branchIds: 1
|
|
314
320
|
}
|
|
315
|
-
}
|
|
321
|
+
},
|
|
322
|
+
limit: 99999
|
|
316
323
|
})
|
|
317
324
|
}, stream);
|
|
318
325
|
const totalActivities = activityResult.payload.data?.filter((item) => {
|
|
@@ -16,8 +16,8 @@ const syncStudentReport = Action.define({
|
|
|
16
16
|
const sessionIds = [];
|
|
17
17
|
const actions = stream.actions.data;
|
|
18
18
|
if (input.groupId !== null) {
|
|
19
|
-
const dbSession = stream.core.dbs["neu-jadwal"].models["neu:jadwal:
|
|
20
|
-
const findSession = await dbSession.find({ groupIds: { $in: [input.groupId] } }).select(["_id"]);
|
|
19
|
+
const dbSession = stream.core.dbs["neu-jadwal"].models["neu:jadwal:classSession"];
|
|
20
|
+
const findSession = (await dbSession.find({ groupIds: { $in: [input.groupId] } }).select(["_id"])).map((s) => s.id);
|
|
21
21
|
sessionIds.push(findSession);
|
|
22
22
|
}
|
|
23
23
|
const dbs = stream.core.dbs;
|
|
@@ -55,6 +55,15 @@ const syncStudentReport = Action.define({
|
|
|
55
55
|
}
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
|
+
const filterPresensi = {
|
|
59
|
+
studentId: input.studentId,
|
|
60
|
+
presenceAt: {
|
|
61
|
+
$gte: input.startedAt,
|
|
62
|
+
$lte: input.endedAt
|
|
63
|
+
},
|
|
64
|
+
deletedAt: { $exists: false },
|
|
65
|
+
...input.groupId && { classSessionBranchIds: { $in: input.branchIds } }
|
|
66
|
+
};
|
|
58
67
|
const dataAttendance = await actions.getMany.execute(
|
|
59
68
|
{
|
|
60
69
|
model: "neu:jadwal:classAttendance",
|
|
@@ -64,16 +73,9 @@ const syncStudentReport = Action.define({
|
|
|
64
73
|
presenceAt: 1,
|
|
65
74
|
sessionType: 1
|
|
66
75
|
},
|
|
67
|
-
filter:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
$gte: input.startedAt,
|
|
71
|
-
$lte: input.endedAt
|
|
72
|
-
},
|
|
73
|
-
deletedAt: { $exists: false },
|
|
74
|
-
...input.groupId && { classSessionBranchIds: { $in: input.branchIds } }
|
|
75
|
-
},
|
|
76
|
-
sort: { createdAt: -1 }
|
|
76
|
+
filter: filterPresensi,
|
|
77
|
+
sort: { createdAt: -1 },
|
|
78
|
+
limit: 99999
|
|
77
79
|
})
|
|
78
80
|
},
|
|
79
81
|
stream
|
|
@@ -201,7 +203,8 @@ const syncStudentReport = Action.define({
|
|
|
201
203
|
startedAt: { $gte: input.startedAt, $lte: input.endedAt },
|
|
202
204
|
branchIds: { $in: input.branchIds },
|
|
203
205
|
studentIds: { $in: [input.studentId] }
|
|
204
|
-
}
|
|
206
|
+
},
|
|
207
|
+
limit: 99999
|
|
205
208
|
})
|
|
206
209
|
}, stream);
|
|
207
210
|
const sessionCount = resultSession.payload?.data?.total || 0;
|
|
@@ -235,7 +238,8 @@ const syncStudentReport = Action.define({
|
|
|
235
238
|
branchIds: { $in: input.branchIds },
|
|
236
239
|
studentIds: { $in: [input.studentId] },
|
|
237
240
|
type: "offline"
|
|
238
|
-
}
|
|
241
|
+
},
|
|
242
|
+
limit: 99999
|
|
239
243
|
})
|
|
240
244
|
}, stream);
|
|
241
245
|
const totalOffline = sessionOffline.payload?.data?.total || 0;
|
|
@@ -247,7 +251,8 @@ const syncStudentReport = Action.define({
|
|
|
247
251
|
branchIds: { $in: input.branchIds },
|
|
248
252
|
studentIds: { $in: [input.studentId] },
|
|
249
253
|
type: "online"
|
|
250
|
-
}
|
|
254
|
+
},
|
|
255
|
+
limit: 99999
|
|
251
256
|
})
|
|
252
257
|
}, stream);
|
|
253
258
|
const totalOnline = sessionOnline.payload?.data?.total || 0;
|
|
@@ -259,7 +264,8 @@ const syncStudentReport = Action.define({
|
|
|
259
264
|
branchIds: { $in: input.branchIds },
|
|
260
265
|
studentIds: { $in: [input.studentId] },
|
|
261
266
|
type: "hybrid"
|
|
262
|
-
}
|
|
267
|
+
},
|
|
268
|
+
limit: 99999
|
|
263
269
|
})
|
|
264
270
|
}, stream);
|
|
265
271
|
const totalHybrid = sessionHybrid.payload?.data?.total || 0;
|
|
@@ -310,7 +316,8 @@ const syncStudentReport = Action.define({
|
|
|
310
316
|
type: 1,
|
|
311
317
|
branchIds: 1
|
|
312
318
|
}
|
|
313
|
-
}
|
|
319
|
+
},
|
|
320
|
+
limit: 99999
|
|
314
321
|
})
|
|
315
322
|
}, stream);
|
|
316
323
|
const totalActivities = activityResult.payload.data?.filter((item) => {
|
|
@@ -8,6 +8,7 @@ export * from './action.prepareConflict';
|
|
|
8
8
|
export * from './action.userCountStats';
|
|
9
9
|
export * from './getClassSessionConflicts';
|
|
10
10
|
export * from './syncClassSessions';
|
|
11
|
+
export * from './setAksesModulSiswaDiClassGroup';
|
|
11
12
|
export * from './setTravelWageSessions';
|
|
12
13
|
export * from './action.customSaveOneClassSession';
|
|
13
14
|
export * from './syncClassGroups';
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const core = require('@neon.id/core');
|
|
4
|
+
const operation = require('@neon.id/operation');
|
|
5
|
+
const utils = require('@neon.id/utils');
|
|
6
|
+
const setAksesModulSiswaDiClassGroup_schema = require('./setAksesModulSiswaDiClassGroup.schema.cjs');
|
|
7
|
+
const useTelemetry = require('../../../providers/useTelemetry.cjs');
|
|
8
|
+
const util_logger = require('../../../utils/util.logger.cjs');
|
|
9
|
+
|
|
10
|
+
const setAksesModulSiswaDiClassGroup = operation.Action.define({
|
|
11
|
+
key: "setAksesModulSiswaDiClassGroup",
|
|
12
|
+
name: "Perbarui Akses Modul Siswa di Class Group",
|
|
13
|
+
type: "command",
|
|
14
|
+
category: "domain",
|
|
15
|
+
execute: async (input, stream) => {
|
|
16
|
+
utils.guard(stream, "streamRequired");
|
|
17
|
+
return useTelemetry.useTelemetry(stream, "setAksesModulSiswaDiClassGroup", {
|
|
18
|
+
userId: stream.context?.identitas?.userId || "",
|
|
19
|
+
...input
|
|
20
|
+
}, async () => {
|
|
21
|
+
const log = util_logger.useLog("setAksesModulSiswaDiClassGroup", { isActive: true });
|
|
22
|
+
const { getActorId } = operation.useStream(stream);
|
|
23
|
+
const { validate } = operation.useValidation(stream, setAksesModulSiswaDiClassGroup_schema.SetAksesModulSiswaDiClassGroupSchema);
|
|
24
|
+
const data = validate(input);
|
|
25
|
+
console.log("data.studentIds", data.studentIds.length);
|
|
26
|
+
console.log("data.moduleIds", data.moduleIds.length);
|
|
27
|
+
if (data.studentIds.length === 0) {
|
|
28
|
+
return core.Result.fail({
|
|
29
|
+
state: `perbaruiAksesModulGagal`,
|
|
30
|
+
message: `Siswa tidak ada diisi.`
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (data.moduleIds.length === 0) {
|
|
34
|
+
return core.Result.fail({
|
|
35
|
+
state: `perbaruiAksesModulGagal`,
|
|
36
|
+
message: `Modul tidak ada diisi.`
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return useTelemetry.useTelemetry(stream, "setAksesModulSiswaDiClassGroup", {
|
|
40
|
+
userId: stream.context?.identitas?.userId || "",
|
|
41
|
+
data
|
|
42
|
+
}, async () => {
|
|
43
|
+
const dbs = stream.core.dbs;
|
|
44
|
+
const dbModules = dbs["neu-akademik"].models["neu:akademik:module"];
|
|
45
|
+
const dbStudent = dbs["neu-akademik"].models["neu:akademik:student"];
|
|
46
|
+
const dbClassGroup = dbs["neu-jadwal"].models["neu:jadwal:classGroup"];
|
|
47
|
+
try {
|
|
48
|
+
getActorId({ throw: true });
|
|
49
|
+
log.object("input", data);
|
|
50
|
+
const findClassGroup = await dbClassGroup.findById(data.classGroupId);
|
|
51
|
+
if (!findClassGroup) {
|
|
52
|
+
return core.Result.fail({
|
|
53
|
+
state: `perbaruiAksesModulGagal`,
|
|
54
|
+
message: `Class Group Id tidak valid.`,
|
|
55
|
+
error: `Class Group Id tidak valid.`
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const findStudents = await dbStudent.find({ _id: { $in: input?.studentIds } });
|
|
59
|
+
if (!findStudents) {
|
|
60
|
+
return core.Result.fail({
|
|
61
|
+
state: `perbaruiAksesModulGagal`,
|
|
62
|
+
message: `Ada Student Id yang tidak valid.`,
|
|
63
|
+
error: `Class Student Id tidak valid.`
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const findModules = await dbModules.find({ _id: { $in: input?.moduleIds } });
|
|
67
|
+
if (!findModules) {
|
|
68
|
+
return core.Result.fail({
|
|
69
|
+
state: `perbaruiAksesModulGagal`,
|
|
70
|
+
message: `Ada Module yang tidak valid.`,
|
|
71
|
+
error: `Ada Module yang tidak valid.`
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const branchIsValid = _ensureBranchIsValid({ modules: findModules, students: findStudents, classGroup: findClassGroup });
|
|
75
|
+
if (branchIsValid.isError) {
|
|
76
|
+
return core.Result.fail({
|
|
77
|
+
state: `perbaruiAksesModulGagal`,
|
|
78
|
+
message: branchIsValid.message,
|
|
79
|
+
error: branchIsValid.message
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
await dbStudent.updateMany({
|
|
83
|
+
_id: { $in: [...data.studentIds] }
|
|
84
|
+
}, {
|
|
85
|
+
$addToSet: { moduleIds: { $each: [...data.moduleIds] } }
|
|
86
|
+
});
|
|
87
|
+
return core.Result.ok({
|
|
88
|
+
state: "perbaruiAksesModulSukses",
|
|
89
|
+
message: "Perbarui akses siswa berhasil."
|
|
90
|
+
});
|
|
91
|
+
} catch (error) {
|
|
92
|
+
if (error?.isFailure)
|
|
93
|
+
throw error;
|
|
94
|
+
console.error(error);
|
|
95
|
+
return core.Result.fail({
|
|
96
|
+
state: `perbaruiAksesModulGagal`,
|
|
97
|
+
message: `Gagal memperbarui akses modul ke siswa.`,
|
|
98
|
+
error: error?.toString()
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
function _ensureBranchIsValid({
|
|
106
|
+
modules,
|
|
107
|
+
students,
|
|
108
|
+
classGroup
|
|
109
|
+
}) {
|
|
110
|
+
for (let i = 0; i < students.length; i++) {
|
|
111
|
+
const classStudentIdString = classGroup.studentIds.map((id) => id.toString());
|
|
112
|
+
if (!classStudentIdString?.includes(students[i]._id.toString())) {
|
|
113
|
+
return {
|
|
114
|
+
isError: true,
|
|
115
|
+
message: `${students[i].name} tidak masuk dalam kelompok belajar`
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
const studentBranches = new Set(students[i].virtualBranchIds.map((id) => id.toString()));
|
|
119
|
+
for (let y = 0; y < modules.length; y++) {
|
|
120
|
+
if (modules[y].status !== "ready") {
|
|
121
|
+
return {
|
|
122
|
+
isError: true,
|
|
123
|
+
message: `${modules[y].name} harus berstatus siap`
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
if (!(Array.isArray(modules[y]?.branchIds) && modules[y]?.branchIds.length > 0)) {
|
|
127
|
+
return {
|
|
128
|
+
isError: true,
|
|
129
|
+
message: `${modules[y].name} tidak memiliki branch`
|
|
130
|
+
};
|
|
131
|
+
} else {
|
|
132
|
+
let foundBranch = false;
|
|
133
|
+
for (const element of modules[y]?.branchIds) {
|
|
134
|
+
if (studentBranches.has(element.toString())) {
|
|
135
|
+
foundBranch = true;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (!foundBranch) {
|
|
140
|
+
return {
|
|
141
|
+
isError: true,
|
|
142
|
+
message: `${students[i].name} tidak dapat mengambil modul ${modules[y].name} karena berbeda cabang`
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
isError: false,
|
|
150
|
+
message: "success"
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
exports.setAksesModulSiswaDiClassGroup = setAksesModulSiswaDiClassGroup;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Action } from '@neon.id/operation';
|
|
2
|
+
import type { z } from '@neon.id/z';
|
|
3
|
+
import type { Schema } from '@neutron.co.id/pendidikan-types';
|
|
4
|
+
import { SetAksesModulSiswaDiClassGroupSchema } from './setAksesModulSiswaDiClassGroup.schema';
|
|
5
|
+
export type SetAksesModulSiswaDiClassGroupInput = z.parse<typeof SetAksesModulSiswaDiClassGroupSchema>;
|
|
6
|
+
export interface SetAksesModulSiswaDiClassGroupOutput {
|
|
7
|
+
updates?: Schema.AkademikModule[];
|
|
8
|
+
}
|
|
9
|
+
export interface SetAksesModulSiswaDiClassGroupMeta {
|
|
10
|
+
}
|
|
11
|
+
export declare const setAksesModulSiswaDiClassGroup: Action<"setAksesModulSiswaDiClassGroup", {
|
|
12
|
+
moduleIds: string[];
|
|
13
|
+
studentIds: string[];
|
|
14
|
+
classGroupId: string;
|
|
15
|
+
}, SetAksesModulSiswaDiClassGroupOutput, SetAksesModulSiswaDiClassGroupMeta>;
|
|
16
|
+
export type SetAksesModulSiswaDiClassGroupAction = typeof setAksesModulSiswaDiClassGroup;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { Result } from '@neon.id/core';
|
|
2
|
+
import { Action, useStream, useValidation } from '@neon.id/operation';
|
|
3
|
+
import { guard } from '@neon.id/utils';
|
|
4
|
+
import { SetAksesModulSiswaDiClassGroupSchema } from './setAksesModulSiswaDiClassGroup.schema.mjs';
|
|
5
|
+
import { useTelemetry } from '../../../providers/useTelemetry.mjs';
|
|
6
|
+
import { useLog } from '../../../utils/util.logger.mjs';
|
|
7
|
+
|
|
8
|
+
const setAksesModulSiswaDiClassGroup = Action.define({
|
|
9
|
+
key: "setAksesModulSiswaDiClassGroup",
|
|
10
|
+
name: "Perbarui Akses Modul Siswa di Class Group",
|
|
11
|
+
type: "command",
|
|
12
|
+
category: "domain",
|
|
13
|
+
execute: async (input, stream) => {
|
|
14
|
+
guard(stream, "streamRequired");
|
|
15
|
+
return useTelemetry(stream, "setAksesModulSiswaDiClassGroup", {
|
|
16
|
+
userId: stream.context?.identitas?.userId || "",
|
|
17
|
+
...input
|
|
18
|
+
}, async () => {
|
|
19
|
+
const log = useLog("setAksesModulSiswaDiClassGroup", { isActive: true });
|
|
20
|
+
const { getActorId } = useStream(stream);
|
|
21
|
+
const { validate } = useValidation(stream, SetAksesModulSiswaDiClassGroupSchema);
|
|
22
|
+
const data = validate(input);
|
|
23
|
+
console.log("data.studentIds", data.studentIds.length);
|
|
24
|
+
console.log("data.moduleIds", data.moduleIds.length);
|
|
25
|
+
if (data.studentIds.length === 0) {
|
|
26
|
+
return Result.fail({
|
|
27
|
+
state: `perbaruiAksesModulGagal`,
|
|
28
|
+
message: `Siswa tidak ada diisi.`
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (data.moduleIds.length === 0) {
|
|
32
|
+
return Result.fail({
|
|
33
|
+
state: `perbaruiAksesModulGagal`,
|
|
34
|
+
message: `Modul tidak ada diisi.`
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return useTelemetry(stream, "setAksesModulSiswaDiClassGroup", {
|
|
38
|
+
userId: stream.context?.identitas?.userId || "",
|
|
39
|
+
data
|
|
40
|
+
}, async () => {
|
|
41
|
+
const dbs = stream.core.dbs;
|
|
42
|
+
const dbModules = dbs["neu-akademik"].models["neu:akademik:module"];
|
|
43
|
+
const dbStudent = dbs["neu-akademik"].models["neu:akademik:student"];
|
|
44
|
+
const dbClassGroup = dbs["neu-jadwal"].models["neu:jadwal:classGroup"];
|
|
45
|
+
try {
|
|
46
|
+
getActorId({ throw: true });
|
|
47
|
+
log.object("input", data);
|
|
48
|
+
const findClassGroup = await dbClassGroup.findById(data.classGroupId);
|
|
49
|
+
if (!findClassGroup) {
|
|
50
|
+
return Result.fail({
|
|
51
|
+
state: `perbaruiAksesModulGagal`,
|
|
52
|
+
message: `Class Group Id tidak valid.`,
|
|
53
|
+
error: `Class Group Id tidak valid.`
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const findStudents = await dbStudent.find({ _id: { $in: input?.studentIds } });
|
|
57
|
+
if (!findStudents) {
|
|
58
|
+
return Result.fail({
|
|
59
|
+
state: `perbaruiAksesModulGagal`,
|
|
60
|
+
message: `Ada Student Id yang tidak valid.`,
|
|
61
|
+
error: `Class Student Id tidak valid.`
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const findModules = await dbModules.find({ _id: { $in: input?.moduleIds } });
|
|
65
|
+
if (!findModules) {
|
|
66
|
+
return Result.fail({
|
|
67
|
+
state: `perbaruiAksesModulGagal`,
|
|
68
|
+
message: `Ada Module yang tidak valid.`,
|
|
69
|
+
error: `Ada Module yang tidak valid.`
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const branchIsValid = _ensureBranchIsValid({ modules: findModules, students: findStudents, classGroup: findClassGroup });
|
|
73
|
+
if (branchIsValid.isError) {
|
|
74
|
+
return Result.fail({
|
|
75
|
+
state: `perbaruiAksesModulGagal`,
|
|
76
|
+
message: branchIsValid.message,
|
|
77
|
+
error: branchIsValid.message
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
await dbStudent.updateMany({
|
|
81
|
+
_id: { $in: [...data.studentIds] }
|
|
82
|
+
}, {
|
|
83
|
+
$addToSet: { moduleIds: { $each: [...data.moduleIds] } }
|
|
84
|
+
});
|
|
85
|
+
return Result.ok({
|
|
86
|
+
state: "perbaruiAksesModulSukses",
|
|
87
|
+
message: "Perbarui akses siswa berhasil."
|
|
88
|
+
});
|
|
89
|
+
} catch (error) {
|
|
90
|
+
if (error?.isFailure)
|
|
91
|
+
throw error;
|
|
92
|
+
console.error(error);
|
|
93
|
+
return Result.fail({
|
|
94
|
+
state: `perbaruiAksesModulGagal`,
|
|
95
|
+
message: `Gagal memperbarui akses modul ke siswa.`,
|
|
96
|
+
error: error?.toString()
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
function _ensureBranchIsValid({
|
|
104
|
+
modules,
|
|
105
|
+
students,
|
|
106
|
+
classGroup
|
|
107
|
+
}) {
|
|
108
|
+
for (let i = 0; i < students.length; i++) {
|
|
109
|
+
const classStudentIdString = classGroup.studentIds.map((id) => id.toString());
|
|
110
|
+
if (!classStudentIdString?.includes(students[i]._id.toString())) {
|
|
111
|
+
return {
|
|
112
|
+
isError: true,
|
|
113
|
+
message: `${students[i].name} tidak masuk dalam kelompok belajar`
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const studentBranches = new Set(students[i].virtualBranchIds.map((id) => id.toString()));
|
|
117
|
+
for (let y = 0; y < modules.length; y++) {
|
|
118
|
+
if (modules[y].status !== "ready") {
|
|
119
|
+
return {
|
|
120
|
+
isError: true,
|
|
121
|
+
message: `${modules[y].name} harus berstatus siap`
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
if (!(Array.isArray(modules[y]?.branchIds) && modules[y]?.branchIds.length > 0)) {
|
|
125
|
+
return {
|
|
126
|
+
isError: true,
|
|
127
|
+
message: `${modules[y].name} tidak memiliki branch`
|
|
128
|
+
};
|
|
129
|
+
} else {
|
|
130
|
+
let foundBranch = false;
|
|
131
|
+
for (const element of modules[y]?.branchIds) {
|
|
132
|
+
if (studentBranches.has(element.toString())) {
|
|
133
|
+
foundBranch = true;
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (!foundBranch) {
|
|
138
|
+
return {
|
|
139
|
+
isError: true,
|
|
140
|
+
message: `${students[i].name} tidak dapat mengambil modul ${modules[y].name} karena berbeda cabang`
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
isError: false,
|
|
148
|
+
message: "success"
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export { setAksesModulSiswaDiClassGroup };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const z = require('@neon.id/z');
|
|
4
|
+
|
|
5
|
+
const SetAksesModulSiswaDiClassGroupSchema = z.z.object({
|
|
6
|
+
classGroupId: z.z.objectId().explain({
|
|
7
|
+
label: "Class Group ID"
|
|
8
|
+
}),
|
|
9
|
+
moduleIds: z.z.array(z.z.objectId()).explain({
|
|
10
|
+
label: "Module IDs"
|
|
11
|
+
}),
|
|
12
|
+
studentIds: z.z.array(z.z.objectId()).explain({
|
|
13
|
+
label: "Student IDs"
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
exports.SetAksesModulSiswaDiClassGroupSchema = SetAksesModulSiswaDiClassGroupSchema;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from '@neon.id/z';
|
|
2
|
+
export declare const SetAksesModulSiswaDiClassGroupSchema: z.ZodObject<{
|
|
3
|
+
classGroupId: z.ZodEffects<z.ZodString, string, string>;
|
|
4
|
+
moduleIds: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
5
|
+
studentIds: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
moduleIds: string[];
|
|
8
|
+
studentIds: string[];
|
|
9
|
+
classGroupId: string;
|
|
10
|
+
}, {
|
|
11
|
+
moduleIds: string[];
|
|
12
|
+
studentIds: string[];
|
|
13
|
+
classGroupId: string;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from '@neon.id/z';
|
|
2
|
+
|
|
3
|
+
const SetAksesModulSiswaDiClassGroupSchema = z.object({
|
|
4
|
+
classGroupId: z.objectId().explain({
|
|
5
|
+
label: "Class Group ID"
|
|
6
|
+
}),
|
|
7
|
+
moduleIds: z.array(z.objectId()).explain({
|
|
8
|
+
label: "Module IDs"
|
|
9
|
+
}),
|
|
10
|
+
studentIds: z.array(z.objectId()).explain({
|
|
11
|
+
label: "Student IDs"
|
|
12
|
+
})
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export { SetAksesModulSiswaDiClassGroupSchema };
|
package/build/index.cjs
CHANGED
|
@@ -25,6 +25,7 @@ const action_deleteManySession = require('./actions/jadwal/action.deleteManySess
|
|
|
25
25
|
const action_syncStudentAdmisi = require('./actions/akademik/action.syncStudentAdmisi.cjs');
|
|
26
26
|
const action_checkClassAttendance = require('./actions/jadwal/action.checkClassAttendance.cjs');
|
|
27
27
|
const syncClassSessions_action = require('./actions/jadwal/syncClassSessions/syncClassSessions.action.cjs');
|
|
28
|
+
const setAksesModulSiswaDiClassGroup_action = require('./actions/jadwal/setAksesModulSiswaDiClassGroup/setAksesModulSiswaDiClassGroup.action.cjs');
|
|
28
29
|
const getClassSessionConflicts_action = require('./actions/jadwal/getClassSessionConflicts/getClassSessionConflicts.action.cjs');
|
|
29
30
|
const setTravelWageSessions_action = require('./actions/jadwal/setTravelWageSessions/setTravelWageSessions.action.cjs');
|
|
30
31
|
const action_customSaveOneClassSession = require('./actions/jadwal/action.customSaveOneClassSession.cjs');
|
|
@@ -59,6 +60,7 @@ const syncStudentReport_schema = require('./actions/akademik/studentReport/syncS
|
|
|
59
60
|
const updateReportStudent_schema = require('./actions/akademik/updateReportStudent/updateReportStudent.schema.cjs');
|
|
60
61
|
const getClassSessionConflicts_schema = require('./actions/jadwal/getClassSessionConflicts/getClassSessionConflicts.schema.cjs');
|
|
61
62
|
const syncClassSessions_schema = require('./actions/jadwal/syncClassSessions/syncClassSessions.schema.cjs');
|
|
63
|
+
const setAksesModulSiswaDiClassGroup_schema = require('./actions/jadwal/setAksesModulSiswaDiClassGroup/setAksesModulSiswaDiClassGroup.schema.cjs');
|
|
62
64
|
const setTravelWageSessions_schema = require('./actions/jadwal/setTravelWageSessions/setTravelWageSessions.schema.cjs');
|
|
63
65
|
const syncClassGroups_schema = require('./actions/jadwal/syncClassGroups/syncClassGroups.schema.cjs');
|
|
64
66
|
const importData_schema = require('./actions/importData/importData.schema.cjs');
|
|
@@ -99,6 +101,7 @@ const actions = {
|
|
|
99
101
|
syncStudentAdmisi: action_syncStudentAdmisi.syncStudentAdmisi,
|
|
100
102
|
checkClassAttendance: action_checkClassAttendance.checkClassAttendance,
|
|
101
103
|
syncClassSessions: syncClassSessions_action.syncClassSessions,
|
|
104
|
+
setAksesModulSiswaDiClassGroup: setAksesModulSiswaDiClassGroup_action.setAksesModulSiswaDiClassGroup,
|
|
102
105
|
getClassSessionConflicts: getClassSessionConflicts_action.getClassSessionConflicts,
|
|
103
106
|
setTravelWageSessions: setTravelWageSessions_action.setTravelWageSessions,
|
|
104
107
|
customSaveOneClassSession: action_customSaveOneClassSession.customSaveOneClassSession,
|
|
@@ -163,6 +166,7 @@ exports.deleteManySession = action_deleteManySession.deleteManySession;
|
|
|
163
166
|
exports.syncStudentAdmisi = action_syncStudentAdmisi.syncStudentAdmisi;
|
|
164
167
|
exports.checkClassAttendance = action_checkClassAttendance.checkClassAttendance;
|
|
165
168
|
exports.syncClassSessions = syncClassSessions_action.syncClassSessions;
|
|
169
|
+
exports.setAksesModulSiswaDiClassGroup = setAksesModulSiswaDiClassGroup_action.setAksesModulSiswaDiClassGroup;
|
|
166
170
|
exports.getClassSessionConflicts = getClassSessionConflicts_action.getClassSessionConflicts;
|
|
167
171
|
exports.setTravelWageSessions = setTravelWageSessions_action.setTravelWageSessions;
|
|
168
172
|
exports.customSaveOneClassSession = action_customSaveOneClassSession.customSaveOneClassSession;
|
|
@@ -199,6 +203,7 @@ exports.StudentReportSchema = syncStudentReport_schema.StudentReportSchema;
|
|
|
199
203
|
exports.UpdateReportStudentSchema = updateReportStudent_schema.UpdateReportStudentSchema;
|
|
200
204
|
exports.GetClassSessionConflictsSchema = getClassSessionConflicts_schema.GetClassSessionConflictsSchema;
|
|
201
205
|
exports.SyncClassSessionsSchema = syncClassSessions_schema.SyncClassSessionsSchema;
|
|
206
|
+
exports.SetAksesModulSiswaDiClassGroupSchema = setAksesModulSiswaDiClassGroup_schema.SetAksesModulSiswaDiClassGroupSchema;
|
|
202
207
|
exports.SetTravelWageSessionsSchema = setTravelWageSessions_schema.SetTravelWageSessionsSchema;
|
|
203
208
|
exports.SyncClassGroupsSchema = syncClassGroups_schema.SyncClassGroupsSchema;
|
|
204
209
|
exports.ImportDataSchema = importData_schema.ImportDataSchema;
|
package/build/index.d.ts
CHANGED
|
@@ -51,6 +51,11 @@ export declare const actions: {
|
|
|
51
51
|
all?: boolean | undefined;
|
|
52
52
|
return?: boolean | undefined;
|
|
53
53
|
}, import("./actions").SyncClassSessionsOutput, import("./actions").SyncClassSessionsMeta>;
|
|
54
|
+
setAksesModulSiswaDiClassGroup: import("@neon.id/operation").Action<"setAksesModulSiswaDiClassGroup", {
|
|
55
|
+
moduleIds: string[];
|
|
56
|
+
studentIds: string[];
|
|
57
|
+
classGroupId: string;
|
|
58
|
+
}, import("./actions").SetAksesModulSiswaDiClassGroupOutput, import("./actions").SetAksesModulSiswaDiClassGroupMeta>;
|
|
54
59
|
getClassSessionConflicts: import("@neon.id/operation").Action<"getClassSessionConflicts", {
|
|
55
60
|
filter?: any;
|
|
56
61
|
}, import("./actions").GetClassSessionConflictsOutput, import("./actions").GetClassSessionConflictsMeta>;
|
package/build/index.mjs
CHANGED
|
@@ -23,6 +23,7 @@ import { deleteManySession } from './actions/jadwal/action.deleteManySession.mjs
|
|
|
23
23
|
import { syncStudentAdmisi } from './actions/akademik/action.syncStudentAdmisi.mjs';
|
|
24
24
|
import { checkClassAttendance } from './actions/jadwal/action.checkClassAttendance.mjs';
|
|
25
25
|
import { syncClassSessions } from './actions/jadwal/syncClassSessions/syncClassSessions.action.mjs';
|
|
26
|
+
import { setAksesModulSiswaDiClassGroup } from './actions/jadwal/setAksesModulSiswaDiClassGroup/setAksesModulSiswaDiClassGroup.action.mjs';
|
|
26
27
|
import { getClassSessionConflicts } from './actions/jadwal/getClassSessionConflicts/getClassSessionConflicts.action.mjs';
|
|
27
28
|
import { setTravelWageSessions } from './actions/jadwal/setTravelWageSessions/setTravelWageSessions.action.mjs';
|
|
28
29
|
import { customSaveOneClassSession } from './actions/jadwal/action.customSaveOneClassSession.mjs';
|
|
@@ -59,6 +60,7 @@ export { StudentReportSchema } from './actions/akademik/studentReport/syncStuden
|
|
|
59
60
|
export { UpdateReportStudentSchema } from './actions/akademik/updateReportStudent/updateReportStudent.schema.mjs';
|
|
60
61
|
export { GetClassSessionConflictsSchema } from './actions/jadwal/getClassSessionConflicts/getClassSessionConflicts.schema.mjs';
|
|
61
62
|
export { SyncClassSessionsSchema } from './actions/jadwal/syncClassSessions/syncClassSessions.schema.mjs';
|
|
63
|
+
export { SetAksesModulSiswaDiClassGroupSchema } from './actions/jadwal/setAksesModulSiswaDiClassGroup/setAksesModulSiswaDiClassGroup.schema.mjs';
|
|
62
64
|
export { SetTravelWageSessionsSchema } from './actions/jadwal/setTravelWageSessions/setTravelWageSessions.schema.mjs';
|
|
63
65
|
export { SyncClassGroupsSchema } from './actions/jadwal/syncClassGroups/syncClassGroups.schema.mjs';
|
|
64
66
|
export { ImportDataSchema } from './actions/importData/importData.schema.mjs';
|
|
@@ -99,6 +101,7 @@ const actions = {
|
|
|
99
101
|
syncStudentAdmisi,
|
|
100
102
|
checkClassAttendance,
|
|
101
103
|
syncClassSessions,
|
|
104
|
+
setAksesModulSiswaDiClassGroup,
|
|
102
105
|
getClassSessionConflicts,
|
|
103
106
|
setTravelWageSessions,
|
|
104
107
|
customSaveOneClassSession,
|
|
@@ -138,4 +141,4 @@ const actions = {
|
|
|
138
141
|
syncStudents
|
|
139
142
|
};
|
|
140
143
|
|
|
141
|
-
export { acceptQuestion, actions, addManyGradingComponent, allConflict, calculateGrading, calculateManyComparator, calculateOneComparator, checkClassAttendance, classSessionInventoryOccurs, classSessionInventoryPreparation, clearAllOverrides, clearGrading, clearOneOverrides, createGradingAndScores, createManySession, customSaveOneClassSession, deleteManySession, editAnswer, generateGrading, getClassSessionConflicts, getGradingCount, getQuestionCount, getStaffId, getStaffPoint, getStudentId, getStudentPoint, getTeacherPoint, hasUnderstand, importData, notUnderstand, prepareConflict, prepareExperience, prepareMediaScanterGradingInsert, presenceSessionStudent, presenceSessionTeacher, rasionalizeGrading, refreshGrading, refreshManyGrading, refreshModuleAccess, reminderQuestions, replaceModuleAccess, sendAnswer, sendQuestion, setTravelWageSessions, syncClassGroups, syncClassSessions, syncCommitment, syncStudentAdmisi, syncStudentBranch, syncStudentInformation, syncStudentReport, syncStudents, updateGradingAndScores, updateMany, updateReportStudent, userCountStats };
|
|
144
|
+
export { acceptQuestion, actions, addManyGradingComponent, allConflict, calculateGrading, calculateManyComparator, calculateOneComparator, checkClassAttendance, classSessionInventoryOccurs, classSessionInventoryPreparation, clearAllOverrides, clearGrading, clearOneOverrides, createGradingAndScores, createManySession, customSaveOneClassSession, deleteManySession, editAnswer, generateGrading, getClassSessionConflicts, getGradingCount, getQuestionCount, getStaffId, getStaffPoint, getStudentId, getStudentPoint, getTeacherPoint, hasUnderstand, importData, notUnderstand, prepareConflict, prepareExperience, prepareMediaScanterGradingInsert, presenceSessionStudent, presenceSessionTeacher, rasionalizeGrading, refreshGrading, refreshManyGrading, refreshModuleAccess, reminderQuestions, replaceModuleAccess, sendAnswer, sendQuestion, setAksesModulSiswaDiClassGroup, setTravelWageSessions, syncClassGroups, syncClassSessions, syncCommitment, syncStudentAdmisi, syncStudentBranch, syncStudentInformation, syncStudentReport, syncStudents, updateGradingAndScores, updateMany, updateReportStudent, userCountStats };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neutron.co.id/pendidikan-operation",
|
|
3
|
-
"version": "1.27.
|
|
3
|
+
"version": "1.27.5",
|
|
4
4
|
"description": "Operation package of Neutron Pendidikan.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"contributors": [
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"@neon.id/types": "^1.69.0",
|
|
40
40
|
"@neon.id/utils": "^1.52.0",
|
|
41
41
|
"@neon.id/z": "^1.16.0",
|
|
42
|
-
"@neutron.co.id/akademik-models": "^1.21.
|
|
43
|
-
"@neutron.co.id/jadwal-models": "^1.19.
|
|
44
|
-
"@neutron.co.id/pendidikan-types": "^1.23.
|
|
42
|
+
"@neutron.co.id/akademik-models": "^1.21.3",
|
|
43
|
+
"@neutron.co.id/jadwal-models": "^1.19.13",
|
|
44
|
+
"@neutron.co.id/pendidikan-types": "^1.23.2",
|
|
45
45
|
"@neutron.co.id/penilaian-models": "^1.17.8",
|
|
46
46
|
"@neutron.co.id/personalia-models": "^1.11.6",
|
|
47
47
|
"@neutron.co.id/tanya-models": "^1.13.4",
|
|
@@ -75,9 +75,9 @@
|
|
|
75
75
|
"@neon.id/types": "^1.69.0",
|
|
76
76
|
"@neon.id/utils": "^1.52.0",
|
|
77
77
|
"@neon.id/z": "^1.16.0",
|
|
78
|
-
"@neutron.co.id/akademik-models": "^1.21.
|
|
79
|
-
"@neutron.co.id/jadwal-models": "^1.19.
|
|
80
|
-
"@neutron.co.id/pendidikan-types": "^1.23.
|
|
78
|
+
"@neutron.co.id/akademik-models": "^1.21.3",
|
|
79
|
+
"@neutron.co.id/jadwal-models": "^1.19.13",
|
|
80
|
+
"@neutron.co.id/pendidikan-types": "^1.23.2",
|
|
81
81
|
"@neutron.co.id/penilaian-models": "^1.17.8",
|
|
82
82
|
"@neutron.co.id/personalia-models": "^1.11.6",
|
|
83
83
|
"@neutron.co.id/tanya-models": "^1.13.4",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"access": "public"
|
|
88
88
|
},
|
|
89
|
-
"build":
|
|
89
|
+
"build": 130
|
|
90
90
|
}
|