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