@neutron.co.id/pendidikan-operation 1.2.1 → 1.3.0-beta.2

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/index.cjs CHANGED
@@ -21,6 +21,564 @@ const setSomething = operation.Action.define({
21
21
  }
22
22
  });
23
23
 
24
+ const presenceSessionStudent = operation.Action.define({
25
+ key: "presenceSessionStudent",
26
+ name: "Presence Student",
27
+ type: "command",
28
+ category: "domain",
29
+ execute: async (input, stream) => {
30
+ const dbs = stream.core.dbs;
31
+ const sessionResult = await stream.actions.data.getOne.execute({
32
+ model: "ClassSession",
33
+ id: input.sessionId,
34
+ query: query.Query.define({
35
+ fields: {
36
+ _id: 1
37
+ }
38
+ })
39
+ });
40
+ const session = sessionResult.value;
41
+ const dbAttendance = dbs.jadwal.models.ClassAttendance;
42
+ const dbStudent = dbs.siswa.models.Student;
43
+ const siswa = await dbStudent.findOne({
44
+ userId: stream.context.identitas.userId
45
+ });
46
+ await dbAttendance.create({
47
+ classSessionId: session._id,
48
+ studentId: siswa.id,
49
+ presenceAt: new Date(),
50
+ updatedAt: new Date(),
51
+ createdBy: stream.context.identitas.userId,
52
+ updatedBy: stream.context.identitas.userId
53
+ });
54
+ return core.Result.ok({
55
+ state: "presenceSessionStudent",
56
+ message: "Presensi berhasil!"
57
+ });
58
+ }
59
+ });
60
+
61
+ const presenceSessionTeacher = operation.Action.define({
62
+ key: "presenceSessionTeacher",
63
+ name: "Presence Teacher",
64
+ type: "command",
65
+ category: "domain",
66
+ execute: async (input, stream) => {
67
+ const dbs = stream.core.dbs;
68
+ const sessionResult = await stream.actions.data.getOne.execute({
69
+ model: "ClassSession",
70
+ id: input.sessionId,
71
+ query: query.Query.define({
72
+ fields: {
73
+ _id: 1
74
+ }
75
+ })
76
+ });
77
+ const session = sessionResult.value;
78
+ const dbAttendance = dbs.jadwal.models.ClassAttendance;
79
+ const dbTeacher = dbs.talenta.models.Teacher;
80
+ const user = stream.context.identitas.userId;
81
+ const pengajar = await dbTeacher.findOne({ userId: user });
82
+ await dbAttendance.create({
83
+ classSessionId: session._id,
84
+ teacherId: pengajar.id,
85
+ presenceAt: new Date(),
86
+ updatedAt: new Date(),
87
+ createdBy: user,
88
+ updatedBy: user
89
+ });
90
+ return core.Result.ok({
91
+ state: "presenceSessionTeacher",
92
+ message: "Presensi berhasil!"
93
+ });
94
+ }
95
+ });
96
+
97
+ const syncCommitment = operation.Action.define({
98
+ key: "syncCommitment",
99
+ name: "Sync Commitment",
100
+ type: "command",
101
+ category: "domain",
102
+ execute: async (input, stream) => {
103
+ const dbs = stream.core.dbs;
104
+ const teacherResult = await stream.actions.data.getOne.execute({
105
+ model: "Teacher",
106
+ id: input.teacherId,
107
+ query: query.Query.define({
108
+ fields: {
109
+ _id: 1,
110
+ teacherCommitments: {
111
+ weekdays: 1,
112
+ startedAt: 1,
113
+ endedAt: 1
114
+ }
115
+ }
116
+ })
117
+ });
118
+ const teacher = teacherResult.value;
119
+ const dbCommitment = dbs.talenta.models.TeacherCommitment;
120
+ const dbTeacher = dbs.talenta.models.Teacher;
121
+ const commitment = await dbCommitment.findOne({ teacherId: teacher._id }).sort({ createdAt: -1 });
122
+ await dbTeacher.updateOne(
123
+ { _id: teacher._id },
124
+ {
125
+ $set: {
126
+ weekdays: commitment.weekdays,
127
+ hourStart: commitment.startedAt,
128
+ hourEnd: commitment.endedAt
129
+ }
130
+ }
131
+ );
132
+ return core.Result.ok({
133
+ state: "syncCommitment",
134
+ message: "Komitment disinkronasi!"
135
+ });
136
+ }
137
+ });
138
+
139
+ const generateGrading = operation.Action.define({
140
+ key: "generateGrading",
141
+ name: "Create Penilaian dan Score",
142
+ type: "command",
143
+ category: "domain",
144
+ execute: async ({ gradingInsertId }, stream) => {
145
+ const comparator = await _getGradingInsert$1(stream, gradingInsertId);
146
+ await _generateGradingRasio(stream, comparator);
147
+ const gradingComparisons = await _getGradingRasio(stream, gradingInsertId);
148
+ await _generateGradingComparisonItem(stream, comparator, gradingComparisons);
149
+ return core.Result.ok({
150
+ state: "allGenerated",
151
+ message: "All Penilaian have been synced.",
152
+ data: {}
153
+ });
154
+ }
155
+ });
156
+ async function _getGradingInsert$1(stream, gradingInsertId) {
157
+ const resultInsert = await stream.actions.data.getOne.execute(
158
+ {
159
+ model: "neu:penilaian:gradingInsert",
160
+ id: gradingInsertId,
161
+ query: query.Query.define({
162
+ fields: {
163
+ id: 1,
164
+ gradingId: 1,
165
+ gradingContexts: {
166
+ id: 1,
167
+ gradingComparators: { id: 1 }
168
+ }
169
+ }
170
+ })
171
+ },
172
+ stream
173
+ );
174
+ return resultInsert.value;
175
+ }
176
+ async function _getGradingRasio(stream, gradingInsertId) {
177
+ const resultRasio = await stream.actions.data.getMany.execute(
178
+ {
179
+ model: "neu:penilaian:gradingRasionalization",
180
+ query: query.Query.define({
181
+ filter: {
182
+ gradingInsertId
183
+ },
184
+ fields: {
185
+ id: 1,
186
+ gradingInsertId: 1,
187
+ gradingContextId: 1,
188
+ gradingComparatorId: 1
189
+ },
190
+ limit: 1e4
191
+ })
192
+ },
193
+ stream
194
+ );
195
+ return resultRasio.value;
196
+ }
197
+ async function _generateGradingRasio(stream, gradingInserts) {
198
+ const operations = [];
199
+ for (const gradingContext of gradingInserts.gradingContexts) {
200
+ for (const comparator of gradingContext.gradingComparators) {
201
+ operations.push({
202
+ insertOne: {
203
+ document: {
204
+ gradingId: gradingInserts.gradingId,
205
+ gradingInsertId: gradingInserts.id,
206
+ gradingComparatorId: comparator?.id,
207
+ gradingContextId: gradingContext?.id
208
+ }
209
+ }
210
+ });
211
+ }
212
+ }
213
+ await stream.core.dbs["neu-penilaian"].models["neu:penilaian:gradingRasionalization"].bulkWrite(operations);
214
+ }
215
+ async function _generateGradingComparisonItem(stream, grading, gradingRasios) {
216
+ const operations = [];
217
+ const resultScore = await stream.actions.data.getMany.execute(
218
+ {
219
+ model: "neu:penilaian:score",
220
+ query: query.Query.define({
221
+ filter: {
222
+ gradingId: grading.gradingId
223
+ },
224
+ fields: {
225
+ id: 1,
226
+ gradingComponentId: 1
227
+ },
228
+ limit: 100
229
+ })
230
+ },
231
+ stream
232
+ );
233
+ for (const rasio of gradingRasios) {
234
+ resultScore.value.map(async (item) => {
235
+ operations.push({
236
+ insertOne: {
237
+ document: {
238
+ gradingRasionalizationId: rasio.id,
239
+ gradingInsertId: rasio.gradingInsertId,
240
+ gradingComparatorId: rasio?.gradingComparatorId,
241
+ scoreId: item?.id
242
+ }
243
+ }
244
+ });
245
+ });
246
+ }
247
+ await stream.core.dbs["neu-penilaian"].models["neu:penilaian:gradingComparisonItem"].bulkWrite(operations);
248
+ }
249
+
250
+ const rasionalizeGrading = operation.Action.define({
251
+ key: "rasionalizeGrading",
252
+ name: "Sync All Penilaian",
253
+ type: "command",
254
+ category: "domain",
255
+ execute: async ({ gradingInsertId }, stream) => {
256
+ await syncModel(stream, "neu:penilaian:gradingComparisonItem", {
257
+ gradingInsertId
258
+ });
259
+ await syncModel(stream, "neu:penilaian:gradingRasionalization", {
260
+ gradingInsertId
261
+ });
262
+ await syncModel(stream, "neu:penilaian:grading", {
263
+ gradingInsertId
264
+ });
265
+ await syncModel(stream, "neu:penilaian:gradingInsert", {
266
+ _id: gradingInsertId
267
+ });
268
+ return core.Result.ok({
269
+ state: "allSynced",
270
+ message: "All penilaian modules have been synced.",
271
+ data: {}
272
+ });
273
+ }
274
+ });
275
+ async function syncModel(stream, model, filter) {
276
+ console.time(`\u23F1\uFE0F syncModel:${model}`);
277
+ await stream.actions.data.syncMany.execute(
278
+ {
279
+ model,
280
+ useDry: false,
281
+ query: query.Query.define({
282
+ filter,
283
+ limit: 1e5
284
+ })
285
+ },
286
+ stream
287
+ );
288
+ console.timeEnd(`\u23F1\uFE0F syncModel:${model}`);
289
+ }
290
+
291
+ const calculateGrading = operation.Action.define({
292
+ key: "calculateGrading",
293
+ name: "Create Penilaian dan Score",
294
+ type: "command",
295
+ category: "domain",
296
+ execute: async ({ gradingInsertId, gradingContextIds, sourceSchoolId, gradingId }, stream) => {
297
+ await _destroyMany(stream, { gradingId, gradingInsertId });
298
+ const cached = {
299
+ gradingContextIds,
300
+ sourceSchoolId
301
+ };
302
+ console.time("\u23F1\uFE0F updateGradingInsertCachedData");
303
+ await stream.actions.data.updateOne.execute(
304
+ {
305
+ model: "neu:penilaian:gradingInsert",
306
+ id: gradingInsertId,
307
+ data: { cached },
308
+ query: query.Query.define({})
309
+ },
310
+ stream
311
+ );
312
+ console.timeEnd("\u23F1\uFE0F updateGradingInsertCachedData");
313
+ console.time("\u23F1\uFE0F generateGrading");
314
+ await generateGrading.execute({ gradingInsertId }, stream);
315
+ console.timeEnd("\u23F1\uFE0F generateGrading");
316
+ console.time("\u23F1\uFE0F rasionalizeGrading");
317
+ await rasionalizeGrading.execute({ gradingInsertId }, stream);
318
+ console.timeEnd("\u23F1\uFE0F rasionalizeGrading");
319
+ return core.Result.ok({
320
+ state: "allCalculated",
321
+ message: "All Penilaian have been calculated.",
322
+ data: {}
323
+ });
324
+ }
325
+ });
326
+ async function _destroyMany(stream, input) {
327
+ const { gradingId, gradingInsertId } = input;
328
+ const db = stream.core.dbs["neu-penilaian"];
329
+ console.time("\u23F1\uFE0F destroyManyGradingRasionalization");
330
+ await db.models["neu:penilaian:gradingRasionalization"].deleteMany({
331
+ gradingId
332
+ });
333
+ console.timeEnd("\u23F1\uFE0F destroyManyGradingRasionalization");
334
+ console.time("\u23F1\uFE0F destroyManyGradingComparisonItem");
335
+ await db.models["neu:penilaian:gradingComparisonItem"].deleteMany({
336
+ gradingInsertId
337
+ });
338
+ console.timeEnd("\u23F1\uFE0F destroyManyGradingComparisonItem");
339
+ }
340
+
341
+ const clearGrading = operation.Action.define({
342
+ key: "clearGrading",
343
+ name: "Clear Grading",
344
+ type: "command",
345
+ category: "domain",
346
+ execute: async ({ gradingInsertId }, stream) => {
347
+ const gradingInsert = await _getGradingInsert(stream, gradingInsertId);
348
+ const gradingId = gradingInsert.gradingId;
349
+ const db = stream.core.dbs["neu-penilaian"];
350
+ console.time("\u23F1\uFE0F deleteManyGrading");
351
+ await db.models["neu:penilaian:grading"].deleteMany({
352
+ _id: gradingId
353
+ });
354
+ console.timeEnd("\u23F1\uFE0F deleteManyGrading");
355
+ console.time("\u23F1\uFE0F deleteManyScore");
356
+ await db.models["neu:penilaian:score"].deleteMany({
357
+ gradingId
358
+ });
359
+ console.timeEnd("\u23F1\uFE0F deleteManyScore");
360
+ console.time("\u23F1\uFE0F deleteManyGradingRasionalization");
361
+ await db.models["neu:penilaian:gradingRasionalization"].deleteMany({
362
+ gradingId
363
+ });
364
+ console.timeEnd("\u23F1\uFE0F deleteManyGradingRasionalization");
365
+ console.time("\u23F1\uFE0F deleteManyGradingComparisonItem");
366
+ await db.models["neu:penilaian:gradingComparisonItem"].deleteMany({
367
+ gradingInsertId
368
+ });
369
+ console.timeEnd("\u23F1\uFE0F deleteManyGradingComparisonItem");
370
+ return core.Result.ok({
371
+ state: "gradingCleared",
372
+ message: "Grading has been cleared.",
373
+ data: {}
374
+ });
375
+ }
376
+ });
377
+ async function _getGradingInsert(stream, gradingInsertId) {
378
+ const result = await stream.actions.data.getOne.execute(
379
+ {
380
+ model: "neu:penilaian:gradingInsert",
381
+ id: gradingInsertId,
382
+ query: query.Query.define({
383
+ fields: { gradingId: 1 },
384
+ useDeleted: true
385
+ })
386
+ },
387
+ stream
388
+ );
389
+ if (result.isFailure)
390
+ throw result;
391
+ else
392
+ return result.value;
393
+ }
394
+
395
+ const createGradingAndScores = operation.Action.define({
396
+ key: "createGradingAndScores",
397
+ name: "Create Penilaian dan Score",
398
+ type: "command",
399
+ category: "domain",
400
+ execute: async ({ gradingTypeId, studentId, gradingInsertId }, stream) => {
401
+ if (!gradingTypeId || !studentId || !gradingInsertId) {
402
+ throw core.Result.fail({
403
+ state: "invalidInput",
404
+ message: "Invalid input.",
405
+ data: {}
406
+ });
407
+ }
408
+ console.time("\u23F1\uFE0F createGrading");
409
+ const grading = await _createGrading(stream, { gradingTypeId, studentId });
410
+ console.timeEnd("\u23F1\uFE0F createGrading");
411
+ console.time("\u23F1\uFE0F getGradingComponents");
412
+ const gradingComponents = await _getGradingComponents$1(stream, gradingTypeId);
413
+ console.timeEnd("\u23F1\uFE0F getGradingComponents");
414
+ console.time("\u23F1\uFE0F generateScores");
415
+ await _generateScores(stream, grading, gradingComponents);
416
+ console.timeEnd("\u23F1\uFE0F generateScores");
417
+ console.time("\u23F1\uFE0F updateGradingInsert");
418
+ await _updateGradingInsert(stream, {
419
+ gradingInsertId,
420
+ gradingId: grading.id
421
+ });
422
+ console.timeEnd("\u23F1\uFE0F updateGradingInsert");
423
+ return core.Result.ok({
424
+ state: "allGradingAndScoresCreated",
425
+ message: "All Penilaian Score have been synced.",
426
+ data: {}
427
+ });
428
+ }
429
+ });
430
+ async function _createGrading(stream, input) {
431
+ const result = await stream.actions.data.createOne.execute(
432
+ {
433
+ model: "neu:penilaian:grading",
434
+ data: {
435
+ gradingTypeId: input.gradingTypeId,
436
+ studentId: input.studentId,
437
+ reportedAt: new Date()
438
+ },
439
+ query: query.Query.define({ fields: { id: 1 } })
440
+ },
441
+ stream
442
+ );
443
+ if (result.isFailure)
444
+ throw result;
445
+ return result.value;
446
+ }
447
+ async function _getGradingComponents$1(stream, gradingTypeId) {
448
+ const result = await stream.actions.data.getMany.execute(
449
+ {
450
+ model: "neu:penilaian:gradingComponent",
451
+ query: query.Query.define({
452
+ filter: { gradingTypeId },
453
+ fields: { id: 1, gradingTypeId: 1, subjectId: 1 },
454
+ limit: 200
455
+ })
456
+ },
457
+ stream
458
+ );
459
+ if (result.isFailure)
460
+ throw result;
461
+ return result.value;
462
+ }
463
+ async function _generateScores(stream, grading, gradingComponents) {
464
+ const operations = [];
465
+ for (const component of gradingComponents) {
466
+ operations.push({
467
+ insertOne: {
468
+ document: {
469
+ gradingId: grading.id,
470
+ gradingComponentId: component.id
471
+ }
472
+ }
473
+ });
474
+ }
475
+ await stream.core.dbs["neu-penilaian"].models["neu:penilaian:score"].bulkWrite(operations);
476
+ await stream.actions.data.syncMany.execute(
477
+ {
478
+ model: "neo:penilaian:score",
479
+ useDry: false,
480
+ query: query.Query.define({
481
+ filter: { gradingId: grading.id },
482
+ limit: 1e4
483
+ })
484
+ },
485
+ stream
486
+ );
487
+ }
488
+ async function _updateGradingInsert(stream, input) {
489
+ await stream.actions.data.updateOne.execute(
490
+ {
491
+ model: "neu:penilaian:gradingInsert",
492
+ id: input.gradingInsertId,
493
+ data: {
494
+ gradingId: input.gradingId
495
+ },
496
+ query: query.Query.define({})
497
+ },
498
+ stream
499
+ );
500
+ }
501
+
502
+ const updateGradingAndScores = operation.Action.define({
503
+ key: "updateGradingAndScores",
504
+ name: "Update Penilaian dan Score",
505
+ type: "command",
506
+ category: "domain",
507
+ execute: async ({ gradingTypeId, gradingId, studentId, data }, stream) => {
508
+ console.time("\u23F1\uFE0F updateGrading");
509
+ await _updateGrading(stream, { gradingId, studentId });
510
+ console.timeEnd("\u23F1\uFE0F updateGrading");
511
+ console.time("\u23F1\uFE0F getGradingComponents");
512
+ const gradingComponents = await _getGradingComponents(stream, gradingTypeId);
513
+ console.timeEnd("\u23F1\uFE0F getGradingComponents");
514
+ console.time("\u23F1\uFE0F updateScores");
515
+ await _updateScores(stream, gradingId, gradingComponents, data);
516
+ console.timeEnd("\u23F1\uFE0F updateScores");
517
+ return core.Result.ok({
518
+ state: "allUpdated",
519
+ message: "All Penilaian have been updated.",
520
+ data: {}
521
+ });
522
+ }
523
+ });
524
+ async function _updateGrading(stream, input) {
525
+ await stream.actions.data.updateOne.execute(
526
+ {
527
+ model: "neu:penilaian:grading",
528
+ id: input.gradingId,
529
+ data: {
530
+ studentId: input.studentId
531
+ },
532
+ query: query.Query.define({})
533
+ },
534
+ stream
535
+ );
536
+ }
537
+ async function _getGradingComponents(stream, gradingTypeId) {
538
+ const result = await stream.actions.data.getMany.execute(
539
+ {
540
+ model: "neu:penilaian:gradingComponent",
541
+ query: query.Query.define({
542
+ filter: { gradingTypeId },
543
+ fields: { id: 1, code: 1 },
544
+ limit: 200
545
+ })
546
+ },
547
+ stream
548
+ );
549
+ if (result.isFailure)
550
+ throw result;
551
+ return result.value;
552
+ }
553
+ async function _updateScores(stream, gradingId, gradingComponents, data) {
554
+ const operations = [];
555
+ for (const component of gradingComponents) {
556
+ operations.push({
557
+ updateOne: {
558
+ filter: {
559
+ gradingId,
560
+ gradingComponentId: component.id
561
+ },
562
+ update: {
563
+ quantitative: data[component.code] || 0
564
+ }
565
+ }
566
+ });
567
+ }
568
+ await stream.core.dbs["neu-penilaian"].models["neu:penilaian:score"].bulkWrite(operations);
569
+ await stream.actions.data.syncMany.execute(
570
+ {
571
+ model: "neo:penilaian:score",
572
+ useDry: false,
573
+ query: query.Query.define({
574
+ filter: { gradingId },
575
+ limit: 1e4
576
+ })
577
+ },
578
+ stream
579
+ );
580
+ }
581
+
24
582
  const acceptQuestion = operation.Action.define({
25
583
  key: "acceptQuestion",
26
584
  name: "Accept Question",
@@ -65,6 +623,45 @@ const acceptQuestion = operation.Action.define({
65
623
  }
66
624
  });
67
625
 
626
+ const editAnswer = operation.Action.define({
627
+ key: "editAnswer",
628
+ name: "Edit Answer",
629
+ type: "command",
630
+ category: "domain",
631
+ execute: async (input, stream) => {
632
+ const dbs = stream.core.dbs;
633
+ const answerResult = await stream.actions.data.getOne.execute({
634
+ model: "Answer",
635
+ id: input.answerId,
636
+ query: query.Query.define({
637
+ fields: {
638
+ _id: 1,
639
+ detail: 1,
640
+ images: 1
641
+ }
642
+ })
643
+ });
644
+ const answer = answerResult.value;
645
+ const dbQuestion = dbs.tanya.models.Question;
646
+ const userId = stream.context.identitas.userId;
647
+ await dbQuestion.updateOne(
648
+ { finalAnswerId: answer._id },
649
+ {
650
+ $set: {
651
+ answeredDetail: answer.detail,
652
+ answeredImages: answer.images,
653
+ updatedAt: new Date(),
654
+ updatedBy: userId
655
+ }
656
+ }
657
+ );
658
+ return core.Result.ok({
659
+ state: "editAnswer",
660
+ message: "Jawaban berhasil dikirim"
661
+ });
662
+ }
663
+ });
664
+
68
665
  const sendAnswer = operation.Action.define({
69
666
  key: "sendAnswer",
70
667
  name: "Send Answer",
@@ -185,210 +782,34 @@ const sendAnswer = operation.Action.define({
185
782
  }
186
783
  });
187
784
 
188
- const editAnswer = operation.Action.define({
189
- key: "editAnswer",
190
- name: "Edit Answer",
191
- type: "command",
192
- category: "domain",
193
- execute: async (input, stream) => {
194
- const dbs = stream.core.dbs;
195
- const answerResult = await stream.actions.data.getOne.execute({
196
- model: "Answer",
197
- id: input.answerId,
198
- query: query.Query.define({
199
- fields: {
200
- _id: 1,
201
- detail: 1,
202
- images: 1
203
- }
204
- })
205
- });
206
- const answer = answerResult.value;
207
- const dbQuestion = dbs.tanya.models.Question;
208
- const userId = stream.context.identitas.userId;
209
- await dbQuestion.updateOne(
210
- { finalAnswerId: answer._id },
211
- {
212
- $set: {
213
- answeredDetail: answer.detail,
214
- answeredImages: answer.images,
215
- updatedAt: new Date(),
216
- updatedBy: userId
217
- }
218
- }
219
- );
220
- return core.Result.ok({
221
- state: "editAnswer",
222
- message: "Jawaban berhasil dikirim"
223
- });
224
- }
225
- });
226
-
227
- const syncAllPenilaian = operation.Action.define({
228
- key: "syncAllPenilaian",
229
- name: "Sync All Penilaian",
230
- type: "command",
231
- category: "domain",
232
- execute: async ({}, stream) => {
233
- const models = [
234
- "neu:penilaian:gradingComponent",
235
- "neu:penilaian:gradingInsert",
236
- "neu:penilaian:grading",
237
- "neu:penilaian:gradingRasionalization",
238
- "neu:penilaian:gradingComparator",
239
- "neu:penilaian:gradingComparisonItem",
240
- "neu:penilaian:gradingComparisonItem",
241
- "neu:penilaian:gradingRasionalization",
242
- "neu:penilaian:gradingRasionalization"
243
- ];
244
- await syncModels(stream, models);
245
- return core.Result.ok({
246
- state: "allSynced",
247
- message: "All penilaian modules have been synced.",
248
- data: {}
249
- });
250
- }
251
- });
252
- async function syncModels(stream, models) {
253
- for (const model of models) {
254
- await stream.actions.data.syncMany.execute(
255
- {
256
- model,
257
- useDry: false,
258
- query: query.Query.define({
259
- limit: 1e5
260
- })
261
- },
262
- stream
263
- );
264
- }
265
- }
266
-
267
- const syncCommitment = operation.Action.define({
268
- key: "syncCommitment",
269
- name: "Sync Commitment",
270
- type: "command",
271
- category: "domain",
272
- execute: async (input, stream) => {
273
- const dbs = stream.core.dbs;
274
- const teacherResult = await stream.actions.data.getOne.execute({
275
- model: "Teacher",
276
- id: input.teacherId,
277
- query: query.Query.define({
278
- fields: {
279
- _id: 1,
280
- teacherCommitments: {
281
- weekdays: 1,
282
- startedAt: 1,
283
- endedAt: 1
284
- }
285
- }
286
- })
287
- });
288
- const teacher = teacherResult.value;
289
- const dbCommitment = dbs.talenta.models.TeacherCommitment;
290
- const dbTeacher = dbs.talenta.models.Teacher;
291
- const commitment = await dbCommitment.findOne({ teacherId: teacher._id }).sort({ createdAt: -1 });
292
- await dbTeacher.updateOne(
293
- { _id: teacher._id },
294
- {
295
- $set: {
296
- weekdays: commitment.weekdays,
297
- hourStart: commitment.startedAt,
298
- hourEnd: commitment.endedAt
299
- }
300
- }
301
- );
302
- return core.Result.ok({
303
- state: "syncCommitment",
304
- message: "Komitment disinkronasi!"
305
- });
306
- }
307
- });
308
-
309
- const presenceSessionStudent = operation.Action.define({
310
- key: "presenceSessionStudent",
311
- name: "Presence Student",
312
- type: "command",
313
- category: "domain",
314
- execute: async (input, stream) => {
315
- const dbs = stream.core.dbs;
316
- const sessionResult = await stream.actions.data.getOne.execute({
317
- model: "ClassSession",
318
- id: input.sessionId,
319
- query: query.Query.define({
320
- fields: {
321
- _id: 1
322
- }
323
- })
324
- });
325
- const session = sessionResult.value;
326
- const dbAttendance = dbs.jadwal.models.ClassAttendance;
327
- const dbStudent = dbs.siswa.models.Student;
328
- const siswa = await dbStudent.findOne({
329
- userId: stream.context.identitas.userId
330
- });
331
- await dbAttendance.create({
332
- classSessionId: session._id,
333
- studentId: siswa.id,
334
- presenceAt: new Date(),
335
- updatedAt: new Date(),
336
- createdBy: stream.context.identitas.userId,
337
- updatedBy: stream.context.identitas.userId
338
- });
339
- return core.Result.ok({
340
- state: "presenceSessionStudent",
341
- message: "Presensi berhasil!"
342
- });
343
- }
344
- });
345
-
346
- const presenceSessionTeacher = operation.Action.define({
347
- key: "presenceSessionTeacher",
348
- name: "Presence Teacher",
349
- type: "command",
350
- category: "domain",
351
- execute: async (input, stream) => {
352
- const dbs = stream.core.dbs;
353
- const sessionResult = await stream.actions.data.getOne.execute({
354
- model: "ClassSession",
355
- id: input.sessionId,
356
- query: query.Query.define({
357
- fields: {
358
- _id: 1
359
- }
360
- })
361
- });
362
- const session = sessionResult.value;
363
- const dbAttendance = dbs.jadwal.models.ClassAttendance;
364
- const dbTeacher = dbs.talenta.models.Teacher;
365
- const user = stream.context.identitas.userId;
366
- const pengajar = await dbTeacher.findOne({ userId: user });
367
- await dbAttendance.create({
368
- classSessionId: session._id,
369
- teacherId: pengajar.id,
370
- presenceAt: new Date(),
371
- updatedAt: new Date(),
372
- createdBy: user,
373
- updatedBy: user
374
- });
375
- return core.Result.ok({
376
- state: "presenceSessionTeacher",
377
- message: "Presensi berhasil!"
378
- });
379
- }
380
- });
381
-
382
785
  const index = {
383
786
  __proto__: null,
384
787
  acceptQuestion: acceptQuestion,
788
+ calculateGrading: calculateGrading,
789
+ clearGrading: clearGrading,
790
+ createGradingAndScores: createGradingAndScores,
385
791
  editAnswer: editAnswer,
792
+ generateGrading: generateGrading,
386
793
  presenceSessionStudent: presenceSessionStudent,
387
794
  presenceSessionTeacher: presenceSessionTeacher,
795
+ rasionalizeGrading: rasionalizeGrading,
388
796
  sendAnswer: sendAnswer,
389
797
  setSomething: setSomething,
390
- syncAllPenilaian: syncAllPenilaian,
391
- syncCommitment: syncCommitment
798
+ syncCommitment: syncCommitment,
799
+ updateGradingAndScores: updateGradingAndScores
392
800
  };
393
801
 
802
+ exports.acceptQuestion = acceptQuestion;
394
803
  exports.actions = index;
804
+ exports.calculateGrading = calculateGrading;
805
+ exports.clearGrading = clearGrading;
806
+ exports.createGradingAndScores = createGradingAndScores;
807
+ exports.editAnswer = editAnswer;
808
+ exports.generateGrading = generateGrading;
809
+ exports.presenceSessionStudent = presenceSessionStudent;
810
+ exports.presenceSessionTeacher = presenceSessionTeacher;
811
+ exports.rasionalizeGrading = rasionalizeGrading;
812
+ exports.sendAnswer = sendAnswer;
813
+ exports.setSomething = setSomething;
814
+ exports.syncCommitment = syncCommitment;
815
+ exports.updateGradingAndScores = updateGradingAndScores;