@things-factory/learning 10.1.269 → 10.1.271
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/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/activities.d.ts +19 -2
- package/dist-server/activities.js +7 -1
- package/dist-server/activities.js.map +1 -1
- package/dist-server/service/enrollment/enrollment-service.js +6 -2
- package/dist-server/service/enrollment/enrollment-service.js.map +1 -1
- package/dist-server/service/enrollment/learning-documents.d.ts +2 -2
- package/dist-server/service/enrollment/learning-documents.js +5 -4
- package/dist-server/service/enrollment/learning-documents.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -13
- package/translations/en.json +2 -1
- package/translations/es.json +2 -1
- package/translations/ja.json +2 -1
- package/translations/ko.json +2 -1
- package/translations/ms.json +2 -1
- package/translations/zh.json +2 -1
|
@@ -19,9 +19,14 @@ export declare const LEARNING_ACTIVITIES: {
|
|
|
19
19
|
inputKey: string;
|
|
20
20
|
tKey: string;
|
|
21
21
|
}[];
|
|
22
|
+
decisionKeys: {
|
|
23
|
+
role: string;
|
|
24
|
+
inputPath: string;
|
|
25
|
+
name: string;
|
|
26
|
+
}[];
|
|
22
27
|
viewType: string;
|
|
23
28
|
viewSource: string;
|
|
24
|
-
model: {
|
|
29
|
+
model: ({
|
|
25
30
|
name: string;
|
|
26
31
|
description: string;
|
|
27
32
|
tag: string;
|
|
@@ -33,6 +38,18 @@ export declare const LEARNING_ACTIVITIES: {
|
|
|
33
38
|
unit: any;
|
|
34
39
|
quantifier: number[];
|
|
35
40
|
spec: {};
|
|
36
|
-
}
|
|
41
|
+
} | {
|
|
42
|
+
name: string;
|
|
43
|
+
description: string;
|
|
44
|
+
tag: string;
|
|
45
|
+
inout: string;
|
|
46
|
+
type: string;
|
|
47
|
+
options: {};
|
|
48
|
+
unit: any;
|
|
49
|
+
quantifier: number[];
|
|
50
|
+
spec: {};
|
|
51
|
+
hidden?: undefined;
|
|
52
|
+
mandatory?: undefined;
|
|
53
|
+
})[];
|
|
37
54
|
standardTime: number;
|
|
38
55
|
}[];
|
|
@@ -29,12 +29,18 @@ exports.LEARNING_ACTIVITIES = [
|
|
|
29
29
|
uiType: 'custom-element',
|
|
30
30
|
uiSource: 'learning-todo',
|
|
31
31
|
searchKeys: [{ name: 'headline', description: 'The course and its due day', inputKey: 'headline', tKey: 'field.subject' }],
|
|
32
|
+
/* What was asked and what was done, on the case itself (worklist finished-case.ts) - the course and its day, and the outcome. */
|
|
33
|
+
decisionKeys: [
|
|
34
|
+
{ role: 'headline', inputPath: 'course', name: 'the course' },
|
|
35
|
+
{ role: 'subject', inputPath: 'headline', name: 'by when' }
|
|
36
|
+
],
|
|
32
37
|
viewType: '',
|
|
33
38
|
viewSource: '',
|
|
34
39
|
model: [
|
|
35
40
|
{ name: 'enrollmentId', description: 'The enrolment', tag: 'enrollmentId', hidden: true, mandatory: true, inout: 'in', type: 'string', options: {}, unit: null, quantifier: [1], spec: {} },
|
|
36
41
|
{ name: 'headline', description: 'The course and its due day', tag: 'headline', hidden: true, mandatory: true, inout: 'in', type: 'string', options: {}, unit: null, quantifier: [1], spec: {} },
|
|
37
|
-
{ name: 'address', description: 'The course screen', tag: 'address', hidden: true, mandatory: true, inout: 'in', type: 'string', options: {}, unit: null, quantifier: [1], spec: {} }
|
|
42
|
+
{ name: 'address', description: 'The course screen', tag: 'address', hidden: true, mandatory: true, inout: 'in', type: 'string', options: {}, unit: null, quantifier: [1], spec: {} },
|
|
43
|
+
{ name: 'outcome', description: 'How it ended - the course completed, on which day', tag: 'outcome', inout: 'out', type: 'string', options: {}, unit: null, quantifier: [1], spec: {} }
|
|
38
44
|
],
|
|
39
45
|
standardTime: 14 * 24 * 60 * 60
|
|
40
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activities.js","sourceRoot":"","sources":["../server/activities.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACU,QAAA,w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- not an approval: one person is asked to take one course by a day. It shows the course and\n * the day, with the way to the course (`learning-todo`). Completing the course ends it as done; a withdrawn or cancelled\n * enrolment aborts it. Reminding one past its day is worklist's (ADR-0186).\n *\n * Data only. An application installs it into its domains (Office `REQUIRED_ACTIVITIES`).\n */\nexport const LEARNING_COURSE_ACTIVITY = 'Learning Course'\n\nexport const LEARNING_ACTIVITIES = [\n {\n name: LEARNING_COURSE_ACTIVITY,\n label: 'course learning',\n description: 'A course to take by a day',\n guide: [\n 'an enrolment hands it out - a mandatory training session, onboarding, or a manager assigning a course.',\n 'it opens the course; completing the course ends it.',\n 'a to-do past its day is reminded as every overdue to-do is.'\n ],\n release: '1.0.0',\n provider: 'hatiolab.com',\n category: 'learning',\n activityType: 'user',\n priority: 2,\n startingType: 'issue',\n multiple: 'single',\n uiType: 'custom-element',\n uiSource: 'learning-todo',\n searchKeys: [{ name: 'headline', description: 'The course and its due day', inputKey: 'headline', tKey: 'field.subject' }],\n /* What was asked and what was done, on the case itself (worklist finished-case.ts) - the course and its day, and the outcome. */\n decisionKeys: [\n { role: 'headline', inputPath: 'course', name: 'the course' },\n { role: 'subject', inputPath: 'headline', name: 'by when' }\n ],\n viewType: '',\n viewSource: '',\n model: [\n { name: 'enrollmentId', description: 'The enrolment', tag: 'enrollmentId', hidden: true, mandatory: true, inout: 'in', type: 'string', options: {}, unit: null, quantifier: [1], spec: {} },\n { name: 'headline', description: 'The course and its due day', tag: 'headline', hidden: true, mandatory: true, inout: 'in', type: 'string', options: {}, unit: null, quantifier: [1], spec: {} },\n { name: 'address', description: 'The course screen', tag: 'address', hidden: true, mandatory: true, inout: 'in', type: 'string', options: {}, unit: null, quantifier: [1], spec: {} },\n { name: 'outcome', description: 'How it ended - the course completed, on which day', tag: 'outcome', inout: 'out', type: 'string', options: {}, unit: null, quantifier: [1], spec: {} }\n ],\n standardTime: 14 * 24 * 60 * 60\n }\n]\n"]}
|
|
@@ -72,7 +72,8 @@ async function issueTodo(context, enrollment, course, person) {
|
|
|
72
72
|
const name = t('text.learning-todo-name', { course: course.name });
|
|
73
73
|
const headline = enrollment.dueOn ? t('text.learning-todo-headline', { dueOn: enrollment.dueOn }) : t('text.learning-todo-headline-no-due');
|
|
74
74
|
const dueAt = enrollment.dueOn ? dueAtOf(enrollment.dueOn, domain.timezone) : undefined;
|
|
75
|
-
const
|
|
75
|
+
const address = (0, exports.learningAddressOf)(enrollment.id);
|
|
76
|
+
const input = { enrollmentId: enrollment.id, course: course.name, headline, address, sourceHref: address };
|
|
76
77
|
const instance = await (0, worklist_1.handOut)({ activityId: activity.id, name, description: headline, input, assignee: person, dueAt }, context);
|
|
77
78
|
return instance.id;
|
|
78
79
|
}
|
|
@@ -91,7 +92,10 @@ async function todoOpen(tx, instanceId) {
|
|
|
91
92
|
async function completeTodo(tx, domain, enrollment, by) {
|
|
92
93
|
if (!enrollment.todoInstanceId || !(await todoOpen(tx, enrollment.todoInstanceId)))
|
|
93
94
|
return;
|
|
94
|
-
|
|
95
|
+
/* What was done, as the finished to-do shows it; no reason - 「course completed」 showed on the timeline as written. */
|
|
96
|
+
const context = todoContextOf(tx, domain, by);
|
|
97
|
+
const outcome = context.t('text.learning-todo-outcome', { day: (0, exports.todayIn)(domain) });
|
|
98
|
+
await (0, worklist_1.complete)({ id: enrollment.todoInstanceId, output: { outcome } }, context);
|
|
95
99
|
}
|
|
96
100
|
/** Aborts the to-do of an enrolment withdrawn or cancelled. */
|
|
97
101
|
async function abortTodo(tx, domain, enrollment, by, reason) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enrollment-service.js","sourceRoot":"","sources":["../../../server/service/enrollment/enrollment-service.ts"],"names":[],"mappings":";;;AAwGA,wBA0BC;AAMD,4BAMC;AAeD,8CAOC;AAmBD,gCAUC;AAID,oCAIC;AAGD,wCAIC;AAGD,wCAGC;AAED,oCAEC;AAGD,gCAiBC;AAiBD,sCAIC;AAaD,gCAiCC;AAGD,sDAOC;AAUD,gCAaC;AAgBD,4CA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AC9D,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,SAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,SAAU,CAAC,CAAC,CAAA;AAC1K,CAAC","sourcesContent":["/*\n * What the doors of enrolments do with the database (ADR-0194 decisions 5-8): enrolling people for whoever asks and\n * withdrawing them, the to-do of each, the time the server counts from ticks, the quiz the server scores, the\n * acknowledgement, and completing an enrolment with its evidence in the same transaction as the handler of whoever\n * asked. Nothing here deletes an enrolment or its progress.\n */\nimport { EntityManager, In, IsNull } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { audienceTargetRefusal, audienceUserIds, departmentTreeOf, domainRolesOf } from '@things-factory/organization'\nimport { logger } from '@things-factory/env'\nimport { translatorFor } from '@things-factory/i18n-base/translator'\nimport { calendarDay, getRepository, Refusal } from '@things-factory/shell'\nimport { abort, Activity, ActivityThread, complete, handOut } from '@things-factory/worklist'\n\nimport { LEARNING_COURSE_ACTIVITY } from '../../activities'\nimport { Course } from '../course/course'\nimport { CourseQuestion } from '../course/course-question'\nimport { CourseUnit, CourseUnitKind } from '../course/course-unit'\nimport { CourseVersion } from '../course/course-version'\nimport { courseOf, learningManagerOf, publishedVersionOf, questionsOf, unitsOf } from '../course/course-service'\nimport { Enrollment, EnrollmentStatus, OPEN_ENROLLMENT_STATUSES } from './enrollment'\nimport { learningOutcomeOf } from './learning-outcome'\nimport { counts, drawQuestions, missingOf, Missing, scoreOf, tickVerdict, unitDone } from './progress-rules'\nimport { QuizAttempt } from './quiz-attempt'\nimport { UnitProgress } from './unit-progress'\n\n/** Who asked for an enrolment - a module's kind of record and the record. A manager's own is `learning.direct`. */\nexport interface LearningSource {\n kind: string\n id?: string | null\n}\n\nexport const DIRECT_SOURCE_KIND = 'learning.direct'\n\n/** The learner's screen of one enrolment - where the to-do leads. */\nexport const learningAddressOf = (enrollmentId: string) => `learning-view?id=${enrollmentId}`\n\nexport const todayIn = (domain: { timezone?: string | null }, now: Date = new Date()) => calendarDay(domain?.timezone, now)\n\nconst notFound = () => new Refusal('learning-not-found', {}, 'the record was not found. reload and try again.')\nconst isOpen = (status: string) => (OPEN_ENROLLMENT_STATUSES as string[]).includes(status)\n\n/* ---------------------------------------------------------------- the to-do (decision 5) */\n\n/** The context worklist closes a to-do under - `by` ends or aborts it; worklist speaks its refusals through `t`. */\nfunction todoContextOf(tx: EntityManager, domain: any, user: User) {\n const t = translatorFor(user.locale || 'ko')\n return { state: { domain, user, tx }, t: (key: string, options?: any) => t(key, options) } as any\n}\n\n/**\n * Hands out 「<과정> 수강」 to the person, with the due day - nothing where the domain has not installed the to-do. worklist's\n * handOut: the person's 할 일 and nobody's 상신함, also when the manager assigning it is the person (2026-11-08). The one\n * who asked (`context`) stands as its issuer.\n */\nasync function issueTodo(context: any, enrollment: Enrollment, course: Course, person: User): Promise<string | null> {\n const { domain, tx } = context.state\n const activity = await tx.getRepository(Activity).findOne({ where: { domain: { id: domain.id }, name: LEARNING_COURSE_ACTIVITY } as any })\n if (!activity) {\n logger.warn(`[learning] ${domain.subdomain}: the activity \"${LEARNING_COURSE_ACTIVITY}\" is not installed - \"${course.name}\" not handed out`)\n return null\n }\n const t = translatorFor(person.locale || 'ko')\n const name = t('text.learning-todo-name', { course: course.name })\n const headline = enrollment.dueOn ? t('text.learning-todo-headline', { dueOn: enrollment.dueOn }) : t('text.learning-todo-headline-no-due')\n const dueAt = enrollment.dueOn ? dueAtOf(enrollment.dueOn, domain.timezone) : undefined\n const input = { enrollmentId: enrollment.id, headline, address: learningAddressOf(enrollment.id) }\n const instance = await handOut({ activityId: activity.id, name, description: headline, input, assignee: person, dueAt }, context)\n return instance.id\n}\n\n/** The end of the due day in the domain's time zone. */\nfunction dueAtOf(dueOn: string, timezone?: string | null): Date {\n const end = new Date(`${dueOn}T23:59:59Z`)\n const zone = timezone || 'UTC'\n const asLocal = new Date(end.toLocaleString('en-US', { timeZone: zone }))\n const asUtc = new Date(end.toLocaleString('en-US', { timeZone: 'UTC' }))\n return new Date(end.getTime() - (asLocal.getTime() - asUtc.getTime()))\n}\n\nasync function todoOpen(tx: EntityManager, instanceId: string): Promise<boolean> {\n return (await tx.getRepository(ActivityThread).count({ where: { activityInstance: { id: instanceId }, state: In(['assigned', 'started', 'unassigned']) } as any })) > 0\n}\n\n/** Ends the to-do as done once the course is completed. */\nasync function completeTodo(tx: EntityManager, domain: any, enrollment: Enrollment, by: User): Promise<void> {\n if (!enrollment.todoInstanceId || !(await todoOpen(tx, enrollment.todoInstanceId))) return\n await complete({ id: enrollment.todoInstanceId, reason: 'course completed' }, todoContextOf(tx, domain, by))\n}\n\n/** Aborts the to-do of an enrolment withdrawn or cancelled. */\nasync function abortTodo(tx: EntityManager, domain: any, enrollment: Enrollment, by: User, reason: string): Promise<void> {\n if (!enrollment.todoInstanceId || !(await todoOpen(tx, enrollment.todoInstanceId))) return\n await abort({ id: enrollment.todoInstanceId, reason } as any, todoContextOf(tx, domain, by))\n}\n\n/* ---------------------------------------------------------------- enrolling and withdrawing (decision 7) */\n\n/**\n * Enrols people in a course for whoever asks (`source`), to be completed by `dueOn` - the server function a using module\n * calls with the people it chose. One open enrolment per person, course and source: a person who has one is left with\n * it. Each new enrolment hands out its to-do. Answers the open enrolments of everyone given.\n */\nexport async function enroll(source: LearningSource, userIds: string[], courseId: string, dueOn: string | null | undefined, context: any): Promise<Enrollment[]> {\n const { domain, user, tx } = context.state\n if (!source?.kind) throw new Refusal('learning-source-required', {}, 'an enrolment names who asked for it')\n if (dueOn && !/^\\d{4}-\\d{2}-\\d{2}$/.test(dueOn)) throw new Refusal('learning-due-invalid', {}, 'the due day is YYYY-MM-DD')\n const course = await courseOf(tx, domain, courseId)\n if (!(await publishedVersionOf(tx, domain, course.id))) throw new Refusal('learning-course-not-published', { course: course.name }, `${course.name} has no published version`)\n const ids = [...new Set(userIds)].filter(Boolean)\n if (!ids.length) return []\n const people = await (tx as EntityManager).getRepository(User).find({ where: { id: In(ids) }, relations: ['domains'] })\n const sourceId = source.id ?? ''\n const repository = (tx as EntityManager).getRepository(Enrollment)\n const out: Enrollment[] = []\n for (const id of ids) {\n const person = people.find(one => one.id === id)\n if (!person || !(person.domains ?? []).some(one => one.id === domain.id)) throw new Refusal('learning-learner-unknown', {}, 'a learner must be a user of this domain')\n const open = await repository.findOne({ where: { domain: { id: domain.id }, user: { id }, course: { id: course.id }, sourceKind: source.kind, sourceId, status: In(OPEN_ENROLLMENT_STATUSES) } as any })\n if (open) {\n out.push(open)\n continue\n }\n const saved = await repository.save({ domain, user: person, course, dueOn: dueOn || null, sourceKind: source.kind, sourceId, status: EnrollmentStatus.ASSIGNED, learnedSeconds: 0, attempts: 0, creator: user, updater: user } as any)\n const todo = await issueTodo(context, saved, course, person)\n if (todo) await repository.update(saved.id, { todoInstanceId: todo } as any)\n out.push((await repository.findOneBy({ id: saved.id }))!)\n }\n return out\n}\n\n/**\n * Withdraws the open enrolments a source asked for - the record they were for was taken back. Each is cancelled with\n * the reason and its to-do aborted; completed ones stay. Answers how many were withdrawn.\n */\nexport async function withdraw(source: LearningSource, reason: string, context: any): Promise<number> {\n const { domain, user, tx } = context.state\n const rows = await (tx as EntityManager).getRepository(Enrollment).find({ where: { domain: { id: domain.id }, sourceKind: source.kind, sourceId: source.id ?? '', status: In(OPEN_ENROLLMENT_STATUSES) } as any })\n let count = 0\n for (const row of rows) if (await cancelOpen(tx, domain, row, user, reason)) count++\n return count\n}\n\n/** Cancels an open enrolment - claimed by an update only an open one matches, so a completion at the same time wins once. */\nasync function cancelOpen(tx: EntityManager, domain: any, row: Enrollment, by: User, reason: string): Promise<boolean> {\n const claimed = await tx.getRepository(Enrollment).update({ id: row.id, status: In(OPEN_ENROLLMENT_STATUSES) } as any, { status: EnrollmentStatus.CANCELLED, cancelledAt: new Date(), cancelReason: reason, updater: by } as any)\n if (!claimed.affected) return false\n await abortTodo(tx, domain, row, by, reason)\n return true\n}\n\n/**\n * A manager cancels enrolments with one reason (decision 8) - together: one refused, none is cancelled. An open one is\n * withdrawn; a completed one stays on record as cancelled - never deleted - and whoever asked for it is told in the same\n * transaction.\n */\nexport async function cancelEnrollments(ids: string[], reason: string, context: any): Promise<Enrollment[]> {\n if (!reason?.trim()) throw new Refusal('learning-cancel-reason-required', {}, 'say why it is cancelled')\n const unique = [...new Set(ids ?? [])]\n if (!unique.length) throw new Refusal('learning-cancel-none', {}, 'pick the enrolments to cancel')\n const out: Enrollment[] = []\n for (const id of unique) out.push(await cancelOne(id, reason.trim(), context))\n return out\n}\n\nasync function cancelOne(id: string, reason: string, context: any): Promise<Enrollment> {\n const { domain, user, tx } = context.state\n const row = await enrollmentOf(tx, domain, id)\n if (isOpen(row.status)) {\n if (!(await cancelOpen(tx, domain, row, user, reason))) throw new Refusal('learning-enrollment-moved', {}, 'the enrolment changed meanwhile - reload and try again')\n } else if (row.status === EnrollmentStatus.COMPLETED) {\n const claimed = await tx.getRepository(Enrollment).update({ id: row.id, status: EnrollmentStatus.COMPLETED } as any, { status: EnrollmentStatus.CANCELLED, cancelledAt: new Date(), cancelReason: reason, updater: user } as any)\n if (!claimed.affected) throw new Refusal('learning-enrollment-moved', {}, 'the enrolment changed meanwhile - reload and try again')\n await learningOutcomeOf(row.sourceKind)?.cancelled?.((await enrollmentOf(tx, domain, id))!, reason, context)\n } else throw new Refusal('learning-enrollment-cancelled', {}, 'the enrolment is cancelled already')\n return await enrollmentOf(tx, domain, id)\n}\n\n/**\n * The people an audience names now - the domain, departments with those under them, roles and people, by organization's\n * one rule (ADR-0163). Each target must be of this domain.\n */\nexport async function learnersOf(audiences: { scope: string; targetId: string; targetName?: string }[], context: any): Promise<string[]> {\n const { domain, tx } = context.state\n if (!audiences?.length) throw new Refusal('learning-audience-required', {}, 'pick who takes the course')\n const departmentIds = [...(await departmentTreeOf(domain, tx)).keys()]\n const roleIds = (await domainRolesOf(domain, undefined, tx)).map(one => one.id)\n for (const target of audiences) {\n const why = audienceTargetRefusal(target as any, { domainId: domain.id, departmentIds, roleIds })\n if (why) throw new Refusal('learning-audience-invalid', { target: target.targetName ?? target.targetId }, `${target.targetName ?? target.targetId} is not of this domain (${why})`)\n }\n return await audienceUserIds(domain, audiences as any, tx)\n}\n\n/* ---------------------------------------------------------------- reading */\n\nexport async function enrollmentOf(tx: EntityManager, domain: { id: string }, id: string): Promise<Enrollment> {\n const row = id && /^[0-9a-f-]{36}$/i.test(id) ? await tx.getRepository(Enrollment).findOne({ where: { id, domain: { id: domain.id } } as any }) : null\n if (!row) throw notFound()\n return row\n}\n\n/** The request's own enrolment - one answer for \"none\" and \"not yours\". */\nexport async function myEnrollmentOf(context: any, id: string, tx: EntityManager = learningManagerOf(context)): Promise<Enrollment> {\n const row = await enrollmentOf(tx, context.state.domain, id)\n if (row.userId !== context.state.user.id) throw notFound()\n return row\n}\n\n/** The version an enrolment shows: its own once started, the published one before. */\nexport async function shownVersionOf(tx: EntityManager, domain: { id: string }, enrollment: Enrollment): Promise<CourseVersion | null> {\n if (enrollment.versionId) return await tx.getRepository(CourseVersion).findOne({ where: { id: enrollment.versionId } as any, withDeleted: true })\n return await publishedVersionOf(tx, domain, enrollment.courseId!)\n}\n\nexport async function progressesOf(tx: EntityManager, enrollmentId: string): Promise<UnitProgress[]> {\n return await tx.getRepository(UnitProgress).find({ where: { enrollment: { id: enrollmentId } } as any })\n}\n\n/** What still stands between an enrolment and its completion - nothing for a completed one. */\nexport async function missingFor(tx: EntityManager, domain: { id: string }, enrollment: Enrollment): Promise<Missing[]> {\n if (enrollment.status === EnrollmentStatus.COMPLETED) return []\n const version = await shownVersionOf(tx, domain, enrollment)\n if (!version) return ['units']\n const units = (await unitsOf(tx, version.id)).filter(counts)\n const progress = await progressesOf(tx, enrollment.id)\n const questions = version.passScore != null ? await tx.getRepository(CourseQuestion).count({ where: { version: { id: version.id } } as any }) : 0\n return missingOf({\n units: units.length,\n unitsDone: units.filter(unit => progress.some(one => one.unitId === unit.id && one.doneAt)).length,\n learnedSeconds: enrollment.learnedSeconds,\n minSeconds: version.minSeconds ?? 0,\n quiz: version.passScore != null && questions > 0,\n passed: enrollment.score != null && enrollment.score >= (version.passScore ?? 101),\n acknowledgement: !!version.acknowledgement,\n acknowledged: !!enrollment.acknowledgedAt\n })\n}\n\n/* ---------------------------------------------------------------- learning (decision 6) */\n\n/** The enrolment, started if it was not: its version fixed to the one published now, in progress from now on. */\nasync function started(tx: EntityManager, domain: any, enrollment: Enrollment, user: User): Promise<Enrollment> {\n if (enrollment.status === EnrollmentStatus.CANCELLED) throw new Refusal('learning-enrollment-cancelled', {}, 'the enrolment is cancelled')\n if (enrollment.versionId) {\n if (enrollment.status === EnrollmentStatus.ASSIGNED) await tx.getRepository(Enrollment).update({ id: enrollment.id, status: EnrollmentStatus.ASSIGNED } as any, { status: EnrollmentStatus.IN_PROGRESS, startedAt: new Date() } as any)\n return await enrollmentOf(tx, domain, enrollment.id)\n }\n const version = await publishedVersionOf(tx, domain, enrollment.courseId!)\n if (!version) throw new Refusal('learning-course-not-published', {}, 'the course has no published version')\n await tx.getRepository(Enrollment).update({ id: enrollment.id, status: In(OPEN_ENROLLMENT_STATUSES) } as any, { version, status: EnrollmentStatus.IN_PROGRESS, startedAt: enrollment.startedAt ?? new Date(), updater: user } as any)\n return await enrollmentOf(tx, domain, enrollment.id)\n}\n\nexport async function unitOfVersion(tx: EntityManager, version: { id: string }, unitId: string): Promise<CourseUnit> {\n const unit = await tx.getRepository(CourseUnit).findOne({ where: { id: unitId, version: { id: version.id } } as any })\n if (!unit) throw notFound()\n return unit\n}\n\nexport interface TickResult {\n enrollment: Enrollment\n progress: UnitProgress\n}\n\n/**\n * One tick of the learner's screen on a unit (decision 6): the server adds the gap since the unit's last tick, at most\n * 15 seconds and at most what the screen says, and refuses a video position ahead of what was watched. A total the\n * screen sends is never taken. A unit that reaches its condition is done, and the enrolment is completed when nothing is\n * missing any more.\n */\nexport async function recordTick(enrollmentId: string, unitId: string, seconds: number, position: number, context: any, now: Date = new Date()): Promise<TickResult> {\n const { domain, user, tx } = context.state\n let enrollment = await myEnrollmentOf(context, enrollmentId, tx)\n enrollment = await started(tx, domain, enrollment, user)\n const unit = await unitOfVersion(tx, { id: enrollment.versionId! }, unitId)\n if (unit.kind === CourseUnitKind.LINK) throw new Refusal('learning-link-not-counted', {}, 'a link is not counted')\n const repository = (tx as EntityManager).getRepository(UnitProgress)\n const progress =\n (await repository.findOne({ where: { enrollment: { id: enrollment.id }, unit: { id: unit.id } } as any })) ??\n (await repository.save({ domain, enrollment, unit, learnedSeconds: 0, watchedSeconds: 0, positionSeconds: 0, pagesSeen: 0, pagesRead: 0, pageSeconds: 0, pageAt: 0, creator: user, updater: user } as any))\n if (enrollment.status === EnrollmentStatus.COMPLETED) return { enrollment, progress }\n\n const verdict = tickVerdict(progress, { seconds, position }, now, unit)\n if ('refusal' in verdict) {\n if (verdict.refusal === 'page-ahead') throw new Refusal('learning-page-ahead', { allowed: verdict.allowed }, `a page cannot be ahead of the one after the last read (${verdict.allowed})`)\n throw new Refusal('learning-position-ahead', { allowed: verdict.allowed }, `the video cannot be ahead of what was watched (${verdict.allowed} s)`)\n }\n progress.learnedSeconds += verdict.add\n progress.watchedSeconds = verdict.watchedSeconds\n progress.positionSeconds = verdict.positionSeconds\n progress.pagesSeen = verdict.pagesSeen\n progress.pagesRead = verdict.pagesRead\n progress.pageSeconds = verdict.pageSeconds\n progress.pageAt = verdict.pageAt\n progress.lastTickAt = now\n if (!progress.doneAt && unitDone(unit, progress)) progress.doneAt = now\n progress.updater = user\n await repository.save(progress)\n if (verdict.add) await tx.getRepository(Enrollment).increment({ id: enrollment.id } as any, 'learnedSeconds', verdict.add)\n /* Where the learner was - the course opens on this unit again (2026-11-08). */\n if (enrollment.lastUnitId !== unit.id) await tx.getRepository(Enrollment).update({ id: enrollment.id } as any, { lastUnitId: unit.id } as any)\n enrollment = await completeIfMet(tx, domain, await enrollmentOf(tx, domain, enrollment.id), context)\n return { enrollment, progress }\n}\n\n/** The learner confirms the version's acknowledgement - recorded once, when they did. */\nexport async function acknowledgeEnrollment(enrollmentId: string, context: any): Promise<Enrollment> {\n const { domain, user, tx } = context.state\n let enrollment = await started(tx, domain, await myEnrollmentOf(context, enrollmentId, tx), user)\n const version = await shownVersionOf(tx, domain, enrollment)\n if (!version?.acknowledgement) throw new Refusal('learning-no-acknowledgement', {}, 'the course asks for no acknowledgement')\n if (!enrollment.acknowledgedAt) await tx.getRepository(Enrollment).update({ id: enrollment.id } as any, { acknowledgedAt: new Date(), updater: user } as any)\n return await completeIfMet(tx, domain, await enrollmentOf(tx, domain, enrollment.id), context)\n}\n\n/* ---------------------------------------------------------------- the quiz (decision 4) */\n\nexport interface DrawnForLearner {\n attempt: QuizAttempt\n questions: { id: string; kind: string; text: string; choices: { id: string; text: string }[] }[]\n}\n\n/** The questions of an attempt as the learner is drawn them - the choices in the order shown, never whether one is right. */\nexport function forLearner(attempt: QuizAttempt, questions: CourseQuestion[]): DrawnForLearner {\n return {\n attempt,\n questions: attempt.drawn.map(drawn => {\n const question = questions.find(one => one.id === drawn.questionId)!\n return {\n id: question.id,\n kind: question.kind,\n text: question.text,\n choices: drawn.choiceIds.map(id => question.choices.find(one => one.id === id)!).map(one => ({ id: one.id, text: one.text }))\n }\n })\n }\n}\n\n/**\n * Starts an attempt at the quiz: the questions drawn and shuffled, their choices shuffled. An attempt not sent yet is\n * answered again; the version's limit on attempts holds.\n */\n/**\n * Holds the enrolment for the rest of the request's transaction - an update takes its row lock on every driver, so two\n * attempts of one enrolment are started, counted and sent one after the other. Two starts at once made two unsent\n * attempts, and a limit of one let both be sent (2026-11-08).\n */\nasync function holdEnrollment(tx: EntityManager, domain: any, enrollment: Enrollment, user: User): Promise<Enrollment> {\n await tx.getRepository(Enrollment).update({ id: enrollment.id } as any, { updater: user } as any)\n return await enrollmentOf(tx, domain, enrollment.id)\n}\n\nexport async function startQuizAttempt(enrollmentId: string, context: any): Promise<DrawnForLearner> {\n const { domain, user, tx } = context.state\n const held = await holdEnrollment(tx, domain, await myEnrollmentOf(context, enrollmentId, tx), user)\n const enrollment = await started(tx, domain, held, user)\n if (enrollment.status === EnrollmentStatus.COMPLETED) throw new Refusal('learning-enrollment-completed', {}, 'the course is completed')\n const version = (await shownVersionOf(tx, domain, enrollment))!\n const questions = await questionsOf(tx, version.id)\n if (version.passScore == null || !questions.length) throw new Refusal('learning-no-quiz', {}, 'the course has no quiz')\n const repository = (tx as EntityManager).getRepository(QuizAttempt)\n const pending = await repository.findOne({ where: { enrollment: { id: enrollment.id }, submittedAt: IsNull() } as any })\n if (pending) return forLearner(pending, questions)\n if (version.attemptLimit != null && enrollment.attempts >= version.attemptLimit) throw new Refusal('learning-attempts-used', { limit: version.attemptLimit }, `all ${version.attemptLimit} attempts are used`)\n const attempt = await repository.save({ domain, enrollment, drawn: drawQuestions(questions, version.questionCount), creator: user, updater: user } as any)\n return forLearner(attempt, questions)\n}\n\nexport interface QuizResult {\n enrollment: Enrollment\n score: number\n passed: boolean\n attemptsLeft: number | null\n}\n\n/**\n * Scores an attempt's answers on the server against what it drew (decision 4) - only the score and whether it passed go\n * back, never the right answers. The best score stays on the enrolment; passing may complete it.\n */\nexport async function submitQuizAttempt(attemptId: string, answers: Record<string, string[]>, context: any): Promise<QuizResult> {\n const { domain, user, tx } = context.state\n const attempt = await (tx as EntityManager).getRepository(QuizAttempt).findOne({ where: { id: attemptId, domain: { id: domain.id } } as any })\n if (!attempt) throw notFound()\n const enrollment = await holdEnrollment(tx, domain, await myEnrollmentOf(context, attempt.enrollmentId!, tx), user)\n const version = (await shownVersionOf(tx, domain, enrollment))!\n if (version.attemptLimit != null && enrollment.attempts >= version.attemptLimit) throw new Refusal('learning-attempts-used', { limit: version.attemptLimit }, `all ${version.attemptLimit} attempts are used`)\n const questions = await questionsOf(tx, version.id)\n const drawn = attempt.drawn.map(one => questions.find(question => question.id === one.questionId)).filter(Boolean) as CourseQuestion[]\n const kept: Record<string, string[]> = Object.fromEntries(drawn.map(question => [question.id, (answers?.[question.id] ?? []).map(String)]))\n const score = scoreOf(drawn, kept)\n const passed = score >= (version.passScore ?? 101)\n const claimed = await tx.getRepository(QuizAttempt).update({ id: attempt.id, submittedAt: IsNull() } as any, { answers: kept, score, passed, submittedAt: new Date(), updater: user } as any)\n if (!claimed.affected) throw new Refusal('learning-attempt-sent', {}, 'the attempt was sent already')\n await tx.getRepository(Enrollment).increment({ id: enrollment.id } as any, 'attempts', 1)\n await tx.getRepository(Enrollment).update({ id: enrollment.id } as any, { score: Math.max(enrollment.score ?? 0, score), updater: user } as any)\n const after = await completeIfMet(tx, domain, await enrollmentOf(tx, domain, enrollment.id), context)\n return { enrollment: after, score, passed, attemptsLeft: version.attemptLimit != null ? Math.max(0, version.attemptLimit - after.attempts) : null }\n}\n\n/* ---------------------------------------------------------------- completing (decision 8) */\n\n/** A certificate number: the day completed and the enrolment's own id - one per completion, never reused. */\nexport const certificateNoOf = (enrollment: { id: string }, day: string) => `LMS-${day.replace(/-/g, '')}-${enrollment.id.replace(/-/g, '').slice(0, 8).toUpperCase()}`\n\n/**\n * Completes an open enrolment when nothing is missing - every unit done, the least time, the quiz passed, the\n * acknowledgement confirmed. The evidence stays on it; whoever asked for it is told in this same transaction (a handler\n * that fails takes the completion back), and the to-do ends as done.\n */\nexport async function completeIfMet(tx: EntityManager, domain: any, enrollment: Enrollment, context: any): Promise<Enrollment> {\n if (!isOpen(enrollment.status) || !enrollment.versionId) return enrollment\n if ((await missingFor(tx, domain, enrollment)).length) return enrollment\n const now = new Date()\n const claimed = await tx\n .getRepository(Enrollment)\n .update({ id: enrollment.id, status: In(OPEN_ENROLLMENT_STATUSES) } as any, { status: EnrollmentStatus.COMPLETED, completedAt: now, certificateNo: certificateNoOf(enrollment, todayIn(domain, now)), updater: context.state.user } as any)\n if (!claimed.affected) return await enrollmentOf(tx, domain, enrollment.id)\n const completed = await enrollmentOf(tx, domain, enrollment.id)\n await learningOutcomeOf(completed.sourceKind)?.completed(completed, context)\n await completeTodo(tx, domain, completed, context.state.user)\n return completed\n}\n\n/* ---------------------------------------------------------------- whom an enrolment is for */\n\n/** The open and completed enrolments of the request's person, the open first and the soonest due first. */\nexport async function myEnrollments(context: any): Promise<Enrollment[]> {\n const { domain, user } = context.state\n const rows = await learningManagerOf(context)\n .getRepository(Enrollment)\n .find({ where: { domain: { id: domain.id }, user: { id: user.id }, status: In([...OPEN_ENROLLMENT_STATUSES, EnrollmentStatus.COMPLETED]) } as any })\n const rank = (one: Enrollment) => (isOpen(one.status) ? 0 : 1)\n return rows.sort((a, b) => rank(a) - rank(b) || String(a.dueOn ?? '9999').localeCompare(String(b.dueOn ?? '9999')) || +new Date(b.createdAt!) - +new Date(a.createdAt!))\n}\n\nexport { isOpen }\n"]}
|
|
1
|
+
{"version":3,"file":"enrollment-service.js","sourceRoot":"","sources":["../../../server/service/enrollment/enrollment-service.ts"],"names":[],"mappings":";;;AA4GA,wBA0BC;AAMD,4BAMC;AAeD,8CAOC;AAmBD,gCAUC;AAID,oCAIC;AAGD,wCAIC;AAGD,wCAGC;AAED,oCAEC;AAGD,gCAiBC;AAiBD,sCAIC;AAaD,gCAiCC;AAGD,sDAOC;AAUD,gCAaC;AAgBD,4CAcC;AAaD,8CAkBC;AAYD,sCAYC;AAKD,sCAOC;AAvbD;;;;;GAKG;AACH,qCAAmD;AAEnD,yDAAgD;AAChD,+DAAsH;AACtH,6CAA4C;AAC5C,qEAAoE;AACpE,iDAA2E;AAC3E,uDAA6F;AAE7F,iDAA2D;AAE3D,+DAA0D;AAC1D,uDAAkE;AAClE,6DAAwD;AACxD,6DAAgH;AAChH,6CAAqF;AACrF,yDAAsD;AACtD,qDA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OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,SAAU,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,SAAU,CAAC,CAAC,CAAA;AAC1K,CAAC","sourcesContent":["/*\n * What the doors of enrolments do with the database (ADR-0194 decisions 5-8): enrolling people for whoever asks and\n * withdrawing them, the to-do of each, the time the server counts from ticks, the quiz the server scores, the\n * acknowledgement, and completing an enrolment with its evidence in the same transaction as the handler of whoever\n * asked. Nothing here deletes an enrolment or its progress.\n */\nimport { EntityManager, In, IsNull } from 'typeorm'\n\nimport { User } from '@things-factory/auth-base'\nimport { audienceTargetRefusal, audienceUserIds, departmentTreeOf, domainRolesOf } from '@things-factory/organization'\nimport { logger } from '@things-factory/env'\nimport { translatorFor } from '@things-factory/i18n-base/translator'\nimport { calendarDay, getRepository, Refusal } from '@things-factory/shell'\nimport { abort, Activity, ActivityThread, complete, handOut } from '@things-factory/worklist'\n\nimport { LEARNING_COURSE_ACTIVITY } from '../../activities'\nimport { Course } from '../course/course'\nimport { CourseQuestion } from '../course/course-question'\nimport { CourseUnit, CourseUnitKind } from '../course/course-unit'\nimport { CourseVersion } from '../course/course-version'\nimport { courseOf, learningManagerOf, publishedVersionOf, questionsOf, unitsOf } from '../course/course-service'\nimport { Enrollment, EnrollmentStatus, OPEN_ENROLLMENT_STATUSES } from './enrollment'\nimport { learningOutcomeOf } from './learning-outcome'\nimport { counts, drawQuestions, missingOf, Missing, scoreOf, tickVerdict, unitDone } from './progress-rules'\nimport { QuizAttempt } from './quiz-attempt'\nimport { UnitProgress } from './unit-progress'\n\n/** Who asked for an enrolment - a module's kind of record and the record. A manager's own is `learning.direct`. */\nexport interface LearningSource {\n kind: string\n id?: string | null\n}\n\nexport const DIRECT_SOURCE_KIND = 'learning.direct'\n\n/** The learner's screen of one enrolment - where the to-do leads. */\nexport const learningAddressOf = (enrollmentId: string) => `learning-view?id=${enrollmentId}`\n\nexport const todayIn = (domain: { timezone?: string | null }, now: Date = new Date()) => calendarDay(domain?.timezone, now)\n\nconst notFound = () => new Refusal('learning-not-found', {}, 'the record was not found. reload and try again.')\nconst isOpen = (status: string) => (OPEN_ENROLLMENT_STATUSES as string[]).includes(status)\n\n/* ---------------------------------------------------------------- the to-do (decision 5) */\n\n/** The context worklist closes a to-do under - `by` ends or aborts it; worklist speaks its refusals through `t`. */\nfunction todoContextOf(tx: EntityManager, domain: any, user: User) {\n const t = translatorFor(user.locale || 'ko')\n return { state: { domain, user, tx }, t: (key: string, options?: any) => t(key, options) } as any\n}\n\n/**\n * Hands out 「<과정> 수강」 to the person, with the due day - nothing where the domain has not installed the to-do. worklist's\n * handOut: the person's 할 일 and nobody's 상신함, also when the manager assigning it is the person (2026-11-08). The one\n * who asked (`context`) stands as its issuer.\n */\nasync function issueTodo(context: any, enrollment: Enrollment, course: Course, person: User): Promise<string | null> {\n const { domain, tx } = context.state\n const activity = await tx.getRepository(Activity).findOne({ where: { domain: { id: domain.id }, name: LEARNING_COURSE_ACTIVITY } as any })\n if (!activity) {\n logger.warn(`[learning] ${domain.subdomain}: the activity \"${LEARNING_COURSE_ACTIVITY}\" is not installed - \"${course.name}\" not handed out`)\n return null\n }\n const t = translatorFor(person.locale || 'ko')\n const name = t('text.learning-todo-name', { course: course.name })\n const headline = enrollment.dueOn ? t('text.learning-todo-headline', { dueOn: enrollment.dueOn }) : t('text.learning-todo-headline-no-due')\n const dueAt = enrollment.dueOn ? dueAtOf(enrollment.dueOn, domain.timezone) : undefined\n const address = learningAddressOf(enrollment.id)\n const input = { enrollmentId: enrollment.id, course: course.name, headline, address, sourceHref: address }\n const instance = await handOut({ activityId: activity.id, name, description: headline, input, assignee: person, dueAt }, context)\n return instance.id\n}\n\n/** The end of the due day in the domain's time zone. */\nfunction dueAtOf(dueOn: string, timezone?: string | null): Date {\n const end = new Date(`${dueOn}T23:59:59Z`)\n const zone = timezone || 'UTC'\n const asLocal = new Date(end.toLocaleString('en-US', { timeZone: zone }))\n const asUtc = new Date(end.toLocaleString('en-US', { timeZone: 'UTC' }))\n return new Date(end.getTime() - (asLocal.getTime() - asUtc.getTime()))\n}\n\nasync function todoOpen(tx: EntityManager, instanceId: string): Promise<boolean> {\n return (await tx.getRepository(ActivityThread).count({ where: { activityInstance: { id: instanceId }, state: In(['assigned', 'started', 'unassigned']) } as any })) > 0\n}\n\n/** Ends the to-do as done once the course is completed. */\nasync function completeTodo(tx: EntityManager, domain: any, enrollment: Enrollment, by: User): Promise<void> {\n if (!enrollment.todoInstanceId || !(await todoOpen(tx, enrollment.todoInstanceId))) return\n /* What was done, as the finished to-do shows it; no reason - 「course completed」 showed on the timeline as written. */\n const context = todoContextOf(tx, domain, by)\n const outcome = context.t('text.learning-todo-outcome', { day: todayIn(domain) })\n await complete({ id: enrollment.todoInstanceId, output: { outcome } }, context)\n}\n\n/** Aborts the to-do of an enrolment withdrawn or cancelled. */\nasync function abortTodo(tx: EntityManager, domain: any, enrollment: Enrollment, by: User, reason: string): Promise<void> {\n if (!enrollment.todoInstanceId || !(await todoOpen(tx, enrollment.todoInstanceId))) return\n await abort({ id: enrollment.todoInstanceId, reason } as any, todoContextOf(tx, domain, by))\n}\n\n/* ---------------------------------------------------------------- enrolling and withdrawing (decision 7) */\n\n/**\n * Enrols people in a course for whoever asks (`source`), to be completed by `dueOn` - the server function a using module\n * calls with the people it chose. One open enrolment per person, course and source: a person who has one is left with\n * it. Each new enrolment hands out its to-do. Answers the open enrolments of everyone given.\n */\nexport async function enroll(source: LearningSource, userIds: string[], courseId: string, dueOn: string | null | undefined, context: any): Promise<Enrollment[]> {\n const { domain, user, tx } = context.state\n if (!source?.kind) throw new Refusal('learning-source-required', {}, 'an enrolment names who asked for it')\n if (dueOn && !/^\\d{4}-\\d{2}-\\d{2}$/.test(dueOn)) throw new Refusal('learning-due-invalid', {}, 'the due day is YYYY-MM-DD')\n const course = await courseOf(tx, domain, courseId)\n if (!(await publishedVersionOf(tx, domain, course.id))) throw new Refusal('learning-course-not-published', { course: course.name }, `${course.name} has no published version`)\n const ids = [...new Set(userIds)].filter(Boolean)\n if (!ids.length) return []\n const people = await (tx as EntityManager).getRepository(User).find({ where: { id: In(ids) }, relations: ['domains'] })\n const sourceId = source.id ?? ''\n const repository = (tx as EntityManager).getRepository(Enrollment)\n const out: Enrollment[] = []\n for (const id of ids) {\n const person = people.find(one => one.id === id)\n if (!person || !(person.domains ?? []).some(one => one.id === domain.id)) throw new Refusal('learning-learner-unknown', {}, 'a learner must be a user of this domain')\n const open = await repository.findOne({ where: { domain: { id: domain.id }, user: { id }, course: { id: course.id }, sourceKind: source.kind, sourceId, status: In(OPEN_ENROLLMENT_STATUSES) } as any })\n if (open) {\n out.push(open)\n continue\n }\n const saved = await repository.save({ domain, user: person, course, dueOn: dueOn || null, sourceKind: source.kind, sourceId, status: EnrollmentStatus.ASSIGNED, learnedSeconds: 0, attempts: 0, creator: user, updater: user } as any)\n const todo = await issueTodo(context, saved, course, person)\n if (todo) await repository.update(saved.id, { todoInstanceId: todo } as any)\n out.push((await repository.findOneBy({ id: saved.id }))!)\n }\n return out\n}\n\n/**\n * Withdraws the open enrolments a source asked for - the record they were for was taken back. Each is cancelled with\n * the reason and its to-do aborted; completed ones stay. Answers how many were withdrawn.\n */\nexport async function withdraw(source: LearningSource, reason: string, context: any): Promise<number> {\n const { domain, user, tx } = context.state\n const rows = await (tx as EntityManager).getRepository(Enrollment).find({ where: { domain: { id: domain.id }, sourceKind: source.kind, sourceId: source.id ?? '', status: In(OPEN_ENROLLMENT_STATUSES) } as any })\n let count = 0\n for (const row of rows) if (await cancelOpen(tx, domain, row, user, reason)) count++\n return count\n}\n\n/** Cancels an open enrolment - claimed by an update only an open one matches, so a completion at the same time wins once. */\nasync function cancelOpen(tx: EntityManager, domain: any, row: Enrollment, by: User, reason: string): Promise<boolean> {\n const claimed = await tx.getRepository(Enrollment).update({ id: row.id, status: In(OPEN_ENROLLMENT_STATUSES) } as any, { status: EnrollmentStatus.CANCELLED, cancelledAt: new Date(), cancelReason: reason, updater: by } as any)\n if (!claimed.affected) return false\n await abortTodo(tx, domain, row, by, reason)\n return true\n}\n\n/**\n * A manager cancels enrolments with one reason (decision 8) - together: one refused, none is cancelled. An open one is\n * withdrawn; a completed one stays on record as cancelled - never deleted - and whoever asked for it is told in the same\n * transaction.\n */\nexport async function cancelEnrollments(ids: string[], reason: string, context: any): Promise<Enrollment[]> {\n if (!reason?.trim()) throw new Refusal('learning-cancel-reason-required', {}, 'say why it is cancelled')\n const unique = [...new Set(ids ?? [])]\n if (!unique.length) throw new Refusal('learning-cancel-none', {}, 'pick the enrolments to cancel')\n const out: Enrollment[] = []\n for (const id of unique) out.push(await cancelOne(id, reason.trim(), context))\n return out\n}\n\nasync function cancelOne(id: string, reason: string, context: any): Promise<Enrollment> {\n const { domain, user, tx } = context.state\n const row = await enrollmentOf(tx, domain, id)\n if (isOpen(row.status)) {\n if (!(await cancelOpen(tx, domain, row, user, reason))) throw new Refusal('learning-enrollment-moved', {}, 'the enrolment changed meanwhile - reload and try again')\n } else if (row.status === EnrollmentStatus.COMPLETED) {\n const claimed = await tx.getRepository(Enrollment).update({ id: row.id, status: EnrollmentStatus.COMPLETED } as any, { status: EnrollmentStatus.CANCELLED, cancelledAt: new Date(), cancelReason: reason, updater: user } as any)\n if (!claimed.affected) throw new Refusal('learning-enrollment-moved', {}, 'the enrolment changed meanwhile - reload and try again')\n await learningOutcomeOf(row.sourceKind)?.cancelled?.((await enrollmentOf(tx, domain, id))!, reason, context)\n } else throw new Refusal('learning-enrollment-cancelled', {}, 'the enrolment is cancelled already')\n return await enrollmentOf(tx, domain, id)\n}\n\n/**\n * The people an audience names now - the domain, departments with those under them, roles and people, by organization's\n * one rule (ADR-0163). Each target must be of this domain.\n */\nexport async function learnersOf(audiences: { scope: string; targetId: string; targetName?: string }[], context: any): Promise<string[]> {\n const { domain, tx } = context.state\n if (!audiences?.length) throw new Refusal('learning-audience-required', {}, 'pick who takes the course')\n const departmentIds = [...(await departmentTreeOf(domain, tx)).keys()]\n const roleIds = (await domainRolesOf(domain, undefined, tx)).map(one => one.id)\n for (const target of audiences) {\n const why = audienceTargetRefusal(target as any, { domainId: domain.id, departmentIds, roleIds })\n if (why) throw new Refusal('learning-audience-invalid', { target: target.targetName ?? target.targetId }, `${target.targetName ?? target.targetId} is not of this domain (${why})`)\n }\n return await audienceUserIds(domain, audiences as any, tx)\n}\n\n/* ---------------------------------------------------------------- reading */\n\nexport async function enrollmentOf(tx: EntityManager, domain: { id: string }, id: string): Promise<Enrollment> {\n const row = id && /^[0-9a-f-]{36}$/i.test(id) ? await tx.getRepository(Enrollment).findOne({ where: { id, domain: { id: domain.id } } as any }) : null\n if (!row) throw notFound()\n return row\n}\n\n/** The request's own enrolment - one answer for \"none\" and \"not yours\". */\nexport async function myEnrollmentOf(context: any, id: string, tx: EntityManager = learningManagerOf(context)): Promise<Enrollment> {\n const row = await enrollmentOf(tx, context.state.domain, id)\n if (row.userId !== context.state.user.id) throw notFound()\n return row\n}\n\n/** The version an enrolment shows: its own once started, the published one before. */\nexport async function shownVersionOf(tx: EntityManager, domain: { id: string }, enrollment: Enrollment): Promise<CourseVersion | null> {\n if (enrollment.versionId) return await tx.getRepository(CourseVersion).findOne({ where: { id: enrollment.versionId } as any, withDeleted: true })\n return await publishedVersionOf(tx, domain, enrollment.courseId!)\n}\n\nexport async function progressesOf(tx: EntityManager, enrollmentId: string): Promise<UnitProgress[]> {\n return await tx.getRepository(UnitProgress).find({ where: { enrollment: { id: enrollmentId } } as any })\n}\n\n/** What still stands between an enrolment and its completion - nothing for a completed one. */\nexport async function missingFor(tx: EntityManager, domain: { id: string }, enrollment: Enrollment): Promise<Missing[]> {\n if (enrollment.status === EnrollmentStatus.COMPLETED) return []\n const version = await shownVersionOf(tx, domain, enrollment)\n if (!version) return ['units']\n const units = (await unitsOf(tx, version.id)).filter(counts)\n const progress = await progressesOf(tx, enrollment.id)\n const questions = version.passScore != null ? await tx.getRepository(CourseQuestion).count({ where: { version: { id: version.id } } as any }) : 0\n return missingOf({\n units: units.length,\n unitsDone: units.filter(unit => progress.some(one => one.unitId === unit.id && one.doneAt)).length,\n learnedSeconds: enrollment.learnedSeconds,\n minSeconds: version.minSeconds ?? 0,\n quiz: version.passScore != null && questions > 0,\n passed: enrollment.score != null && enrollment.score >= (version.passScore ?? 101),\n acknowledgement: !!version.acknowledgement,\n acknowledged: !!enrollment.acknowledgedAt\n })\n}\n\n/* ---------------------------------------------------------------- learning (decision 6) */\n\n/** The enrolment, started if it was not: its version fixed to the one published now, in progress from now on. */\nasync function started(tx: EntityManager, domain: any, enrollment: Enrollment, user: User): Promise<Enrollment> {\n if (enrollment.status === EnrollmentStatus.CANCELLED) throw new Refusal('learning-enrollment-cancelled', {}, 'the enrolment is cancelled')\n if (enrollment.versionId) {\n if (enrollment.status === EnrollmentStatus.ASSIGNED) await tx.getRepository(Enrollment).update({ id: enrollment.id, status: EnrollmentStatus.ASSIGNED } as any, { status: EnrollmentStatus.IN_PROGRESS, startedAt: new Date() } as any)\n return await enrollmentOf(tx, domain, enrollment.id)\n }\n const version = await publishedVersionOf(tx, domain, enrollment.courseId!)\n if (!version) throw new Refusal('learning-course-not-published', {}, 'the course has no published version')\n await tx.getRepository(Enrollment).update({ id: enrollment.id, status: In(OPEN_ENROLLMENT_STATUSES) } as any, { version, status: EnrollmentStatus.IN_PROGRESS, startedAt: enrollment.startedAt ?? new Date(), updater: user } as any)\n return await enrollmentOf(tx, domain, enrollment.id)\n}\n\nexport async function unitOfVersion(tx: EntityManager, version: { id: string }, unitId: string): Promise<CourseUnit> {\n const unit = await tx.getRepository(CourseUnit).findOne({ where: { id: unitId, version: { id: version.id } } as any })\n if (!unit) throw notFound()\n return unit\n}\n\nexport interface TickResult {\n enrollment: Enrollment\n progress: UnitProgress\n}\n\n/**\n * One tick of the learner's screen on a unit (decision 6): the server adds the gap since the unit's last tick, at most\n * 15 seconds and at most what the screen says, and refuses a video position ahead of what was watched. A total the\n * screen sends is never taken. A unit that reaches its condition is done, and the enrolment is completed when nothing is\n * missing any more.\n */\nexport async function recordTick(enrollmentId: string, unitId: string, seconds: number, position: number, context: any, now: Date = new Date()): Promise<TickResult> {\n const { domain, user, tx } = context.state\n let enrollment = await myEnrollmentOf(context, enrollmentId, tx)\n enrollment = await started(tx, domain, enrollment, user)\n const unit = await unitOfVersion(tx, { id: enrollment.versionId! }, unitId)\n if (unit.kind === CourseUnitKind.LINK) throw new Refusal('learning-link-not-counted', {}, 'a link is not counted')\n const repository = (tx as EntityManager).getRepository(UnitProgress)\n const progress =\n (await repository.findOne({ where: { enrollment: { id: enrollment.id }, unit: { id: unit.id } } as any })) ??\n (await repository.save({ domain, enrollment, unit, learnedSeconds: 0, watchedSeconds: 0, positionSeconds: 0, pagesSeen: 0, pagesRead: 0, pageSeconds: 0, pageAt: 0, creator: user, updater: user } as any))\n if (enrollment.status === EnrollmentStatus.COMPLETED) return { enrollment, progress }\n\n const verdict = tickVerdict(progress, { seconds, position }, now, unit)\n if ('refusal' in verdict) {\n if (verdict.refusal === 'page-ahead') throw new Refusal('learning-page-ahead', { allowed: verdict.allowed }, `a page cannot be ahead of the one after the last read (${verdict.allowed})`)\n throw new Refusal('learning-position-ahead', { allowed: verdict.allowed }, `the video cannot be ahead of what was watched (${verdict.allowed} s)`)\n }\n progress.learnedSeconds += verdict.add\n progress.watchedSeconds = verdict.watchedSeconds\n progress.positionSeconds = verdict.positionSeconds\n progress.pagesSeen = verdict.pagesSeen\n progress.pagesRead = verdict.pagesRead\n progress.pageSeconds = verdict.pageSeconds\n progress.pageAt = verdict.pageAt\n progress.lastTickAt = now\n if (!progress.doneAt && unitDone(unit, progress)) progress.doneAt = now\n progress.updater = user\n await repository.save(progress)\n if (verdict.add) await tx.getRepository(Enrollment).increment({ id: enrollment.id } as any, 'learnedSeconds', verdict.add)\n /* Where the learner was - the course opens on this unit again (2026-11-08). */\n if (enrollment.lastUnitId !== unit.id) await tx.getRepository(Enrollment).update({ id: enrollment.id } as any, { lastUnitId: unit.id } as any)\n enrollment = await completeIfMet(tx, domain, await enrollmentOf(tx, domain, enrollment.id), context)\n return { enrollment, progress }\n}\n\n/** The learner confirms the version's acknowledgement - recorded once, when they did. */\nexport async function acknowledgeEnrollment(enrollmentId: string, context: any): Promise<Enrollment> {\n const { domain, user, tx } = context.state\n let enrollment = await started(tx, domain, await myEnrollmentOf(context, enrollmentId, tx), user)\n const version = await shownVersionOf(tx, domain, enrollment)\n if (!version?.acknowledgement) throw new Refusal('learning-no-acknowledgement', {}, 'the course asks for no acknowledgement')\n if (!enrollment.acknowledgedAt) await tx.getRepository(Enrollment).update({ id: enrollment.id } as any, { acknowledgedAt: new Date(), updater: user } as any)\n return await completeIfMet(tx, domain, await enrollmentOf(tx, domain, enrollment.id), context)\n}\n\n/* ---------------------------------------------------------------- the quiz (decision 4) */\n\nexport interface DrawnForLearner {\n attempt: QuizAttempt\n questions: { id: string; kind: string; text: string; choices: { id: string; text: string }[] }[]\n}\n\n/** The questions of an attempt as the learner is drawn them - the choices in the order shown, never whether one is right. */\nexport function forLearner(attempt: QuizAttempt, questions: CourseQuestion[]): DrawnForLearner {\n return {\n attempt,\n questions: attempt.drawn.map(drawn => {\n const question = questions.find(one => one.id === drawn.questionId)!\n return {\n id: question.id,\n kind: question.kind,\n text: question.text,\n choices: drawn.choiceIds.map(id => question.choices.find(one => one.id === id)!).map(one => ({ id: one.id, text: one.text }))\n }\n })\n }\n}\n\n/**\n * Starts an attempt at the quiz: the questions drawn and shuffled, their choices shuffled. An attempt not sent yet is\n * answered again; the version's limit on attempts holds.\n */\n/**\n * Holds the enrolment for the rest of the request's transaction - an update takes its row lock on every driver, so two\n * attempts of one enrolment are started, counted and sent one after the other. Two starts at once made two unsent\n * attempts, and a limit of one let both be sent (2026-11-08).\n */\nasync function holdEnrollment(tx: EntityManager, domain: any, enrollment: Enrollment, user: User): Promise<Enrollment> {\n await tx.getRepository(Enrollment).update({ id: enrollment.id } as any, { updater: user } as any)\n return await enrollmentOf(tx, domain, enrollment.id)\n}\n\nexport async function startQuizAttempt(enrollmentId: string, context: any): Promise<DrawnForLearner> {\n const { domain, user, tx } = context.state\n const held = await holdEnrollment(tx, domain, await myEnrollmentOf(context, enrollmentId, tx), user)\n const enrollment = await started(tx, domain, held, user)\n if (enrollment.status === EnrollmentStatus.COMPLETED) throw new Refusal('learning-enrollment-completed', {}, 'the course is completed')\n const version = (await shownVersionOf(tx, domain, enrollment))!\n const questions = await questionsOf(tx, version.id)\n if (version.passScore == null || !questions.length) throw new Refusal('learning-no-quiz', {}, 'the course has no quiz')\n const repository = (tx as EntityManager).getRepository(QuizAttempt)\n const pending = await repository.findOne({ where: { enrollment: { id: enrollment.id }, submittedAt: IsNull() } as any })\n if (pending) return forLearner(pending, questions)\n if (version.attemptLimit != null && enrollment.attempts >= version.attemptLimit) throw new Refusal('learning-attempts-used', { limit: version.attemptLimit }, `all ${version.attemptLimit} attempts are used`)\n const attempt = await repository.save({ domain, enrollment, drawn: drawQuestions(questions, version.questionCount), creator: user, updater: user } as any)\n return forLearner(attempt, questions)\n}\n\nexport interface QuizResult {\n enrollment: Enrollment\n score: number\n passed: boolean\n attemptsLeft: number | null\n}\n\n/**\n * Scores an attempt's answers on the server against what it drew (decision 4) - only the score and whether it passed go\n * back, never the right answers. The best score stays on the enrolment; passing may complete it.\n */\nexport async function submitQuizAttempt(attemptId: string, answers: Record<string, string[]>, context: any): Promise<QuizResult> {\n const { domain, user, tx } = context.state\n const attempt = await (tx as EntityManager).getRepository(QuizAttempt).findOne({ where: { id: attemptId, domain: { id: domain.id } } as any })\n if (!attempt) throw notFound()\n const enrollment = await holdEnrollment(tx, domain, await myEnrollmentOf(context, attempt.enrollmentId!, tx), user)\n const version = (await shownVersionOf(tx, domain, enrollment))!\n if (version.attemptLimit != null && enrollment.attempts >= version.attemptLimit) throw new Refusal('learning-attempts-used', { limit: version.attemptLimit }, `all ${version.attemptLimit} attempts are used`)\n const questions = await questionsOf(tx, version.id)\n const drawn = attempt.drawn.map(one => questions.find(question => question.id === one.questionId)).filter(Boolean) as CourseQuestion[]\n const kept: Record<string, string[]> = Object.fromEntries(drawn.map(question => [question.id, (answers?.[question.id] ?? []).map(String)]))\n const score = scoreOf(drawn, kept)\n const passed = score >= (version.passScore ?? 101)\n const claimed = await tx.getRepository(QuizAttempt).update({ id: attempt.id, submittedAt: IsNull() } as any, { answers: kept, score, passed, submittedAt: new Date(), updater: user } as any)\n if (!claimed.affected) throw new Refusal('learning-attempt-sent', {}, 'the attempt was sent already')\n await tx.getRepository(Enrollment).increment({ id: enrollment.id } as any, 'attempts', 1)\n await tx.getRepository(Enrollment).update({ id: enrollment.id } as any, { score: Math.max(enrollment.score ?? 0, score), updater: user } as any)\n const after = await completeIfMet(tx, domain, await enrollmentOf(tx, domain, enrollment.id), context)\n return { enrollment: after, score, passed, attemptsLeft: version.attemptLimit != null ? Math.max(0, version.attemptLimit - after.attempts) : null }\n}\n\n/* ---------------------------------------------------------------- completing (decision 8) */\n\n/** A certificate number: the day completed and the enrolment's own id - one per completion, never reused. */\nexport const certificateNoOf = (enrollment: { id: string }, day: string) => `LMS-${day.replace(/-/g, '')}-${enrollment.id.replace(/-/g, '').slice(0, 8).toUpperCase()}`\n\n/**\n * Completes an open enrolment when nothing is missing - every unit done, the least time, the quiz passed, the\n * acknowledgement confirmed. The evidence stays on it; whoever asked for it is told in this same transaction (a handler\n * that fails takes the completion back), and the to-do ends as done.\n */\nexport async function completeIfMet(tx: EntityManager, domain: any, enrollment: Enrollment, context: any): Promise<Enrollment> {\n if (!isOpen(enrollment.status) || !enrollment.versionId) return enrollment\n if ((await missingFor(tx, domain, enrollment)).length) return enrollment\n const now = new Date()\n const claimed = await tx\n .getRepository(Enrollment)\n .update({ id: enrollment.id, status: In(OPEN_ENROLLMENT_STATUSES) } as any, { status: EnrollmentStatus.COMPLETED, completedAt: now, certificateNo: certificateNoOf(enrollment, todayIn(domain, now)), updater: context.state.user } as any)\n if (!claimed.affected) return await enrollmentOf(tx, domain, enrollment.id)\n const completed = await enrollmentOf(tx, domain, enrollment.id)\n await learningOutcomeOf(completed.sourceKind)?.completed(completed, context)\n await completeTodo(tx, domain, completed, context.state.user)\n return completed\n}\n\n/* ---------------------------------------------------------------- whom an enrolment is for */\n\n/** The open and completed enrolments of the request's person, the open first and the soonest due first. */\nexport async function myEnrollments(context: any): Promise<Enrollment[]> {\n const { domain, user } = context.state\n const rows = await learningManagerOf(context)\n .getRepository(Enrollment)\n .find({ where: { domain: { id: domain.id }, user: { id: user.id }, status: In([...OPEN_ENROLLMENT_STATUSES, EnrollmentStatus.COMPLETED]) } as any })\n const rank = (one: Enrollment) => (isOpen(one.status) ? 0 : 1)\n return rows.sort((a, b) => rank(a) - rank(b) || String(a.dueOn ?? '9999').localeCompare(String(b.dueOn ?? '9999')) || +new Date(b.createdAt!) - +new Date(a.createdAt!))\n}\n\nexport { isOpen }\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const LEARNING_CERTIFICATE_KIND = "learning.certificate";
|
|
2
2
|
export declare const LEARNING_REGISTER_KIND = "learning.completion-register";
|
|
3
3
|
/** The certificate's template in code - a domain's own `PDFTemplate` of the kind prints in its place. */
|
|
4
|
-
export declare const CERTIFICATE_TEMPLATE = "<!doctype html><html lang=\"ko\"><head><meta charset=\"utf-8\"><style>\n@page { size: A4; margin: 0 }\nbody { margin: 0; font-family: \"Apple SD Gothic Neo\", \"Malgun Gothic\", \"Noto Sans KR\", sans-serif; color: #222 }\n.page { position: relative; box-sizing: border-box; width: 210mm; min-height: 297mm; padding: 30mm 24mm }\n.number { position: absolute; top: 16mm; left: 24mm; font-size: 9.5pt; color: #666 }\nh1 { margin: 6mm 0 16mm; text-align: center; font-size: 26pt; letter-spacing: 12pt }\ntable { width: 100%; border-collapse: collapse; font-size: 11.5pt }\nth, td { border: 1px solid #444; padding: 3.2mm 4mm; text-align: left; vertical-align: middle }\nth { background: #f2f2f2; font-weight: 600; text-align: center }\n.statement { margin: 22mm 0 0; text-align: center; font-size: 13pt; line-height: 2 }\n.date { margin-top: 18mm; text-align: center; font-size: 13pt; letter-spacing: 1pt }\n.issuer {
|
|
4
|
+
export declare const CERTIFICATE_TEMPLATE = "<!doctype html><html lang=\"ko\"><head><meta charset=\"utf-8\"><style>\n@page { size: A4; margin: 0 }\nbody { margin: 0; font-family: \"Apple SD Gothic Neo\", \"Malgun Gothic\", \"Noto Sans KR\", sans-serif; color: #222 }\n.page { position: relative; box-sizing: border-box; width: 210mm; min-height: 297mm; padding: 30mm 24mm }\n.number { position: absolute; top: 16mm; left: 24mm; font-size: 9.5pt; color: #666 }\nh1 { margin: 6mm 0 16mm; text-align: center; font-size: 26pt; letter-spacing: 12pt }\ntable { width: 100%; border-collapse: collapse; font-size: 11.5pt }\nth, td { border: 1px solid #444; padding: 3.2mm 4mm; text-align: left; vertical-align: middle }\nth { background: #f2f2f2; font-weight: 600; text-align: center }\n.statement { margin: 22mm 0 0; text-align: center; font-size: 13pt; line-height: 2 }\n.date { margin-top: 18mm; text-align: center; font-size: 13pt; letter-spacing: 1pt }\n.issuer { margin: 20mm auto 0; width: max-content; max-width: 100%; font-size: 14pt; line-height: 2; text-align: left }\n.issuer > div { padding-left: 3.5em; text-indent: -3.5em }\n.issuer .stamp { position: relative; display: inline-block; margin-left: 3mm; text-indent: 0 }\n.issuer .stamp img { position: absolute; left: 50%; top: 50%; width: 22mm; transform: translate(-50%, -50%); opacity: .9 }\nth { width: 32mm }\n</style></head><body><div class=\"page\">\n<div class=\"number\">\uBC1C\uAE09\uBC88\uD638 {{issue.number}}</div>\n<h1>\uC218\uB8CC\uC99D</h1>\n<table>\n<tr><th>\uC131\uBA85</th><td>{{learner.name}}</td></tr>\n<tr><th>\uACFC\uC815</th><td>{{course.name}} (\uAC1C\uC815\uBCF8 {{course.version}})</td></tr>\n<tr><th>\uC774\uC218\uC77C</th><td>{{completion.completedOn}}</td></tr>\n<tr><th>\uD559\uC2B5 \uC2DC\uAC04</th><td>{{completion.minutes}}\uBD84</td></tr>\n{{#if completion.score}}<tr><th>\uD3C9\uAC00 \uC810\uC218</th><td>{{completion.score}}\uC810</td></tr>{{/if}}\n<tr><th>\uC218\uB8CC \uBC88\uD638</th><td>{{completion.certificateNo}}</td></tr>\n</table>\n<p class=\"statement\">\uC704 \uC0AC\uB78C\uC740 \uC704 \uACFC\uC815\uC744 \uC774\uC218\uD558\uC600\uC74C\uC744 \uC99D\uBA85\uD569\uB2C8\uB2E4.</p>\n<div class=\"date\">{{issue.issuedOn}}</div>\n<div class=\"issuer\">\n<div>\uC0C1\uD638 : {{company.name}}</div>\n{{#if company.address}}<div>\uC8FC\uC18C : {{company.address}}</div>{{/if}}\n<div>\uB300\uD45C\uC774\uC0AC : {{company.representative}}<span class=\"stamp\">(\uC778){{#if company.seal}}<img src=\"{{company.seal}}\" alt=\"\">{{/if}}</span></div>\n</div>\n</div></body></html>";
|
|
5
5
|
/** The completion register's template - one row per completion. */
|
|
6
|
-
export declare const REGISTER_TEMPLATE = "<!doctype html><html lang=\"ko\"><head><meta charset=\"utf-8\"><style>\n@page { size: A4; margin: 0 }\nbody { margin: 0; font-family: \"Apple SD Gothic Neo\", \"Malgun Gothic\", \"Noto Sans KR\", sans-serif; color: #222 }\n.page { position: relative; box-sizing: border-box; width: 210mm; min-height: 297mm; padding: 30mm 24mm }\n.number { position: absolute; top: 16mm; left: 24mm; font-size: 9.5pt; color: #666 }\nh1 { margin: 6mm 0 16mm; text-align: center; font-size: 26pt; letter-spacing: 12pt }\ntable { width: 100%; border-collapse: collapse; font-size: 11.5pt }\nth, td { border: 1px solid #444; padding: 3.2mm 4mm; text-align: left; vertical-align: middle }\nth { background: #f2f2f2; font-weight: 600; text-align: center }\n.statement { margin: 22mm 0 0; text-align: center; font-size: 13pt; line-height: 2 }\n.date { margin-top: 18mm; text-align: center; font-size: 13pt; letter-spacing: 1pt }\n.issuer {
|
|
6
|
+
export declare const REGISTER_TEMPLATE = "<!doctype html><html lang=\"ko\"><head><meta charset=\"utf-8\"><style>\n@page { size: A4; margin: 0 }\nbody { margin: 0; font-family: \"Apple SD Gothic Neo\", \"Malgun Gothic\", \"Noto Sans KR\", sans-serif; color: #222 }\n.page { position: relative; box-sizing: border-box; width: 210mm; min-height: 297mm; padding: 30mm 24mm }\n.number { position: absolute; top: 16mm; left: 24mm; font-size: 9.5pt; color: #666 }\nh1 { margin: 6mm 0 16mm; text-align: center; font-size: 26pt; letter-spacing: 12pt }\ntable { width: 100%; border-collapse: collapse; font-size: 11.5pt }\nth, td { border: 1px solid #444; padding: 3.2mm 4mm; text-align: left; vertical-align: middle }\nth { background: #f2f2f2; font-weight: 600; text-align: center }\n.statement { margin: 22mm 0 0; text-align: center; font-size: 13pt; line-height: 2 }\n.date { margin-top: 18mm; text-align: center; font-size: 13pt; letter-spacing: 1pt }\n.issuer { margin: 20mm auto 0; width: max-content; max-width: 100%; font-size: 14pt; line-height: 2; text-align: left }\n.issuer > div { padding-left: 3.5em; text-indent: -3.5em }\n.issuer .stamp { position: relative; display: inline-block; margin-left: 3mm; text-indent: 0 }\n.issuer .stamp img { position: absolute; left: 50%; top: 50%; width: 22mm; transform: translate(-50%, -50%); opacity: .9 }\n.page { padding: 24mm 16mm }\nh1 { font-size: 20pt; letter-spacing: 4pt; margin-bottom: 8mm }\n.meta { margin-bottom: 6mm; font-size: 10.5pt }\ntable { font-size: 9.5pt }\nth, td { padding: 2mm 2.4mm }\n</style></head><body><div class=\"page\">\n<div class=\"number\">\uBC1C\uAE09\uBC88\uD638 {{issue.number}}</div>\n<h1>\uC774\uC218 \uB300\uC7A5</h1>\n<div class=\"meta\">\uACFC\uC815 : {{course.name}} \u00B7 \uAE30\uC900\uC77C : {{issue.asOf}} \u00B7 \uC774\uC218\uC790 {{count}}\uBA85</div>\n<table>\n<tr><th>\uBC88\uD638</th><th>\uC131\uBA85</th><th>\uBD80\uC11C</th><th>\uAC1C\uC815\uBCF8</th><th>\uC774\uC218\uC77C</th><th>\uD559\uC2B5 \uC2DC\uAC04(\uBD84)</th><th>\uC810\uC218</th><th>\uC218\uB8CC \uBC88\uD638</th></tr>\n{{#each rows}}<tr><td>{{this.no}}</td><td>{{this.name}}</td><td>{{this.department}}</td><td>{{this.version}}</td><td>{{this.completedOn}}</td><td>{{this.minutes}}</td><td>{{this.score}}</td><td>{{this.certificateNo}}</td></tr>{{/each}}\n</table>\n<div class=\"date\">{{issue.issuedOn}}</div>\n<div class=\"issuer\">\n<div>\uC0C1\uD638 : {{company.name}}</div>\n{{#if company.address}}<div>\uC8FC\uC18C : {{company.address}}</div>{{/if}}\n<div>\uB300\uD45C\uC774\uC0AC : {{company.representative}}<span class=\"stamp\">(\uC778){{#if company.seal}}<img src=\"{{company.seal}}\" alt=\"\">{{/if}}</span></div>\n</div>\n</div></body></html>";
|
|
7
7
|
export declare function registerLearningDocuments(): void;
|
|
@@ -26,13 +26,14 @@ th, td { border: 1px solid #444; padding: 3.2mm 4mm; text-align: left; vertical-
|
|
|
26
26
|
th { background: #f2f2f2; font-weight: 600; text-align: center }
|
|
27
27
|
.statement { margin: 22mm 0 0; text-align: center; font-size: 13pt; line-height: 2 }
|
|
28
28
|
.date { margin-top: 18mm; text-align: center; font-size: 13pt; letter-spacing: 1pt }
|
|
29
|
-
.issuer {
|
|
30
|
-
.issuer
|
|
29
|
+
.issuer { margin: 20mm auto 0; width: max-content; max-width: 100%; font-size: 14pt; line-height: 2; text-align: left }
|
|
30
|
+
.issuer > div { padding-left: 3.5em; text-indent: -3.5em }
|
|
31
|
+
.issuer .stamp { position: relative; display: inline-block; margin-left: 3mm; text-indent: 0 }
|
|
32
|
+
.issuer .stamp img { position: absolute; left: 50%; top: 50%; width: 22mm; transform: translate(-50%, -50%); opacity: .9 }`;
|
|
31
33
|
const ISSUER = `<div class="issuer">
|
|
32
34
|
<div>상호 : {{company.name}}</div>
|
|
33
35
|
{{#if company.address}}<div>주소 : {{company.address}}</div>{{/if}}
|
|
34
|
-
<div>대표이사 : {{company.representative}}</div>
|
|
35
|
-
{{#if company.seal}}<img src="{{company.seal}}" alt="">{{/if}}
|
|
36
|
+
<div>대표이사 : {{company.representative}}<span class="stamp">(인){{#if company.seal}}<img src="{{company.seal}}" alt="">{{/if}}</span></div>
|
|
36
37
|
</div>`;
|
|
37
38
|
/** The certificate's template in code - a domain's own `PDFTemplate` of the kind prints in its place. */
|
|
38
39
|
exports.CERTIFICATE_TEMPLATE = `<!doctype html><html lang="ko"><head><meta charset="utf-8"><style>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"learning-documents.js","sourceRoot":"","sources":["../../../server/service/enrollment/learning-documents.ts"],"names":[],"mappings":";;;AA2FA,8DAuEC;AAlKD;;;;GAIG;AACH,yDAA8D;AAC9D,6CAAgE;AAChE,iDAA8D;AAE9D,6CAAyC;AACzC,6DAAwD;AACxD,6CAA2D;AAC3D,2DAAwD;AAE3C,QAAA,yBAAyB,GAAG,sBAAsB,CAAA;AAClD,QAAA,sBAAsB,GAAG,8BAA8B,CAAA;AAEpE,MAAM,KAAK,GAAG;;;;;;;;;;;iFAWmE,CAAA;AAEjF,MAAM,MAAM,GAAG;;;;;OAKR,CAAA;AAEP,yGAAyG;AAC5F,QAAA,oBAAoB,GAAG;EAClC,KAAK;;;;;;;;;;;;;;;EAeL,MAAM;qBACa,CAAA;AAErB,mEAAmE;AACtD,QAAA,iBAAiB,GAAG;EAC/B,KAAK;;;;;;;;;;;;;;;EAeL,MAAM;qBACa,CAAA;AAErB,MAAM,KAAK,GAAG,CAAC,EAAoC,EAAE,QAAwB,EAAE,EAAE,CAC/E,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAA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C;QACD,KAAK,CAAC,OAAO,CAAC,OAAO;YACnB,OAAO,MAAM,IAAA,wBAAY,EAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;QACvD,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["/*\n * The documents this module issues through the pdf module (ADR-0194 decisions 9, 10 · ADR-0176): the certificate of a completed\n * enrolment (`learning.certificate`) and the completion register of a course (`learning.completion-register`). The pdf module\n * numbers and prints them with 「우리 회사」 - the company's name, representative and seal as the application keeps them.\n */\nimport { requestHolds, User } from '@things-factory/auth-base'\nimport { registerIssuedDocumentKind } from '@things-factory/pdf'\nimport { getRepository, Refusal } from '@things-factory/shell'\n\nimport { Course } from '../course/course'\nimport { CourseVersion } from '../course/course-version'\nimport { Enrollment, EnrollmentStatus } from './enrollment'\nimport { completionRegister } from './enrollment-status'\n\nexport const LEARNING_CERTIFICATE_KIND = 'learning.certificate'\nexport const LEARNING_REGISTER_KIND = 'learning.completion-register'\n\nconst STYLE = `@page { size: A4; margin: 0 }\nbody { margin: 0; font-family: \"Apple SD Gothic Neo\", \"Malgun Gothic\", \"Noto Sans KR\", sans-serif; color: #222 }\n.page { position: relative; box-sizing: border-box; width: 210mm; min-height: 297mm; padding: 30mm 24mm }\n.number { position: absolute; top: 16mm; left: 24mm; font-size: 9.5pt; color: #666 }\nh1 { margin: 6mm 0 16mm; text-align: center; font-size: 26pt; letter-spacing: 12pt }\ntable { width: 100%; border-collapse: collapse; font-size: 11.5pt }\nth, td { border: 1px solid #444; padding: 3.2mm 4mm; text-align: left; vertical-align: middle }\nth { background: #f2f2f2; font-weight: 600; text-align: center }\n.statement { margin: 22mm 0 0; text-align: center; font-size: 13pt; line-height: 2 }\n.date { margin-top: 18mm; text-align: center; font-size: 13pt; letter-spacing: 1pt }\n.issuer { position: relative; margin: 20mm auto 0; width: max-content; font-size: 14pt; line-height: 2; text-align: left; padding-right: 22mm }\n.issuer img { position: absolute; right: 0; top: 2mm; width: 22mm; opacity: .9 }`\n\nconst ISSUER = `<div class=\"issuer\">\n<div>상호 : {{company.name}}</div>\n{{#if company.address}}<div>주소 : {{company.address}}</div>{{/if}}\n<div>대표이사 : {{company.representative}}</div>\n{{#if company.seal}}<img src=\"{{company.seal}}\" alt=\"\">{{/if}}\n</div>`\n\n/** The certificate's template in code - a domain's own `PDFTemplate` of the kind prints in its place. */\nexport const CERTIFICATE_TEMPLATE = `<!doctype html><html lang=\"ko\"><head><meta charset=\"utf-8\"><style>\n${STYLE}\nth { width: 32mm }\n</style></head><body><div class=\"page\">\n<div class=\"number\">발급번호 {{issue.number}}</div>\n<h1>수료증</h1>\n<table>\n<tr><th>성명</th><td>{{learner.name}}</td></tr>\n<tr><th>과정</th><td>{{course.name}} (개정본 {{course.version}})</td></tr>\n<tr><th>이수일</th><td>{{completion.completedOn}}</td></tr>\n<tr><th>학습 시간</th><td>{{completion.minutes}}분</td></tr>\n{{#if completion.score}}<tr><th>평가 점수</th><td>{{completion.score}}점</td></tr>{{/if}}\n<tr><th>수료 번호</th><td>{{completion.certificateNo}}</td></tr>\n</table>\n<p class=\"statement\">위 사람은 위 과정을 이수하였음을 증명합니다.</p>\n<div class=\"date\">{{issue.issuedOn}}</div>\n${ISSUER}\n</div></body></html>`\n\n/** The completion register's template - one row per completion. */\nexport const REGISTER_TEMPLATE = `<!doctype html><html lang=\"ko\"><head><meta charset=\"utf-8\"><style>\n${STYLE}\n.page { padding: 24mm 16mm }\nh1 { font-size: 20pt; letter-spacing: 4pt; margin-bottom: 8mm }\n.meta { margin-bottom: 6mm; font-size: 10.5pt }\ntable { font-size: 9.5pt }\nth, td { padding: 2mm 2.4mm }\n</style></head><body><div class=\"page\">\n<div class=\"number\">발급번호 {{issue.number}}</div>\n<h1>이수 대장</h1>\n<div class=\"meta\">과정 : {{course.name}} · 기준일 : {{issue.asOf}} · 이수자 {{count}}명</div>\n<table>\n<tr><th>번호</th><th>성명</th><th>부서</th><th>개정본</th><th>이수일</th><th>학습 시간(분)</th><th>점수</th><th>수료 번호</th></tr>\n{{#each rows}}<tr><td>{{this.no}}</td><td>{{this.name}}</td><td>{{this.department}}</td><td>{{this.version}}</td><td>{{this.completedOn}}</td><td>{{this.minutes}}</td><td>{{this.score}}</td><td>{{this.certificateNo}}</td></tr>{{/each}}\n</table>\n<div class=\"date\">{{issue.issuedOn}}</div>\n${ISSUER}\n</div></body></html>`\n\nconst dayOf = (at: Date | string | null | undefined, timezone?: string | null) =>\n at ? new Intl.DateTimeFormat('en-CA', { timeZone: timezone || 'UTC', year: 'numeric', month: '2-digit', day: '2-digit' }).format(new Date(at)) : ''\n\nasync function enrollmentFor(context: any, id: string): Promise<Enrollment | null> {\n return id ? await getRepository(Enrollment, context.state.tx).findOne({ where: { id, domain: { id: context.state.domain.id } } as any }) : null\n}\n\n/** A certificate is issued and read by the person it is of, once completed, and by a manager. */\nasync function mayHaveCertificate(context: any, id: string | null | undefined): Promise<boolean> {\n const enrollment = await enrollmentFor(context, id ?? '')\n if (!enrollment || enrollment.status !== EnrollmentStatus.COMPLETED) return false\n return enrollment.userId === context.state.user?.id || (await requestHolds(context, 'course', 'query'))\n}\n\nexport function registerLearningDocuments(): void {\n registerIssuedDocumentKind({\n kind: LEARNING_CERTIFICATE_KIND,\n prefix: '수료',\n refType: 'Enrollment',\n template: { content_template: CERTIFICATE_TEMPLATE, page_size: 'A4' },\n async dataOf(context, refId) {\n const enrollment = await enrollmentFor(context, refId)\n if (!enrollment || enrollment.status !== EnrollmentStatus.COMPLETED) throw new Refusal('learning-not-completed', {}, 'a certificate is issued for a completed enrolment')\n const tx = context.state.tx\n const course = await getRepository(Course, tx).findOneBy({ id: enrollment.courseId! })\n const version = await getRepository(CourseVersion, tx).findOne({ where: { id: enrollment.versionId! } as any, withDeleted: true })\n const learner = await getRepository(User, tx).findOneBy({ id: enrollment.userId! })\n return {\n subjectName: `${learner?.name ?? ''} · ${course?.name ?? ''}`,\n data: {\n learner: { name: learner?.name ?? '' },\n course: { name: course?.name ?? '', version: version?.number ?? '' },\n completion: {\n completedOn: dayOf(enrollment.completedAt, context.state.domain.timezone),\n minutes: Math.floor((enrollment.learnedSeconds ?? 0) / 60),\n score: enrollment.score ?? null,\n certificateNo: enrollment.certificateNo ?? ''\n }\n }\n }\n },\n async mayIssue(context, refId) {\n return await mayHaveCertificate(context, refId)\n },\n async mayRead(context, row) {\n return await mayHaveCertificate(context, row.refId)\n }\n })\n\n registerIssuedDocumentKind({\n kind: LEARNING_REGISTER_KIND,\n prefix: '이수대장',\n refType: 'Course',\n asOf: true,\n template: { content_template: REGISTER_TEMPLATE, page_size: 'A4' },\n async dataOf(context, refId, input) {\n const course = await getRepository(Course, context.state.tx).findOne({ where: { id: refId, domain: { id: context.state.domain.id } } as any })\n if (!course) throw new Refusal('learning-not-found', {}, 'the record was not found. reload and try again.')\n const timezone = context.state.domain.timezone\n const rows = (await completionRegister(course.id, context)).filter(row => !input.asOf || dayOf(row.enrollment.completedAt, timezone) <= input.asOf)\n return {\n subjectName: course.name,\n data: {\n course: { name: course.name },\n count: rows.length,\n rows: rows.map((row, index) => ({\n no: index + 1,\n name: row.user?.name ?? '',\n department: row.departmentName ?? '',\n version: row.versionNumber ?? '',\n completedOn: dayOf(row.enrollment.completedAt, timezone),\n minutes: Math.floor((row.enrollment.learnedSeconds ?? 0) / 60),\n score: row.enrollment.score ?? '',\n certificateNo: row.enrollment.certificateNo ?? ''\n }))\n }\n }\n },\n async mayIssue(context) {\n return await requestHolds(context, 'course', 'query')\n },\n async mayRead(context) {\n return await requestHolds(context, 'course', 'query')\n }\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"learning-documents.js","sourceRoot":"","sources":["../../../server/service/enrollment/learning-documents.ts"],"names":[],"mappings":";;;AA4FA,8DAuEC;AAnKD;;;;GAIG;AACH,yDAA8D;AAC9D,6CAAgE;AAChE,iDAA8D;AAE9D,6CAAyC;AACzC,6DAAwD;AACxD,6CAA2D;AAC3D,2DAAwD;AAE3C,QAAA,yBAAyB,GAAG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UAAU,CAAC,WAAW,EAAE,QAAQ,CAAC;wBACxD,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,cAAc,IAAI,CAAC,CAAC,GAAG,EAAE,CAAC;wBAC9D,KAAK,EAAE,GAAG,CAAC,UAAU,CAAC,KAAK,IAAI,EAAE;wBACjC,aAAa,EAAE,GAAG,CAAC,UAAU,CAAC,aAAa,IAAI,EAAE;qBAClD,CAAC,CAAC;iBACJ;aACF,CAAA;QACH,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,OAAO;YACpB,OAAO,MAAM,IAAA,wBAAY,EAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;QACvD,CAAC;QACD,KAAK,CAAC,OAAO,CAAC,OAAO;YACnB,OAAO,MAAM,IAAA,wBAAY,EAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;QACvD,CAAC;KACF,CAAC,CAAA;AACJ,CAAC","sourcesContent":["/*\n * The documents this module issues through the pdf module (ADR-0194 decisions 9, 10 · ADR-0176): the certificate of a completed\n * enrolment (`learning.certificate`) and the completion register of a course (`learning.completion-register`). The pdf module\n * numbers and prints them with 「우리 회사」 - the company's name, representative and seal as the application keeps them.\n */\nimport { requestHolds, User } from '@things-factory/auth-base'\nimport { registerIssuedDocumentKind } from '@things-factory/pdf'\nimport { getRepository, Refusal } from '@things-factory/shell'\n\nimport { Course } from '../course/course'\nimport { CourseVersion } from '../course/course-version'\nimport { Enrollment, EnrollmentStatus } from './enrollment'\nimport { completionRegister } from './enrollment-status'\n\nexport const LEARNING_CERTIFICATE_KIND = 'learning.certificate'\nexport const LEARNING_REGISTER_KIND = 'learning.completion-register'\n\nconst STYLE = `@page { size: A4; margin: 0 }\nbody { margin: 0; font-family: \"Apple SD Gothic Neo\", \"Malgun Gothic\", \"Noto Sans KR\", sans-serif; color: #222 }\n.page { position: relative; box-sizing: border-box; width: 210mm; min-height: 297mm; padding: 30mm 24mm }\n.number { position: absolute; top: 16mm; left: 24mm; font-size: 9.5pt; color: #666 }\nh1 { margin: 6mm 0 16mm; text-align: center; font-size: 26pt; letter-spacing: 12pt }\ntable { width: 100%; border-collapse: collapse; font-size: 11.5pt }\nth, td { border: 1px solid #444; padding: 3.2mm 4mm; text-align: left; vertical-align: middle }\nth { background: #f2f2f2; font-weight: 600; text-align: center }\n.statement { margin: 22mm 0 0; text-align: center; font-size: 13pt; line-height: 2 }\n.date { margin-top: 18mm; text-align: center; font-size: 13pt; letter-spacing: 1pt }\n.issuer { margin: 20mm auto 0; width: max-content; max-width: 100%; font-size: 14pt; line-height: 2; text-align: left }\n.issuer > div { padding-left: 3.5em; text-indent: -3.5em }\n.issuer .stamp { position: relative; display: inline-block; margin-left: 3mm; text-indent: 0 }\n.issuer .stamp img { position: absolute; left: 50%; top: 50%; width: 22mm; transform: translate(-50%, -50%); opacity: .9 }`\n\nconst ISSUER = `<div class=\"issuer\">\n<div>상호 : {{company.name}}</div>\n{{#if company.address}}<div>주소 : {{company.address}}</div>{{/if}}\n<div>대표이사 : {{company.representative}}<span class=\"stamp\">(인){{#if company.seal}}<img src=\"{{company.seal}}\" alt=\"\">{{/if}}</span></div>\n</div>`\n\n/** The certificate's template in code - a domain's own `PDFTemplate` of the kind prints in its place. */\nexport const CERTIFICATE_TEMPLATE = `<!doctype html><html lang=\"ko\"><head><meta charset=\"utf-8\"><style>\n${STYLE}\nth { width: 32mm }\n</style></head><body><div class=\"page\">\n<div class=\"number\">발급번호 {{issue.number}}</div>\n<h1>수료증</h1>\n<table>\n<tr><th>성명</th><td>{{learner.name}}</td></tr>\n<tr><th>과정</th><td>{{course.name}} (개정본 {{course.version}})</td></tr>\n<tr><th>이수일</th><td>{{completion.completedOn}}</td></tr>\n<tr><th>학습 시간</th><td>{{completion.minutes}}분</td></tr>\n{{#if completion.score}}<tr><th>평가 점수</th><td>{{completion.score}}점</td></tr>{{/if}}\n<tr><th>수료 번호</th><td>{{completion.certificateNo}}</td></tr>\n</table>\n<p class=\"statement\">위 사람은 위 과정을 이수하였음을 증명합니다.</p>\n<div class=\"date\">{{issue.issuedOn}}</div>\n${ISSUER}\n</div></body></html>`\n\n/** The completion register's template - one row per completion. */\nexport const REGISTER_TEMPLATE = `<!doctype html><html lang=\"ko\"><head><meta charset=\"utf-8\"><style>\n${STYLE}\n.page { padding: 24mm 16mm }\nh1 { font-size: 20pt; letter-spacing: 4pt; margin-bottom: 8mm }\n.meta { margin-bottom: 6mm; font-size: 10.5pt }\ntable { font-size: 9.5pt }\nth, td { padding: 2mm 2.4mm }\n</style></head><body><div class=\"page\">\n<div class=\"number\">발급번호 {{issue.number}}</div>\n<h1>이수 대장</h1>\n<div class=\"meta\">과정 : {{course.name}} · 기준일 : {{issue.asOf}} · 이수자 {{count}}명</div>\n<table>\n<tr><th>번호</th><th>성명</th><th>부서</th><th>개정본</th><th>이수일</th><th>학습 시간(분)</th><th>점수</th><th>수료 번호</th></tr>\n{{#each rows}}<tr><td>{{this.no}}</td><td>{{this.name}}</td><td>{{this.department}}</td><td>{{this.version}}</td><td>{{this.completedOn}}</td><td>{{this.minutes}}</td><td>{{this.score}}</td><td>{{this.certificateNo}}</td></tr>{{/each}}\n</table>\n<div class=\"date\">{{issue.issuedOn}}</div>\n${ISSUER}\n</div></body></html>`\n\nconst dayOf = (at: Date | string | null | undefined, timezone?: string | null) =>\n at ? new Intl.DateTimeFormat('en-CA', { timeZone: timezone || 'UTC', year: 'numeric', month: '2-digit', day: '2-digit' }).format(new Date(at)) : ''\n\nasync function enrollmentFor(context: any, id: string): Promise<Enrollment | null> {\n return id ? await getRepository(Enrollment, context.state.tx).findOne({ where: { id, domain: { id: context.state.domain.id } } as any }) : null\n}\n\n/** A certificate is issued and read by the person it is of, once completed, and by a manager. */\nasync function mayHaveCertificate(context: any, id: string | null | undefined): Promise<boolean> {\n const enrollment = await enrollmentFor(context, id ?? '')\n if (!enrollment || enrollment.status !== EnrollmentStatus.COMPLETED) return false\n return enrollment.userId === context.state.user?.id || (await requestHolds(context, 'course', 'query'))\n}\n\nexport function registerLearningDocuments(): void {\n registerIssuedDocumentKind({\n kind: LEARNING_CERTIFICATE_KIND,\n prefix: '수료',\n refType: 'Enrollment',\n template: { content_template: CERTIFICATE_TEMPLATE, page_size: 'A4' },\n async dataOf(context, refId) {\n const enrollment = await enrollmentFor(context, refId)\n if (!enrollment || enrollment.status !== EnrollmentStatus.COMPLETED) throw new Refusal('learning-not-completed', {}, 'a certificate is issued for a completed enrolment')\n const tx = context.state.tx\n const course = await getRepository(Course, tx).findOneBy({ id: enrollment.courseId! })\n const version = await getRepository(CourseVersion, tx).findOne({ where: { id: enrollment.versionId! } as any, withDeleted: true })\n const learner = await getRepository(User, tx).findOneBy({ id: enrollment.userId! })\n return {\n subjectName: `${learner?.name ?? ''} · ${course?.name ?? ''}`,\n data: {\n learner: { name: learner?.name ?? '' },\n course: { name: course?.name ?? '', version: version?.number ?? '' },\n completion: {\n completedOn: dayOf(enrollment.completedAt, context.state.domain.timezone),\n minutes: Math.floor((enrollment.learnedSeconds ?? 0) / 60),\n score: enrollment.score ?? null,\n certificateNo: enrollment.certificateNo ?? ''\n }\n }\n }\n },\n async mayIssue(context, refId) {\n return await mayHaveCertificate(context, refId)\n },\n async mayRead(context, row) {\n return await mayHaveCertificate(context, row.refId)\n }\n })\n\n registerIssuedDocumentKind({\n kind: LEARNING_REGISTER_KIND,\n prefix: '이수대장',\n refType: 'Course',\n asOf: true,\n template: { content_template: REGISTER_TEMPLATE, page_size: 'A4' },\n async dataOf(context, refId, input) {\n const course = await getRepository(Course, context.state.tx).findOne({ where: { id: refId, domain: { id: context.state.domain.id } } as any })\n if (!course) throw new Refusal('learning-not-found', {}, 'the record was not found. reload and try again.')\n const timezone = context.state.domain.timezone\n const rows = (await completionRegister(course.id, context)).filter(row => !input.asOf || dayOf(row.enrollment.completedAt, timezone) <= input.asOf)\n return {\n subjectName: course.name,\n data: {\n course: { name: course.name },\n count: rows.length,\n rows: rows.map((row, index) => ({\n no: index + 1,\n name: row.user?.name ?? '',\n department: row.departmentName ?? '',\n version: row.versionNumber ?? '',\n completedOn: dayOf(row.enrollment.completedAt, timezone),\n minutes: Math.floor((row.enrollment.learnedSeconds ?? 0) / 60),\n score: row.enrollment.score ?? '',\n certificateNo: row.enrollment.certificateNo ?? ''\n }))\n }\n }\n },\n async mayIssue(context) {\n return await requestHolds(context, 'course', 'query')\n },\n async mayRead(context) {\n return await requestHolds(context, 'course', 'query')\n }\n })\n}\n"]}
|