@eliceio/cdk-cli 1.2.0 → 1.3.0-contenttypes.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 +69 -60
- package/es/cli.js +11 -2
- package/es/commands/build/index.js +12 -0
- package/es/commands/create/index.js +2 -1
- package/es/commands/create/scaffold.d.ts +2 -2
- package/es/commands/create/scaffold.js +3 -3
- package/es/commands/dev/index.d.ts +10 -1
- package/es/commands/dev/index.js +47 -7
- package/es/core/config.d.ts +20 -9
- package/es/core/config.js +53 -12
- package/es/core/project-check.d.ts +3 -2
- package/es/core/project-check.js +14 -3
- package/es/core/regex.d.ts +11 -0
- package/es/core/regex.js +41 -0
- package/es/core/sandbox.d.ts +26 -0
- package/es/core/sandbox.js +240 -30
- package/es/dev/check.d.ts +30 -0
- package/es/dev/check.js +224 -34
- package/es/dev/grading.d.ts +20 -1
- package/es/dev/grading.js +38 -7
- package/es/dev/host-page.js +1 -1
- package/es/dev/mock-api.d.ts +3 -1
- package/es/dev/mock-api.js +20 -11
- package/es/engines/vite/index.js +1 -1
- package/es/engines/vite/plugin.d.ts +2 -0
- package/es/engines/vite/plugin.js +33 -5
- package/es/rules/answers.d.ts +13 -0
- package/es/rules/answers.js +94 -0
- package/es/rules/check.js +70 -1
- package/es/rules/index.d.ts +1 -0
- package/es/rules/index.js +1 -0
- package/es/rules/size.d.ts +31 -0
- package/es/rules/size.js +58 -0
- package/es/rules/types.d.ts +12 -0
- package/es/rules.json.js +2 -2
- package/package.json +2 -2
- package/rules.json +32 -3
- package/skills/_shared/always.md +3 -3
- package/skills/_shared/references/00-what-the-person-decides.md +1 -1
- package/skills/_shared/references/02-design-the-material.md +10 -7
- package/skills/_shared/references/03-create-the-project.md +2 -1
- package/skills/_shared/references/05-screen-code.md +49 -22
- package/skills/_shared/references/06-using-the-quiz-template.md +7 -6
- package/skills/_shared/references/08-fix-check-errors.md +23 -22
- package/skills/_shared/references/09-check.md +7 -6
- package/skills/_shared/references/12-upload-with-the-material-mcp.md +13 -13
- package/skills/_shared/references/13-edit-screen-design.md +122 -0
- package/skills/_shared/references/14-layouts.md +96 -0
- package/skills/elice-content-check/SKILL.md +2 -2
- package/skills/elice-content-create/SKILL.md +1 -1
- package/skills/elice-content-migrate/SKILL.md +1 -1
- package/templates/_shared/lib/cdk-mock.d.ts +30 -3
- package/templates/_shared/lib/cdk-mock.js +88 -15
- package/templates/_shared/lib/elice-content-editor.js +89 -58
- package/templates/_shared/lib/elice-content.css +1313 -126
- package/templates/_shared/lib/elice-content.d.ts +162 -23
- package/templates/_shared/lib/elice-content.js +865 -84
- package/templates/_shared/lib/icons/empty-content.d.ts +2 -0
- package/templates/_shared/lib/icons/empty-content.js +11 -0
- package/templates/_shared/lib/icons/file-video.d.ts +2 -0
- package/templates/_shared/lib/icons/file-video.js +11 -0
- package/templates/_shared/lib/icons/file.d.ts +2 -0
- package/templates/_shared/lib/icons/file.js +11 -0
- package/templates/blank/README.md +5 -3
- package/templates/blank/edit.html +8 -2
- package/templates/blank/index.html +6 -1
- package/templates/blank/instructor.html +6 -1
- package/templates/blank/template.json +1 -1
- package/templates/quiz/README.md +28 -12
- package/templates/quiz/core/behaviors.d.ts +13 -7
- package/templates/quiz/core/behaviors.js +36 -51
- package/templates/quiz/core/editor.d.ts +10 -0
- package/templates/quiz/core/editor.js +471 -8
- package/templates/quiz/core/markdown.d.ts +4 -0
- package/templates/quiz/core/markdown.js +65 -11
- package/templates/quiz/core/model.d.ts +34 -1
- package/templates/quiz/core/model.js +89 -7
- package/templates/quiz/core/rich-text.d.ts +19 -0
- package/templates/quiz/core/rich-text.js +521 -0
- package/templates/quiz/edit.html +12 -3
- package/templates/quiz/index.html +12 -3
- package/templates/quiz/screens/edit.js +848 -168
- package/templates/quiz/screens/learn.js +90 -14
- package/templates/quiz/styles.css +889 -213
- package/templates/quiz/template.json +9 -2
- package/templates/quiz/ui/templates/edit.d.ts +19 -6
- package/templates/quiz/ui/templates/edit.js +666 -87
- package/templates/quiz/ui/templates/group.js +19 -8
- package/templates/quiz/ui/templates/order.js +25 -24
- package/templates/quiz/ui/templates/page.js +19 -8
- package/templates/quiz/ui/templates/question.js +2 -2
- package/templates/quiz/ui/texts.js +104 -35
- package/templates/quiz/ui/theme.css +8 -9
- package/templates/steps/README.md +77 -0
- package/templates/steps/commentary.txt +7 -0
- package/templates/steps/edit.html +21 -0
- package/templates/steps/gitignore +4 -0
- package/templates/steps/index.html +69 -0
- package/templates/steps/metadata.json +9 -0
- package/templates/steps/package.json +13 -0
- package/templates/steps/screens/edit.js +32 -0
- package/templates/steps/screens/learn.js +108 -0
- package/templates/steps/styles.css +54 -0
- package/templates/steps/template.json +6 -0
|
@@ -38,7 +38,11 @@ export declare function validateAnswerKey(
|
|
|
38
38
|
/** 보기 줄에서 정답을 고르는 유형 (단일 · 복수 · 그룹) */
|
|
39
39
|
export declare const INLINE_ANSWER_TYPES: string[];
|
|
40
40
|
/** 보기 하나의 정답 표시: 단일 · 복수는 true/false, 그룹은 속한 그룹 id('' = 없음) */
|
|
41
|
-
export declare function optionAnswer(
|
|
41
|
+
export declare function optionAnswer(
|
|
42
|
+
q: any,
|
|
43
|
+
value: any,
|
|
44
|
+
optionId: string
|
|
45
|
+
): boolean | string | undefined;
|
|
42
46
|
/** 보기 하나의 정답 표시를 바꾼 새 정답 (화면 값 모양 그대로) */
|
|
43
47
|
export declare function withOptionAnswer(
|
|
44
48
|
q: any,
|
|
@@ -58,3 +62,32 @@ export declare function checkAnswerKey(
|
|
|
58
62
|
messages: Record<string, any>
|
|
59
63
|
): { questionIndex: number; message: string } | null;
|
|
60
64
|
export declare function shuffled<T>(items: T[], seed: string): T[];
|
|
65
|
+
/** 문항별 부분 점수 채점 방식 이름 */
|
|
66
|
+
export declare const PARTIAL: 'partial_pattern';
|
|
67
|
+
/** 채점 방식: 저장된 grading.type → 공개 값 settings.gradingType → pattern */
|
|
68
|
+
export declare function gradingTypeOf(
|
|
69
|
+
content: unknown,
|
|
70
|
+
grading: unknown
|
|
71
|
+
): 'pattern' | 'partial_pattern';
|
|
72
|
+
/** 문항별 답 → 제출할 문자열 배열 (partial_pattern) */
|
|
73
|
+
export declare function joinAnswerList(questions: any[], values: unknown[]): string[];
|
|
74
|
+
/** 문항별 정답 → 문항마다 정답 정규식 (partial_pattern) */
|
|
75
|
+
export declare function buildAnswerKeys(questions: any[], key: Record<string, any>): string[];
|
|
76
|
+
/** buildAnswerKeys가 만든 정규식 배열 → 문항별 정답. 다른 모양이면 null */
|
|
77
|
+
export declare function parseAnswerKeys(
|
|
78
|
+
questions: any[],
|
|
79
|
+
keys: unknown
|
|
80
|
+
): Record<string, any> | null;
|
|
81
|
+
/** 정답 검증 2 (문항별) */
|
|
82
|
+
export declare function checkAnswerKeys(
|
|
83
|
+
questions: any[],
|
|
84
|
+
key: Record<string, any>,
|
|
85
|
+
keys: string[],
|
|
86
|
+
messages: Record<string, any>
|
|
87
|
+
): { questionIndex: number; message: string } | null;
|
|
88
|
+
/** 저장할 문항별 점수: 저장된 정규식의 문제 id로 맞춰 지금 순서로, 문제 id가 다르면 split으로 다시 나눔 */
|
|
89
|
+
export declare function scoresFor(
|
|
90
|
+
questions: any[],
|
|
91
|
+
saved: { answer_key?: unknown; scores?: unknown } | undefined,
|
|
92
|
+
split: (n: number) => number[]
|
|
93
|
+
): { scores: number[]; resplit: boolean };
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
// 퀴즈 데이터 모델. 학생 · 교육자 · 편집 화면이 같이 씁니다. (기존 퀴즈 material 명세: docs/quiz-spec.md)
|
|
2
2
|
//
|
|
3
3
|
// 편집 화면이 저장하는 settings (학생에게 공개, 정답 없음)
|
|
4
|
-
// {
|
|
4
|
+
// { questions: [{ id, type, title, description?, options?, groups?, slots?,
|
|
5
5
|
// shuffle?, placeholder?, explanation: { enabled, text } }] }
|
|
6
|
+
// 퀴즈 제목 · 안내(title · description)는 지금 화면이 쓰지 않는다. 예전에 저장한 값은 지우지 않고 그대로 둔다
|
|
6
7
|
// 문항 description은 편집 화면에서 적을 때만 생긴다 (새 문항에는 키가 없음)
|
|
7
8
|
// 제출하는 답: 문자열 하나 (ADR 0008). 문항 순서대로 `문항id=답`을 `;`로 잇고, 주관식 답은 encodeURIComponent
|
|
8
9
|
// "q1=b;q2=a,d;q3=c,a,b;q4=%EA%B0%80%EC%A4%91%EC%B9%98;q5=g1:a|g2:b,c"
|
|
9
|
-
//
|
|
10
|
-
//
|
|
10
|
+
// 채점 방식은 둘 중 하나 (작성자가 고름, 완료 정책은 LXP 설정, ADR 0012). 정답(settings.grading)은 편집 화면이 문항마다 고른 답으로 만든다.
|
|
11
|
+
// - pattern (기본, 모두 맞혀야 100점): 정규식 하나 { type: 'pattern', answer_key: '^q1=b;…$' }, 답은 위 문자열 하나
|
|
12
|
+
// - partial_pattern (문항별 부분 점수): 문항마다 정규식 { type: 'partial_pattern', answer_key: ['^q1=b$', …], scores: [50, …] },
|
|
13
|
+
// 답은 문항 순서대로 문자열 배열 ["q1=b", "q2=a,d", …] (한 항목의 모양은 pattern 답 · 정답의 한 조각과 같음).
|
|
14
|
+
// 학생 화면은 grading을 받지 못하므로 settings에 공개 값 gradingType: 'partial_pattern'을 같이 둔다 (없으면 pattern)
|
|
11
15
|
|
|
12
16
|
// 화면에 보이는 문구는 여기 두지 않습니다 (ui/texts.js). 문구가 필요한 함수는 화면(screens/)이 문구를 넘겨 줍니다.
|
|
13
17
|
|
|
@@ -19,8 +23,11 @@ export const LIMITS = {
|
|
|
19
23
|
optionsMax: 20,
|
|
20
24
|
groupsMin: 2,
|
|
21
25
|
groupsMax: 6,
|
|
22
|
-
//
|
|
23
|
-
questionsMax:
|
|
26
|
+
// 여러 문항 퀴즈: 문항 20개까지. pattern은 모든 문항을 맞혀야 100점, partial_pattern은 맞은 문항 점수의 합
|
|
27
|
+
questionsMax: 20,
|
|
28
|
+
// 편집 화면에서 올린 그림 (지문 · 해설): 하나는 data: 주소 40만 자까지 줄이고, 모두 합쳐 270만 자(약 2MB)까지 내용 images에
|
|
29
|
+
imageChars: 400_000,
|
|
30
|
+
imagesTotalChars: 2_700_000,
|
|
24
31
|
};
|
|
25
32
|
|
|
26
33
|
/** 편집 화면에서 문항을 더 넣을 수 있는지. 이미 여러 문항으로 저장된 퀴즈도 그대로 보이고 저장되며, 더 넣는 것만 막는다 */
|
|
@@ -65,7 +72,8 @@ export function convertType(q, type, names) {
|
|
|
65
72
|
text: names.option(options.length + 1),
|
|
66
73
|
});
|
|
67
74
|
next.options = options;
|
|
68
|
-
|
|
75
|
+
// 순서 맞추기는 정답 순서대로 적으므로 학생에게는 섞어 보이는 게 기본 (이미 정한 값이 있으면 그대로)
|
|
76
|
+
next.shuffle = q.shuffle === undefined ? type === 'order' : Boolean(q.shuffle);
|
|
69
77
|
} else {
|
|
70
78
|
delete next.options;
|
|
71
79
|
delete next.shuffle;
|
|
@@ -92,7 +100,6 @@ export function convertType(q, type, names) {
|
|
|
92
100
|
* @param {object} v 검증 문구 (ui/texts.js의 validation)
|
|
93
101
|
*/
|
|
94
102
|
export function validateQuiz(content, v) {
|
|
95
|
-
if (!content.title?.trim()) return { questionIndex: -1, message: v.quizTitle };
|
|
96
103
|
if (!content.questions?.length) return { questionIndex: -1, message: v.noQuestions };
|
|
97
104
|
for (const [i, q] of content.questions.entries()) {
|
|
98
105
|
const at = (message) => ({ questionIndex: i, message: v.at(i + 1, message) });
|
|
@@ -184,6 +191,9 @@ export function joinAnswers(questions, values) {
|
|
|
184
191
|
* `;`로 나누고 첫 `=`에서 문항 id와 답을 나눈 뒤, 주관식은 decodeURIComponent
|
|
185
192
|
*/
|
|
186
193
|
export function splitAnswers(questions, answer) {
|
|
194
|
+
// partial_pattern 답: 문항별 문자열 배열 → 한 문자열로 이어 같은 방식으로 푼다
|
|
195
|
+
if (Array.isArray(answer))
|
|
196
|
+
return splitAnswers(questions, answer.filter((a) => typeof a === 'string').join(';'));
|
|
187
197
|
if (answer && typeof answer === 'object') return { ...(answer.answers ?? {}) };
|
|
188
198
|
if (typeof answer !== 'string') return {};
|
|
189
199
|
const byId = Object.fromEntries(questions.map((q) => [q.id, q]));
|
|
@@ -259,6 +269,78 @@ export function parseAnswerKey(questions, regex) {
|
|
|
259
269
|
return out;
|
|
260
270
|
}
|
|
261
271
|
|
|
272
|
+
// ---------- 문항별 부분 점수 (partial_pattern) ----------
|
|
273
|
+
|
|
274
|
+
export const PARTIAL = 'partial_pattern';
|
|
275
|
+
|
|
276
|
+
/** 채점 방식: 저장된 settings.grading.type, 없으면 학생 화면에도 보이는 settings.gradingType, 둘 다 없으면 pattern */
|
|
277
|
+
export function gradingTypeOf(content, grading) {
|
|
278
|
+
if (grading?.type === PARTIAL || grading?.type === 'pattern') return grading.type;
|
|
279
|
+
return content?.gradingType === PARTIAL ? PARTIAL : 'pattern';
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** 문항별 답 → 제출할 문자열 배열 (문항 순서). 한 항목은 pattern 답의 한 조각과 같은 `문항id=답` */
|
|
283
|
+
export function joinAnswerList(questions, values) {
|
|
284
|
+
return questions.map((q, i) => joinAnswers([q], [values[i]]));
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/** 문항별 정답 → 문항마다 정답 정규식 `^문항id=…$` (buildAnswerKey를 문항 하나씩) */
|
|
288
|
+
export function buildAnswerKeys(questions, key) {
|
|
289
|
+
return questions.map((q) => buildAnswerKey([q], key));
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** buildAnswerKeys가 만든 정규식 배열 → 문항별 정답(화면 값). 다른 모양이면 null */
|
|
293
|
+
export function parseAnswerKeys(questions, keys) {
|
|
294
|
+
if (!Array.isArray(keys) || keys.length === 0) return null;
|
|
295
|
+
if (keys.some((k) => typeof k !== 'string' || !k.startsWith('^') || !k.endsWith('$'))) return null;
|
|
296
|
+
return parseAnswerKey(questions, `^${keys.map((k) => k.slice(1, -1)).join(';')}$`);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* 정답 검증 2 (문항별): 문항마다 checkAnswerKey (정답으로 낸 답은 맞고, 하나 바꾼 답은 맞지 않음).
|
|
301
|
+
* 문제가 없으면 null, 있으면 { questionIndex, message }
|
|
302
|
+
*/
|
|
303
|
+
export function checkAnswerKeys(questions, key, keys, v) {
|
|
304
|
+
for (const [i, q] of questions.entries()) {
|
|
305
|
+
const at = (_no, message) => v.at(i + 1, message);
|
|
306
|
+
const problem = checkAnswerKey([q], key, keys[i], { ...v, at });
|
|
307
|
+
if (!problem) continue;
|
|
308
|
+
if (problem.message === v.badRegex) return { questionIndex: i, message: at(0, v.badRegex) };
|
|
309
|
+
return {
|
|
310
|
+
questionIndex: i,
|
|
311
|
+
message: problem.questionIndex === -1 ? at(0, problem.message) : problem.message,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* 저장할 문항별 점수. 저장된 점수는 같은 자리 정규식(answer_key[i] = "^문제id=…")의 문제 것이라, 문제 id로 맞춰 지금 문제 순서로 다시 놓는다
|
|
319
|
+
* (순서를 바꿔도 점수가 제 문제를 따라감). 저장된 문제 id와 지금 문제 id가 하나라도 다르면(더함 · 지움) 똑같이 나눈 점수 (split = 키트 splitScores).
|
|
320
|
+
* resplit: 저장된 점수가 있었는데 맞추지 못해 다시 나눴는지 (화면이 짧게 알림)
|
|
321
|
+
* @param {{ answer_key?: unknown, scores?: unknown } | undefined} saved 저장된 partial_pattern 채점 설정
|
|
322
|
+
* @returns {{ scores: number[], resplit: boolean }}
|
|
323
|
+
*/
|
|
324
|
+
export function scoresFor(questions, saved, split) {
|
|
325
|
+
const keys = saved?.answer_key;
|
|
326
|
+
const scores = saved?.scores;
|
|
327
|
+
const had = Array.isArray(scores) && scores.length > 0;
|
|
328
|
+
if (Array.isArray(keys) && Array.isArray(scores) && keys.length === scores.length) {
|
|
329
|
+
const byId = new Map();
|
|
330
|
+
keys.forEach((key, i) => {
|
|
331
|
+
const id = typeof key === 'string' ? /^\^([A-Za-z0-9_-]+)=/.exec(key)?.[1] : undefined;
|
|
332
|
+
if (id) byId.set(id, scores[i]);
|
|
333
|
+
});
|
|
334
|
+
if (
|
|
335
|
+
byId.size === keys.length &&
|
|
336
|
+
byId.size === questions.length &&
|
|
337
|
+
questions.every((q) => byId.has(q.id))
|
|
338
|
+
)
|
|
339
|
+
return { scores: questions.map((q) => byId.get(q.id)), resplit: false };
|
|
340
|
+
}
|
|
341
|
+
return { scores: split(questions.length), resplit: had };
|
|
342
|
+
}
|
|
343
|
+
|
|
262
344
|
/**
|
|
263
345
|
* 정답 검증 1: 모든 문항에 정답이 있고, 정답이 지금 있는 보기 · 그룹을 가리키는지.
|
|
264
346
|
* 문제가 없으면 null, 있으면 { questionIndex, message }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface RichText {
|
|
2
|
+
el: HTMLElement;
|
|
3
|
+
set(markdown: string): void;
|
|
4
|
+
get(): string;
|
|
5
|
+
focus(atEnd?: boolean): void;
|
|
6
|
+
split(): { before: string; after: string };
|
|
7
|
+
state(): { bold: boolean; italic: boolean; strike: boolean; ul: boolean; ol: boolean; code: boolean };
|
|
8
|
+
bold(): void;
|
|
9
|
+
italic(): void;
|
|
10
|
+
strike(): void;
|
|
11
|
+
list(tag?: 'ul' | 'ol'): void;
|
|
12
|
+
code(sample: string): void;
|
|
13
|
+
}
|
|
14
|
+
export type Block = { type: 'text'; text: string } | { type: 'image'; alt: string; id: string };
|
|
15
|
+
export declare function toMarkdown(root: Node): string;
|
|
16
|
+
export declare function richText(el: HTMLElement, opts: { onChange: (markdown: string) => void }): RichText;
|
|
17
|
+
export declare function splitBlocks(source: string): Block[];
|
|
18
|
+
export declare function joinBlocks(items: Block[]): string;
|
|
19
|
+
export declare function compressImage(file: File, maxChars: number): Promise<string>;
|