@eliceio/cdk-cli 1.3.0-contenttypes.1 → 1.3.0
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/README.md +100 -94
- package/es/commands/dev/index.d.ts +1 -1
- package/es/commands/dev/index.js +2 -1
- package/es/commands/doctor/index.d.ts +1 -1
- package/es/commands/doctor/index.js +38 -3
- package/es/commands/setup/index.d.ts +1 -1
- package/es/commands/setup/index.js +1 -1
- package/es/commands/uninstall/index.d.ts +1 -1
- package/es/commands/uninstall/index.js +1 -1
- package/es/core/collect.js +3 -1
- package/es/core/quiz-check.d.ts +21 -0
- package/es/core/quiz-check.js +364 -0
- package/es/dev/host-page.js +8 -5
- package/es/dev/mock-api.d.ts +3 -1
- package/es/rules/check.js +6 -0
- package/es/rules/privacy.d.ts +20 -0
- package/es/rules/privacy.js +177 -0
- package/es/rules.json.js +1 -1
- package/package.json +2 -2
- package/rules.json +7 -1
- package/skills/_shared/always.md +6 -3
- package/skills/_shared/references/00-what-the-person-decides.md +3 -2
- package/skills/_shared/references/02-design-the-material.md +12 -6
- package/skills/_shared/references/03-create-the-project.md +9 -9
- package/skills/_shared/references/04-rules.md +2 -0
- package/skills/_shared/references/05-screen-code.md +2 -0
- package/skills/_shared/references/06-using-the-quiz-template.md +15 -5
- package/skills/_shared/references/07-move-existing-html.md +1 -1
- package/skills/_shared/references/08-fix-check-errors.md +26 -23
- package/skills/_shared/references/09-check.md +1 -1
- package/skills/_shared/references/12-upload-with-the-material-mcp.md +3 -2
- package/skills/_shared/references/15-edit-settings-by-hand.md +184 -0
- package/skills/elice-content-check/SKILL.md +1 -1
- package/skills/elice-content-create/SKILL.md +3 -3
- package/skills/elice-content-edit/SKILL.md +26 -0
- package/skills/elice-content-migrate/SKILL.md +2 -1
- package/skills/elice-content-publish/SKILL.md +1 -1
- package/templates/_shared/AGENTS.md +10 -0
- package/templates/_shared/CLAUDE.md +1 -0
- package/templates/_shared/lib/cdk-mock.js +28 -7
- package/templates/blank/package.json +1 -1
- package/templates/blank/template.json +1 -1
- package/templates/document/template.json +8 -1
- package/templates/quiz/README.md +5 -3
- package/templates/quiz/core/model.d.ts +47 -7
- package/templates/quiz/core/model.js +354 -37
- package/templates/quiz/package.json +1 -1
- package/templates/quiz/screens/edit.js +238 -74
- package/templates/quiz/screens/learn.js +12 -2
- package/templates/quiz/styles.css +120 -0
- package/templates/quiz/template.json +1 -1
- package/templates/quiz/ui/templates/edit.d.ts +2 -0
- package/templates/quiz/ui/templates/edit.js +48 -2
- package/templates/quiz/ui/texts.js +51 -6
- package/templates/steps/package.json +1 -1
- package/templates/steps/template.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type McpEnv, type SetupResult } from '../../core/mcp.js';
|
|
2
2
|
import { type DoctorCheck } from '../doctor/index.js';
|
|
3
3
|
import type { CommandResult } from '../../types.js';
|
|
4
|
-
export declare const usage = "\uC0AC\uC6A9\uBC95: ecdk setup [--only skills|mcp] [--project] [--url <\uC8FC\uC18C>] [--target claude|helpycode|all] [--force] [--json]\n\n \uCC98\uC74C \uD55C \uBC88 \uC2E4\uD589\uD55C\uB2E4 (\uB2E4\uC2DC \uC2E4\uD589\uD574\uB3C4 \uB41C\uB2E4: \uC788\uB294 \uAC83\uC740 \uAC74\uB108\uB6F0\uACE0 \uC61B \uAC83 \u00B7 \uBE60\uC9C4 \uAC83\uB9CC \uACE0\uCE5C\uB2E4). --only \uC5C6\uC774\uB294 \uCC28\uB840\uB85C:\n 1. \uC2A4\uD0AC \uC124\uCE58 (--only skills\uC640 \uAC19\uC74C, ~/.claude/skills/)\n 2. \uD559\uC2B5\uC790\uB8CC \uC11C\uBC84 MCP \uB4F1\uB85D (--only mcp\uC640 \uAC19\uC74C, \uC635\uC158\uB3C4 \uAC19\uC74C)\n 3. \uC810\uAC80 \uC694\uC57D (Node \u00B7 \uC2A4\uD0AC \u00B7 MCP)\n 4. \uB3C4\uAD6C\uBCC4 \uB85C\uADF8\uC778 \uC548\uB0B4\n MCP\uB294 \uC544\uC9C1 \uBC30\uD3EC\uB418\uC9C0 \uC54A\uC558\uAC70\uB098 \uC9C1\uC811 \uD560 \uC77C\uC774 \uC788\uC5B4\uB3C4 \uC2E4\uD328\uB85C \uCE58\uC9C0 \uC54A\uB294\uB2E4 (\"\uC9C1\uC811 \uD560 \uC77C\"\uC5D0 \uC801\uC74C, \uC2A4\uD0AC\uC774 \uC4F8 \uC218 \uC788\uC73C\uBA74 \uC885\uB8CC \uCF54\uB4DC 0).\n\n --only skills: Claude Code \uC2A4\uD0AC
|
|
4
|
+
export declare const usage = "\uC0AC\uC6A9\uBC95: ecdk setup [--only skills|mcp] [--project] [--url <\uC8FC\uC18C>] [--target claude|helpycode|all] [--force] [--json]\n\n \uCC98\uC74C \uD55C \uBC88 \uC2E4\uD589\uD55C\uB2E4 (\uB2E4\uC2DC \uC2E4\uD589\uD574\uB3C4 \uB41C\uB2E4: \uC788\uB294 \uAC83\uC740 \uAC74\uB108\uB6F0\uACE0 \uC61B \uAC83 \u00B7 \uBE60\uC9C4 \uAC83\uB9CC \uACE0\uCE5C\uB2E4). --only \uC5C6\uC774\uB294 \uCC28\uB840\uB85C:\n 1. \uC2A4\uD0AC \uC124\uCE58 (--only skills\uC640 \uAC19\uC74C, ~/.claude/skills/)\n 2. \uD559\uC2B5\uC790\uB8CC \uC11C\uBC84 MCP \uB4F1\uB85D (--only mcp\uC640 \uAC19\uC74C, \uC635\uC158\uB3C4 \uAC19\uC74C)\n 3. \uC810\uAC80 \uC694\uC57D (Node \u00B7 \uC2A4\uD0AC \u00B7 MCP)\n 4. \uB3C4\uAD6C\uBCC4 \uB85C\uADF8\uC778 \uC548\uB0B4\n MCP\uB294 \uC544\uC9C1 \uBC30\uD3EC\uB418\uC9C0 \uC54A\uC558\uAC70\uB098 \uC9C1\uC811 \uD560 \uC77C\uC774 \uC788\uC5B4\uB3C4 \uC2E4\uD328\uB85C \uCE58\uC9C0 \uC54A\uB294\uB2E4 (\"\uC9C1\uC811 \uD560 \uC77C\"\uC5D0 \uC801\uC74C, \uC2A4\uD0AC\uC774 \uC4F8 \uC218 \uC788\uC73C\uBA74 \uC885\uB8CC \uCF54\uB4DC 0).\n\n --only skills: Claude Code \uC2A4\uD0AC 5\uAC1C(\uAC01 \uC2A4\uD0AC \uD3F4\uB354\uC5D0 \uCC38\uACE0 \uBB38\uC11C references/ \uD3EC\uD568)\uB9CC \uC124\uCE58 \u00B7 \uAC31\uC2E0\uD55C\uB2E4\n \uAC19\uC740 \uBC84\uC804 \u00B7 \uAC19\uC740 \uB0B4\uC6A9\uC774\uBA74 \uAC74\uB108\uB6F0\uACE0, \uC61B \uBC84\uC804\uC774\uAC70\uB098 \uB0B4\uC6A9\uC774 \uB2E4\uB974\uBA74 \uBC14\uAFBC\uB2E4. \uC61B ecdk\uAC00 \uC124\uCE58\uD55C \uC61B \uC774\uB984 \uC2A4\uD0AC(elice-content-guide)\uC740 \uC9C0\uC6B4\uB2E4\n mcp: Elice \uD559\uC2B5\uC790\uB8CC \uC11C\uBC84 MCP(elice-material)\uB9CC AI \uB3C4\uAD6C\uC5D0 \uB4F1\uB85D\uD55C\uB2E4. \uC790\uB8CC\uB97C LXP\uC5D0 \uC62C\uB9AC\uB294 \uC2A4\uD0AC\uC774 \uC4F4\uB2E4\n \uB4F1\uB85D \uC804\uC5D0 \uC11C\uBC84\uC5D0 MCP\uAC00 \uC788\uB294\uC9C0 \uD655\uC778\uD558\uACE0, \uB85C\uADF8\uC778\uC740 \uB4F1\uB85D \uB4A4 \uAC01 \uB3C4\uAD6C\uC5D0\uC11C \uD55C\uB2E4 (\uC548\uB0B4\uB97C \uCD9C\uB825\uD568)\n --project \uD604\uC7AC \uD3F4\uB354\uC758 .claude/skills/\uC5D0 \uC124\uCE58 (--only skills\uC5D0\uC11C\uB9CC)\n --url \uC11C\uBC84 MCP \uC8FC\uC18C (https, \uAE30\uBCF8\uC740 \uC6B4\uC601). MCP \uB4F1\uB85D\uC5D0\uB9CC\n --target MCP\uB97C \uB4F1\uB85D\uD560 \uB3C4\uAD6C claude(Claude Code) \u00B7 helpycode(Helpy Code \uB370\uC2A4\uD06C\uD1B1 \u00B7 CLI) \u00B7 all(\uCC3E\uC740 \uB3C4\uAD6C \uBAA8\uB450, \uAE30\uBCF8). MCP \uB4F1\uB85D\uC5D0\uB9CC\n --force --only skills: CLI\uBCF4\uB2E4 \uC0C8 \uBC84\uC804\uC774\uAC70\uB098 \uC190\uC73C\uB85C \uACE0\uCE5C \uC2A4\uD0AC\uB3C4 \uBC14\uAFBC\uB2E4\n MCP \uB4F1\uB85D: \uC774\uBBF8 \uB2E4\uB978 \uC8FC\uC18C\uB85C \uB4F1\uB85D\uB3FC \uC788\uAC70\uB098 \uC11C\uBC84\uC5D0 MCP\uAC00 \uC5C6\uC5B4 \uBCF4\uC5EC\uB3C4 \uB4F1\uB85D\uD55C\uB2E4 (--only \uC5C6\uC774\uB294 MCP\uC5D0\uB9CC)\n\n\uC885\uB8CC \uCF54\uB4DC:\n --only \uC5C6\uC774 0 \uC2A4\uD0AC \uC124\uCE58\uB428(MCP\uB294 \uC9C1\uC811 \uD560 \uC77C\uC774 \uB0A8\uC544\uB3C4) \u00B7 1 \uC2A4\uD0AC\uC744 \uC124\uCE58\uD558\uC9C0 \uBABB\uD568\n --only skills 0 \uC131\uACF5 \u00B7 1 \uC190\uC73C\uB85C \uACE0\uCE5C \uC2A4\uD0AC\uC774 \uC788\uC5B4 \uAC74\uB108\uB700\n --only mcp 0 \uC131\uACF5 \u00B7 1 \uC9C1\uC811 \uD560 \uC77C\uC774 \uC788\uC74C(\uC11C\uBC84\uC5D0 MCP \uC5C6\uC74C, \uC8FC\uC11D\uC774 \uC788\uB294 \uC124\uC815 \uD30C\uC77C, \uB2E4\uB978 \uC8FC\uC18C\uB85C \uB4F1\uB85D\uB428, \uB3C4\uAD6C\uB97C \uCC3E\uC9C0 \uBABB\uD568)\n \uBAA8\uB450 2 \uC798\uBABB\uB41C \uC0AC\uC6A9 (\uBAA8\uB974\uB294 --only \uAC12, --only skills\uC5D0 MCP \uC635\uC158, --project\uB97C --only skills \uC5C6\uC774)";
|
|
5
5
|
export interface SetupAllResult {
|
|
6
6
|
skills: {
|
|
7
7
|
ok: true;
|
|
@@ -11,7 +11,7 @@ const usage = `사용법: ecdk setup [--only skills|mcp] [--project] [--url <주
|
|
|
11
11
|
4. 도구별 로그인 안내
|
|
12
12
|
MCP는 아직 배포되지 않았거나 직접 할 일이 있어도 실패로 치지 않는다 ("직접 할 일"에 적음, 스킬이 쓸 수 있으면 종료 코드 0).
|
|
13
13
|
|
|
14
|
-
--only skills: Claude Code 스킬
|
|
14
|
+
--only skills: Claude Code 스킬 5개(각 스킬 폴더에 참고 문서 references/ 포함)만 설치 · 갱신한다
|
|
15
15
|
같은 버전 · 같은 내용이면 건너뛰고, 옛 버전이거나 내용이 다르면 바꾼다. 옛 ecdk가 설치한 옛 이름 스킬(elice-content-guide)은 지운다
|
|
16
16
|
mcp: Elice 학습자료 서버 MCP(elice-material)만 AI 도구에 등록한다. 자료를 LXP에 올리는 스킬이 쓴다
|
|
17
17
|
등록 전에 서버에 MCP가 있는지 확인하고, 로그인은 등록 뒤 각 도구에서 한다 (안내를 출력함)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type McpEnv, type McpTarget } from '../../core/mcp.js';
|
|
2
2
|
import { type SkillState } from '../../core/skills.js';
|
|
3
3
|
import type { CommandResult } from '../../types.js';
|
|
4
|
-
export declare const usage = "\uC0AC\uC6A9\uBC95: ecdk uninstall [--only skills|mcp] [--project] [--target claude|helpycode|all] [--force] [--json]\n\n ecdk setup\uC774 \uC124\uCE58\uD55C \uAC83\uC744 \uC9C0\uC6B4\uB2E4: \uC2A4\uD0AC
|
|
4
|
+
export declare const usage = "\uC0AC\uC6A9\uBC95: ecdk uninstall [--only skills|mcp] [--project] [--target claude|helpycode|all] [--force] [--json]\n\n ecdk setup\uC774 \uC124\uCE58\uD55C \uAC83\uC744 \uC9C0\uC6B4\uB2E4: \uC2A4\uD0AC 5\uAC1C(elice-content-create \u00B7 -edit \u00B7 -migrate \u00B7 -check \u00B7 -publish, \uAC01 references/ \uD3EC\uD568),\n \uC61B ecdk\uAC00 \uC9C0\uAE08\uC740 \uC5C6\uB294 \uC774\uB984\uC73C\uB85C \uC124\uCE58\uD55C \uC2A4\uD0AC(elice-content-guide \uB4F1, SKILL.md \uB05D\uC5D0 ecdk \uC124\uCE58 \uD45C\uC2DC\uAC00 \uC788\uB294 \uAC83)\uACFC\n \uD559\uC2B5\uC790\uB8CC \uC11C\uBC84 MCP \uB4F1\uB85D(elice-material, Claude Code \uC0AC\uC6A9\uC790 \uC124\uC815 \u00B7 Helpy Code \uC124\uC815).\n \uB2E4\uB978 \uC2A4\uD0AC \u00B7 \uB2E4\uB978 MCP \uC11C\uBC84 \u00B7 \uD504\uB85C\uC81D\uD2B8 \u00B7 .ecdk/\uB294 \uAC74\uB4DC\uB9AC\uC9C0 \uC54A\uB294\uB2E4. CLI \uC790\uCCB4\uB294 \uC9C0\uC6B0\uC9C0 \uC54A\uB294\uB2E4 (\uB05D\uC5D0 \uBA85\uB839\uC744 \uC54C\uB824 \uC90C).\n\n --only skills: \uC2A4\uD0AC\uB9CC \uC9C0\uC6B4\uB2E4 (~/.claude/skills/)\n mcp: \uD559\uC2B5\uC790\uB8CC \uC11C\uBC84 MCP \uB4F1\uB85D\uB9CC \uC9C0\uC6B4\uB2E4\n --project \uD604\uC7AC \uD3F4\uB354\uC758 .claude/skills/\uC5D0 \uC124\uCE58\uD55C \uC2A4\uD0AC\uC744 \uC9C0\uC6B4\uB2E4 (--only skills\uC5D0\uC11C\uB9CC)\n --target MCP \uB4F1\uB85D\uC744 \uC9C0\uC6B8 \uB3C4\uAD6C claude \u00B7 helpycode \u00B7 all(\uAE30\uBCF8). MCP \uB4F1\uB85D\uC5D0\uB9CC\n --force \uC190\uC73C\uB85C \uACE0\uCE5C \uC2A4\uD0AC \u00B7 \uC190\uC73C\uB85C \uACE0\uCE5C Helpy Code \uD56D\uBAA9\uB3C4 \uC9C0\uC6B4\uB2E4\n\n\uC885\uB8CC \uCF54\uB4DC: 0 \uC9C0\uC6C0(\uB610\uB294 \uC9C0\uC6B8 \uAC83 \uC5C6\uC74C) \u00B7 1 \uB0A8\uAE34 \uAC83 \u00B7 \uC9C1\uC811 \uD560 \uC77C\uC774 \uC788\uC74C(\uC190\uC73C\uB85C \uACE0\uCE5C \uC2A4\uD0AC, \uC8FC\uC11D\uC774 \uC788\uB294 \uC124\uC815 \uD30C\uC77C)\n 2 \uC798\uBABB\uB41C \uC0AC\uC6A9 (\uBAA8\uB974\uB294 --only \uAC12, --only skills\uC5D0 --target, --project\uB97C --only skills \uC5C6\uC774)";
|
|
5
5
|
export type SkillRemoveAction = 'removed' | 'kept' | 'missing';
|
|
6
6
|
export interface SkillRemoveStep {
|
|
7
7
|
name: string;
|
|
@@ -4,7 +4,7 @@ import { skillsDir, skillNames, markedSkillNames, inspectSkill, skillFiles, oldS
|
|
|
4
4
|
|
|
5
5
|
const usage = `사용법: ecdk uninstall [--only skills|mcp] [--project] [--target claude|helpycode|all] [--force] [--json]
|
|
6
6
|
|
|
7
|
-
ecdk setup이 설치한 것을 지운다: 스킬
|
|
7
|
+
ecdk setup이 설치한 것을 지운다: 스킬 5개(elice-content-create · -edit · -migrate · -check · -publish, 각 references/ 포함),
|
|
8
8
|
옛 ecdk가 지금은 없는 이름으로 설치한 스킬(elice-content-guide 등, SKILL.md 끝에 ecdk 설치 표시가 있는 것)과
|
|
9
9
|
학습자료 서버 MCP 등록(elice-material, Claude Code 사용자 설정 · Helpy Code 설정).
|
|
10
10
|
다른 스킬 · 다른 MCP 서버 · 프로젝트 · .ecdk/는 건드리지 않는다. CLI 자체는 지우지 않는다 (끝에 명령을 알려 줌).
|
package/es/core/collect.js
CHANGED
|
@@ -9,7 +9,9 @@ const PROJECT_FILES = ['package.json', 'package-lock.json', 'pnpm-lock.yaml', 'p
|
|
|
9
9
|
// ecdk build · dev가 쓰는 Vite 설정 (engines/vite)
|
|
10
10
|
'*.d.ts',
|
|
11
11
|
// 편집기 자동완성용 타입 (템플릿 lib/elice-content.d.ts)
|
|
12
|
-
'README*', 'LICENSE*', '
|
|
12
|
+
'README*', 'LICENSE*', 'AGENTS.md',
|
|
13
|
+
// AI 작업 안내 (ecdk create가 만듦, CLAUDE.md는 이것을 불러옴)
|
|
14
|
+
'CLAUDE.md', '.*'];
|
|
13
15
|
function matcher(patterns) {
|
|
14
16
|
const names = patterns.filter(p => !p.includes('/')).map(globToRegExp);
|
|
15
17
|
const prefixes = patterns.filter(p => p.includes('/')).map(p => p.replace(/^\.\//, '').replace(/\/$/, ''));
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface QuizCheck {
|
|
2
|
+
level: 'ok' | 'skip' | 'warn' | 'fail';
|
|
3
|
+
message: string;
|
|
4
|
+
/** 찾은 문제 (fail일 때) */
|
|
5
|
+
problems: string[];
|
|
6
|
+
/** 경고 (채점은 되지만 확인할 것) */
|
|
7
|
+
warnings: string[];
|
|
8
|
+
/** 정답 답 형식이 꼬리표와 어긋남: 편집 화면에서 한 번 저장하면 맞는 형식으로 다시 저장된다 (doctor fix 문구) */
|
|
9
|
+
resave?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** 답 형식 어긋남의 고치는 방법 */
|
|
12
|
+
export declare const RESAVE_FIX = "\uD3B8\uC9D1 \uD654\uBA74\uC5D0\uC11C \uCD08\uC548\uC73C\uB85C \uC800\uC7A5\uC744 \uD55C \uBC88 \uB204\uB974\uBA74 \uC815\uB2F5\uC774 \uB9DE\uB294 \uD615\uC2DD\uC73C\uB85C \uB2E4\uC2DC \uC800\uC7A5\uB429\uB2C8\uB2E4.";
|
|
13
|
+
export interface QuizCheckOptions {
|
|
14
|
+
/** 프로젝트를 만든 템플릿 (package.json "ecdk".template, 예: "quiz@1.9.1"). 안내 문구 · requires 비교에 쓴다 */
|
|
15
|
+
template?: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 저장한 settings(`.ecdk/settings.json` 내용)를 퀴즈 편집 화면 규칙으로 검사한다.
|
|
19
|
+
* srcDir는 원본 폴더(core/model.js · ui/texts.js가 있는 곳)
|
|
20
|
+
*/
|
|
21
|
+
export declare function checkQuizSettings(srcDir: string, saved: Record<string, unknown>, options?: QuizCheckOptions): Promise<QuizCheck>;
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { existsSync, statSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
|
+
import { compareVersions } from '../rules/semver.js';
|
|
5
|
+
import { ANSWER_KEY_MAX } from './config.js';
|
|
6
|
+
import { parseTemplateRef } from './templates.js';
|
|
7
|
+
|
|
8
|
+
const REQUIRED = ['validateQuiz', 'parseAnswerKey', 'buildAnswerKey', 'validateAnswerKey', 'checkAnswerKey'];
|
|
9
|
+
const PARTIAL_FUNCTIONS = ['parseAnswerKeys', 'buildAnswerKeys', 'checkAnswerKeys', 'equalPoints'];
|
|
10
|
+
const PARTIAL = 'partial_pattern';
|
|
11
|
+
/** 이 CLI에 든 퀴즈 템플릿 문구 (프로젝트 ui/texts.js를 읽지 못하거나 모양이 다를 때) */
|
|
12
|
+
const SHIPPED_TEXTS = fileURLToPath(new URL('../../templates/quiz/ui/texts.js', import.meta.url));
|
|
13
|
+
/** 답 형식 어긋남의 고치는 방법 */
|
|
14
|
+
const RESAVE_FIX = '편집 화면에서 초안으로 저장을 한 번 누르면 정답이 맞는 형식으로 다시 저장됩니다.';
|
|
15
|
+
/** 같은 프로세스에서 고친 파일을 다시 읽게 수정 시각을 주소에 붙인다 */
|
|
16
|
+
async function importFresh(path) {
|
|
17
|
+
const url = `${pathToFileURL(path).href}?mtime=${statSync(path).mtimeMs}`;
|
|
18
|
+
return await import(url);
|
|
19
|
+
}
|
|
20
|
+
/** 편집 화면 검증 문구 (validation · answers.validation). 모양이 다르면 null */
|
|
21
|
+
async function loadMessages(path) {
|
|
22
|
+
try {
|
|
23
|
+
const texts = (await importFresh(path)).texts;
|
|
24
|
+
const quiz = texts?.validation;
|
|
25
|
+
const answers = texts?.answers?.validation;
|
|
26
|
+
if (typeof quiz?.at !== 'function' || typeof answers?.at !== 'function') return null;
|
|
27
|
+
return {
|
|
28
|
+
quiz,
|
|
29
|
+
answers
|
|
30
|
+
};
|
|
31
|
+
} catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const isQuestion = q => typeof q === 'object' && q !== null && typeof q.id === 'string';
|
|
36
|
+
/** 정규식 `^문항id=…$`의 문항 id */
|
|
37
|
+
const keyId = key => typeof key === 'string' ? /^\^([A-Za-z0-9_-]+)=/.exec(key)?.[1] : undefined;
|
|
38
|
+
const MOVE_HINT = '문항을 지우거나 순서를 바꾸면 grading.answer_key · scores도 같은 자리로 옮깁니다 (core/model.js parseAnswerKeys로 읽고 buildAnswerKeys로 다시 만들기)';
|
|
39
|
+
const BUILD_HINT = '정답 정규식은 손으로 쓰지 않고 core/model.js buildAnswerKey(s)로 만듭니다 (주관식 답 모양은 프로젝트 템플릿 버전과 settings answerFormat을 따름, 참고 문서 15)';
|
|
40
|
+
const REGEX_HINT = '정규식 문항(answerMode "regex")은 편집 화면처럼 맨 앞 ^ · 맨 뒤 $를 떼고, 맨 앞 (?i)는 (?i:…)로, %는 %25로 바꿔 (?:…)에 넣습니다 (core/model.js compileTextRegex · buildAnswerKey(s))';
|
|
41
|
+
/** 꼬리표 키 snake_case(answer_format · answer_mode)도 camelCase로 읽는다. 옛 SDK는 settings 안 키 모양을 바꿨다 */
|
|
42
|
+
const SNAKE_TAGS = {
|
|
43
|
+
answer_format: 'answerFormat'
|
|
44
|
+
};
|
|
45
|
+
function camelTags(settings) {
|
|
46
|
+
const snake = [];
|
|
47
|
+
const out = {
|
|
48
|
+
...settings
|
|
49
|
+
};
|
|
50
|
+
for (const [from, to] of Object.entries(SNAKE_TAGS)) {
|
|
51
|
+
if (!(from in out)) continue;
|
|
52
|
+
if (!(to in out)) out[to] = out[from];
|
|
53
|
+
delete out[from];
|
|
54
|
+
snake.push(from);
|
|
55
|
+
}
|
|
56
|
+
if (Array.isArray(out.questions)) {
|
|
57
|
+
let modes = false;
|
|
58
|
+
out.questions = out.questions.map(q => {
|
|
59
|
+
if (typeof q !== 'object' || q === null || !('answer_mode' in q)) return q;
|
|
60
|
+
modes = true;
|
|
61
|
+
const {
|
|
62
|
+
answer_mode: mode,
|
|
63
|
+
...rest
|
|
64
|
+
} = q;
|
|
65
|
+
return 'answerMode' in rest ? rest : {
|
|
66
|
+
...rest,
|
|
67
|
+
answerMode: mode
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
if (modes) snake.push('questions[].answer_mode');
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
settings: out,
|
|
74
|
+
snake
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
const questionLabel = (questions, q) => `문제 ${questions.indexOf(q) + 1}(${q.id})`;
|
|
78
|
+
/**
|
|
79
|
+
* 저장한 settings(`.ecdk/settings.json` 내용)를 퀴즈 편집 화면 규칙으로 검사한다.
|
|
80
|
+
* srcDir는 원본 폴더(core/model.js · ui/texts.js가 있는 곳)
|
|
81
|
+
*/
|
|
82
|
+
async function checkQuizSettings(srcDir, saved, options = {}) {
|
|
83
|
+
const skip = message => ({
|
|
84
|
+
level: 'skip',
|
|
85
|
+
message,
|
|
86
|
+
problems: [],
|
|
87
|
+
warnings: []
|
|
88
|
+
});
|
|
89
|
+
const modelPath = join(srcDir, 'core', 'model.js');
|
|
90
|
+
if (!existsSync(modelPath)) return skip('퀴즈 템플릿 아님 (core/model.js 없음)');
|
|
91
|
+
let model;
|
|
92
|
+
try {
|
|
93
|
+
const mod = await importFresh(modelPath);
|
|
94
|
+
if (REQUIRED.some(name => typeof mod[name] !== 'function')) return skip('퀴즈 템플릿 아님 (core/model.js에 퀴즈 검증 함수 없음)');
|
|
95
|
+
model = mod;
|
|
96
|
+
} catch (e) {
|
|
97
|
+
return {
|
|
98
|
+
level: 'fail',
|
|
99
|
+
message: `core/model.js를 불러오지 못했습니다: ${e.message}`,
|
|
100
|
+
problems: [],
|
|
101
|
+
warnings: []
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const {
|
|
105
|
+
settings,
|
|
106
|
+
snake
|
|
107
|
+
} = camelTags(saved);
|
|
108
|
+
const questions = settings.questions;
|
|
109
|
+
if (questions === undefined) return skip('저장한 문항 없음 (편집 화면에서 아직 저장하지 않음)');
|
|
110
|
+
if (!Array.isArray(questions) || !questions.every(isQuestion)) return {
|
|
111
|
+
level: 'fail',
|
|
112
|
+
message: 'questions는 문항 객체(id · type …) 배열이어야 합니다.',
|
|
113
|
+
problems: [],
|
|
114
|
+
warnings: []
|
|
115
|
+
};
|
|
116
|
+
const projectTexts = join(srcDir, 'ui', 'texts.js');
|
|
117
|
+
const messages = (existsSync(projectTexts) ? await loadMessages(projectTexts) : null) ?? (await loadMessages(SHIPPED_TEXTS));
|
|
118
|
+
if (!messages) return skip('편집 화면 검증 문구(ui/texts.js)를 읽지 못함');
|
|
119
|
+
const problems = [];
|
|
120
|
+
const warnings = [];
|
|
121
|
+
const add = p => problems.push(p);
|
|
122
|
+
const warn = p => warnings.push(p);
|
|
123
|
+
let resave = false;
|
|
124
|
+
if (snake.length > 0) warn(`${snake.join(' · ')}가 snake_case로 적혀 있어 camelCase(answerFormat · answerMode)로 읽고 검사했습니다. 퀴즈 화면(core/model.js)은 camelCase를 읽고 지금 SDK · ecdk dev는 settings 키를 바꾸지 않으므로, 편집 화면에서 다시 저장하거나 camelCase로 고칩니다.`);
|
|
125
|
+
const fromModel = (p, where) => {
|
|
126
|
+
if (p) add(`${where}: ${p.message}`);
|
|
127
|
+
};
|
|
128
|
+
const grading = settings.grading;
|
|
129
|
+
try {
|
|
130
|
+
fromModel(model.validateQuiz(settings, messages.quiz), '편집 화면 검증');
|
|
131
|
+
// 답 형식을 이 프로젝트가 읽지 못하면 정답 검사는 뜻이 없다 (학생 답과 정답 모양이 어긋남)
|
|
132
|
+
const known = typeof model.ANSWER_FORMAT === 'number' ? model.ANSWER_FORMAT : 1;
|
|
133
|
+
if (!checkFormat(model, questions, settings, known, options, add)) {
|
|
134
|
+
const format = model.answerFormatOf ? model.answerFormatOf(settings) : 1;
|
|
135
|
+
const isRegex = q => model.isRegexMode?.(q) === true;
|
|
136
|
+
const ctx = {
|
|
137
|
+
model,
|
|
138
|
+
questions,
|
|
139
|
+
settings,
|
|
140
|
+
format,
|
|
141
|
+
isRegex,
|
|
142
|
+
v: messages.answers,
|
|
143
|
+
add,
|
|
144
|
+
warn,
|
|
145
|
+
resave: () => {
|
|
146
|
+
resave = true;
|
|
147
|
+
},
|
|
148
|
+
untaggedFormat: settings.answerFormat === undefined && known >= 2 ? known : undefined
|
|
149
|
+
};
|
|
150
|
+
if (ctx.untaggedFormat !== undefined) {
|
|
151
|
+
const regexQs = questions.filter(isRegex);
|
|
152
|
+
if (regexQs.length > 0) {
|
|
153
|
+
resave = true;
|
|
154
|
+
add(`${regexQs.map(q => questionLabel(questions, q)).join(', ')}는 정규식 입력(answerMode "regex")인데 settings에 answerFormat이 없습니다. 꼬리표가 없으면 학생 답이 옛 형식(URL 인코딩)으로 가 한글 · 공백 · 특수문자 답이 오답이 됩니다. ${RESAVE_FIX}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (!grading || typeof grading !== 'object') {
|
|
158
|
+
add('정답(grading)이 없습니다. 퀴즈는 편집 화면이 문항마다 고른 정답으로 grading을 저장합니다.');
|
|
159
|
+
} else if (grading.type === PARTIAL) {
|
|
160
|
+
checkPartial(ctx, grading);
|
|
161
|
+
} else if (grading.type === 'pattern') {
|
|
162
|
+
checkPattern(ctx, grading.answer_key);
|
|
163
|
+
} else {
|
|
164
|
+
add(`퀴즈 채점 방식은 pattern 또는 partial_pattern입니다 (지금 ${JSON.stringify(grading.type)}).`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
} catch (e) {
|
|
168
|
+
add(`core/model.js 검사 중 오류: ${e.message}`);
|
|
169
|
+
}
|
|
170
|
+
if (problems.length > 0) return {
|
|
171
|
+
level: 'fail',
|
|
172
|
+
message: `퀴즈 settings가 편집 화면 규칙과 맞지 않습니다 (${problems.length}개): ${[...problems, ...warnings].join(' / ')}`,
|
|
173
|
+
problems,
|
|
174
|
+
warnings,
|
|
175
|
+
resave
|
|
176
|
+
};
|
|
177
|
+
const summary = `퀴즈 문항 ${questions.length}개 · ${String(grading?.type)}${settings.answerFormat === undefined ? '' : ` · 답 형식 ${JSON.stringify(settings.answerFormat)}`}`;
|
|
178
|
+
if (warnings.length > 0) return {
|
|
179
|
+
level: 'warn',
|
|
180
|
+
message: `${summary} · 편집 화면 검증은 통과, 확인할 것 ${warnings.length}개: ${warnings.join(' / ')}`,
|
|
181
|
+
problems,
|
|
182
|
+
warnings
|
|
183
|
+
};
|
|
184
|
+
return {
|
|
185
|
+
level: 'ok',
|
|
186
|
+
message: `${summary} · 편집 화면 검증 통과`,
|
|
187
|
+
problems,
|
|
188
|
+
warnings
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* 답 형식 꼬리표(answerFormat · requires · answerMode)를 이 프로젝트 core/model.js가 아는지.
|
|
193
|
+
* 모르면(더 새 템플릿이 저장한 settings) 문제를 더하고 true
|
|
194
|
+
*/
|
|
195
|
+
function checkFormat(model, questions, settings, known, options, add) {
|
|
196
|
+
const project = options.template ?? '이 프로젝트의 퀴즈 템플릿';
|
|
197
|
+
const requires = settings.requires?.quiz;
|
|
198
|
+
const need = typeof requires === 'string' ? `퀴즈 템플릿 ${requires} 이상` : '더 새 퀴즈 템플릿';
|
|
199
|
+
const tag = settings.answerFormat;
|
|
200
|
+
let failed = false;
|
|
201
|
+
const fail = p => {
|
|
202
|
+
failed = true;
|
|
203
|
+
add(p);
|
|
204
|
+
};
|
|
205
|
+
if (tag !== undefined) {
|
|
206
|
+
if (typeof tag !== 'number' || !Number.isInteger(tag) || tag < 1) {
|
|
207
|
+
fail(`answerFormat이 ${JSON.stringify(tag)}입니다. 답 형식은 편집 화면이 저장하는 숫자(이 프로젝트는 ${known})입니다. 손으로 바꾸지 않습니다.`);
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
if (tag > known) {
|
|
211
|
+
fail(`settings의 답 형식 answerFormat ${tag}는 ${need}이 저장한 형식인데 ${project}는 형식 ${known}까지만 압니다. 이 프로젝트의 학생 화면 · 편집 화면은 주관식 답과 정답을 다른 모양으로 읽어 한글 · 공백 · 특수문자 답이 오답이 됩니다 (이 프로젝트 편집 화면에서 다시 저장해도 꼬리표가 남아 고쳐지지 않음). ${need}으로 만든 프로젝트에서 엽니다.`);
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
const version = options.template ? parseTemplateRef(options.template).version : undefined;
|
|
216
|
+
if (typeof requires === 'string' && version !== undefined && (compareVersions(version, requires) ?? 0) < 0) {
|
|
217
|
+
fail(`settings requires.quiz가 ${requires}인데 ${project}는 그보다 옛 판입니다. ${need}으로 만든 프로젝트에서 엽니다.`);
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
if (!model.isRegexMode) {
|
|
221
|
+
const modes = questions.filter(q => q.answerMode !== undefined);
|
|
222
|
+
if (modes.length > 0) fail(`${modes.map(q => questionLabel(questions, q)).join(', ')}에 정답 입력 방식 answerMode가 있는데 ${project}의 core/model.js는 이 값을 모릅니다 (정규식 정답은 ${need}부터). 이 프로젝트에서는 answerMode를 빼고 허용 답 목록으로 둡니다.`);
|
|
223
|
+
}
|
|
224
|
+
return failed;
|
|
225
|
+
}
|
|
226
|
+
/** 정규식 문항마다: 저장한 조각이 편집 화면이 그 정규식으로 만드는 조각과 같은지 ("원래 정규식 보존"). 다른 문항 라벨 */
|
|
227
|
+
function regexMismatches(ctx, key, stored) {
|
|
228
|
+
const out = [];
|
|
229
|
+
for (const q of ctx.questions) {
|
|
230
|
+
if (!ctx.isRegex(q) || !(q.id in key)) continue;
|
|
231
|
+
const built = ctx.model.buildAnswerKey([q], {
|
|
232
|
+
[q.id]: key[q.id]
|
|
233
|
+
}, ctx.format);
|
|
234
|
+
if (!stored(q, built)) out.push(`${questionLabel(ctx.questions, q)} 정답 정규식 ${JSON.stringify(key[q.id])}의 저장 모양이 편집 화면과 다릅니다 (편집 화면: ${built})`);
|
|
235
|
+
}
|
|
236
|
+
return out;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* 지금 형식으로는 다시 만들어지지 않는 정답이 다른 형식으로는 그대로 다시 만들어지면 경고 문구:
|
|
240
|
+
* 꼬리표 없이 원문 형식, 또는 꼬리표는 있는데 옛 형식. 형식은 core/model.js build 함수가 정한다
|
|
241
|
+
*/
|
|
242
|
+
function formatMismatch(ctx, same) {
|
|
243
|
+
if (ctx.untaggedFormat !== undefined && same(ctx.untaggedFormat)) return `주관식 정답이 원문 형식(답 형식 ${ctx.untaggedFormat})으로 보이는데 settings에 answerFormat이 없습니다. 꼬리표가 없으면 학생 답은 옛 형식(URL 인코딩)으로 가 한글 · 공백 · 특수문자 답이 오답이 됩니다. ${RESAVE_FIX}`;
|
|
244
|
+
// 꼬리표는 있는데 정답은 옛 형식: 1.10 자료를 1.9.x 편집 화면에서 저장한 뒤 다시 1.10 zip으로 올린 경우 (ADR 0013 §5)
|
|
245
|
+
if (ctx.format >= 2 && same(1)) return `settings에 answerFormat ${ctx.format}가 있는데 주관식 정답은 옛 형식(URL 인코딩)입니다. 1.9.x 이하 편집 화면이 꼬리표를 남긴 채 저장한 자료로 보이며, 학생 답은 원문으로 가 한글 · 공백 · 특수문자 답이 오답이 됩니다. 이 프로젝트(퀴즈 1.10.0 이상)의 ${RESAVE_FIX}`;
|
|
246
|
+
return undefined;
|
|
247
|
+
}
|
|
248
|
+
/** 형식이 어긋나 보이면 실패로 더하고 true (한글 · 공백 · % 답이 실제로 오답이 됨) */
|
|
249
|
+
function formatFailure(ctx, same) {
|
|
250
|
+
const w = formatMismatch(ctx, same);
|
|
251
|
+
if (w) {
|
|
252
|
+
ctx.add(w);
|
|
253
|
+
ctx.resave();
|
|
254
|
+
}
|
|
255
|
+
return w !== undefined;
|
|
256
|
+
}
|
|
257
|
+
function checkLength(ctx, key, label) {
|
|
258
|
+
if (typeof key === 'string' && key.length > ANSWER_KEY_MAX) ctx.add(`${label}이 너무 깁니다 (${key.length}자, 최대 ${ANSWER_KEY_MAX}자, 서버 한도). 정답을 줄이거나 퀴즈를 나눕니다.`);
|
|
259
|
+
}
|
|
260
|
+
function checkPattern(ctx, answerKey) {
|
|
261
|
+
const {
|
|
262
|
+
model,
|
|
263
|
+
questions,
|
|
264
|
+
v,
|
|
265
|
+
add,
|
|
266
|
+
format
|
|
267
|
+
} = ctx;
|
|
268
|
+
checkLength(ctx, answerKey, '정답 정규식(퀴즈 전체)');
|
|
269
|
+
const key = model.parseAnswerKey(questions, answerKey);
|
|
270
|
+
if (!key) {
|
|
271
|
+
add(`grading.answer_key를 편집 화면이 읽지 못합니다 (손으로 쓴 정규식). ${BUILD_HINT}`);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const missing = questions.filter(q => !(q.id in key)).map(q => q.id);
|
|
275
|
+
if (missing.length > 0) add(`grading.answer_key에 문항 ${missing.join(', ')}의 정답이 없습니다. ${MOVE_HINT}`);
|
|
276
|
+
const invalid = model.validateAnswerKey(questions, key, v);
|
|
277
|
+
if (invalid) {
|
|
278
|
+
// 막는 정규식 문법 · 빈 정답 · 지운 보기. 다시 만든 모양 비교는 이것을 고친 뒤에
|
|
279
|
+
add(`정답: ${invalid.message}`);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
const regex = answerKey;
|
|
283
|
+
if (model.buildAnswerKey(questions, key, format) !== regex) {
|
|
284
|
+
const body = `;${regex.slice(1, -1)};`;
|
|
285
|
+
const regexDiff = regexMismatches(ctx, key, (_q, built) => body.includes(`;${built.slice(1, -1)};`));
|
|
286
|
+
if (regexDiff.length > 0) add(`${regexDiff.join(', ')}. ${REGEX_HINT}`);else if (formatFailure(ctx, f => model.buildAnswerKey(questions, key, f) === regex)) return;else add(`grading.answer_key가 편집 화면이 만드는 모양과 다릅니다 (문항 순서 · 이스케이프 · 주관식 답 형식). ${BUILD_HINT}`);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const check = model.checkAnswerKey(questions, key, regex, v, format);
|
|
290
|
+
if (check) add(`정답 정규식: ${check.message}`);
|
|
291
|
+
}
|
|
292
|
+
function checkPartial(ctx, grading) {
|
|
293
|
+
const {
|
|
294
|
+
model,
|
|
295
|
+
questions,
|
|
296
|
+
settings,
|
|
297
|
+
v,
|
|
298
|
+
add,
|
|
299
|
+
format
|
|
300
|
+
} = ctx;
|
|
301
|
+
if (settings.gradingType !== PARTIAL) add(`공개 값 gradingType이 ${settings.gradingType === undefined ? '없습니다' : `${JSON.stringify(settings.gradingType)}입니다`}. partial_pattern이면 settings에 "gradingType": "partial_pattern"을 같이 둡니다 (없으면 학생 화면이 답을 문자열 하나로 내 제출이 거절됨).`);
|
|
302
|
+
const keys = grading.answer_key;
|
|
303
|
+
const scores = grading.scores;
|
|
304
|
+
if (!Array.isArray(keys) || !Array.isArray(scores)) return; // 모양 오류는 project.grading이 알린다
|
|
305
|
+
keys.forEach((k, i) => checkLength(ctx, k, `${keyId(k) ?? `${i + 1}번째`} 정답 정규식`));
|
|
306
|
+
if (keys.length !== questions.length) add(`문항은 ${questions.length}개인데 grading.answer_key는 ${keys.length}개입니다. ${MOVE_HINT}`);
|
|
307
|
+
if (scores.length !== questions.length) add(`문항은 ${questions.length}개인데 grading.scores는 ${scores.length}개입니다. ${MOVE_HINT}`);
|
|
308
|
+
const misplaced = keys.map((k, i) => ({
|
|
309
|
+
i,
|
|
310
|
+
id: keyId(k),
|
|
311
|
+
want: questions[i]?.id
|
|
312
|
+
})).filter(x => x.want !== undefined && x.id !== x.want);
|
|
313
|
+
if (misplaced.length > 0) add(`answer_key 자리가 문항 순서와 다릅니다 (${misplaced.map(x => `${x.i + 1}번째가 ${x.id ?? '?'} 정답, 문항은 ${x.want}`).join(', ')}). ${MOVE_HINT}`);
|
|
314
|
+
if (scores.length === questions.length) {
|
|
315
|
+
const differ = questions.map((q, i) => ({
|
|
316
|
+
no: i + 1,
|
|
317
|
+
points: q.points,
|
|
318
|
+
score: scores[i]
|
|
319
|
+
})).filter(x => x.points !== x.score);
|
|
320
|
+
if (differ.length > 0) add(`배점 points와 채점 점수 scores가 다릅니다 (${differ.map(x => `문제 ${x.no}: points ${JSON.stringify(x.points)} · scores ${JSON.stringify(x.score)}`).join(', ')}). 문제마다 points와 같은 자리 scores를 같은 값으로 둡니다.`);
|
|
321
|
+
}
|
|
322
|
+
if (settings.pointsMode !== 'equal' && settings.pointsMode !== 'custom') add(`pointsMode가 ${settings.pointsMode === undefined ? '없습니다' : JSON.stringify(settings.pointsMode)}. 자동 배점은 "equal", 직접 배점은 "custom"입니다.`);
|
|
323
|
+
if (settings.pointsMode === 'equal' && model.equalPoints) {
|
|
324
|
+
const even = model.equalPoints(questions.length);
|
|
325
|
+
if (JSON.stringify(even) !== JSON.stringify(scores)) add(`pointsMode "equal"(자동 배점)인데 scores가 [${scores.join(', ')}]입니다. 자동 배점은 문제마다 ${even[0] ?? 0}점 (core/model.js equalPoints)이고, 다른 배점이면 pointsMode "custom"입니다.`);
|
|
326
|
+
}
|
|
327
|
+
if (PARTIAL_FUNCTIONS.some(name => typeof model[name] !== 'function')) {
|
|
328
|
+
add('이 프로젝트의 core/model.js는 부분 채점(partial_pattern)을 모릅니다 (옛 템플릿).');
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
const key = model.parseAnswerKeys?.(questions, keys);
|
|
332
|
+
if (!key) {
|
|
333
|
+
// 어느 문항 정규식인지 하나씩 읽어 본다
|
|
334
|
+
const unreadable = keys.map((k, i) => ({
|
|
335
|
+
k,
|
|
336
|
+
name: keyId(k) ?? `${i + 1}번째`
|
|
337
|
+
})).filter(({
|
|
338
|
+
k
|
|
339
|
+
}) => !model.parseAnswerKeys?.(questions, [k])).map(({
|
|
340
|
+
name
|
|
341
|
+
}) => name);
|
|
342
|
+
add(`grading.answer_key${unreadable.length > 0 ? `의 ${unreadable.join(', ')} 정답` : ''}을 편집 화면이 읽지 못합니다 (손으로 쓴 정규식). ${BUILD_HINT}`);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
const missing = questions.filter(q => !(q.id in key)).map(q => q.id);
|
|
346
|
+
if (missing.length > 0) add(`grading.answer_key에 문항 ${missing.join(', ')}의 정답이 없습니다. ${MOVE_HINT}`);
|
|
347
|
+
const invalid = model.validateAnswerKey(questions, key, v);
|
|
348
|
+
if (invalid) {
|
|
349
|
+
add(`정답: ${invalid.message}`);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
const same = f => JSON.stringify(model.buildAnswerKeys?.(questions, key, f)) === JSON.stringify(keys);
|
|
353
|
+
if (misplaced.length === 0 && !same(format)) {
|
|
354
|
+
const regexDiff = regexMismatches(ctx, key, (q, built) => keys[questions.indexOf(q)] === built);
|
|
355
|
+
if (regexDiff.length > 0) add(`${regexDiff.join(', ')}. ${REGEX_HINT}`);else if (formatFailure(ctx, same)) return;else add(`grading.answer_key가 편집 화면이 만드는 모양과 다릅니다 (이스케이프 · 주관식 답 형식). ${BUILD_HINT}`);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
if (keys.length === questions.length && misplaced.length === 0) {
|
|
359
|
+
const check = model.checkAnswerKeys?.(questions, key, keys, v, format);
|
|
360
|
+
if (check) add(`정답 정규식: ${check.message}`);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export { RESAVE_FIX, checkQuizSettings };
|
package/es/dev/host-page.js
CHANGED
|
@@ -91,11 +91,14 @@ function hostPage(opts) {
|
|
|
91
91
|
const SDK_SOURCE = 'eliceio-content-sdk';
|
|
92
92
|
// ecdk dev가 콘텐츠 HTML에 넣는 스크립트(inject.ts)의 메시지: 콘텐츠 CSP가 막은 요청
|
|
93
93
|
const DEV_SOURCE = ${JSON.stringify(DEV_MESSAGE_SOURCE)};
|
|
94
|
-
// [보기, 이름, 화면, 주소
|
|
94
|
+
// [보기, 이름, 화면, 주소 조각, 토큰 뒤에 붙일 조각, 토큰 보기(없으면 보기와 같음)]. token은 흉내 서버가 발급.
|
|
95
|
+
// 내용 편집은 LXP처럼 저장된 버전을 edit 토큰으로 연다.
|
|
96
|
+
// 학습 페이지에서는 교육자도 학생 화면을 보므로(학생 보기와 같은 화면) 학습 페이지의 교육자 보기는 두지 않는다.
|
|
97
|
+
// 교육자 화면은 LXP 편집기 미리보기의 교육자 토글처럼 edit 토큰 + screen=instructor로만 연다 (제출은 edit 토큰이라 거절)
|
|
95
98
|
const SCENARIOS = [
|
|
96
99
|
['student', '학생', 'learn', 'token'],
|
|
97
100
|
['tutor', '튜터링', 'learn', 'token'],
|
|
98
|
-
['instructor', '교육자 화면', 'instructor', 'token'],
|
|
101
|
+
['instructor', '교육자 화면 (미리보기)', 'instructor', 'token', 'screen=instructor', 'edit'],
|
|
99
102
|
['edit', '내용 편집', 'edit', 'token'],
|
|
100
103
|
// 완료 정책 보기는 없다: 완료 정책은 LXP에 올린 뒤 설정 탭에서 교육자가 고른다 (ADR 0012)
|
|
101
104
|
];
|
|
@@ -142,13 +145,13 @@ function hostPage(opts) {
|
|
|
142
145
|
for (const b of scenariosEl.children) b.setAttribute('aria-pressed', String(b.dataset.scenario === scenario));
|
|
143
146
|
previewEl.setAttribute('aria-pressed', String(scenario === PREVIEW[0]));
|
|
144
147
|
editDraftEl.setAttribute('aria-pressed', String(scenario === EDIT_DRAFT[0]));
|
|
145
|
-
const [, label, screen, fragment] = scenarioOf(scenario);
|
|
148
|
+
const [, label, screen, fragment, extra, tokenScenario = scenario] = scenarioOf(scenario);
|
|
146
149
|
const entry = entryOf(screen);
|
|
147
150
|
// 같은 파일이면 해시만 바뀌어 다시 로드되지 않으므로 매번 쿼리를 바꾼다
|
|
148
151
|
const url = state.contentBase + entry + '?ecdk=' + Date.now();
|
|
149
152
|
if (fragment === 'token') {
|
|
150
|
-
const { token } = await (await fetch('/__ecdk/token?scenario=' +
|
|
151
|
-
frame.src = url + '#token=' + token + '&baseUrl=' + BASE_URL;
|
|
153
|
+
const { token } = await (await fetch('/__ecdk/token?scenario=' + tokenScenario)).json();
|
|
154
|
+
frame.src = url + '#token=' + token + (extra ? '&' + extra : '') + '&baseUrl=' + BASE_URL;
|
|
152
155
|
} else {
|
|
153
156
|
frame.src = url + '#' + fragment + '&baseUrl=' + BASE_URL;
|
|
154
157
|
}
|
package/es/dev/mock-api.d.ts
CHANGED
|
@@ -20,7 +20,9 @@ export type MaterialScope = 'learn' | 'edit';
|
|
|
20
20
|
export type MaterialViewer = 'student' | 'instructor' | 'tutor';
|
|
21
21
|
/**
|
|
22
22
|
* dev 호스트 화면의 보기 (dev 전용). 토큰은 scope + viewer로 바뀐다.
|
|
23
|
-
* - student · instructor · tutor: `#token=…` (scope learn)
|
|
23
|
+
* - student · instructor · tutor: `#token=…` (scope learn). 학습 페이지라 교육자도 학생 화면(learn)을 본다
|
|
24
|
+
* (SDK resolveScreen). dev 화면의 '교육자 화면 (미리보기)'는 이 토큰이 아니라 edit 토큰에 `screen=instructor`를 붙여 연다
|
|
25
|
+
* (LXP 편집기 미리보기의 교육자 토글과 같음)
|
|
24
26
|
* - edit: `#token=…` (scope edit). LXP 편집 페이지처럼 편집 화면을 edit 토큰으로 열고,
|
|
25
27
|
* 콘텐츠의 `saveSettings`가 이 토큰으로 `PATCH /materials/{id}/draft`를 부른다 (토큰 없는 `#edit=1` draft는 저장할 수 없음).
|
|
26
28
|
* dev에는 draft 발행 단계가 없어 draft에 저장한 settings가 바로 지금 버전 settings가 된다
|
package/es/rules/check.js
CHANGED
|
@@ -2,6 +2,7 @@ import { zipSync } from 'fflate';
|
|
|
2
2
|
import { isAllowedExternal, allowedOrigins } from './csp.js';
|
|
3
3
|
import { parseManifest } from './manifest.js';
|
|
4
4
|
import { isUnsafePath, extname, resolveRef, globToRegExp } from './path.js';
|
|
5
|
+
import { privacyFindings, PRIVACY_RULE } from './privacy.js';
|
|
5
6
|
import { lineAt, parseTags, extractRefs, classifyRef, FRAME_TAGS } from './refs.js';
|
|
6
7
|
import { compareVersions } from './semver.js';
|
|
7
8
|
import { screenSizeIssues, screenSizes, isLazyBundleFile } from './size.js';
|
|
@@ -456,6 +457,11 @@ function checkFiles(input, opts = {}) {
|
|
|
456
457
|
break;
|
|
457
458
|
}
|
|
458
459
|
}
|
|
460
|
+
// 학습자 개인정보를 받는 입력 칸 · 저장 · 전송 (화면 코드만: 키트 lib/ · 라이브러리 제외, 같은 파일은 처음 한 곳)
|
|
461
|
+
if (!vendor && !f.path.startsWith('lib/')) {
|
|
462
|
+
const [first] = privacyFindings(scanned);
|
|
463
|
+
if (first) add(PRIVACY_RULE, first.message, f.path, first.line);
|
|
464
|
+
}
|
|
459
465
|
}
|
|
460
466
|
return {
|
|
461
467
|
ok: !issues.some(i => i.level === 'error'),
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* privacy.personal-field (warn): 학습자 개인정보를 받거나 저장 · 전송하는 것으로 보이는 화면 코드.
|
|
3
|
+
* 화면 HTML · JS(키트 lib/ · 라이브러리 제외)를 정규식으로 본다. 흐름은 따라가지 않으므로 경고만이고,
|
|
4
|
+
* 개인정보를 다루는 법을 가르치는 실습처럼 정당한 경우는 `ecdk-ignore-next-line privacy.personal-field`와 이유로 넘긴다.
|
|
5
|
+
*
|
|
6
|
+
* - (a) 개인정보를 받는 입력 칸: `<input type="tel|email">`, `autocomplete`가 이름 · 연락처 · 주소 · 생일 · 카드 값
|
|
7
|
+
* - (b) 입력 칸(input · textarea · select)의 name · id · placeholder · aria-label이나 `<label>` 글에 개인정보 단어
|
|
8
|
+
* (주소 · address는 IP 주소 · 메모리 주소와 헷갈려 빼고, birth는 출생률과 헷갈려 birthday · birthdate만)
|
|
9
|
+
* - (c) 제출 · kvstore 저장 인자의 key가 개인정보 이름 (phone · email · 학번 …)
|
|
10
|
+
* - (d) `account.fullname`(학습자 이름)을 제출 · 저장 · 업로드 · AI 호출 인자에 넣음
|
|
11
|
+
*
|
|
12
|
+
* HTML 파일과 JS 문자열(템플릿 문자열 · html`…`)의 태그를 같은 정규식으로 본다.
|
|
13
|
+
*/
|
|
14
|
+
export declare const PRIVACY_RULE = "privacy.personal-field";
|
|
15
|
+
export interface PrivacyFinding {
|
|
16
|
+
line: number;
|
|
17
|
+
message: string;
|
|
18
|
+
}
|
|
19
|
+
/** 화면 HTML · JS 하나에서 찾은 곳 (주석뿐인 줄 · ecdk-ignore로 끈 줄 제외, 같은 줄은 하나만) */
|
|
20
|
+
export declare function privacyFindings(text: string): PrivacyFinding[];
|