@eliceio/cdk-cli 1.4.1 → 1.5.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 +17 -16
- package/es/cli.js +1 -1
- package/es/commands/create/index.js +1 -0
- package/es/commands/create/scaffold.d.ts +1 -1
- package/es/commands/create/scaffold.js +1 -1
- package/es/core/config.d.ts +36 -0
- package/es/core/config.js +234 -6
- package/es/core/quiz-check.js +123 -4
- package/es/dev/grading.d.ts +26 -4
- package/es/dev/grading.js +66 -11
- package/es/dev/mock-api.d.ts +6 -1
- package/es/dev/mock-api.js +45 -6
- package/es/rules/answers.d.ts +1 -0
- package/es/rules/answers.js +8 -0
- package/es/rules.json.js +1 -1
- package/package.json +2 -2
- package/rules.json +1 -1
- package/skills/_shared/always.md +1 -1
- package/skills/_shared/references/02-design-the-material.md +8 -7
- package/skills/_shared/references/03-create-the-project.md +10 -9
- package/skills/_shared/references/12-upload-with-the-material-mcp.md +5 -5
- package/skills/_shared/references/16-using-the-survey-template.md +158 -0
- package/skills/elice-content-create/SKILL.md +2 -2
- package/skills/elice-content-edit/SKILL.md +2 -2
- package/skills/elice-content-publish/SKILL.md +1 -1
- package/templates/_shared/lib/cdk-mock.d.ts +22 -3
- package/templates/_shared/lib/cdk-mock.js +78 -11
- package/templates/_shared/lib/elice-content.d.ts +17 -1
- package/templates/_shared/lib/elice-content.js +47 -5
- package/templates/blank/template.json +1 -1
- package/templates/document/template.json +1 -1
- package/templates/quiz/README.md +26 -1
- package/templates/quiz/core/behaviors.d.ts +5 -0
- package/templates/quiz/core/behaviors.js +16 -1
- package/templates/quiz/core/model.d.ts +78 -1
- package/templates/quiz/core/model.js +219 -4
- package/templates/quiz/screens/edit.js +244 -55
- package/templates/quiz/screens/learn.js +137 -27
- package/templates/quiz/styles.css +258 -5
- package/templates/quiz/template.json +1 -1
- package/templates/quiz/ui/templates/edit.d.ts +1 -0
- package/templates/quiz/ui/templates/edit.js +67 -8
- package/templates/quiz/ui/templates/page.js +34 -0
- package/templates/quiz/ui/templates/text.js +15 -2
- package/templates/quiz/ui/texts.js +61 -0
- package/templates/steps/template.json +1 -1
- package/templates/survey/README.md +112 -0
- package/templates/survey/commentary.txt +2 -0
- package/templates/survey/core/behaviors.d.ts +14 -0
- package/templates/survey/core/behaviors.js +115 -0
- package/templates/survey/core/dom.d.ts +13 -0
- package/templates/survey/core/dom.js +83 -0
- package/templates/survey/core/editor.d.ts +80 -0
- package/templates/survey/core/editor.js +720 -0
- package/templates/survey/core/markdown.d.ts +21 -0
- package/templates/survey/core/markdown.js +298 -0
- package/templates/survey/core/model.d.ts +83 -0
- package/templates/survey/core/model.js +209 -0
- package/templates/survey/core/rich-text.d.ts +18 -0
- package/templates/survey/core/rich-text.js +469 -0
- package/templates/survey/edit.html +26 -0
- package/templates/survey/gitignore +4 -0
- package/templates/survey/index.html +26 -0
- package/templates/survey/metadata.json +9 -0
- package/templates/survey/package.json +13 -0
- package/templates/survey/screens/edit.js +345 -0
- package/templates/survey/screens/learn.js +100 -0
- package/templates/survey/styles.css +1264 -0
- package/templates/survey/template.json +6 -0
- package/templates/survey/ui/templates/edit.d.ts +27 -0
- package/templates/survey/ui/templates/edit.js +656 -0
- package/templates/survey/ui/templates/index.d.ts +3 -0
- package/templates/survey/ui/templates/index.js +3 -0
- package/templates/survey/ui/templates/learn.js +147 -0
- package/templates/survey/ui/templates/page.js +19 -0
- package/templates/survey/ui/texts.d.ts +3 -0
- package/templates/survey/ui/texts.js +116 -0
- package/templates/survey/ui/theme.css +42 -0
- package/templates/video/template.json +1 -1
package/es/core/quiz-check.js
CHANGED
|
@@ -8,6 +8,11 @@ import { parseTemplateRef } from './templates.js';
|
|
|
8
8
|
const REQUIRED = ['validateQuiz', 'parseAnswerKey', 'buildAnswerKey', 'validateAnswerKey', 'checkAnswerKey'];
|
|
9
9
|
const PARTIAL_FUNCTIONS = ['parseAnswerKeys', 'buildAnswerKeys', 'checkAnswerKeys', 'equalPoints'];
|
|
10
10
|
const PARTIAL = 'partial_pattern';
|
|
11
|
+
const PER_QUESTION = 'per_question';
|
|
12
|
+
/** 1.11.0 개발 중 제안 (서버는 받지 않음) */
|
|
13
|
+
const ITEMS = 'items';
|
|
14
|
+
/** per_question을 아는 첫 퀴즈 템플릿 */
|
|
15
|
+
const PER_QUESTION_VERSION = '1.11.0';
|
|
11
16
|
/** 이 CLI에 든 퀴즈 템플릿 문구 (프로젝트 ui/texts.js를 읽지 못하거나 모양이 다를 때) */
|
|
12
17
|
const SHIPPED_TEXTS = fileURLToPath(new URL('../../templates/quiz/ui/texts.js', import.meta.url));
|
|
13
18
|
/** 답 형식 어긋남의 고치는 방법 */
|
|
@@ -128,8 +133,10 @@ async function checkQuizSettings(srcDir, saved, options = {}) {
|
|
|
128
133
|
const grading = settings.grading;
|
|
129
134
|
try {
|
|
130
135
|
fromModel(model.validateQuiz(settings, messages.quiz), '편집 화면 검증');
|
|
131
|
-
// 답 형식을 이 프로젝트가 읽지 못하면 정답 검사는 뜻이 없다 (학생 답과 정답 모양이 어긋남)
|
|
132
|
-
|
|
136
|
+
// 답 형식을 이 프로젝트가 읽지 못하면 정답 검사는 뜻이 없다 (학생 답과 정답 모양이 어긋남).
|
|
137
|
+
// known: 이 프로젝트가 읽는 가장 새 형식 (1.11.0부터 ANSWER_FORMAT_MAX, per_question 3), saves: 정답 인코딩 형식(ANSWER_FORMAT)
|
|
138
|
+
const saves = typeof model.ANSWER_FORMAT === 'number' ? model.ANSWER_FORMAT : 1;
|
|
139
|
+
const known = typeof model.ANSWER_FORMAT_MAX === 'number' ? model.ANSWER_FORMAT_MAX : saves;
|
|
133
140
|
if (!checkFormat(model, questions, settings, known, options, add)) {
|
|
134
141
|
const format = model.answerFormatOf ? model.answerFormatOf(settings) : 1;
|
|
135
142
|
const isRegex = q => model.isRegexMode?.(q) === true;
|
|
@@ -145,7 +152,7 @@ async function checkQuizSettings(srcDir, saved, options = {}) {
|
|
|
145
152
|
resave: () => {
|
|
146
153
|
resave = true;
|
|
147
154
|
},
|
|
148
|
-
untaggedFormat: settings.answerFormat === undefined &&
|
|
155
|
+
untaggedFormat: settings.answerFormat === undefined && saves >= 2 ? saves : undefined
|
|
149
156
|
};
|
|
150
157
|
if (ctx.untaggedFormat !== undefined) {
|
|
151
158
|
const regexQs = questions.filter(isRegex);
|
|
@@ -154,14 +161,22 @@ async function checkQuizSettings(srcDir, saved, options = {}) {
|
|
|
154
161
|
add(`${regexQs.map(q => questionLabel(questions, q)).join(', ')}는 정규식 입력(answerMode "regex")인데 settings에 answerFormat이 없습니다. 꼬리표가 없으면 학생 답이 옛 형식(URL 인코딩)으로 가 한글 · 공백 · 특수문자 답이 오답이 됩니다. ${RESAVE_FIX}`);
|
|
155
162
|
}
|
|
156
163
|
}
|
|
164
|
+
const rubricQs = model.isRubricMode ? questions.filter(q => model.isRubricMode?.(q)) : [];
|
|
157
165
|
if (!grading || typeof grading !== 'object') {
|
|
158
166
|
add('정답(grading)이 없습니다. 퀴즈는 편집 화면이 문항마다 고른 정답으로 grading을 저장합니다.');
|
|
167
|
+
} else if (grading.type === ITEMS) {
|
|
168
|
+
add(`grading.type "items"는 1.11.0 개발 중의 제안 형식이라 서버가 받지 않습니다. ${RESAVE_FIX} (per_question으로 다시 저장됨)`);
|
|
169
|
+
ctx.resave();
|
|
170
|
+
} else if (grading.type === PER_QUESTION) {
|
|
171
|
+
checkPerQuestion(ctx, grading);
|
|
172
|
+
} else if (rubricQs.length > 0) {
|
|
173
|
+
add(`${rubricQs.map(q => questionLabel(questions, q)).join(', ')}는 AI 채점(answerMode "rubric")인데 grading.type이 ${JSON.stringify(grading.type)}입니다. AI 채점 문항이 있으면 편집 화면은 grading을 per_question으로 저장합니다.`);
|
|
159
174
|
} else if (grading.type === PARTIAL) {
|
|
160
175
|
checkPartial(ctx, grading);
|
|
161
176
|
} else if (grading.type === 'pattern') {
|
|
162
177
|
checkPattern(ctx, grading.answer_key);
|
|
163
178
|
} else {
|
|
164
|
-
add(`퀴즈 채점 방식은 pattern
|
|
179
|
+
add(`퀴즈 채점 방식은 pattern · partial_pattern · per_question(AI 채점 문항이 있을 때)입니다 (지금 ${JSON.stringify(grading.type)}).`);
|
|
165
180
|
}
|
|
166
181
|
}
|
|
167
182
|
} catch (e) {
|
|
@@ -360,5 +375,109 @@ function checkPartial(ctx, grading) {
|
|
|
360
375
|
if (check) add(`정답 정규식: ${check.message}`);
|
|
361
376
|
}
|
|
362
377
|
}
|
|
378
|
+
/**
|
|
379
|
+
* per_question (AI 채점 문항이 있는 퀴즈, 1.11.0 · 서버 #65): questions 자리 = 문항 순서. AI 채점 문항 자리는 rubric 채점기
|
|
380
|
+
* (채점 기준 + 문제 글), 나머지는 partial_pattern과 같은 문항별 정답 정규식(pattern 채점기). 배점은 문제마다 points와 같은 자리 score.
|
|
381
|
+
* 공개 값: gradingType per_question · answerFormat 3(1.10 편집 화면이 덮어쓰지 못하게) · requires 1.11.0 · passScore(= pass_score).
|
|
382
|
+
* 서버 저장 규칙(배점 합 · AI 채점 10개 · pass_score 범위)은 project.grading이 본다
|
|
383
|
+
*/
|
|
384
|
+
function checkPerQuestion(ctx, grading) {
|
|
385
|
+
const {
|
|
386
|
+
model,
|
|
387
|
+
questions,
|
|
388
|
+
settings,
|
|
389
|
+
v,
|
|
390
|
+
add,
|
|
391
|
+
warn,
|
|
392
|
+
format
|
|
393
|
+
} = ctx;
|
|
394
|
+
if (!model.parsePerQuestionGrading || !model.buildPerQuestionGrading || !model.isRubricMode) {
|
|
395
|
+
add(`이 프로젝트의 core/model.js는 per_question(AI 채점)을 모릅니다 (퀴즈 템플릿 ${PER_QUESTION_VERSION}부터).`);
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
const isRubric = q => model.isRubricMode?.(q) === true;
|
|
399
|
+
if (settings.gradingType !== PER_QUESTION) add(`공개 값 gradingType이 ${settings.gradingType === undefined ? '없습니다' : `${JSON.stringify(settings.gradingType)}입니다`}. per_question이면 settings에 "gradingType": "per_question"을 같이 둡니다 (없으면 학생 화면이 답을 문항별 배열로 내지 않아 제출이 거절됨).`);
|
|
400
|
+
const tag = model.ANSWER_FORMAT_PER_QUESTION;
|
|
401
|
+
if (typeof tag === 'number' && settings.answerFormat !== tag) warn(`per_question 퀴즈의 answerFormat이 ${JSON.stringify(settings.answerFormat)}입니다. 편집 화면은 ${tag}로 저장해 퀴즈 1.10 편집 화면이 이 채점 설정을 덮어쓰지 못하게 합니다. ${RESAVE_FIX}`);
|
|
402
|
+
const requires = settings.requires?.quiz;
|
|
403
|
+
if (typeof requires !== 'string' || (compareVersions(requires, PER_QUESTION_VERSION) ?? 0) < 0) warn(`settings requires.quiz가 ${JSON.stringify(requires)}입니다. per_question은 퀴즈 템플릿 ${PER_QUESTION_VERSION} 이상이 읽으므로 편집 화면은 requires { "quiz": "${PER_QUESTION_VERSION}" }을 같이 저장합니다.`);
|
|
404
|
+
const pass = grading.pass_score;
|
|
405
|
+
if (pass === undefined) warn('grading.pass_score가 없습니다 (서버는 100점이어야 완료). 편집 화면은 AI 채점 문항이 있으면 통과 점수를 늘 같이 저장합니다.');
|
|
406
|
+
if (settings.passScore !== (pass ?? 100)) warn(`공개 값 passScore(${JSON.stringify(settings.passScore)})가 grading.pass_score(${JSON.stringify(pass ?? 100)})와 다릅니다. 학생 화면은 passScore로 "통과"를 보입니다 (학생은 grading을 받지 못함).`);
|
|
407
|
+
const list = grading.questions;
|
|
408
|
+
if (!Array.isArray(list)) return; // 모양 오류는 project.grading이 알린다
|
|
409
|
+
if (list.length !== questions.length) add(`문항은 ${questions.length}개인데 grading.questions는 ${list.length}개입니다. ${MOVE_HINT}`);
|
|
410
|
+
const graderOf = entry => entry?.grader;
|
|
411
|
+
const wrongKind = questions.map((q, i) => ({
|
|
412
|
+
q,
|
|
413
|
+
i,
|
|
414
|
+
grader: graderOf(list[i])
|
|
415
|
+
})).filter(({
|
|
416
|
+
q,
|
|
417
|
+
grader
|
|
418
|
+
}) => grader !== undefined && grader?.type === 'rubric' !== isRubric(q));
|
|
419
|
+
if (wrongKind.length > 0) add(`questions 자리와 문항이 맞지 않습니다 (${wrongKind.map(({
|
|
420
|
+
q,
|
|
421
|
+
i,
|
|
422
|
+
grader
|
|
423
|
+
}) => `${i + 1}번째 채점기는 ${JSON.stringify(grader?.type)}인데 ${questionLabel(questions, q)}는 ${isRubric(q) ? 'AI 채점' : 'AI 채점이 아님'}`).join(', ')}). questions 자리는 문항 순서와 같고, AI 채점 문항(answerMode "rubric") 자리는 rubric 채점기입니다.`);
|
|
424
|
+
const misplaced = list.map((entry, i) => ({
|
|
425
|
+
i,
|
|
426
|
+
id: keyId(graderOf(entry)?.answer_key),
|
|
427
|
+
want: questions[i]
|
|
428
|
+
})).filter(x => x.want !== undefined && !isRubric(x.want) && x.id !== undefined && x.id !== x.want.id);
|
|
429
|
+
if (misplaced.length > 0) add(`questions 정답 정규식 자리가 문항 순서와 다릅니다 (${misplaced.map(x => `${x.i + 1}번째가 ${x.id ?? '?'} 정답, 문항은 ${x.want?.id}`).join(', ')}). ${MOVE_HINT}`);
|
|
430
|
+
const scores = list.map(entry => entry?.score);
|
|
431
|
+
if (questions.length > 1 && scores.length === questions.length) {
|
|
432
|
+
const differ = questions.map((q, i) => ({
|
|
433
|
+
no: i + 1,
|
|
434
|
+
points: q.points,
|
|
435
|
+
score: scores[i]
|
|
436
|
+
})).filter(x => x.points !== x.score);
|
|
437
|
+
if (differ.length > 0) add(`배점 points와 questions score가 다릅니다 (${differ.map(x => `문제 ${x.no}: points ${JSON.stringify(x.points)} · score ${JSON.stringify(x.score)}`).join(', ')}). 문제마다 points와 같은 자리 score를 같은 값으로 둡니다.`);
|
|
438
|
+
}
|
|
439
|
+
if (wrongKind.length > 0 || misplaced.length > 0 || list.length !== questions.length) return;
|
|
440
|
+
const parsed = model.parsePerQuestionGrading(questions, grading);
|
|
441
|
+
if (!parsed) {
|
|
442
|
+
add(`grading.questions를 편집 화면이 읽지 못합니다 (손으로 쓴 정규식). ${BUILD_HINT}`);
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
const invalid = model.validateAnswerKey(questions, parsed.key, v);
|
|
446
|
+
if (invalid) {
|
|
447
|
+
add(`정답: ${invalid.message}`);
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
const rebuilt = model.buildPerQuestionGrading(questions, parsed.key, parsed.scores, format, parsed.passScore).questions;
|
|
451
|
+
if (JSON.stringify(rebuilt) !== JSON.stringify(list)) {
|
|
452
|
+
// 문제 글(question)만 다르면 경고: 채점은 되지만 AI가 지금 문제와 다른 글을 읽는다
|
|
453
|
+
const strip = xs => JSON.stringify(xs.map(x => {
|
|
454
|
+
const e = x;
|
|
455
|
+
const {
|
|
456
|
+
question: _q,
|
|
457
|
+
...g
|
|
458
|
+
} = e.grader ?? {};
|
|
459
|
+
return {
|
|
460
|
+
score: e.score,
|
|
461
|
+
grader: g
|
|
462
|
+
};
|
|
463
|
+
}));
|
|
464
|
+
if (strip(rebuilt) === strip(list)) warn('AI 채점 문항의 문제 글(grader.question)이 지금 문제(질문 + 지문)와 다릅니다. AI는 이 글을 채점 기준과 같이 읽으므로 편집 화면에서 다시 저장해 맞춥니다.');else {
|
|
465
|
+
add(`grading.questions가 편집 화면이 만드는 모양과 다릅니다 (필드 순서 · 이스케이프 · 주관식 답 형식). ${BUILD_HINT}`);
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
// 왕복 · 오답 검사는 정규식 문항만 (문항 번호는 원래 자리)
|
|
470
|
+
const kept = questions.map((q, i) => isRubric(q) ? -1 : i).filter(i => i >= 0);
|
|
471
|
+
const sub = kept.map(i => questions[i]);
|
|
472
|
+
if (sub.length > 0 && model.buildAnswerKeys && model.checkAnswerKeys) {
|
|
473
|
+
const keys = model.buildAnswerKeys(sub, parsed.key, format);
|
|
474
|
+
const at = v.at;
|
|
475
|
+
const check = model.checkAnswerKeys(sub, parsed.key, keys, {
|
|
476
|
+
...v,
|
|
477
|
+
at: (no, message) => at((kept[no - 1] ?? 0) + 1, message)
|
|
478
|
+
}, format);
|
|
479
|
+
if (check) add(`정답 정규식: ${check.message}`);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
363
482
|
|
|
364
483
|
export { RESAVE_FIX, checkQuizSettings };
|
package/es/dev/grading.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LocalGrading } from '../core/config.js';
|
|
1
|
+
import type { GradingQuestion, LocalGrading } from '../core/config.js';
|
|
2
2
|
/**
|
|
3
3
|
* `ecdk dev` 흉내 채점. 서버 elice-material(`sprint/custom-material-2`)과 같은 규칙이다:
|
|
4
4
|
* `app/core/grading.py`(get_effective_completion · get_completion_score · build_*_outcome),
|
|
@@ -16,12 +16,19 @@ export declare const isCompletionPolicy: (v: unknown) => v is CompletionPolicy;
|
|
|
16
16
|
* (제출이 없는 자료에 제안하는 `on_access`는 dev가 코드만으로 알 수 없어 SDK 기능 메뉴에서 고른다)
|
|
17
17
|
*/
|
|
18
18
|
export declare function recommendedCompletionPolicy(local: LocalGrading | undefined): CompletionPolicy;
|
|
19
|
-
/**
|
|
19
|
+
/** 문항 하나의 결과 (응답 `question_results[i]`, 응답에서는 is_correct): 그 문항이 받은 정수 점수, 채점기가 만점(100)을 줬을 때만 isCorrect */
|
|
20
|
+
export interface QuestionResult {
|
|
21
|
+
score: number;
|
|
22
|
+
isCorrect: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** 제출 응답 `{ is_correct, score, answer_correctness, question_results }`. 채점하지 않으면 is_correct · score가 null */
|
|
20
25
|
export interface GradeResult {
|
|
21
26
|
isCorrect: boolean | null;
|
|
22
27
|
score: number | null;
|
|
23
|
-
/** partial_pattern 문항별 맞음 (
|
|
28
|
+
/** partial_pattern · per_question 문항별 맞음 (문항 순서, 없는 답은 false). 그 밖은 서버처럼 [] */
|
|
24
29
|
answerCorrectness: boolean[];
|
|
30
|
+
/** partial_pattern · per_question 문항별 결과 (서버 #65 question_results). 그 밖은 서버처럼 [] */
|
|
31
|
+
questionResults: QuestionResult[];
|
|
25
32
|
}
|
|
26
33
|
/** pattern: 정답 정규식(문자열 하나)이 답 문자열(앞뒤 공백을 자름) 전체와 맞는지. 정규식이 틀리거나 없으면 오답 */
|
|
27
34
|
export declare function matchesPattern(answerKey: unknown, answer: string): boolean;
|
|
@@ -39,6 +46,19 @@ export declare function answerError(local: LocalGrading | undefined, answer: unk
|
|
|
39
46
|
* 없는 문항은 0점(answerCorrectness false), 남는 답은 무시. 100점일 때만 정답. 답 모양은 answerError가 먼저 본다
|
|
40
47
|
*/
|
|
41
48
|
export declare function gradePartial(answerKey: string[], scores: number[], answer: unknown): GradeResult;
|
|
49
|
+
/**
|
|
50
|
+
* per_question AI 채점(rubric) 문항의 흉내 점수 0~100. AI를 부르지 않고 같은 답이면 늘 같은 점수:
|
|
51
|
+
* 빈 답 0(서버도 빈 답은 AI 없이 0점), 아니면 min(100, floor(20 + 글자 수 / 5)). 템플릿 mock(cdk-mock.js mockRubricScore)과 같은 식
|
|
52
|
+
*/
|
|
53
|
+
export declare function mockRubricScore(answer: unknown): number;
|
|
54
|
+
/** per_question에서 AI(흉내)에 보낼 답이 있는 rubric 문항이 있는지 (서버는 이때만 AI를 부른다) */
|
|
55
|
+
export declare function hasRubricAnswers(questions: GradingQuestion[], answer: unknown): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* per_question (서버 build_per_question_outcome): 문항마다 채점기 점수 0~100 (pattern은 `answer[i]`가 정규식에 맞으면 100,
|
|
58
|
+
* rubric은 AI 점수 — dev는 mockRubricScore)를 floor(채점기 점수 × score / 100)으로. 합은 100에서 자르고 100점일 때만 정답
|
|
59
|
+
* (완료는 completionScore의 pass_score). 문항별 is_correct는 채점기 점수가 100일 때만. 없는 답 · 남는 답은 partial_pattern과 같다
|
|
60
|
+
*/
|
|
61
|
+
export declare function gradePerQuestion(questions: GradingQuestion[], answer: unknown): GradeResult;
|
|
42
62
|
/**
|
|
43
63
|
* 제출 하나를 서버처럼 채점한다 (`_grade`). 답 모양은 answerError가 먼저 본다.
|
|
44
64
|
* - `on_access`: 채점하지 않음 `{ null, null }` (열면 완료)
|
|
@@ -46,11 +66,13 @@ export declare function gradePartial(answerKey: string[], scores: number[], answ
|
|
|
46
66
|
* - `on_graded` + pattern: 0 / 100. partial_pattern: 맞은 문항 점수의 합(최대 100), 100점만 정답
|
|
47
67
|
* - `on_graded` + rubric: dev는 채점하지 않음 `{ null, null }`. 서버는 AI 모델이 매긴 점수(100점만 정답, 1점 이상 완료)를
|
|
48
68
|
* 주는데 dev는 부를 수 없고, 지어낸 점수는 진짜처럼 읽힌다 (SDK 미리보기 채점과 같음)
|
|
69
|
+
* - `on_graded` + per_question: pattern 문항 + rubric 흉내 점수(mockRubricScore)의 합. rubric 단독과 달리 흉내 점수를 준다:
|
|
70
|
+
* 정규식 · AI 채점을 섞은 퀴즈의 흐름(점수 상자 · 문항별 표시)을 dev에서 보려고. 흉내 값이라고 로그에 남긴다
|
|
49
71
|
* - `on_graded` + 채점 설정 없음: `{ false, 0 }` (서버도 0점이라 완료되지 않음)
|
|
50
72
|
*/
|
|
51
73
|
export declare function grade(local: LocalGrading | undefined, answer: unknown, policy: CompletionPolicy): GradeResult;
|
|
52
74
|
/**
|
|
53
75
|
* 제출 뒤 결과의 완료 기준 점수 (서버 get_completion_score). on_access는 null(제출과 상관없이 완료).
|
|
54
|
-
* rubric은 1점, 그 밖은 100점
|
|
76
|
+
* rubric은 1점, per_question은 pass_score(없으면 100), 그 밖은 100점
|
|
55
77
|
*/
|
|
56
78
|
export declare function completionScore(local: LocalGrading | undefined, policy: CompletionPolicy): number | null;
|
package/es/dev/grading.js
CHANGED
|
@@ -30,15 +30,15 @@ function answerError(local, answer, policy) {
|
|
|
30
30
|
reason: 'not_a_string',
|
|
31
31
|
message: 'pattern: answer must be a string'
|
|
32
32
|
};
|
|
33
|
-
if (type === 'partial_pattern') {
|
|
33
|
+
if (type === 'partial_pattern' || type === 'per_question') {
|
|
34
34
|
if (!Array.isArray(answer)) return {
|
|
35
35
|
reason: 'not_a_string_array',
|
|
36
|
-
message:
|
|
36
|
+
message: `${type}: answer must be an array of strings`
|
|
37
37
|
};
|
|
38
38
|
const bad = answer.findIndex(item => typeof item !== 'string');
|
|
39
39
|
if (bad >= 0) return {
|
|
40
40
|
reason: 'not_a_string_array',
|
|
41
|
-
message:
|
|
41
|
+
message: `${type}: answer[${bad}] must be a string`
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
return null;
|
|
@@ -55,10 +55,54 @@ function gradePartial(answerKey, scores, answer) {
|
|
|
55
55
|
});
|
|
56
56
|
const total = answerCorrectness.reduce((sum, ok, i) => sum + (ok ? scores[i] ?? 0 : 0), 0);
|
|
57
57
|
const score = Math.min(SCORE_MAX, total);
|
|
58
|
+
// 서버는 partial_pattern도 per_question으로 바꿔 채점해 question_results를 준다 (맞으면 배점, 아니면 0)
|
|
59
|
+
const questionResults = answerCorrectness.map((ok, i) => ({
|
|
60
|
+
score: ok ? scores[i] ?? 0 : 0,
|
|
61
|
+
isCorrect: ok
|
|
62
|
+
}));
|
|
58
63
|
return {
|
|
59
64
|
isCorrect: score === SCORE_MAX,
|
|
60
65
|
score,
|
|
61
|
-
answerCorrectness
|
|
66
|
+
answerCorrectness,
|
|
67
|
+
questionResults
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* per_question AI 채점(rubric) 문항의 흉내 점수 0~100. AI를 부르지 않고 같은 답이면 늘 같은 점수:
|
|
72
|
+
* 빈 답 0(서버도 빈 답은 AI 없이 0점), 아니면 min(100, floor(20 + 글자 수 / 5)). 템플릿 mock(cdk-mock.js mockRubricScore)과 같은 식
|
|
73
|
+
*/
|
|
74
|
+
function mockRubricScore(answer) {
|
|
75
|
+
const text = typeof answer === 'string' ? answer.trim() : '';
|
|
76
|
+
if (!text) return 0;
|
|
77
|
+
return Math.min(SCORE_MAX, Math.floor(20 + text.length / 5));
|
|
78
|
+
}
|
|
79
|
+
/** per_question에서 AI(흉내)에 보낼 답이 있는 rubric 문항이 있는지 (서버는 이때만 AI를 부른다) */
|
|
80
|
+
function hasRubricAnswers(questions, answer) {
|
|
81
|
+
const pieces = Array.isArray(answer) ? answer : [];
|
|
82
|
+
return questions.some((q, i) => q.grader.type === 'rubric' && typeof pieces[i] === 'string' && pieces[i].trim() !== '');
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* per_question (서버 build_per_question_outcome): 문항마다 채점기 점수 0~100 (pattern은 `answer[i]`가 정규식에 맞으면 100,
|
|
86
|
+
* rubric은 AI 점수 — dev는 mockRubricScore)를 floor(채점기 점수 × score / 100)으로. 합은 100에서 자르고 100점일 때만 정답
|
|
87
|
+
* (완료는 completionScore의 pass_score). 문항별 is_correct는 채점기 점수가 100일 때만. 없는 답 · 남는 답은 partial_pattern과 같다
|
|
88
|
+
*/
|
|
89
|
+
function gradePerQuestion(questions, answer) {
|
|
90
|
+
const pieces = Array.isArray(answer) ? answer : [];
|
|
91
|
+
const graderScores = questions.map((q, i) => {
|
|
92
|
+
const piece = pieces[i];
|
|
93
|
+
if (q.grader.type === 'rubric') return mockRubricScore(piece);
|
|
94
|
+
return typeof piece === 'string' && fullMatch(q.grader.answer_key, piece) ? SCORE_MAX : 0;
|
|
95
|
+
});
|
|
96
|
+
const questionResults = questions.map((q, i) => ({
|
|
97
|
+
score: Math.floor((graderScores[i] ?? 0) * q.score / SCORE_MAX),
|
|
98
|
+
isCorrect: graderScores[i] === SCORE_MAX
|
|
99
|
+
}));
|
|
100
|
+
const score = Math.min(SCORE_MAX, questionResults.reduce((sum, r) => sum + r.score, 0));
|
|
101
|
+
return {
|
|
102
|
+
isCorrect: score === SCORE_MAX,
|
|
103
|
+
score,
|
|
104
|
+
answerCorrectness: questionResults.map(r => r.isCorrect),
|
|
105
|
+
questionResults
|
|
62
106
|
};
|
|
63
107
|
}
|
|
64
108
|
/**
|
|
@@ -68,18 +112,22 @@ function gradePartial(answerKey, scores, answer) {
|
|
|
68
112
|
* - `on_graded` + pattern: 0 / 100. partial_pattern: 맞은 문항 점수의 합(최대 100), 100점만 정답
|
|
69
113
|
* - `on_graded` + rubric: dev는 채점하지 않음 `{ null, null }`. 서버는 AI 모델이 매긴 점수(100점만 정답, 1점 이상 완료)를
|
|
70
114
|
* 주는데 dev는 부를 수 없고, 지어낸 점수는 진짜처럼 읽힌다 (SDK 미리보기 채점과 같음)
|
|
115
|
+
* - `on_graded` + per_question: pattern 문항 + rubric 흉내 점수(mockRubricScore)의 합. rubric 단독과 달리 흉내 점수를 준다:
|
|
116
|
+
* 정규식 · AI 채점을 섞은 퀴즈의 흐름(점수 상자 · 문항별 표시)을 dev에서 보려고. 흉내 값이라고 로그에 남긴다
|
|
71
117
|
* - `on_graded` + 채점 설정 없음: `{ false, 0 }` (서버도 0점이라 완료되지 않음)
|
|
72
118
|
*/
|
|
73
119
|
function grade(local, answer, policy) {
|
|
74
120
|
if (policy === 'on_access') return {
|
|
75
121
|
isCorrect: null,
|
|
76
122
|
score: null,
|
|
77
|
-
answerCorrectness: []
|
|
123
|
+
answerCorrectness: [],
|
|
124
|
+
questionResults: []
|
|
78
125
|
};
|
|
79
126
|
if (policy === 'on_submit') return {
|
|
80
127
|
isCorrect: null,
|
|
81
128
|
score: SCORE_MAX,
|
|
82
|
-
answerCorrectness: []
|
|
129
|
+
answerCorrectness: [],
|
|
130
|
+
questionResults: []
|
|
83
131
|
};
|
|
84
132
|
const grading = local?.grading;
|
|
85
133
|
switch (grading?.type) {
|
|
@@ -89,7 +137,8 @@ function grade(local, answer, policy) {
|
|
|
89
137
|
return {
|
|
90
138
|
isCorrect: ok,
|
|
91
139
|
score: ok ? SCORE_MAX : 0,
|
|
92
|
-
answerCorrectness: []
|
|
140
|
+
answerCorrectness: [],
|
|
141
|
+
questionResults: []
|
|
93
142
|
};
|
|
94
143
|
}
|
|
95
144
|
case 'partial_pattern':
|
|
@@ -98,24 +147,30 @@ function grade(local, answer, policy) {
|
|
|
98
147
|
return {
|
|
99
148
|
isCorrect: null,
|
|
100
149
|
score: null,
|
|
101
|
-
answerCorrectness: []
|
|
150
|
+
answerCorrectness: [],
|
|
151
|
+
questionResults: []
|
|
102
152
|
};
|
|
153
|
+
case 'per_question':
|
|
154
|
+
return gradePerQuestion(grading.questions, answer);
|
|
103
155
|
default:
|
|
104
156
|
return {
|
|
105
157
|
isCorrect: false,
|
|
106
158
|
score: 0,
|
|
107
|
-
answerCorrectness: []
|
|
159
|
+
answerCorrectness: [],
|
|
160
|
+
questionResults: []
|
|
108
161
|
};
|
|
109
162
|
}
|
|
110
163
|
}
|
|
111
164
|
/**
|
|
112
165
|
* 제출 뒤 결과의 완료 기준 점수 (서버 get_completion_score). on_access는 null(제출과 상관없이 완료).
|
|
113
|
-
* rubric은 1점, 그 밖은 100점
|
|
166
|
+
* rubric은 1점, per_question은 pass_score(없으면 100), 그 밖은 100점
|
|
114
167
|
*/
|
|
115
168
|
function completionScore(local, policy) {
|
|
116
169
|
if (policy === 'on_access') return null;
|
|
117
170
|
if (policy === 'on_graded' && local?.grading?.type === 'rubric') return RUBRIC_COMPLETION_SCORE;
|
|
171
|
+
// per_question: pass_score 이상이면 완료 (없으면 100)
|
|
172
|
+
if (policy === 'on_graded' && local?.grading?.type === 'per_question') return local.grading.pass_score ?? SCORE_MAX;
|
|
118
173
|
return SCORE_MAX;
|
|
119
174
|
}
|
|
120
175
|
|
|
121
|
-
export { COMPLETION_POLICIES, answerError, completionScore, grade, gradePartial, isCompletionPolicy, matchesPattern, recommendedCompletionPolicy };
|
|
176
|
+
export { COMPLETION_POLICIES, answerError, completionScore, grade, gradePartial, gradePerQuestion, hasRubricAnswers, isCompletionPolicy, matchesPattern, mockRubricScore, recommendedCompletionPolicy };
|
package/es/dev/mock-api.d.ts
CHANGED
|
@@ -48,8 +48,13 @@ interface Submission {
|
|
|
48
48
|
answer: unknown;
|
|
49
49
|
is_correct: boolean | null;
|
|
50
50
|
score: number | null;
|
|
51
|
-
/** partial_pattern 문항별 맞음, 그 밖은 [] */
|
|
51
|
+
/** partial_pattern · per_question 문항별 맞음, 그 밖은 [] */
|
|
52
52
|
answer_correctness: boolean[];
|
|
53
|
+
/** partial_pattern · per_question 문항별 결과 { score, is_correct } (서버 #65), 그 밖은 [] */
|
|
54
|
+
question_results: {
|
|
55
|
+
score: number;
|
|
56
|
+
is_correct: boolean;
|
|
57
|
+
}[];
|
|
53
58
|
}
|
|
54
59
|
interface Result {
|
|
55
60
|
score: number | null;
|
package/es/dev/mock-api.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseGrading, serverGradingError } from '../core/config.js';
|
|
2
|
-
import { answerError, grade, completionScore, recommendedCompletionPolicy } from './grading.js';
|
|
2
|
+
import { answerError, hasRubricAnswers, grade, completionScore, recommendedCompletionPolicy } from './grading.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* elice-material API 흉내 (서버 설계 v25, @eliceio/cdk 1.x가 부르는 것만).
|
|
@@ -94,6 +94,13 @@ function send(res, status, data) {
|
|
|
94
94
|
meta: {}
|
|
95
95
|
}));
|
|
96
96
|
}
|
|
97
|
+
/** per_question AI 채점 흉내의 기다림 (서버는 묶음 run 한 번에 몇 초). 채점 중 화면을 dev에서 보려고 */
|
|
98
|
+
const RUBRIC_DELAY_MS = 1200;
|
|
99
|
+
/**
|
|
100
|
+
* 입력 가드가 거절하는 지시문 흉내 (서버: elice-helpy-agent input_guard가 run을 거절하면 reason refused).
|
|
101
|
+
* dev에서 거절 화면을 보려고 노골적인 문구 몇 개만
|
|
102
|
+
*/
|
|
103
|
+
const GUARD_REFUSAL = /이전 지시를 무시|지시를 무시하고|ignore (all |the )?(previous|prior|above) instructions/i;
|
|
97
104
|
function fail(res, status, code, message, details = []) {
|
|
98
105
|
res.writeHead(status, {
|
|
99
106
|
'Content-Type': 'application/json; charset=utf-8'
|
|
@@ -338,7 +345,8 @@ async function handleMockApi(req, res, path, opts) {
|
|
|
338
345
|
};
|
|
339
346
|
state.settings = next;
|
|
340
347
|
await opts.saveSettings?.(next);
|
|
341
|
-
|
|
348
|
+
const savedType = next.grading?.type;
|
|
349
|
+
log(`내용을 .ecdk/settings.json에 저장했습니다${savedType ? ` (채점 설정 ${savedType})` : ''}. 로컬에만 있고, publish 스킬이 동의를 받아 업로드와 함께 보낼 수 있습니다`);
|
|
342
350
|
const {
|
|
343
351
|
metadata
|
|
344
352
|
} = material(state.settings).current_version;
|
|
@@ -406,17 +414,47 @@ async function handleMockApi(req, res, path, opts) {
|
|
|
406
414
|
reason: shapeError.reason
|
|
407
415
|
}
|
|
408
416
|
}]);
|
|
417
|
+
const perQuestion = policy === 'on_graded' && local?.grading?.type === 'per_question';
|
|
418
|
+
if (perQuestion && local?.grading?.type === 'per_question') {
|
|
419
|
+
const {
|
|
420
|
+
questions
|
|
421
|
+
} = local.grading;
|
|
422
|
+
// 서버처럼 답이 있는 AI 채점 문항이 있을 때만 AI(흉내)를 "부른다": 잠깐 기다려 채점 중 화면을 볼 수 있게 하고,
|
|
423
|
+
// 답에 입력 가드가 거절하는 지시문이 있으면 502 MATERIAL_GRADING_FAILED (reason refused, 저장하지 않음)
|
|
424
|
+
if (hasRubricAnswers(questions, answer)) {
|
|
425
|
+
await new Promise(r => setTimeout(r, RUBRIC_DELAY_MS));
|
|
426
|
+
const pieces = Array.isArray(answer) ? answer : [];
|
|
427
|
+
if (questions.some((q, i) => q.grader.type === 'rubric' && typeof pieces[i] === 'string' && GUARD_REFUSAL.test(pieces[i]))) {
|
|
428
|
+
log('학생 제출: AI 채점 거절 흉내 (답에 지시문, 502 MATERIAL_GRADING_FAILED refused, 기록 안 함)');
|
|
429
|
+
return fail(res, 502, 'MATERIAL_GRADING_FAILED', 'rubric grading refused (dev)', [{
|
|
430
|
+
type: 'value_error',
|
|
431
|
+
loc: [],
|
|
432
|
+
ctx: {
|
|
433
|
+
reason: 'refused'
|
|
434
|
+
}
|
|
435
|
+
}]);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
409
439
|
const {
|
|
410
440
|
isCorrect,
|
|
411
441
|
score,
|
|
412
|
-
answerCorrectness
|
|
442
|
+
answerCorrectness,
|
|
443
|
+
questionResults
|
|
413
444
|
} = grade(local, answer, policy);
|
|
445
|
+
// 서버처럼 문항별 결과 question_results도 준다 (partial_pattern · per_question, 그 밖은 []).
|
|
446
|
+
// SDK는 submit 결과 · 제출 기록(GET /submissions/me) 모두 questionResults로 넘긴다
|
|
447
|
+
const questionResultsBody = questionResults.map(r => ({
|
|
448
|
+
score: r.score,
|
|
449
|
+
is_correct: r.isCorrect
|
|
450
|
+
}));
|
|
414
451
|
const response = {
|
|
415
452
|
is_correct: isCorrect,
|
|
416
453
|
score,
|
|
417
|
-
answer_correctness: answerCorrectness
|
|
454
|
+
answer_correctness: answerCorrectness,
|
|
455
|
+
question_results: questionResultsBody
|
|
418
456
|
};
|
|
419
|
-
const graded = policy === 'on_graded' && local?.grading?.type === 'rubric' ? '채점 안 함: rubric(AI)은 dev에서 채점하지 않음' : isCorrect === null ? `채점 안 함: ${policy}` : isCorrect ? '정답' : '오답';
|
|
457
|
+
const graded = policy === 'on_graded' && local?.grading?.type === 'rubric' ? '채점 안 함: rubric(AI)은 dev에서 채점하지 않음' : perQuestion ? `per_question 문항별 [${questionResults.map(r => r.score).join(', ')}], AI 채점 문항은 흉내 점수(실제 AI 아님), ${(score ?? 0) >= (completionScore(local, policy) ?? 100) ? '통과' : '미통과'}` : isCorrect === null ? `채점 안 함: ${policy}` : isCorrect ? '정답' : '오답';
|
|
420
458
|
if (claims.viewer !== 'student') {
|
|
421
459
|
log(`${claims.viewer} 제출: 채점만 (${score ?? '-'}점, ${graded}, 기록 안 함)`);
|
|
422
460
|
return send(res, 200, response);
|
|
@@ -429,7 +467,8 @@ async function handleMockApi(req, res, path, opts) {
|
|
|
429
467
|
answer,
|
|
430
468
|
is_correct: isCorrect,
|
|
431
469
|
score,
|
|
432
|
-
answer_correctness: answerCorrectness
|
|
470
|
+
answer_correctness: answerCorrectness,
|
|
471
|
+
question_results: questionResultsBody
|
|
433
472
|
});
|
|
434
473
|
recordSubmission(state, subject, score, completionScore(local, policy));
|
|
435
474
|
log(`학생 제출: ${score ?? '-'}점 (${graded}, 완료 정책 ${policy})`);
|
package/es/rules/answers.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* (`\.` 같은 이스케이프는 풀어서). `^(서울|Seoul)$` → 서울 · Seoul. `^\d+$`처럼 글이 아닌 갈래는 건너뜀
|
|
7
7
|
* - partial_pattern: 문항마다 정답 정규식 배열이라 원소마다 위와 같이
|
|
8
8
|
* - rubric: 평가 기준 글 전체
|
|
9
|
+
* - per_question: 문항마다 grader가 pattern이면 위 정규식처럼, rubric이면 채점 기준 글 전체 (문제 글 question은 학생에게도 보이는 글이라 뺀다)
|
|
9
10
|
* 흔한 글과 겹치는 짧은 글은 뺀다: 한글이 든 글은 2자 미만, 그 밖(영문 · 숫자 등)은 3자 미만, 숫자만 3자 이하(100 · 0.5)
|
|
10
11
|
*/
|
|
11
12
|
export declare function answerNeedles(grading: unknown): string[];
|
package/es/rules/answers.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* (`\.` 같은 이스케이프는 풀어서). `^(서울|Seoul)$` → 서울 · Seoul. `^\d+$`처럼 글이 아닌 갈래는 건너뜀
|
|
7
7
|
* - partial_pattern: 문항마다 정답 정규식 배열이라 원소마다 위와 같이
|
|
8
8
|
* - rubric: 평가 기준 글 전체
|
|
9
|
+
* - per_question: 문항마다 grader가 pattern이면 위 정규식처럼, rubric이면 채점 기준 글 전체 (문제 글 question은 학생에게도 보이는 글이라 뺀다)
|
|
9
10
|
* 흔한 글과 겹치는 짧은 글은 뺀다: 한글이 든 글은 2자 미만, 그 밖(영문 · 숫자 등)은 3자 미만, 숫자만 3자 이하(100 · 0.5)
|
|
10
11
|
*/
|
|
11
12
|
function answerNeedles(grading) {
|
|
@@ -14,6 +15,13 @@ function answerNeedles(grading) {
|
|
|
14
15
|
const out = [];
|
|
15
16
|
const key = g.answer_key ?? g.answerKey;
|
|
16
17
|
const keys = Array.isArray(key) ? key : [key];
|
|
18
|
+
// per_question: 문항마다 grader의 pattern 정규식 · rubric 채점 기준
|
|
19
|
+
const questions = Array.isArray(g.questions) ? g.questions : [];
|
|
20
|
+
for (const q of questions) {
|
|
21
|
+
const grader = q && typeof q === 'object' ? q.grader : undefined;
|
|
22
|
+
if (typeof grader?.answer_key === 'string') keys.push(grader.answer_key);
|
|
23
|
+
if (typeof grader?.rubric === 'string') out.push(grader.rubric.trim());
|
|
24
|
+
}
|
|
17
25
|
for (const k of keys) if (typeof k === 'string') out.push(...regexLiterals(k));
|
|
18
26
|
if (typeof g.rubric === 'string') out.push(g.rubric.trim());
|
|
19
27
|
return [...new Set(out)].filter(s => s.length >= (/[가-힣]/.test(s) ? 2 : 3) && !/^\d{1,3}$/.test(s));
|
package/es/rules.json.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const version="0.20.0";const manifest={file:"metadata.json",kinds:["material","description"],defaultKind:"material",modes:["learn","instructor","edit"],required:["learn"],kindModes:{material:["learn","instructor","edit"],description:["learn"]},graderTypes:["pattern","partial_pattern","rubric"],commentaryFile:"commentary.txt",defaultEntry:"index.html"};const externalAllow={"style-src":[],"font-src":[]};const minVersions={sdk:"1.0.0-alpha.4"};const layouts={content:["single","split","stage","media"],regions:["main","aside","stage","controls","readout","actions"]};const limits={maxZipBytes:20971520,maxUnpackedBytes:209715200,maxFiles:300,maxEntries:3000,warnRatio:0.8,maxImageBytes:1048576,maxScreenBytes:1572864};const allowedExtensions=["html","htm","css","js","mjs","json","map","txt","md","csv","xml","vtt","svg","png","jpg","jpeg","gif","webp","avif","ico","bmp","mp3","wav","ogg","m4a","mp4","webm","woff","woff2","ttf","otf","glb","gltf","bin","wasm","pdf"];const imageExtensions=["png","jpg","jpeg","gif","webp","avif","bmp","svg"];const excluded={secret:{level:"error",files:[".env",".env.*","elice.config.*","grading.json","answers.*","*.pem","*.key"],dirs:[]},dev:{level:"error",files:[],dirs:[".git","node_modules",".ecdk"]},junk:{level:"warn",files:[".DS_Store","Thumbs.db","desktop.ini"],dirs:["__MACOSX"]}};const forbiddenApis=[{id:"api.parent-access",pattern:"\\bwindow\\.(?:top|parent)\\b|\\b(?:top|parent)\\.(?:document|location)\\b",title:"부모 창 직접 접근 (다른 출처라 막힘, SDK 사용)"},{id:"api.cookie",pattern:"\\bdocument\\.cookie\\b",title:"쿠키 사용 (이 브라우저에만 남고 학습 기록이 아님, 남길 입력값은 SDK로 저장)"},{id:"api.storage",pattern:"\\b(?:localStorage|sessionStorage|indexedDB)\\b",title:"브라우저 저장소 사용 (이 브라우저 · 기기에만 남고 학습 기록이 아님, 남길 입력값은 SDK로 저장)"},{id:"api.eval",pattern:"\\beval\\s*\\(|\\bnew\\s+Function\\s*\\(|\\bset(?:Timeout|Interval)\\s*\\(\\s*[\"'`]",title:"eval · new Function · 문자열 setTimeout 사용"},{id:"api.dialog",pattern:"\\b(?:alert|confirm|prompt)\\s*\\(",title:"alert · confirm · prompt 사용 (sandbox에서 막힘, 화면 안 메시지로)"},{id:"api.window-open",pattern:"\\bwindow\\.open\\s*\\(",title:"새 창 열기 (sandbox에서 막힘)"},{id:"api.external-send",pattern:"(?<!\\bmlapi\\??\\.)\\b(?:fetch|sendBeacon|EventSource|WebSocket)\\s*\\(\\s*['\"`](?:https?|wss?):\\/\\/|\\.open\\(\\s*['\"`][A-Za-z]+['\"`]\\s*,\\s*['\"`]https?:\\/\\/",title:"외부 주소로 요청을 보냄 (학생 정보 유출 위험)"},{id:"sec.html-injection",pattern:"\\.(?:inner|outer)HTML\\s*\\+?=(?!=)(?!\\s*(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`$\\n]*`)\\s*(?:[;,)}\\n]|$))|\\.insertAdjacentHTML\\s*\\(|\\bdocument\\.write(?:ln)?\\s*\\(|\\bdangerouslySetInnerHTML\\b",title:"HTML 문자열을 그대로 넣음 (XSS 위험, textContent나 이스케이프 사용)"},{id:"sec.redirect",pattern:"\\blocation(?:\\.href)?\\s*=(?!=)(?!\\s*[\"'`][^\"'`$]*[\"'`])|\\blocation\\.(?:replace|assign)\\s*\\((?!\\s*[\"'`][^\"'`$]*[\"'`]\\s*\\))",title:"주소를 값으로 바꿈 (열린 리디렉션 · javascript: XSS 위험)"},{id:"sec.postmessage-wildcard",pattern:"\\.postMessage\\s*\\([^;]*?,\\s*[\"'`]\\*[\"'`]",title:"postMessage 대상이 * (아무 창이나 받을 수 있음)"},{id:"sandbox.fetch-local",pattern:"(?<!\\bmlapi\\??\\.)\\bfetch\\(\\s*(['\"`])(?![a-z][a-z0-9+.-]*:|//)[^'\"`]*(?<!\\.json)\\1|\\bimport\\(\\s*(?!['\"`])[A-Za-z_$]|\\bnew\\s+(?:Shared)?Worker\\(\\s*['\"`](?![a-z][a-z0-9+.-]*:|//)",title:"zip 안 파일을 fetch · 변수 import() · Worker로 읽음 (콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없으면 CORS로 막힘)"}];const secretPatterns=[{source:"elice-hardcoded-private-key · detected-private-key · detected-pgp-private-key-block",title:"개인키",pattern:"-----BEGIN[ A-Z0-9_-]*PRIVATE KEY(?: BLOCK)?-----"},{source:"elice-hardcoded-secret",title:"하드코딩된 비밀 값",pattern:"(?:secret|token|api[_-]?key|access[_-]?key|password|passwd)\\s*[:=]\\s*[\"'][A-Za-z0-9_\\-/+]{16,}[\"']",flags:"i",not:"os\\.environ|getenv|process\\.env|dotenv|\\$\\{|<[a-z_]+>|example|dummy|placeholder|changeme|xxxx|your[_-]"},{source:"detected-aws-access-key-id-value",title:"AWS 액세스 키",pattern:"\\b(?:A3T[A-Z0-9]|AKIA|AGPA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}\\b",not:"example|sample|test|fake"},{source:"detected-aws-secret-access-key",title:"AWS 비밀 키",pattern:"[\"'`]?aws_?\\w*secret_?\\w*[\"'`]?\\s{0,50}(?::|=>|=)\\s{0,50}[\"'`]?[A-Za-z0-9/+=]{40}",flags:"i",not:"example|sample|test|fake|xxxxxx"},{source:"detected-aws-session-token",title:"AWS 세션 토큰",pattern:"AWS_SESSION_TOKEN\\s*(?::|=>|=)\\s*[A-Za-z0-9/+=]{16,}",flags:"i",not:"example|sample|test|fake"},{source:"detected-aws-appsync-graphql-key",title:"AWS AppSync 키",pattern:"da2-[a-z0-9]{26}"},{source:"detected-amazon-mws-auth-token",title:"Amazon MWS 토큰",pattern:"amzn\\.mws\\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"},{source:"detected-artifactory-token",title:"Artifactory 토큰",pattern:"\\bAKC[a-zA-Z0-9]{10,}\\n",not:"sha(?:128|256|512)"},{source:"detected-artifactory-password",title:"Artifactory 비밀번호",pattern:"[Aa][Rr][Tt][Ii][-_]?[Ff][Aa][Cc][Tt][Oo][Rr][Yy].*\\bAP[\\dA-F][a-zA-Z0-9]{8,}|\\bAP[\\dA-F][a-zA-Z0-9]{8,}.*[Aa][Rr][Tt][Ii][-_]?[Ff][Aa][Cc][Tt][Oo][Rr][Yy]",not:"sha(?:1|2|3|118|256|512)"},{source:"detected-bcrypt-hash",title:"bcrypt 해시",pattern:"\\$2[aby]?\\$\\d+\\$[./A-Za-z0-9]{53}"},{source:"detected-codeclimate",title:"Code Climate 토큰",pattern:"codeclima.{0,50}[\"'`]?[0-9a-f]{64}",flags:"i"},{source:"detected-etc-shadow",title:"/etc/shadow 내용",pattern:"^\\s*root:[x!*]*:\\d*:\\d*",flags:"m"},{source:"detected-facebook-access-token",title:"Facebook 액세스 토큰",pattern:"EAACEdEose0cBA[0-9A-Za-z]+|EAAAACZAVC6ygB[0-9A-Za-z]+|EAAAAZAw4[0-9A-Za-z]+"},{source:"detected-facebook-oauth",title:"Facebook OAuth 비밀",pattern:"[fF][aA][cC][eE][bB][oO][oO][kK].*[tT][oO][kK][eE][nN].*[\"'`]?[0-9a-f]{32}"},{source:"detected-google-gcm-service-account",title:"Google 서비스 계정 키",pattern:"[\"'`]?type[\"'`]?\\s{0,50}(?::|=>|=)\\s{0,50}[\"'`]?service_account"},{source:"detected-google-oauth-access-token",title:"Google OAuth 토큰",pattern:"ya29\\.[0-9A-Za-z_-]+"},{source:"detected-heroku-api-key",title:"Heroku API 키",pattern:"[hH][eE][rR][oO][kK][uU].*[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}"},{source:"detected-hockeyapp",title:"HockeyApp 토큰",pattern:"hockey.{0,50}[\"'`]?[0-9a-f]{32}",flags:"i"},{source:"detected-mailchimp-api-key",title:"Mailchimp API 키",pattern:"[0-9a-f]{32}-us\\d{1,2}"},{source:"detected-mailgun-api-key",title:"Mailgun API 키",pattern:"key-[0-9a-zA-Z]{32}"},{source:"detected-onfido-live-api-token",title:"Onfido API 토큰",pattern:"api_live(?:_[a-zA-Z]{2})?\\.[a-zA-Z0-9_-]{11}\\.[a-zA-Z0-9_-]{32}"},{source:"detected-outlook-team",title:"Outlook 웹훅",pattern:"https://outlook\\.office\\.com/webhook/[0-9a-f-]{36}"},{source:"detected-paypal-braintree-access-token",title:"PayPal Braintree 토큰",pattern:"access_token\\$production\\$[0-9a-z]{16}\\$[0-9a-z]{32}"},{source:"detected-picatic-api-key",title:"Picatic API 키",pattern:"sk_live_[0-9a-z]{32}"},{source:"detected-sauce-token",title:"Sauce Labs 토큰",pattern:"sauce.{0,50}[\"'`]?[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}",flags:"i"},{source:"detected-slack-token",title:"Slack 토큰",pattern:"xox[pboa]-\\d{12}-\\d{12}-\\d{12}-[a-z0-9]{32}|xox.-\\d{12}-\\d{12}-[0-9a-zA-Z]{24}"},{source:"detected-slack-webhook",title:"Slack 웹훅",pattern:"https://hooks\\.slack\\.com/services/T[a-zA-Z0-9_]{8,10}/B[a-zA-Z0-9_]{8,10}/[a-zA-Z0-9_]{24}",not:"T00000000/B00000000/X{24}"},{source:"detected-sonarqube-docs-api-key",title:"SonarQube 토큰",pattern:"sonar[a-z0-9_.-]{0,30}(?:token|key|login|password|pass|secret|auth)?\\s*[:=]\\s*\\\\?[\"'`]?[0-9a-f]{40}\\b",flags:"i"},{source:"detected-square-access-token",title:"Square 액세스 토큰",pattern:"sq0atp-[0-9A-Za-z_-]{22}"},{source:"detected-square-oauth-secret",title:"Square OAuth 비밀",pattern:"sq0csp-[0-9A-Za-z\\\\_-]{43}"},{source:"detected-ssh-password",title:"sshpass 비밀번호",pattern:"sshpass[ ]-p\\s*['\"]"},{source:"detected-stripe-api-key",title:"Stripe API 키",pattern:"sk_live_[0-9a-zA-Z]{24}"},{source:"detected-stripe-restricted-api-key",title:"Stripe 제한 키",pattern:"rk_live_[0-9a-zA-Z]{24}"},{source:"detected-telegram-bot-api-key",title:"Telegram 봇 토큰",pattern:"\\d+:AA[0-9A-Za-z_-]{33}",not:"go\\.mod|v\\d+\\.\\d+\\.\\d+"},{source:"detected-twilio-api-key",title:"Twilio API 키",pattern:"SK[0-9a-fA-F]{32}"},{source:"detected-username-and-password-in-uri",title:"주소에 들어 있는 아이디 · 비밀번호",pattern:"[A-Za-z0-9+.-]*(?:http|sql|ftp|smtp)[A-Za-z0-9+.-]*://\\{?[A-Za-z][A-Za-z0-9_-]{5,31}\\}?:(?=[^\\s@/]*\\d)(?=[^\\s@/]*[a-z])(?=[^\\s@/]*[A-Z])(?=[^\\s@/]*[!-.:-?\\[-`{-~])[^\\s@/]{6,32}@"}];const rules=[{id:"manifest.missing",level:"error",scope:"server",title:"metadata.json 없음"},{id:"manifest.invalid",level:"error",scope:"server",title:"metadata.json 형식 오류"},{id:"manifest.entry-missing",level:"error",scope:"server",title:"metadata.json에 적은 파일(진입 파일 · 학습 참고 내용)이 없음"},{id:"manifest.commentary-missing",level:"error",scope:"server",title:"학습 참고 내용 파일(commentary.txt) 없음 (LXP 업로드가 거절함)"},{id:"manifest.grading-types",level:"warn",scope:"server",title:"쓰지 않는 gradingTypes (완료 정책은 LXP 설정, 채점 방식은 편집 화면)"},{id:"manifest.completion-policies-ignored",level:"warn",scope:"client",title:"쓰지 않는 completionPolicies · 완료 정책 화면(screens.completionPolicy) (완료 정책은 LXP 설정, build가 zip에서 뺌)"},{id:"entry.missing",level:"error",scope:"server",title:"학생 화면 진입 파일 없음"},{id:"entry.nested",level:"error",scope:"server",title:"폴더째 묶은 zip (metadata.json이 최상위에 없음)"},{id:"input.not-zip",level:"error",scope:"server",title:"zip이 아닌 업로드 (HTML 파일 하나 등)"},{id:"limit.zip-size",level:"error",scope:"server",title:"zip 크기 한도 초과"},{id:"limit.file-count",level:"error",scope:"server",title:"파일 개수 한도 초과"},{id:"limit.unpacked-size",level:"error",scope:"server",title:"풀면 너무 큰 zip (압축 폭탄 의심)"},{id:"limit.near",level:"warn",scope:"client",title:"한도에 가까움"},{id:"limit.screen-size",level:"warn",scope:"client",title:"화면 하나를 열 때 받는 JS · CSS가 큼 (기준 limits.maxScreenBytes, 큰 라이브러리는 import()로)"},{id:"path.unsafe",level:"error",scope:"server",title:"안전하지 않은 경로 (절대경로, .., 역슬래시, 정규화 안 됨)"},{id:"path.case-collision",level:"error",scope:"server",title:"대소문자만 다른 경로"},{id:"path.non-ascii",level:"warn",scope:"client",title:"공백·한글 등 ASCII 밖 문자가 든 경로"},{id:"file.extension",level:"error",scope:"server",title:"허용하지 않는 확장자"},{id:"file.secret",level:"error",scope:"server",title:"정답·비밀 파일 포함"},{id:"file.dev",level:"error",scope:"server",title:"개발용 폴더 포함"},{id:"file.junk",level:"warn",scope:"server",title:"운영체제가 만든 불필요한 파일"},{id:"file.large-image",level:"warn",scope:"client",title:"1MB 넘는 이미지"},{id:"file.encoding",level:"error",scope:"client",title:"UTF-8이 아닌 텍스트 파일 (한글이 깨짐)"},{id:"file.bom",level:"warn",scope:"client",title:"학습 참고 내용 맨 앞의 BOM (보이지 않는 글자)"},{id:"content.answer-key",level:"warn",scope:"client",title:"학생에게 내려가는 JSON에 정답처럼 보이는 키"},{id:"grading.no-submit",level:"warn",scope:"client",title:"편집 화면이 채점 설정을 저장하는데 화면 코드에 제출이 없음"},{id:"grading.client-score",level:"warn",scope:"client",title:"제출하는 답에 화면에서 계산한 점수(score · scores · points key)를 넣음 (서버는 답 안 점수를 쓰지 않음, settings.grading rubric · pattern으로 채점)"},{id:"grading.ai-without-grading",level:"warn",scope:"client",title:"화면이 AI(mlapi.fetch)를 부르고 제출하는데 편집 화면이 채점 설정(settings.grading)을 저장하지 않음 (on_graded면 0점 · 미완료, on_submit이면 늘 100점. AI 평가는 rubric으로)"},{id:"edit.no-save",level:"warn",scope:"client",title:"편집 화면인데 저장이 없음"},{id:"project.legacy-file",level:"warn",scope:"client",title:"더 쓰지 않는 프로젝트 파일(elice.config.json · content.json · grading.json)이 남아 있음 (프로젝트 검사만, ADR 0011)"},{id:"build.template-unknown",level:"warn",scope:"client",title:"metadata.json build.template이 이 ecdk가 모르는 템플릿이거나 더 새 템플릿 버전"},{id:"layout.unknown",level:"warn",scope:"client",title:"data-ec-layout · data-ec-region에 키트가 모르는 값 (single · split · stage · media, main · aside · stage · controls · readout · actions)"},{id:"layout.own-step-nav",level:"warn",scope:"client",title:"화면 코드가 이전 · 다음 버튼을 직접 그림 (LXP 이전 · 다음 막대와 헷갈림, 키트 app.useStepper)"},{id:"ref.missing",level:"error",scope:"client",title:"참조한 파일이 없음"},{id:"ref.case-mismatch",level:"error",scope:"client",title:"참조 경로의 대소문자가 실제 파일과 다름"},{id:"ref.root-absolute",level:"error",scope:"client",title:"/로 시작하는 경로 · 자기 폴더가 아닌 <base href> (배포 주소 /s/{서명}/ 아래에서 깨짐)"},{id:"ref.external-script",level:"error",scope:"client",title:"외부 스크립트 (zip 안에 넣고 상대경로로)"},{id:"ref.external-request",level:"error",scope:"client",title:"외부 리소스 요청 (이미지 · 글꼴 · 영상 · CSS, 콘텐츠 CSP가 막음: zip 안에 넣기)"},{id:"ref.external-font",level:"warn",scope:"client",title:"허용 목록(externalAllow)의 외부 글꼴 (망분리 기관에서는 받지 못해 기본 글꼴로 보일 수 있음)"},{id:"ref.insecure",level:"error",scope:"client",title:"http:// 외부 리소스 (https 페이지 · 콘텐츠 CSP가 막음)"},{id:"ref.vendor-external-url",level:"warn",scope:"client",title:"라이브러리 파일 안의 외부 주소 (실행 중 외부를 부르면 콘텐츠 CSP가 막음, ecdk dev 로그 확인)"},{id:"ref.script-not-public",level:"error",scope:"client",title:"type=\"module\" 없는 <script src>가 public/ 밖 파일 (프로젝트 검사만. build가 묶지 않고 zip에도 넣지 않음, type=\"module\"을 붙이거나 public/으로)"},{id:"sandbox.module-src",level:"warn",scope:"client",title:"모듈 스크립트 파일(<script type=\"module\" src>): 콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없는 LXP에서는 CORS로 막혀 화면이 뜨지 않음 (ecdk build가 HTML 안에 묶음)"},{id:"sandbox.fetch-local",level:"warn",scope:"client",title:"zip 안 파일을 fetch · 변수 import() · Worker로 읽음: 콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없는 LXP에서는 CORS로 막힘 (JSON fetch · 문자열 import()는 ecdk build가 처리)"},{id:"html.img-alt",level:"warn",scope:"client",title:"대체 텍스트 없는 이미지"},{id:"html.iframe",level:"error",scope:"client",title:"src로 띄우는 iframe · frame, object · embed (콘텐츠 CSP가 막음, 영상은 Elice 비디오 자료로, srcdoc 미리보기는 통과)"},{id:"html.form",level:"warn",scope:"client",title:"form 제출 (sandbox · CSP form-action이 막음, 버튼 click으로 처리)"},{id:"api.external-send",level:"error",scope:"client",title:"외부 주소로 요청 보냄"},{id:"api.parent-access",level:"warn",scope:"client",title:"부모 창 직접 접근"},{id:"api.cookie",level:"warn",scope:"client",title:"쿠키 사용 (학습 기록이 아님)"},{id:"api.storage",level:"warn",scope:"client",title:"브라우저 저장소 사용 (학습 기록이 아님)"},{id:"api.eval",level:"warn",scope:"client",title:"eval · new Function 사용"},{id:"api.dialog",level:"error",scope:"client",title:"alert · confirm · prompt 사용"},{id:"api.window-open",level:"error",scope:"client",title:"새 창 열기"},{id:"sec.secret",level:"error",scope:"server",title:"비밀 값 (키 · 토큰 · 비밀번호)"},{id:"sec.answer-in-bundle",level:"warn",scope:"client",title:"편집 화면에 저장한 정답(.ecdk/settings.json 채점 설정)과 같은 글이 zip에 들어갈 파일에 있음 (프로젝트 검사만)"},{id:"sec.html-injection",level:"warn",scope:"client",title:"HTML 문자열 삽입"},{id:"sec.redirect",level:"warn",scope:"client",title:"주소를 값으로 바꿈"},{id:"sec.postmessage-wildcard",level:"warn",scope:"client",title:"postMessage 대상 *"},{id:"privacy.personal-field",level:"warn",scope:"client",title:"학습자 개인정보를 받는 입력 칸(전화 · 이메일 · 이름 autocomplete 등)이나 개인정보 · 학습자 이름(account.fullname)을 제출 · 저장 · AI 호출로 보냄 (익명 id account.anonymousId, 이름은 보여 주기만)"},{id:"sdk.outdated",level:"error",scope:"client",title:"SDK가 최소 버전보다 낮음 (metadata.json build.sdk < rules.json minVersions.sdk. alpha.3 이하는 LXP 편집 화면 저장(초안) 실패, npm update @eliceio/cdk)"},{id:"sdk.lib-copy",level:"error",scope:"client",title:"SDK 복사본 lib/cdk.js (zip에 넣지 않음, 프로젝트 검사만. SDK는 package.json 의존성 @eliceio/cdk를 build가 번들로 묶음)"}];var rulesJson = {version:version,manifest:manifest,externalAllow:externalAllow,minVersions:minVersions,layouts:layouts,limits:limits,allowedExtensions:allowedExtensions,imageExtensions:imageExtensions,excluded:excluded,forbiddenApis:forbiddenApis,secretPatterns:secretPatterns,rules:rules};
|
|
1
|
+
const version="0.21.0";const manifest={file:"metadata.json",kinds:["material","description"],defaultKind:"material",modes:["learn","instructor","edit"],required:["learn"],kindModes:{material:["learn","instructor","edit"],description:["learn"]},graderTypes:["pattern","partial_pattern","rubric"],commentaryFile:"commentary.txt",defaultEntry:"index.html"};const externalAllow={"style-src":[],"font-src":[]};const minVersions={sdk:"1.0.0-alpha.4"};const layouts={content:["single","split","stage","media"],regions:["main","aside","stage","controls","readout","actions"]};const limits={maxZipBytes:20971520,maxUnpackedBytes:209715200,maxFiles:300,maxEntries:3000,warnRatio:0.8,maxImageBytes:1048576,maxScreenBytes:1572864};const allowedExtensions=["html","htm","css","js","mjs","json","map","txt","md","csv","xml","vtt","svg","png","jpg","jpeg","gif","webp","avif","ico","bmp","mp3","wav","ogg","m4a","mp4","webm","woff","woff2","ttf","otf","glb","gltf","bin","wasm","pdf"];const imageExtensions=["png","jpg","jpeg","gif","webp","avif","bmp","svg"];const excluded={secret:{level:"error",files:[".env",".env.*","elice.config.*","grading.json","answers.*","*.pem","*.key"],dirs:[]},dev:{level:"error",files:[],dirs:[".git","node_modules",".ecdk"]},junk:{level:"warn",files:[".DS_Store","Thumbs.db","desktop.ini"],dirs:["__MACOSX"]}};const forbiddenApis=[{id:"api.parent-access",pattern:"\\bwindow\\.(?:top|parent)\\b|\\b(?:top|parent)\\.(?:document|location)\\b",title:"부모 창 직접 접근 (다른 출처라 막힘, SDK 사용)"},{id:"api.cookie",pattern:"\\bdocument\\.cookie\\b",title:"쿠키 사용 (이 브라우저에만 남고 학습 기록이 아님, 남길 입력값은 SDK로 저장)"},{id:"api.storage",pattern:"\\b(?:localStorage|sessionStorage|indexedDB)\\b",title:"브라우저 저장소 사용 (이 브라우저 · 기기에만 남고 학습 기록이 아님, 남길 입력값은 SDK로 저장)"},{id:"api.eval",pattern:"\\beval\\s*\\(|\\bnew\\s+Function\\s*\\(|\\bset(?:Timeout|Interval)\\s*\\(\\s*[\"'`]",title:"eval · new Function · 문자열 setTimeout 사용"},{id:"api.dialog",pattern:"\\b(?:alert|confirm|prompt)\\s*\\(",title:"alert · confirm · prompt 사용 (sandbox에서 막힘, 화면 안 메시지로)"},{id:"api.window-open",pattern:"\\bwindow\\.open\\s*\\(",title:"새 창 열기 (sandbox에서 막힘)"},{id:"api.external-send",pattern:"(?<!\\bmlapi\\??\\.)\\b(?:fetch|sendBeacon|EventSource|WebSocket)\\s*\\(\\s*['\"`](?:https?|wss?):\\/\\/|\\.open\\(\\s*['\"`][A-Za-z]+['\"`]\\s*,\\s*['\"`]https?:\\/\\/",title:"외부 주소로 요청을 보냄 (학생 정보 유출 위험)"},{id:"sec.html-injection",pattern:"\\.(?:inner|outer)HTML\\s*\\+?=(?!=)(?!\\s*(?:'[^'\\n]*'|\"[^\"\\n]*\"|`[^`$\\n]*`)\\s*(?:[;,)}\\n]|$))|\\.insertAdjacentHTML\\s*\\(|\\bdocument\\.write(?:ln)?\\s*\\(|\\bdangerouslySetInnerHTML\\b",title:"HTML 문자열을 그대로 넣음 (XSS 위험, textContent나 이스케이프 사용)"},{id:"sec.redirect",pattern:"\\blocation(?:\\.href)?\\s*=(?!=)(?!\\s*[\"'`][^\"'`$]*[\"'`])|\\blocation\\.(?:replace|assign)\\s*\\((?!\\s*[\"'`][^\"'`$]*[\"'`]\\s*\\))",title:"주소를 값으로 바꿈 (열린 리디렉션 · javascript: XSS 위험)"},{id:"sec.postmessage-wildcard",pattern:"\\.postMessage\\s*\\([^;]*?,\\s*[\"'`]\\*[\"'`]",title:"postMessage 대상이 * (아무 창이나 받을 수 있음)"},{id:"sandbox.fetch-local",pattern:"(?<!\\bmlapi\\??\\.)\\bfetch\\(\\s*(['\"`])(?![a-z][a-z0-9+.-]*:|//)[^'\"`]*(?<!\\.json)\\1|\\bimport\\(\\s*(?!['\"`])[A-Za-z_$]|\\bnew\\s+(?:Shared)?Worker\\(\\s*['\"`](?![a-z][a-z0-9+.-]*:|//)",title:"zip 안 파일을 fetch · 변수 import() · Worker로 읽음 (콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없으면 CORS로 막힘)"}];const secretPatterns=[{source:"elice-hardcoded-private-key · detected-private-key · detected-pgp-private-key-block",title:"개인키",pattern:"-----BEGIN[ A-Z0-9_-]*PRIVATE KEY(?: BLOCK)?-----"},{source:"elice-hardcoded-secret",title:"하드코딩된 비밀 값",pattern:"(?:secret|token|api[_-]?key|access[_-]?key|password|passwd)\\s*[:=]\\s*[\"'][A-Za-z0-9_\\-/+]{16,}[\"']",flags:"i",not:"os\\.environ|getenv|process\\.env|dotenv|\\$\\{|<[a-z_]+>|example|dummy|placeholder|changeme|xxxx|your[_-]"},{source:"detected-aws-access-key-id-value",title:"AWS 액세스 키",pattern:"\\b(?:A3T[A-Z0-9]|AKIA|AGPA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}\\b",not:"example|sample|test|fake"},{source:"detected-aws-secret-access-key",title:"AWS 비밀 키",pattern:"[\"'`]?aws_?\\w*secret_?\\w*[\"'`]?\\s{0,50}(?::|=>|=)\\s{0,50}[\"'`]?[A-Za-z0-9/+=]{40}",flags:"i",not:"example|sample|test|fake|xxxxxx"},{source:"detected-aws-session-token",title:"AWS 세션 토큰",pattern:"AWS_SESSION_TOKEN\\s*(?::|=>|=)\\s*[A-Za-z0-9/+=]{16,}",flags:"i",not:"example|sample|test|fake"},{source:"detected-aws-appsync-graphql-key",title:"AWS AppSync 키",pattern:"da2-[a-z0-9]{26}"},{source:"detected-amazon-mws-auth-token",title:"Amazon MWS 토큰",pattern:"amzn\\.mws\\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"},{source:"detected-artifactory-token",title:"Artifactory 토큰",pattern:"\\bAKC[a-zA-Z0-9]{10,}\\n",not:"sha(?:128|256|512)"},{source:"detected-artifactory-password",title:"Artifactory 비밀번호",pattern:"[Aa][Rr][Tt][Ii][-_]?[Ff][Aa][Cc][Tt][Oo][Rr][Yy].*\\bAP[\\dA-F][a-zA-Z0-9]{8,}|\\bAP[\\dA-F][a-zA-Z0-9]{8,}.*[Aa][Rr][Tt][Ii][-_]?[Ff][Aa][Cc][Tt][Oo][Rr][Yy]",not:"sha(?:1|2|3|118|256|512)"},{source:"detected-bcrypt-hash",title:"bcrypt 해시",pattern:"\\$2[aby]?\\$\\d+\\$[./A-Za-z0-9]{53}"},{source:"detected-codeclimate",title:"Code Climate 토큰",pattern:"codeclima.{0,50}[\"'`]?[0-9a-f]{64}",flags:"i"},{source:"detected-etc-shadow",title:"/etc/shadow 내용",pattern:"^\\s*root:[x!*]*:\\d*:\\d*",flags:"m"},{source:"detected-facebook-access-token",title:"Facebook 액세스 토큰",pattern:"EAACEdEose0cBA[0-9A-Za-z]+|EAAAACZAVC6ygB[0-9A-Za-z]+|EAAAAZAw4[0-9A-Za-z]+"},{source:"detected-facebook-oauth",title:"Facebook OAuth 비밀",pattern:"[fF][aA][cC][eE][bB][oO][oO][kK].*[tT][oO][kK][eE][nN].*[\"'`]?[0-9a-f]{32}"},{source:"detected-google-gcm-service-account",title:"Google 서비스 계정 키",pattern:"[\"'`]?type[\"'`]?\\s{0,50}(?::|=>|=)\\s{0,50}[\"'`]?service_account"},{source:"detected-google-oauth-access-token",title:"Google OAuth 토큰",pattern:"ya29\\.[0-9A-Za-z_-]+"},{source:"detected-heroku-api-key",title:"Heroku API 키",pattern:"[hH][eE][rR][oO][kK][uU].*[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}"},{source:"detected-hockeyapp",title:"HockeyApp 토큰",pattern:"hockey.{0,50}[\"'`]?[0-9a-f]{32}",flags:"i"},{source:"detected-mailchimp-api-key",title:"Mailchimp API 키",pattern:"[0-9a-f]{32}-us\\d{1,2}"},{source:"detected-mailgun-api-key",title:"Mailgun API 키",pattern:"key-[0-9a-zA-Z]{32}"},{source:"detected-onfido-live-api-token",title:"Onfido API 토큰",pattern:"api_live(?:_[a-zA-Z]{2})?\\.[a-zA-Z0-9_-]{11}\\.[a-zA-Z0-9_-]{32}"},{source:"detected-outlook-team",title:"Outlook 웹훅",pattern:"https://outlook\\.office\\.com/webhook/[0-9a-f-]{36}"},{source:"detected-paypal-braintree-access-token",title:"PayPal Braintree 토큰",pattern:"access_token\\$production\\$[0-9a-z]{16}\\$[0-9a-z]{32}"},{source:"detected-picatic-api-key",title:"Picatic API 키",pattern:"sk_live_[0-9a-z]{32}"},{source:"detected-sauce-token",title:"Sauce Labs 토큰",pattern:"sauce.{0,50}[\"'`]?[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[0-9a-f]{4}-[0-9a-f]{12}",flags:"i"},{source:"detected-slack-token",title:"Slack 토큰",pattern:"xox[pboa]-\\d{12}-\\d{12}-\\d{12}-[a-z0-9]{32}|xox.-\\d{12}-\\d{12}-[0-9a-zA-Z]{24}"},{source:"detected-slack-webhook",title:"Slack 웹훅",pattern:"https://hooks\\.slack\\.com/services/T[a-zA-Z0-9_]{8,10}/B[a-zA-Z0-9_]{8,10}/[a-zA-Z0-9_]{24}",not:"T00000000/B00000000/X{24}"},{source:"detected-sonarqube-docs-api-key",title:"SonarQube 토큰",pattern:"sonar[a-z0-9_.-]{0,30}(?:token|key|login|password|pass|secret|auth)?\\s*[:=]\\s*\\\\?[\"'`]?[0-9a-f]{40}\\b",flags:"i"},{source:"detected-square-access-token",title:"Square 액세스 토큰",pattern:"sq0atp-[0-9A-Za-z_-]{22}"},{source:"detected-square-oauth-secret",title:"Square OAuth 비밀",pattern:"sq0csp-[0-9A-Za-z\\\\_-]{43}"},{source:"detected-ssh-password",title:"sshpass 비밀번호",pattern:"sshpass[ ]-p\\s*['\"]"},{source:"detected-stripe-api-key",title:"Stripe API 키",pattern:"sk_live_[0-9a-zA-Z]{24}"},{source:"detected-stripe-restricted-api-key",title:"Stripe 제한 키",pattern:"rk_live_[0-9a-zA-Z]{24}"},{source:"detected-telegram-bot-api-key",title:"Telegram 봇 토큰",pattern:"\\d+:AA[0-9A-Za-z_-]{33}",not:"go\\.mod|v\\d+\\.\\d+\\.\\d+"},{source:"detected-twilio-api-key",title:"Twilio API 키",pattern:"SK[0-9a-fA-F]{32}"},{source:"detected-username-and-password-in-uri",title:"주소에 들어 있는 아이디 · 비밀번호",pattern:"[A-Za-z0-9+.-]*(?:http|sql|ftp|smtp)[A-Za-z0-9+.-]*://\\{?[A-Za-z][A-Za-z0-9_-]{5,31}\\}?:(?=[^\\s@/]*\\d)(?=[^\\s@/]*[a-z])(?=[^\\s@/]*[A-Z])(?=[^\\s@/]*[!-.:-?\\[-`{-~])[^\\s@/]{6,32}@"}];const rules=[{id:"manifest.missing",level:"error",scope:"server",title:"metadata.json 없음"},{id:"manifest.invalid",level:"error",scope:"server",title:"metadata.json 형식 오류"},{id:"manifest.entry-missing",level:"error",scope:"server",title:"metadata.json에 적은 파일(진입 파일 · 학습 참고 내용)이 없음"},{id:"manifest.commentary-missing",level:"error",scope:"server",title:"학습 참고 내용 파일(commentary.txt) 없음 (LXP 업로드가 거절함)"},{id:"manifest.grading-types",level:"warn",scope:"server",title:"쓰지 않는 gradingTypes (완료 정책은 LXP 설정, 채점 방식은 편집 화면)"},{id:"manifest.completion-policies-ignored",level:"warn",scope:"client",title:"쓰지 않는 completionPolicies · 완료 정책 화면(screens.completionPolicy) (완료 정책은 LXP 설정, build가 zip에서 뺌)"},{id:"entry.missing",level:"error",scope:"server",title:"학생 화면 진입 파일 없음"},{id:"entry.nested",level:"error",scope:"server",title:"폴더째 묶은 zip (metadata.json이 최상위에 없음)"},{id:"input.not-zip",level:"error",scope:"server",title:"zip이 아닌 업로드 (HTML 파일 하나 등)"},{id:"limit.zip-size",level:"error",scope:"server",title:"zip 크기 한도 초과"},{id:"limit.file-count",level:"error",scope:"server",title:"파일 개수 한도 초과"},{id:"limit.unpacked-size",level:"error",scope:"server",title:"풀면 너무 큰 zip (압축 폭탄 의심)"},{id:"limit.near",level:"warn",scope:"client",title:"한도에 가까움"},{id:"limit.screen-size",level:"warn",scope:"client",title:"화면 하나를 열 때 받는 JS · CSS가 큼 (기준 limits.maxScreenBytes, 큰 라이브러리는 import()로)"},{id:"path.unsafe",level:"error",scope:"server",title:"안전하지 않은 경로 (절대경로, .., 역슬래시, 정규화 안 됨)"},{id:"path.case-collision",level:"error",scope:"server",title:"대소문자만 다른 경로"},{id:"path.non-ascii",level:"warn",scope:"client",title:"공백·한글 등 ASCII 밖 문자가 든 경로"},{id:"file.extension",level:"error",scope:"server",title:"허용하지 않는 확장자"},{id:"file.secret",level:"error",scope:"server",title:"정답·비밀 파일 포함"},{id:"file.dev",level:"error",scope:"server",title:"개발용 폴더 포함"},{id:"file.junk",level:"warn",scope:"server",title:"운영체제가 만든 불필요한 파일"},{id:"file.large-image",level:"warn",scope:"client",title:"1MB 넘는 이미지"},{id:"file.encoding",level:"error",scope:"client",title:"UTF-8이 아닌 텍스트 파일 (한글이 깨짐)"},{id:"file.bom",level:"warn",scope:"client",title:"학습 참고 내용 맨 앞의 BOM (보이지 않는 글자)"},{id:"content.answer-key",level:"warn",scope:"client",title:"학생에게 내려가는 JSON에 정답처럼 보이는 키"},{id:"grading.no-submit",level:"warn",scope:"client",title:"편집 화면이 채점 설정을 저장하는데 화면 코드에 제출이 없음"},{id:"grading.client-score",level:"warn",scope:"client",title:"제출하는 답에 화면에서 계산한 점수(score · scores · points key)를 넣음 (서버는 답 안 점수를 쓰지 않음, settings.grading rubric · pattern으로 채점)"},{id:"grading.ai-without-grading",level:"warn",scope:"client",title:"화면이 AI(mlapi.fetch)를 부르고 제출하는데 편집 화면이 채점 설정(settings.grading)을 저장하지 않음 (on_graded면 0점 · 미완료, on_submit이면 늘 100점. AI 평가는 rubric으로)"},{id:"edit.no-save",level:"warn",scope:"client",title:"편집 화면인데 저장이 없음"},{id:"project.legacy-file",level:"warn",scope:"client",title:"더 쓰지 않는 프로젝트 파일(elice.config.json · content.json · grading.json)이 남아 있음 (프로젝트 검사만, ADR 0011)"},{id:"build.template-unknown",level:"warn",scope:"client",title:"metadata.json build.template이 이 ecdk가 모르는 템플릿이거나 더 새 템플릿 버전"},{id:"layout.unknown",level:"warn",scope:"client",title:"data-ec-layout · data-ec-region에 키트가 모르는 값 (single · split · stage · media, main · aside · stage · controls · readout · actions)"},{id:"layout.own-step-nav",level:"warn",scope:"client",title:"화면 코드가 이전 · 다음 버튼을 직접 그림 (LXP 이전 · 다음 막대와 헷갈림, 키트 app.useStepper)"},{id:"ref.missing",level:"error",scope:"client",title:"참조한 파일이 없음"},{id:"ref.case-mismatch",level:"error",scope:"client",title:"참조 경로의 대소문자가 실제 파일과 다름"},{id:"ref.root-absolute",level:"error",scope:"client",title:"/로 시작하는 경로 · 자기 폴더가 아닌 <base href> (배포 주소 /s/{서명}/ 아래에서 깨짐)"},{id:"ref.external-script",level:"error",scope:"client",title:"외부 스크립트 (zip 안에 넣고 상대경로로)"},{id:"ref.external-request",level:"error",scope:"client",title:"외부 리소스 요청 (이미지 · 글꼴 · 영상 · CSS, 콘텐츠 CSP가 막음: zip 안에 넣기)"},{id:"ref.external-font",level:"warn",scope:"client",title:"허용 목록(externalAllow)의 외부 글꼴 (망분리 기관에서는 받지 못해 기본 글꼴로 보일 수 있음)"},{id:"ref.insecure",level:"error",scope:"client",title:"http:// 외부 리소스 (https 페이지 · 콘텐츠 CSP가 막음)"},{id:"ref.vendor-external-url",level:"warn",scope:"client",title:"라이브러리 파일 안의 외부 주소 (실행 중 외부를 부르면 콘텐츠 CSP가 막음, ecdk dev 로그 확인)"},{id:"ref.script-not-public",level:"error",scope:"client",title:"type=\"module\" 없는 <script src>가 public/ 밖 파일 (프로젝트 검사만. build가 묶지 않고 zip에도 넣지 않음, type=\"module\"을 붙이거나 public/으로)"},{id:"sandbox.module-src",level:"warn",scope:"client",title:"모듈 스크립트 파일(<script type=\"module\" src>): 콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없는 LXP에서는 CORS로 막혀 화면이 뜨지 않음 (ecdk build가 HTML 안에 묶음)"},{id:"sandbox.fetch-local",level:"warn",scope:"client",title:"zip 안 파일을 fetch · 변수 import() · Worker로 읽음: 콘텐츠 서버의 sandbox 헤더에 allow-same-origin이 없는 LXP에서는 CORS로 막힘 (JSON fetch · 문자열 import()는 ecdk build가 처리)"},{id:"html.img-alt",level:"warn",scope:"client",title:"대체 텍스트 없는 이미지"},{id:"html.iframe",level:"error",scope:"client",title:"src로 띄우는 iframe · frame, object · embed (콘텐츠 CSP가 막음, 영상은 Elice 비디오 자료로, srcdoc 미리보기는 통과)"},{id:"html.form",level:"warn",scope:"client",title:"form 제출 (sandbox · CSP form-action이 막음, 버튼 click으로 처리)"},{id:"api.external-send",level:"error",scope:"client",title:"외부 주소로 요청 보냄"},{id:"api.parent-access",level:"warn",scope:"client",title:"부모 창 직접 접근"},{id:"api.cookie",level:"warn",scope:"client",title:"쿠키 사용 (학습 기록이 아님)"},{id:"api.storage",level:"warn",scope:"client",title:"브라우저 저장소 사용 (학습 기록이 아님)"},{id:"api.eval",level:"warn",scope:"client",title:"eval · new Function 사용"},{id:"api.dialog",level:"error",scope:"client",title:"alert · confirm · prompt 사용"},{id:"api.window-open",level:"error",scope:"client",title:"새 창 열기"},{id:"sec.secret",level:"error",scope:"server",title:"비밀 값 (키 · 토큰 · 비밀번호)"},{id:"sec.answer-in-bundle",level:"warn",scope:"client",title:"편집 화면에 저장한 정답(.ecdk/settings.json 채점 설정)과 같은 글이 zip에 들어갈 파일에 있음 (프로젝트 검사만)"},{id:"sec.html-injection",level:"warn",scope:"client",title:"HTML 문자열 삽입"},{id:"sec.redirect",level:"warn",scope:"client",title:"주소를 값으로 바꿈"},{id:"sec.postmessage-wildcard",level:"warn",scope:"client",title:"postMessage 대상 *"},{id:"privacy.personal-field",level:"warn",scope:"client",title:"학습자 개인정보를 받는 입력 칸(전화 · 이메일 · 이름 autocomplete 등)이나 개인정보 · 학습자 이름(account.fullname)을 제출 · 저장 · AI 호출로 보냄 (익명 id account.anonymousId, 이름은 보여 주기만)"},{id:"sdk.outdated",level:"error",scope:"client",title:"SDK가 최소 버전보다 낮음 (metadata.json build.sdk < rules.json minVersions.sdk. alpha.3 이하는 LXP 편집 화면 저장(초안) 실패, npm update @eliceio/cdk)"},{id:"sdk.lib-copy",level:"error",scope:"client",title:"SDK 복사본 lib/cdk.js (zip에 넣지 않음, 프로젝트 검사만. SDK는 package.json 의존성 @eliceio/cdk를 build가 번들로 묶음)"}];var rulesJson = {version:version,manifest:manifest,externalAllow:externalAllow,minVersions:minVersions,layouts:layouts,limits:limits,allowedExtensions:allowedExtensions,imageExtensions:imageExtensions,excluded:excluded,forbiddenApis:forbiddenApis,secretPatterns:secretPatterns,rules:rules};
|
|
2
2
|
|
|
3
3
|
export { allowedExtensions, rulesJson as default, excluded, externalAllow, forbiddenApis, imageExtensions, layouts, limits, manifest, minVersions, rules, secretPatterns, version };
|