@eliceio/cdk-cli 1.2.1 → 1.3.0-contenttypes.1
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 +63 -53
- package/es/cli.js +11 -2
- package/es/commands/build/index.js +12 -0
- package/es/commands/create/index.js +2 -0
- 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/commands/doctor/index.js +6 -2
- package/es/core/config.d.ts +42 -9
- package/es/core/config.js +217 -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/assets.d.ts +80 -0
- package/es/dev/assets.js +240 -0
- package/es/dev/check.d.ts +30 -0
- package/es/dev/check.js +224 -34
- package/es/dev/grading.d.ts +49 -14
- package/es/dev/grading.js +109 -29
- package/es/dev/host-page.js +27 -3
- package/es/dev/inject.d.ts +2 -1
- package/es/dev/inject.js +10 -2
- package/es/dev/mock-api.d.ts +26 -3
- package/es/dev/mock-api.js +219 -40
- package/es/dev/server.d.ts +12 -1
- package/es/dev/server.js +115 -9
- 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 +34 -5
- 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 +10 -8
- package/skills/_shared/references/04-rules.md +1 -1
- package/skills/_shared/references/05-screen-code.md +52 -23
- 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 +8 -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/skills/elice-content-publish/SKILL.md +1 -1
- package/templates/_shared/lib/cdk-mock.d.ts +47 -3
- package/templates/_shared/lib/cdk-mock.js +293 -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 +222 -23
- package/templates/_shared/lib/elice-content.js +1176 -88
- 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 +6 -4
- package/templates/blank/edit.html +8 -2
- package/templates/blank/index.html +6 -1
- package/templates/blank/instructor.html +6 -1
- package/templates/blank/screens/instructor.js +8 -2
- package/templates/blank/screens/learn.js +1 -1
- package/templates/blank/template.json +1 -1
- package/templates/document/README.md +92 -0
- package/templates/document/commentary.txt +2 -0
- package/templates/document/core/dom.d.ts +13 -0
- package/templates/document/core/dom.js +83 -0
- package/templates/document/core/file-type.d.ts +21 -0
- package/templates/document/core/file-type.js +85 -0
- package/templates/document/core/group-3d.d.ts +20 -0
- package/templates/document/core/group-3d.js +256 -0
- package/templates/document/core/inline-edit.d.ts +15 -0
- package/templates/document/core/inline-edit.js +377 -0
- package/templates/document/core/load.d.ts +13 -0
- package/templates/document/core/load.js +40 -0
- package/templates/document/core/pdf-options.d.ts +9 -0
- package/templates/document/core/pdf-options.js +36 -0
- package/templates/document/core/pdf-worker.d.ts +24 -0
- package/templates/document/core/pdf-worker.js +122 -0
- package/templates/document/core/pdf.d.ts +12 -0
- package/templates/document/core/pdf.js +190 -0
- package/templates/document/core/pptx-edit.d.ts +14 -0
- package/templates/document/core/pptx-edit.js +137 -0
- package/templates/document/core/pptx-fonts.d.ts +5 -0
- package/templates/document/core/pptx-fonts.js +115 -0
- package/templates/document/core/pptx-media.d.ts +18 -0
- package/templates/document/core/pptx-media.js +83 -0
- package/templates/document/core/pptx-view.d.ts +5 -0
- package/templates/document/core/pptx-view.js +185 -0
- package/templates/document/core/settings.d.ts +25 -0
- package/templates/document/core/settings.js +86 -0
- package/templates/document/core/slide-edges.d.ts +3 -0
- package/templates/document/core/slide-edges.js +82 -0
- package/templates/document/core/viewer.d.ts +28 -0
- package/templates/document/core/viewer.js +159 -0
- package/templates/document/edit.html +17 -0
- package/templates/document/gitignore +4 -0
- package/templates/document/index.html +18 -0
- package/templates/document/metadata.json +9 -0
- package/templates/document/package.json +17 -0
- package/templates/document/public/fonts/OFL-Caladea.txt +93 -0
- package/templates/document/public/fonts/OFL-Carlito.txt +93 -0
- package/templates/document/public/fonts/caladea-latin-400-normal.woff2 +0 -0
- package/templates/document/public/fonts/caladea-latin-700-normal.woff2 +0 -0
- package/templates/document/public/fonts/carlito-latin-400-normal.woff2 +0 -0
- package/templates/document/public/fonts/carlito-latin-700-normal.woff2 +0 -0
- package/templates/document/screens/edit.js +574 -0
- package/templates/document/screens/learn.js +61 -0
- package/templates/document/styles.css +644 -0
- package/templates/document/template.json +6 -0
- package/templates/document/ui/templates/edit.js +82 -0
- package/templates/document/ui/templates/page.js +11 -0
- package/templates/document/ui/templates/viewer.js +41 -0
- package/templates/document/ui/texts.d.ts +3 -0
- package/templates/document/ui/texts.js +62 -0
- package/templates/document/ui/theme.css +69 -0
- package/templates/quiz/README.md +32 -14
- package/templates/quiz/core/behaviors.d.ts +17 -7
- package/templates/quiz/core/behaviors.js +40 -53
- package/templates/quiz/core/editor.d.ts +27 -2
- package/templates/quiz/core/editor.js +412 -11
- package/templates/quiz/core/markdown.d.ts +19 -0
- package/templates/quiz/core/markdown.js +225 -11
- package/templates/quiz/core/model.d.ts +40 -3
- package/templates/quiz/core/model.js +112 -5
- package/templates/quiz/core/rich-text.d.ts +18 -0
- package/templates/quiz/core/rich-text.js +469 -0
- package/templates/quiz/edit.html +12 -3
- package/templates/quiz/index.html +12 -3
- package/templates/quiz/public/img/mascot-half.webp +0 -0
- package/templates/quiz/screens/edit.js +331 -49
- package/templates/quiz/screens/learn.js +147 -15
- package/templates/quiz/styles.css +1244 -622
- package/templates/quiz/template.json +9 -2
- package/templates/quiz/ui/templates/edit.d.ts +19 -5
- package/templates/quiz/ui/templates/edit.js +371 -77
- 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 +33 -8
- package/templates/quiz/ui/templates/question.js +6 -4
- package/templates/quiz/ui/texts.js +91 -26
- 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
|
@@ -3,54 +3,184 @@
|
|
|
3
3
|
// 모양은 ui/(templates · texts · theme.css), 동작은 core/에 있습니다.
|
|
4
4
|
import { start } from '../lib/elice-content.js';
|
|
5
5
|
import { renderQuestion } from '../core/behaviors.js';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
ASSET_FILLED_EVENT,
|
|
8
|
+
ASSET_TIMEOUT_MS,
|
|
9
|
+
resolveAssets,
|
|
10
|
+
setAssetFailedText,
|
|
11
|
+
setImages,
|
|
12
|
+
} from '../core/markdown.js';
|
|
13
|
+
import {
|
|
14
|
+
decodeAnswer,
|
|
15
|
+
isAnswered,
|
|
16
|
+
joinAnswerList,
|
|
17
|
+
joinAnswers,
|
|
18
|
+
PARTIAL,
|
|
19
|
+
splitAnswers,
|
|
20
|
+
} from '../core/model.js';
|
|
7
21
|
import { labels, templates } from '../ui/templates/index.js';
|
|
8
|
-
import {
|
|
22
|
+
import { loading, partialScore, someWrong } from '../ui/templates/page.js';
|
|
9
23
|
import { texts } from '../ui/texts.js';
|
|
10
24
|
|
|
11
25
|
const root = document.getElementById('app');
|
|
12
26
|
document.title = texts.page.learn;
|
|
13
27
|
root.replaceChildren(loading());
|
|
14
28
|
const app = await start({ screen: 'learn' });
|
|
15
|
-
// 편집 화면에서 아직 내용을 저장하지 않았으면 안내만 보인다 (기본 문항은
|
|
16
|
-
|
|
17
|
-
|
|
29
|
+
// 편집 화면에서 아직 내용을 저장하지 않았으면 키트 빈 안내만 보인다 (기본 문항은 없음, 모든 템플릿 공통 모양 · 문구,
|
|
30
|
+
// 교육자 · 튜터도 같은 문구 — 연주님 최종 수정본)
|
|
31
|
+
if (app.hasContent) {
|
|
32
|
+
// 편집 화면에서 지문 · 해설에 올린 그림 을 받기 시작한다. 기다리지 않고 문항을 먼저 그리고,
|
|
33
|
+
// 받으면 그 자리만 그림으로 바꾼다 (그림 하나 10초까지, 못 받으면 새로고침 안내). 해설 그림도 같이 받아 두어 제출 뒤 바로 보인다
|
|
34
|
+
setAssetFailedText(texts.learn.imageExpired);
|
|
35
|
+
void resolveAssets(
|
|
36
|
+
(app.content.questions ?? []).flatMap((q) => [q.description, q.explanation?.text]),
|
|
37
|
+
app.assets.url,
|
|
38
|
+
);
|
|
39
|
+
show();
|
|
40
|
+
} else root.replaceChildren(app.emptyState());
|
|
41
|
+
// 그림이 깨지면(받은 blob이 그림이 아님 등) 그 자리에 새로고침 안내 (error는 거품이 없어 capture로)
|
|
42
|
+
root.addEventListener(
|
|
43
|
+
'error',
|
|
44
|
+
(e) => {
|
|
45
|
+
const img = e.target;
|
|
46
|
+
if (!(img instanceof HTMLImageElement) || !img.dataset.asset) return;
|
|
47
|
+
const notice = document.createElement('span');
|
|
48
|
+
notice.className = 'qz-image-missing';
|
|
49
|
+
notice.setAttribute('role', 'alert');
|
|
50
|
+
notice.textContent = texts.learn.imageExpired;
|
|
51
|
+
img.replaceWith(notice);
|
|
52
|
+
},
|
|
53
|
+
true,
|
|
54
|
+
);
|
|
55
|
+
// 제출 뒤 맨 아래로(scrollOnResult 'bottom'): 키트는 그때 이미 있는 <img>만 기다린다. 아직 받는 중이던 올린 그림(해설 그림 등)이
|
|
56
|
+
// 그림 한도(10초) 안에 들어오면 한 번 더 맨 아래로 맞춘다. 학생이 직접 스크롤하면 따라가지 않는다
|
|
57
|
+
let followUntil = 0;
|
|
58
|
+
document.addEventListener(
|
|
59
|
+
'click',
|
|
60
|
+
(e) => {
|
|
61
|
+
if (e.target instanceof Element && e.target.closest('.ec-submitbar button'))
|
|
62
|
+
followUntil = Date.now() + ASSET_TIMEOUT_MS + 3000;
|
|
63
|
+
},
|
|
64
|
+
true,
|
|
65
|
+
);
|
|
66
|
+
for (const type of ['wheel', 'touchmove'])
|
|
67
|
+
addEventListener(type, () => (followUntil = 0), { passive: true });
|
|
68
|
+
document.addEventListener(ASSET_FILLED_EVENT, (e) => {
|
|
69
|
+
const element = e.detail?.element;
|
|
70
|
+
if (Date.now() > followUntil || !(element instanceof HTMLImageElement) || !root.contains(element))
|
|
71
|
+
return;
|
|
72
|
+
const go = () => {
|
|
73
|
+
const reduce =
|
|
74
|
+
typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
75
|
+
const page = document.scrollingElement ?? document.documentElement;
|
|
76
|
+
page.scrollTo?.({ top: page.scrollHeight, behavior: reduce ? 'auto' : 'smooth' });
|
|
77
|
+
};
|
|
78
|
+
if (element.complete) go();
|
|
79
|
+
else element.addEventListener('load', go, { once: true });
|
|
80
|
+
});
|
|
81
|
+
// 불러오는 자리에서 내용으로 바뀔 때 살짝 나타나게 (styles.css .qz-enter)
|
|
82
|
+
root.classList.add('qz-enter');
|
|
18
83
|
|
|
19
84
|
function show() {
|
|
20
|
-
|
|
85
|
+
// 퀴즈 제목 · 안내는 보이지 않는다 (연주님 최종 수정본: 문제부터 바로). 예전에 저장한 값은 settings에 그대로
|
|
86
|
+
const { questions = [] } = app.content;
|
|
87
|
+
// 1.9.0 전 편집 화면이 지문 · 해설에 넣은 그림 (글에는 , 그림은 내용 images에 data: 주소로)
|
|
88
|
+
setImages(app.content.images);
|
|
89
|
+
// 답 모양은 채점 방식을 따른다 (학생 화면은 grading을 받지 못해 편집 화면이 같이 저장한 공개 값 gradingType으로 안다):
|
|
90
|
+
// pattern은 문자열 하나 "q1=b;q2=a,d;…" (ADR 0008 · 0009), partial_pattern은 문항별 배열 ["q1=b", "q2=a,d", …]
|
|
91
|
+
const partial = app.content.gradingType === PARTIAL;
|
|
92
|
+
// 부분 채점 · 직접 배점이면 문제 제목 옆에 배점 (자동 배점은 보이지 않음, 연주님 부분 채점 UI)
|
|
93
|
+
const showPoints = partial && questions.length > 1 && app.content.pointsMode === 'custom';
|
|
21
94
|
// 문항 유형은 보이지 않는다 (무엇을 할지는 질문 문장이 알려 줌). 교육자도 이 화면에서 풀어 본다 (교육자 화면 없음)
|
|
22
95
|
const views = questions.map((q, i) =>
|
|
23
96
|
renderQuestion(q, i, {
|
|
24
97
|
templates,
|
|
25
98
|
labels: { ...labels, types: null },
|
|
99
|
+
// 문제가 하나면 번호 없이 제목만 (연주님 최종 수정본)
|
|
100
|
+
single: questions.length === 1,
|
|
101
|
+
points: showPoints,
|
|
26
102
|
seed: app.account?.anonymousId ?? '',
|
|
27
103
|
}),
|
|
28
104
|
);
|
|
29
105
|
|
|
30
|
-
root.replaceChildren(
|
|
106
|
+
root.replaceChildren(...views.map((v) => v.el));
|
|
31
107
|
|
|
32
|
-
|
|
108
|
+
/**
|
|
109
|
+
* 문제별 맞음 (partial_pattern), 지금 문제 순서대로. answerCorrectness[i]는 낸 답 answer[i]의 맞음이고 answer[i]는 "문제id=답"이라
|
|
110
|
+
* 문제 id로 맞춘다 (제출 뒤 교육자가 문제 순서를 바꿔도 표시가 제 문제에). 다시 열 때는 마지막 제출 기록의 answer,
|
|
111
|
+
* 제출 직후에는 지금 답(방금 낸 답과 같음). 낸 답과 지금 문제가 하나라도 맞지 않으면(빠짐 · 더함 · 옛 문자열 답) null → 전체 결과만
|
|
112
|
+
*/
|
|
113
|
+
const correctnessOf = (res) => {
|
|
114
|
+
const marks = res.answerCorrectness;
|
|
115
|
+
const answer = res.answer ?? joinAnswerList(questions, views.map((v) => v.getValue()));
|
|
116
|
+
if (!Array.isArray(marks) || !Array.isArray(answer) || marks.length !== answer.length) return null;
|
|
117
|
+
const byId = new Map();
|
|
118
|
+
answer.forEach((piece, i) => {
|
|
119
|
+
const at = typeof piece === 'string' ? piece.indexOf('=') : -1;
|
|
120
|
+
if (at > 0) byId.set(piece.slice(0, at), marks[i] === true);
|
|
121
|
+
});
|
|
122
|
+
if (byId.size !== questions.length || questions.some((q) => !byId.has(q.id))) return null;
|
|
123
|
+
return questions.map((q) => byId.get(q.id));
|
|
124
|
+
};
|
|
125
|
+
// 키트 점수 줄(정답 · 오답)은 감추고 문제 카드의 정답 · 오답과 제출 바 위 상자(.qz-overall)로 알린다 (styles.css, 연주님 디자인).
|
|
126
|
+
// pattern: 여러 문제 중 틀린 것이 있으면 한 줄 (어느 문제인지는 pattern이 알려 주지 않음).
|
|
127
|
+
// partial_pattern: 100점보다 낮으면 점수 · "아쉬워요!" · 마스코트 상자, 100점이면 상자 없음
|
|
128
|
+
const overall = someWrong();
|
|
129
|
+
const wrongText = overall.textContent;
|
|
130
|
+
const hideOverall = () => {
|
|
131
|
+
overall.hidden = true;
|
|
132
|
+
delete overall.dataset.result;
|
|
133
|
+
overall.classList.remove('qz-overall-mascot');
|
|
134
|
+
};
|
|
135
|
+
const showWrong = () => {
|
|
136
|
+
overall.classList.remove('qz-overall-mascot');
|
|
137
|
+
overall.textContent = wrongText;
|
|
138
|
+
overall.dataset.result = 'wrong';
|
|
139
|
+
overall.hidden = false;
|
|
140
|
+
};
|
|
141
|
+
const showScore = (score) => {
|
|
142
|
+
if (score >= 100) return hideOverall();
|
|
143
|
+
overall.replaceChildren(partialScore({ score }));
|
|
144
|
+
overall.classList.add('qz-overall-mascot');
|
|
145
|
+
overall.dataset.result = 'partial';
|
|
146
|
+
overall.hidden = false;
|
|
147
|
+
};
|
|
33
148
|
app.useSubmit({
|
|
34
|
-
|
|
149
|
+
label: texts.learn.submit,
|
|
150
|
+
// 제출하면 결과(점수 상자 · 제출 바)가 있는 맨 아래로 (성공 · 실패 모두, 단건 · 여러 문항 · pattern · partial_pattern 같음)
|
|
151
|
+
scrollOnResult: 'bottom',
|
|
152
|
+
getAnswer: () => {
|
|
153
|
+
const values = views.map((v) => v.getValue());
|
|
154
|
+
return partial ? joinAnswerList(questions, values) : joinAnswers(questions, values);
|
|
155
|
+
},
|
|
35
156
|
setAnswer: (answer) => {
|
|
36
157
|
const byId = splitAnswers(questions, answer);
|
|
37
158
|
questions.forEach((q, i) => views[i].setValue(decodeAnswer(q, byId[q.id])));
|
|
38
159
|
},
|
|
39
160
|
validate: () => {
|
|
40
161
|
const left = questions.findIndex((q, i) => !isAnswered(q, views[i].getValue()));
|
|
41
|
-
|
|
162
|
+
if (left < 0) return true;
|
|
163
|
+
return questions.length === 1 ? texts.learn.unansweredSingle : texts.learn.unanswered(left + 1);
|
|
42
164
|
},
|
|
43
|
-
//
|
|
44
|
-
//
|
|
165
|
+
// partial_pattern이면 서버가 문항별 맞음 answerCorrectness를 준다 (제출 직후 · 다시 열 때 마지막 제출 기록에서).
|
|
166
|
+
// 문제 id로 맞춘 결과가 있으면 문제마다 정답 · 오답을 표시한다. 없거나([] = pattern · rubric) 맞추지 못하면 전체 결과만:
|
|
167
|
+
// 문항이 하나면 그 결과가 곧 문항의 정답 · 오답, 여러 문항이면 모두 맞았을 때만 정답 표시. 해설은 한 번이라도 제출하면
|
|
45
168
|
onResult: (res) => {
|
|
46
169
|
const single = views.length === 1;
|
|
47
|
-
|
|
170
|
+
const items = correctnessOf(res);
|
|
171
|
+
views.forEach((v, i) => {
|
|
48
172
|
const correct = typeof res.isCorrect === 'boolean' ? res.isCorrect : null;
|
|
49
|
-
v.setResult(
|
|
173
|
+
if (items) v.setResult(items[i]);
|
|
174
|
+
else v.setResult(single ? correct : correct === true ? true : null);
|
|
50
175
|
v.showExplanation();
|
|
51
176
|
});
|
|
177
|
+
if (partial && typeof res.score === 'number') showScore(res.score);
|
|
178
|
+
else if (!partial && !single && res.isCorrect === false) showWrong();
|
|
179
|
+
else hideOverall();
|
|
180
|
+
// 만점 축하(토끼 · 소리)는 LXP가 서버 점수 변경(소켓)을 받아 보인다. 콘텐츠는 제출만 하면 된다
|
|
52
181
|
},
|
|
53
182
|
});
|
|
183
|
+
document.querySelector('.ec-submitbar')?.before(overall);
|
|
54
184
|
|
|
55
185
|
// 다시 고치면 그 문항의 결과 색을 지운다 (기존 동작)
|
|
56
186
|
root.addEventListener('input', (e) => clearResult(e.target));
|
|
@@ -58,6 +188,8 @@ function show() {
|
|
|
58
188
|
function clearResult(target) {
|
|
59
189
|
const card = target instanceof Element ? target.closest('[data-role="question"]') : null;
|
|
60
190
|
const i = card ? questions.findIndex((q) => q.id === card.dataset.id) : -1;
|
|
61
|
-
if (i
|
|
191
|
+
if (i < 0 || app.readOnly) return;
|
|
192
|
+
views[i].setResult(null);
|
|
193
|
+
hideOverall();
|
|
62
194
|
}
|
|
63
195
|
}
|