@eliceio/cdk-cli 0.1.0-alpha.3 → 0.1.0-alpha.5
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 +288 -200
- package/es/cli.js +70 -66
- package/es/commands/build/index.d.ts +1 -1
- package/es/commands/build/index.js +27 -15
- package/es/commands/create/index.d.ts +5 -1
- package/es/commands/create/index.js +34 -15
- package/es/commands/create/install.d.ts +17 -0
- package/es/commands/create/install.js +53 -0
- package/es/commands/create/scaffold.d.ts +4 -1
- package/es/commands/create/scaffold.js +19 -13
- package/es/commands/dev/index.d.ts +1 -1
- package/es/commands/dev/index.js +5 -5
- package/es/commands/doctor/index.d.ts +29 -2
- package/es/commands/doctor/index.js +253 -55
- package/es/commands/mcp/index.d.ts +0 -12
- package/es/commands/mcp/index.js +6 -57
- package/es/commands/setup/index.d.ts +11 -3
- package/es/commands/setup/index.js +112 -37
- package/es/commands/skill/index.d.ts +46 -8
- package/es/commands/skill/index.js +151 -35
- package/es/commands/uninstall/index.d.ts +54 -0
- package/es/commands/uninstall/index.js +304 -0
- package/es/commands/update/index.d.ts +59 -0
- package/es/commands/update/index.js +251 -0
- package/es/commands/validate/index.d.ts +18 -0
- package/es/commands/{check → validate}/index.js +16 -10
- package/es/core/collect.d.ts +5 -2
- package/es/core/config.d.ts +99 -50
- package/es/core/config.js +244 -91
- package/es/core/latest.d.ts +21 -0
- package/es/core/latest.js +43 -0
- package/es/core/manifest.d.ts +2 -1
- package/es/core/manifest.js +2 -1
- package/es/core/minify.js +2 -2
- package/es/core/prepare.d.ts +18 -2
- package/es/core/prepare.js +48 -16
- package/es/core/project-check.d.ts +19 -8
- package/es/core/project-check.js +36 -9
- package/es/core/sandbox.js +2 -2
- package/es/core/sdk.d.ts +39 -0
- package/es/core/sdk.js +95 -0
- package/es/core/templates.d.ts +2 -4
- package/es/core/templates.js +2 -5
- package/es/dev/grading.d.ts +7 -8
- package/es/dev/grading.js +6 -16
- package/es/dev/host-page.d.ts +1 -1
- package/es/dev/host-page.js +12 -10
- package/es/dev/mock-api.d.ts +13 -18
- package/es/dev/mock-api.js +56 -66
- package/es/dev/server.js +52 -52
- package/es/rules/check.js +43 -31
- package/es/rules/index.d.ts +1 -1
- package/es/rules/index.js +1 -1
- package/es/rules/manifest.d.ts +28 -20
- package/es/rules/manifest.js +58 -55
- package/es/rules/types.d.ts +18 -20
- package/es/rules.json.js +2 -2
- package/es/test-packages.d.ts +7 -0
- package/package.json +3 -4
- package/rules.json +27 -43
- package/skills/_shared/always.md +4 -4
- package/skills/elice-content-check/SKILL.md +11 -8
- package/skills/elice-content-create/SKILL.md +8 -7
- package/skills/elice-content-guide/SKILL.md +42 -0
- package/skills/elice-content-guide/topics/00-what-the-person-decides.md +11 -0
- package/skills/elice-content-guide/topics/01-check-the-environment.md +10 -0
- package/skills/elice-content-guide/topics/02-design-the-material.md +35 -0
- package/skills/elice-content-guide/topics/03-create-the-project.md +22 -0
- package/skills/elice-content-guide/topics/04-rules.md +12 -0
- package/skills/elice-content-guide/topics/05-screen-code.md +101 -0
- package/skills/elice-content-guide/topics/06-using-the-quiz-template.md +22 -0
- package/skills/elice-content-guide/topics/07-move-existing-html.md +10 -0
- package/skills/elice-content-guide/topics/08-fix-check-errors.md +24 -0
- package/skills/elice-content-guide/topics/09-check.md +10 -0
- package/skills/elice-content-guide/topics/10-build.md +8 -0
- package/skills/elice-content-guide/topics/11-more.md +4 -0
- package/skills/elice-content-guide/topics/12-upload-with-the-material-mcp.md +41 -0
- package/skills/elice-content-migrate/SKILL.md +8 -7
- package/skills/elice-content-publish/SKILL.md +8 -7
- package/templates/_shared/lib/cdk-mock.d.ts +5 -13
- package/templates/_shared/lib/cdk-mock.js +49 -144
- package/templates/_shared/lib/elice-content.css +68 -1
- package/templates/_shared/lib/elice-content.d.ts +11 -38
- package/templates/_shared/lib/elice-content.js +43 -248
- package/templates/blank/README.md +12 -10
- package/templates/blank/metadata.json +9 -0
- package/templates/blank/package.json +13 -0
- package/templates/blank/screens/edit.js +1 -1
- package/templates/blank/screens/instructor.js +12 -5
- package/templates/blank/screens/learn.js +16 -11
- package/templates/blank/template.json +2 -2
- package/templates/quiz/README.md +15 -12
- package/templates/quiz/core/behaviors.js +4 -1
- package/templates/quiz/core/editor.d.ts +21 -10
- package/templates/quiz/core/editor.js +44 -31
- package/templates/quiz/core/model.d.ts +14 -0
- package/templates/quiz/core/model.js +76 -4
- package/templates/quiz/metadata.json +9 -0
- package/templates/quiz/package.json +13 -0
- package/templates/quiz/screens/edit.js +101 -34
- package/templates/quiz/screens/instructor.js +18 -12
- package/templates/quiz/screens/learn.js +45 -36
- package/templates/quiz/styles.css +65 -22
- package/templates/quiz/template.json +2 -2
- package/templates/quiz/ui/templates/edit.d.ts +1 -0
- package/templates/quiz/ui/templates/edit.js +65 -19
- package/templates/quiz/ui/templates/group.js +10 -2
- package/templates/quiz/ui/texts.js +11 -11
- package/es/commands/check/index.d.ts +0 -15
- package/es/commands/guide/index.d.ts +0 -29
- package/es/commands/guide/index.js +0 -120
- package/guides/content-development.md +0 -294
- package/templates/_shared/lib/cdk.js +0 -3
- package/templates/blank/completion.html +0 -15
- package/templates/blank/content.json +0 -4
- package/templates/blank/elice.config.json +0 -10
- package/templates/blank/screens/completion.js +0 -7
- package/templates/quiz/content.json +0 -35
- package/templates/quiz/elice.config.json +0 -9
- package/templates/quiz/grading.json +0 -4
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* 화면은 누가 보는지(학생 · 교육자 · 튜터)나 미리보기인지 몰라도 됩니다.
|
|
5
5
|
* 학생 화면: app.useSubmit({ getAnswer, setAnswer, validate })
|
|
6
6
|
* 편집 화면: app.useSave({ getContent, getGrading, validate }) · 채점 방식과 답: app.useGradingBlock() (퀴즈가 아닌 자료)
|
|
7
|
-
* 완료 정책 화면: app.useCompletion() (metadata completionPolicies 안에서 고르고 SDK saveCompletionPolicy로 저장)
|
|
8
7
|
* 여러 단계: app.usePaging({ count, onChange }) (옆 화살표 · n / N, 첫 · 마지막 단계에서 이전 · 다음 자료)
|
|
9
8
|
* 읽기 전용 잠금, 답 복원, 결과·오류 안내, 저장 문구, 로컬 mock 표시는 키트가 합니다.
|
|
10
9
|
*
|
|
@@ -12,7 +11,8 @@
|
|
|
12
11
|
* 제출 · 저장 · 오류 안내를 처리합니다. SDK는 둘 중 하나를 자동으로 고릅니다.
|
|
13
12
|
*
|
|
14
13
|
* real lib/cdk.js (@eliceio/cdk 1.x) 플랫폼에서 열 때 (#token=, 편집기 #preview=1 · #edit=1)
|
|
15
|
-
* 편집 화면은 edit 토큰으로 열려 '저장'이
|
|
14
|
+
* 편집 화면은 edit 토큰으로 열려 '저장'이 자료의 draft에 저장.
|
|
15
|
+
* 학생에게는 LXP 편집 페이지의 '저장'(새 버전)부터 보임
|
|
16
16
|
* mock lib/cdk-mock.js (같은 인터페이스) 그 밖 (로컬): 로컬 채점, 화면 사이 저장 공유
|
|
17
17
|
*
|
|
18
18
|
* 바꾸기: 주소에 ?sdk=mock 또는 ?sdk=real, 또는 start({ screen, sdk: 'mock' })
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
*
|
|
22
22
|
* import { start } from '../lib/elice-content.js';
|
|
23
23
|
* const app = await start({ screen: 'learn' });
|
|
24
|
-
* app.
|
|
24
|
+
* if (!app.hasContent) root.replaceChildren(app.emptyState()) // 편집 화면에서 아직 저장하지 않음
|
|
25
|
+
* app.content // 편집 화면(CMS)이 저장한 내용 (settings, 없으면 {})
|
|
25
26
|
* await app.submit(answer)
|
|
26
27
|
*
|
|
27
28
|
* 정답은 콘텐츠(zip)에 넣지 않습니다. 채점은 서버가 채점 설정(settings.grading)으로 합니다 (ADR 0009).
|
|
28
29
|
* 채점 설정 { type: pattern | rubric, answer_key | rubric }은 편집 화면이 edit 토큰으로 저장하고, 서버는 학생에게
|
|
29
|
-
* settings.grading을 내려주지 않습니다. 완료 정책(on_access · on_submit · on_graded)은
|
|
30
|
-
*
|
|
31
|
-
* 완료 정책 화면이 그 안에서 SDK saveCompletionPolicy로 바꿉니다 (키트 app.completion.get() · set()).
|
|
30
|
+
* settings.grading을 내려주지 않습니다. 완료 정책(on_access · on_submit · on_graded)은 콘텐츠가 다루지 않습니다:
|
|
31
|
+
* LXP에 올린 뒤 설정 탭에서 교육자가 고릅니다 (ADR 0012).
|
|
32
32
|
*/
|
|
33
33
|
|
|
34
34
|
/**
|
|
@@ -41,7 +41,6 @@ const SCREEN_ALLOWED = {
|
|
|
41
41
|
instructor: sdk =>
|
|
42
42
|
(sdk.screen === 'learn' || sdk.screen === 'instructor') && sdk.viewer === 'instructor',
|
|
43
43
|
edit: sdk => sdk.screen === 'edit',
|
|
44
|
-
completionPolicy: sdk => sdk.screen === 'completionPolicy',
|
|
45
44
|
};
|
|
46
45
|
|
|
47
46
|
const MESSAGES = {
|
|
@@ -51,6 +50,8 @@ const MESSAGES = {
|
|
|
51
50
|
rate_limited: '제출이 너무 잦습니다. 잠시 뒤 다시 시도해 주세요.',
|
|
52
51
|
invalid_input: '답이 너무 크거나 형식이 올바르지 않습니다.',
|
|
53
52
|
content_not_ready: '아직 저장된 자료가 없습니다.',
|
|
53
|
+
// 키트만의 문구: 편집 화면이 아직 내용을 저장하지 않음 (기본 내용 파일은 없음)
|
|
54
|
+
content_empty: '아직 내용이 없습니다. 편집 화면에서 내용을 만들어 저장하면 여기에 보입니다.',
|
|
54
55
|
external_service_error: '채점하지 못했어요. 제출이 저장되지 않았으니 다시 제출해 주세요.',
|
|
55
56
|
screen_not_supported: '이 화면에서는 할 수 없는 일입니다.',
|
|
56
57
|
navigation_timeout: '수업 페이지 정보를 받지 못했습니다. 잠시 뒤 다시 시도해 주세요.',
|
|
@@ -59,8 +60,9 @@ const MESSAGES = {
|
|
|
59
60
|
// 서버 코드: 채점 설정(settings.grading) 없이 채점해 완료(on_graded)를 고름
|
|
60
61
|
material_grading_required:
|
|
61
62
|
'채점 방식과 답이 아직 없어 채점해 통과하면 완료로 바꿀 수 없어요. 내용 편집에서 답을 먼저 저장해 주세요.',
|
|
62
|
-
// 서버 코드 (SDK
|
|
63
|
-
|
|
63
|
+
// 서버 코드 (SDK content_not_ready의 cause): 업로드한 draft를 아직 처리 중이거나 처리에 실패함 (409)
|
|
64
|
+
material_draft_not_ready:
|
|
65
|
+
'업로드한 자료를 아직 처리하고 있거나 처리하지 못했어요. 잠시 뒤 다시 저장하고, 계속되면 자료를 다시 올려 주세요.',
|
|
64
66
|
not_initialized: '아직 준비되지 않았습니다.',
|
|
65
67
|
request_failed: '서버와 연결하지 못했습니다. 잠시 뒤 다시 시도해 주세요.',
|
|
66
68
|
// 키트만의 코드: 자료 주소인데 접속 토큰이 없음 (새로고침 · 다른 HTML로 이동하면 SDK가 지운 토큰이 남지 않는다)
|
|
@@ -84,10 +86,10 @@ export class ContentError extends Error {
|
|
|
84
86
|
/** SDK 오류를 화면이 그대로 보여 줄 수 있는 한국어 메시지로 */
|
|
85
87
|
function toContentError(err) {
|
|
86
88
|
if (err instanceof ContentError) return err;
|
|
87
|
-
// 서버 오류 코드는 SDK
|
|
89
|
+
// 서버 오류 코드는 SDK 오류의 cause.cause.code에 있다 (예: 409 MATERIAL_DRAFT_NOT_READY → SDK content_not_ready)
|
|
88
90
|
const serverCode = err?.cause?.cause?.code;
|
|
89
|
-
if (serverCode === '
|
|
90
|
-
return new ContentError('
|
|
91
|
+
if (serverCode === 'MATERIAL_DRAFT_NOT_READY')
|
|
92
|
+
return new ContentError('material_draft_not_ready', MESSAGES.material_draft_not_ready, err);
|
|
91
93
|
if (serverCode === 'MATERIAL_GRADING_REQUIRED')
|
|
92
94
|
return new ContentError('material_grading_required', MESSAGES.material_grading_required, err);
|
|
93
95
|
const code = typeof err?.code === 'string' ? err.code : 'request_failed';
|
|
@@ -112,54 +114,16 @@ export function normalizeGrading(grading) {
|
|
|
112
114
|
return null;
|
|
113
115
|
}
|
|
114
116
|
|
|
115
|
-
/** 완료 정책 값 (서버 material_version.completion_policy) */
|
|
116
|
-
const POLICY_VALUES = Object.freeze(['on_access', 'on_submit', 'on_graded']);
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* 완료 정책 읽기 · 바꾸기. 지금 값은 SDK material.completionPolicy, 지원하는 정책은 material.completionPolicies
|
|
120
|
-
* (metadata completionPolicies. 서버가 아직 돌려주지 않으면 null, G132), 저장은 SDK saveCompletionPolicy
|
|
121
|
-
* (PATCH completion_policy, 완료 정책 화면에서만). 값 이름은 서버와 같은 completion_policy
|
|
122
|
-
* @returns {{ readonly policies: string[] | null, get(): Promise<{ completion_policy: string | null, policies: string[] | null }>, set(policy: string): Promise<void> }}
|
|
123
|
-
*/
|
|
124
|
-
function completionApi(sdk) {
|
|
125
|
-
const listed = () => {
|
|
126
|
-
const policies = sdk.material?.completionPolicies;
|
|
127
|
-
return Array.isArray(policies) && policies.length > 0 ? policies : null;
|
|
128
|
-
};
|
|
129
|
-
return {
|
|
130
|
-
get policies() {
|
|
131
|
-
return listed();
|
|
132
|
-
},
|
|
133
|
-
async get() {
|
|
134
|
-
return { completion_policy: sdk.material?.completionPolicy ?? null, policies: listed() };
|
|
135
|
-
},
|
|
136
|
-
async set(policy) {
|
|
137
|
-
const policies = listed() ?? POLICY_VALUES;
|
|
138
|
-
if (!policies.includes(policy))
|
|
139
|
-
throw new ContentError(
|
|
140
|
-
'invalid_input',
|
|
141
|
-
`이 자료가 지원하지 않는 완료 정책입니다: ${policy} (가능: ${policies.join(', ')})`
|
|
142
|
-
);
|
|
143
|
-
try {
|
|
144
|
-
await sdk.saveCompletionPolicy(policy);
|
|
145
|
-
} catch (err) {
|
|
146
|
-
throw toContentError(err);
|
|
147
|
-
}
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
117
|
/** 로컬 mock에서 화면별 기본 fragment (보는 사람 · 설정 화면) */
|
|
153
118
|
const LOCAL_MOCK_HASH = {
|
|
154
119
|
learn: '',
|
|
155
120
|
instructor: 'viewer=instructor',
|
|
156
121
|
edit: 'scope=edit',
|
|
157
|
-
completionPolicy: 'scope=edit&screen=completionPolicy',
|
|
158
122
|
};
|
|
159
123
|
|
|
160
|
-
/** 토큰 없는 draft: 편집기 미리보기 · 편집 화면
|
|
161
|
-
const DRAFT_HASH = /(?:^#|&)(?:preview|edit
|
|
162
|
-
const LAUNCH_HASH = /(?:^#|&)(?:token|preview|edit
|
|
124
|
+
/** 토큰 없는 draft: 편집기 미리보기 · 편집 화면 */
|
|
125
|
+
const DRAFT_HASH = /(?:^#|&)(?:preview|edit)=1/;
|
|
126
|
+
const LAUNCH_HASH = /(?:^#|&)(?:token|preview|edit)=/;
|
|
163
127
|
|
|
164
128
|
const isLoopback = h => h === 'localhost' || h === '127.0.0.1' || h === '[::1]';
|
|
165
129
|
|
|
@@ -182,7 +146,7 @@ export function pickSdk({ hash, pathname, search, hostname = '' }) {
|
|
|
182
146
|
|
|
183
147
|
/** mock: 주소에 보는 사람 · 미리보기 · 설정 화면이 없으면 화면에 맞게 */
|
|
184
148
|
function mockLaunch(hash, screen) {
|
|
185
|
-
if (/(?:^#|&)(?:viewer|preview|edit|
|
|
149
|
+
if (/(?:^#|&)(?:viewer|preview|edit|scope)=/.test(hash))
|
|
186
150
|
return { hash, pathname: '/', local: true };
|
|
187
151
|
const parts = [LOCAL_MOCK_HASH[screen], hash.replace(/^#/, '')].filter(Boolean);
|
|
188
152
|
return { hash: parts.length ? `#${parts.join('&')}` : '', pathname: '/', local: true };
|
|
@@ -235,12 +199,7 @@ export function resolveLaunch(hash, pathname, screen) {
|
|
|
235
199
|
return { hash, pathname: local ? LOCAL_MATERIAL_PATH : pathname, local };
|
|
236
200
|
}
|
|
237
201
|
return {
|
|
238
|
-
hash:
|
|
239
|
-
screen === 'edit'
|
|
240
|
-
? '#edit=1'
|
|
241
|
-
: screen === 'completionPolicy'
|
|
242
|
-
? '#completionPolicy=1'
|
|
243
|
-
: '#preview=1',
|
|
202
|
+
hash: screen === 'edit' ? '#edit=1' : '#preview=1',
|
|
244
203
|
pathname: LOCAL_MATERIAL_PATH,
|
|
245
204
|
local: true,
|
|
246
205
|
};
|
|
@@ -248,12 +207,11 @@ export function resolveLaunch(hash, pathname, screen) {
|
|
|
248
207
|
|
|
249
208
|
/**
|
|
250
209
|
* @typedef {object} StartOptions
|
|
251
|
-
* @property {'learn' | 'instructor' | 'edit'
|
|
252
|
-
* @property {string} [defaults] 저장된 내용이 없을 때 쓸 내용 파일 (기본 'content.json')
|
|
210
|
+
* @property {'learn' | 'instructor' | 'edit'} screen 이 HTML이 어떤 화면인지
|
|
253
211
|
* @property {(error: ContentError) => void} [onError] 화면 밖 오류(세션 만료 등)를 받을 함수. 기본은 상단 알림
|
|
254
212
|
* @property {'real' | 'mock' | object} [sdk] SDK 고르기 (기본: pickSdk). 객체면 그대로 씀 (테스트)
|
|
255
213
|
* @property {object} [mock] mock 옵션 (scenario, grading, settings, delayMs)
|
|
256
|
-
* @property {(url: string) => Promise<unknown>} [loadJson] 테스트용
|
|
214
|
+
* @property {(url: string) => Promise<unknown>} [loadJson] 테스트용 (mock이 읽는 로컬 파일)
|
|
257
215
|
* @property {string} [hash] 테스트용: location.hash 대신
|
|
258
216
|
* @property {string} [pathname] 테스트용: location.pathname 대신
|
|
259
217
|
* @property {string} [search] 테스트용: location.search 대신
|
|
@@ -266,7 +224,7 @@ export function resolveLaunch(hash, pathname, screen) {
|
|
|
266
224
|
* @param {StartOptions} options
|
|
267
225
|
*/
|
|
268
226
|
export async function start(options) {
|
|
269
|
-
const { screen
|
|
227
|
+
const { screen } = options;
|
|
270
228
|
if (!SCREEN_ALLOWED[screen]) throw new Error(`알 수 없는 화면: ${screen}`);
|
|
271
229
|
const notify = options.onError ?? showBanner;
|
|
272
230
|
|
|
@@ -326,14 +284,12 @@ export async function start(options) {
|
|
|
326
284
|
throw e;
|
|
327
285
|
}
|
|
328
286
|
|
|
329
|
-
// 저장된 settings에서 채점 설정(grading, edit 범위에만 옴)을 떼어 둔다: 화면 내용(content)은 grading
|
|
330
|
-
//
|
|
287
|
+
// 저장된 settings에서 채점 설정(grading, edit 범위에만 옴)을 떼어 둔다: 화면 내용(content)은 grading 없이.
|
|
288
|
+
// 내용은 편집 화면이 저장한 settings뿐이다 (기본 내용 파일은 없음, ADR 0011). 아직 없으면 {}이고 hasContent가 false
|
|
331
289
|
const { grading: rawGrading = null, ...saved } = sdk.material?.settings ?? {};
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
let grading = savedGrading;
|
|
336
|
-
/** 다음 저장의 바탕: 서버에 저장된 settings 그대로 (content.json 기본값은 넣지 않음) */
|
|
290
|
+
let content = saved;
|
|
291
|
+
let grading = normalizeGrading(rawGrading);
|
|
292
|
+
/** 다음 저장의 바탕: 서버에 저장된 settings 그대로 */
|
|
337
293
|
let savedSettings = sdk.material?.settings ?? {};
|
|
338
294
|
|
|
339
295
|
const readOnly = viewer === 'tutor';
|
|
@@ -346,7 +302,7 @@ export async function start(options) {
|
|
|
346
302
|
viewer,
|
|
347
303
|
/** 튜터가 학생 화면을 보는 중 */
|
|
348
304
|
readOnly,
|
|
349
|
-
/**
|
|
305
|
+
/** 편집기의 draft 미리보기 (#preview=1, edit 토큰이 있으면 draft의 내용을 읽음) · 저장 전 업로드의 편집 화면 (#edit=1). 제출을 기록하지 않음 */
|
|
350
306
|
isDraft: Boolean(sdk.isDraft),
|
|
351
307
|
/** 수업 페이지 이동 (previous · next · navigate · getHasPrevious · getHasNext) */
|
|
352
308
|
navigation: sdk.navigation ?? null,
|
|
@@ -362,10 +318,18 @@ export async function start(options) {
|
|
|
362
318
|
get records() {
|
|
363
319
|
return viewer === 'student' && !app.isDraft && kind !== 'mock';
|
|
364
320
|
},
|
|
365
|
-
/** 편집 화면(CMS)이 저장한 내용. 학생에게도 공개되므로 정답을 넣지
|
|
321
|
+
/** 편집 화면(CMS)이 저장한 내용. 학생에게도 공개되므로 정답을 넣지 않는다. 아직 저장하지 않았으면 {} */
|
|
366
322
|
get content() {
|
|
367
323
|
return content;
|
|
368
324
|
},
|
|
325
|
+
/** 편집 화면이 내용을 저장했는지. false면 학생 · 교육자 화면은 emptyState()를 보여 준다 */
|
|
326
|
+
get hasContent() {
|
|
327
|
+
return Object.keys(content).length > 0;
|
|
328
|
+
},
|
|
329
|
+
/** 내용이 없을 때 보여 줄 안내 ("아직 내용이 없습니다 …"). 학생 · 교육자 화면에서 app.hasContent가 false일 때 */
|
|
330
|
+
emptyState() {
|
|
331
|
+
return h('p', { className: 'ec-empty', role: 'status', textContent: MESSAGES.content_empty });
|
|
332
|
+
},
|
|
369
333
|
/**
|
|
370
334
|
* 저장된 채점 설정 `{ type: 'pattern', answer_key }` · `{ type: 'rubric', rubric }` 또는 null.
|
|
371
335
|
* edit 범위(편집 · 완료 정책 화면)에서만 오고, 학생 · 튜터 · 교육자 화면에는 서버가 내려주지 않는다
|
|
@@ -402,7 +366,8 @@ export async function start(options) {
|
|
|
402
366
|
},
|
|
403
367
|
|
|
404
368
|
/**
|
|
405
|
-
* 내용 저장 (편집 화면): SDK saveSettings가 edit 토큰으로
|
|
369
|
+
* 내용 저장 (편집 화면): SDK saveSettings가 edit 토큰으로 자료의 draft에 저장한다. 학생에게는 LXP 편집 페이지에서
|
|
370
|
+
* 저장(새 버전)한 뒤 보인다. 보통은 useSave를 쓴다.
|
|
406
371
|
* nextGrading(채점 설정 `{ type, answer_key | rubric }`)을 주면 settings.grading으로 같이 저장하고,
|
|
407
372
|
* 주지 않으면 저장된 채점 설정을 그대로 둔다
|
|
408
373
|
* @param {Record<string, unknown>} next
|
|
@@ -423,13 +388,6 @@ export async function start(options) {
|
|
|
423
388
|
}
|
|
424
389
|
},
|
|
425
390
|
|
|
426
|
-
/**
|
|
427
|
-
* 완료 정책 (on_access · on_submit · on_graded). settings가 아니라 material_version.completion_policy:
|
|
428
|
-
* policies는 metadata completionPolicies, set은 SDK saveCompletionPolicy (완료 정책 화면에서만).
|
|
429
|
-
* 보통은 완료 정책 화면에서 useCompletion을 쓴다
|
|
430
|
-
*/
|
|
431
|
-
completion: completionApi(sdk),
|
|
432
|
-
|
|
433
391
|
/**
|
|
434
392
|
* 학생 화면의 제출 영역. 화면은 답을 모으고 채우는 방법만 알려 주면, 보는 사람별 처리는 키트가 한다.
|
|
435
393
|
* - 튜터링: 화면을 읽기 전용으로 잠그고 학생 답을 채움, 제출 버튼 없음
|
|
@@ -459,16 +417,6 @@ export async function start(options) {
|
|
|
459
417
|
return mountGradingBlock(app, opts ?? {});
|
|
460
418
|
},
|
|
461
419
|
|
|
462
|
-
/**
|
|
463
|
-
* 완료 정책 화면 (LXP 설정 탭의 완료 정책 영역, ADR 0009). 정책 라디오 · 저장 버튼 · 변경 표시를 키트가 한다.
|
|
464
|
-
* metadata completionPolicies 안의 정책만 보이고, 저장은 app.completion.set (SDK saveCompletionPolicy).
|
|
465
|
-
* completionPolicies가 하나(고정)인 자료는 이 화면을 두지 않는다
|
|
466
|
-
* @param {CompletionOptions} [opts]
|
|
467
|
-
*/
|
|
468
|
-
useCompletion(opts) {
|
|
469
|
-
return mountCompletion(app, opts ?? {});
|
|
470
|
-
},
|
|
471
|
-
|
|
472
420
|
/**
|
|
473
421
|
* 자료 안 여러 단계 이동. 내용 양옆 동그란 화살표 + 안쪽 `n / N` 표시.
|
|
474
422
|
* 첫 단계의 왼쪽 · 마지막 단계의 오른쪽은 LXP 이전 · 다음 수업 자료로 가는 버튼(모양이 다름)이 되고,
|
|
@@ -521,7 +469,6 @@ const appRoot = root => root ?? document.getElementById('app') ?? document.body;
|
|
|
521
469
|
export function statusText(app) {
|
|
522
470
|
if (app.sdkKind !== 'mock') return '';
|
|
523
471
|
if (app.screen === 'edit') return 'mock SDK · 저장 내용은 이 브라우저에만';
|
|
524
|
-
if (app.screen === 'completionPolicy') return 'mock SDK · 완료 정책은 이 브라우저에만';
|
|
525
472
|
const parts = ['mock SDK · 로컬 채점, 서버에 저장되지 않음'];
|
|
526
473
|
if (app.viewer === 'tutor')
|
|
527
474
|
parts.push(`튜터링 · ${app.account?.fullname ?? '학생'}의 화면 (읽기 전용)`);
|
|
@@ -723,7 +670,8 @@ function mountSave(app, { getContent, getGrading, validate, root, label = '저
|
|
|
723
670
|
let dirty = false;
|
|
724
671
|
const markDirty = () => {
|
|
725
672
|
dirty = true;
|
|
726
|
-
//
|
|
673
|
+
// settings는 이 버튼만 저장한다 (LXP 하단 저장은 draft를 새 버전으로 낼 뿐, 화면 안 내용을 가져가지 않음).
|
|
674
|
+
// 그래서 저장 전 상태는 이 문구가 유일한 안내
|
|
727
675
|
status.textContent = '저장하지 않은 변경이 있어요.';
|
|
728
676
|
};
|
|
729
677
|
area.addEventListener('input', markDirty);
|
|
@@ -746,11 +694,11 @@ function mountSave(app, { getContent, getGrading, validate, root, label = '저
|
|
|
746
694
|
if (dirty) e.preventDefault();
|
|
747
695
|
});
|
|
748
696
|
|
|
749
|
-
// 실제 SDK의 saveSettings는 edit 토큰으로
|
|
697
|
+
// 실제 SDK의 saveSettings는 edit 토큰으로 자료의 draft에 저장한다. 학생에게는 LXP 편집 페이지의 저장(새 버전)부터 보인다
|
|
750
698
|
const savedText = () =>
|
|
751
699
|
app.sdkKind === 'mock'
|
|
752
700
|
? '저장했어요 (mock · 이 브라우저에만).'
|
|
753
|
-
:
|
|
701
|
+
: "저장했어요. 학생에게는 편집 페이지에서 '저장'을 누르면 반영됩니다.";
|
|
754
702
|
|
|
755
703
|
button.addEventListener('click', async () => {
|
|
756
704
|
const next = getContent();
|
|
@@ -795,31 +743,6 @@ function mountSave(app, { getContent, getGrading, validate, root, label = '저
|
|
|
795
743
|
* @property {Element} [root] 블록을 넣을 곳 (기본: 화면 영역 #app 바로 뒤)
|
|
796
744
|
*/
|
|
797
745
|
|
|
798
|
-
/**
|
|
799
|
-
* @typedef {object} CompletionOptions
|
|
800
|
-
* @property {Array<'on_access' | 'on_submit' | 'on_graded'>} [policies] 고를 수 있는 완료 정책
|
|
801
|
-
* (기본 metadata completionPolicies, 서버가 주지 않으면 셋 다)
|
|
802
|
-
* @property {Element} [root] 넣을 곳 (기본: 화면 영역 #app을 이 영역으로 채움)
|
|
803
|
-
* @property {string} [label] 버튼 글자 (기본 '저장')
|
|
804
|
-
*/
|
|
805
|
-
|
|
806
|
-
/** 완료 정책 문구 (ADR 0009). 열람 · 제출은 LXP 설정 탭 문구 그대로 (qa5 2026-11-10) */
|
|
807
|
-
export const COMPLETION_POLICIES = Object.freeze({
|
|
808
|
-
on_access: {
|
|
809
|
-
label: '열람 시 학습 완료',
|
|
810
|
-
description: "자료를 열면 학습 완료로 처리됩니다. 학생 화면에는 점수 대신 '완료'로 표시됩니다.",
|
|
811
|
-
},
|
|
812
|
-
on_submit: {
|
|
813
|
-
label: '제출 시 학습 완료',
|
|
814
|
-
description:
|
|
815
|
-
"답과 관계없이 제출하면 학습 완료로 처리됩니다. 학생 화면에는 점수 대신 '완료'로 표시됩니다.",
|
|
816
|
-
},
|
|
817
|
-
on_graded: {
|
|
818
|
-
label: '채점해 통과하면 학습 완료',
|
|
819
|
-
description:
|
|
820
|
-
'제출한 답을 편집 화면에서 정한 채점 방식으로 채점하고, 통과하면 학습 완료로 처리됩니다.',
|
|
821
|
-
},
|
|
822
|
-
});
|
|
823
746
|
|
|
824
747
|
/** 채점 방식 문구 (settings.grading.type, LXP 설정 탭 문구 그대로) */
|
|
825
748
|
export const GRADER_TYPES = Object.freeze({
|
|
@@ -854,14 +777,6 @@ const GRADING_TEXT = {
|
|
|
854
777
|
emptyRubric: '평가 기준을 입력해 주세요.',
|
|
855
778
|
};
|
|
856
779
|
|
|
857
|
-
const COMPLETION_TEXT = {
|
|
858
|
-
heading: '완료 정책',
|
|
859
|
-
headingHelp: '학습 완료를 언제 기록할지 고릅니다: 열면, 제출하면, 채점해 통과하면.',
|
|
860
|
-
grader: name => `채점 방식: ${name} (편집 화면에서 정함)`,
|
|
861
|
-
noGrader: '채점 방식과 답이 아직 없습니다. 편집 화면에서 먼저 정해 주세요.',
|
|
862
|
-
loading: '완료 정책을 불러오는 중…',
|
|
863
|
-
};
|
|
864
|
-
|
|
865
780
|
/** 정답 정규식 길이 상한 (서버에 보내는 값, 너무 긴 정규식은 막는다) */
|
|
866
781
|
export const ANSWER_KEY_MAX = 5000;
|
|
867
782
|
/** 정답 정규식 한 번 맞춰 보는 시간 상한(ms). 넘으면 ReDoS 위험으로 막는다 */
|
|
@@ -1006,126 +921,6 @@ function mountGradingBlock(app, { graders = ['pattern', 'rubric'], examples = GR
|
|
|
1006
921
|
};
|
|
1007
922
|
}
|
|
1008
923
|
|
|
1009
|
-
function mountCompletion(app, { policies = app.completion.policies ?? POLICY_VALUES, root, label = '저장' }) {
|
|
1010
|
-
if (app.screen !== 'completionPolicy')
|
|
1011
|
-
throw new Error('useCompletion은 완료 정책 화면(screen: completionPolicy)에서만 씁니다.');
|
|
1012
|
-
const t = COMPLETION_TEXT;
|
|
1013
|
-
const area = appRoot(root);
|
|
1014
|
-
const name = `ec-completion-${Math.random().toString(36).slice(2, 8)}`;
|
|
1015
|
-
const section = h('section', { className: 'ec-grading' });
|
|
1016
|
-
const head = h('div', { className: 'ec-grading-head' });
|
|
1017
|
-
head.append(
|
|
1018
|
-
h('h2', { textContent: t.heading }),
|
|
1019
|
-
h('p', { className: 'ec-muted', textContent: t.headingHelp })
|
|
1020
|
-
);
|
|
1021
|
-
const group = h('div', { className: 'ec-grading-types', role: 'radiogroup' });
|
|
1022
|
-
group.setAttribute('aria-label', t.heading);
|
|
1023
|
-
section.append(head, group);
|
|
1024
|
-
// 완료 정책 화면은 이 영역이 화면 전부라 기본 영역(#app)의 "불러오는 중"을 비운다. root를 주면 그 뒤에 더한다
|
|
1025
|
-
if (root) area.append(section);
|
|
1026
|
-
else area.replaceChildren(section);
|
|
1027
|
-
|
|
1028
|
-
let current = policies[0];
|
|
1029
|
-
const graderInfo = GRADER_TYPES[app.grading?.type];
|
|
1030
|
-
|
|
1031
|
-
// 채점해 통과(on_graded): 편집 화면이 정한 채점 방식을 보여 준다
|
|
1032
|
-
const gradedDetail = h('div', { className: 'ec-grading-detail' });
|
|
1033
|
-
gradedDetail.append(
|
|
1034
|
-
h('p', {
|
|
1035
|
-
className: graderInfo ? 'ec-muted' : 'ec-error',
|
|
1036
|
-
textContent: graderInfo ? t.grader(graderInfo.label) : t.noGrader,
|
|
1037
|
-
})
|
|
1038
|
-
);
|
|
1039
|
-
|
|
1040
|
-
const cards = policies.map(policy => {
|
|
1041
|
-
const { card, input } = radioCard(name, policy, COMPLETION_POLICIES[policy] ?? { label: policy, description: '' }, policy === current);
|
|
1042
|
-
const wrap = h('div', { className: 'ec-grading-item' });
|
|
1043
|
-
wrap.append(card);
|
|
1044
|
-
if (policy === 'on_graded') wrap.append(gradedDetail);
|
|
1045
|
-
input.addEventListener('change', () => select(policy));
|
|
1046
|
-
group.append(wrap);
|
|
1047
|
-
return { policy, card, input };
|
|
1048
|
-
});
|
|
1049
|
-
function select(policy) {
|
|
1050
|
-
current = policy;
|
|
1051
|
-
for (const c of cards) {
|
|
1052
|
-
c.card.classList.toggle('selected', c.policy === policy);
|
|
1053
|
-
c.input.checked = c.policy === policy;
|
|
1054
|
-
}
|
|
1055
|
-
gradedDetail.hidden = policy !== 'on_graded';
|
|
1056
|
-
}
|
|
1057
|
-
select(current);
|
|
1058
|
-
|
|
1059
|
-
const status = h('p', { className: 'ec-muted', role: 'status', textContent: t.loading });
|
|
1060
|
-
const error = h('p', { className: 'ec-error', role: 'alert' });
|
|
1061
|
-
const button = h('button', { className: 'ec-primary', type: 'button', textContent: label, disabled: true });
|
|
1062
|
-
const bar = h('div', { className: 'ec-submitbar' });
|
|
1063
|
-
bar.append(status, error, button);
|
|
1064
|
-
area.after(bar);
|
|
1065
|
-
|
|
1066
|
-
let dirty = false;
|
|
1067
|
-
const markDirty = () => {
|
|
1068
|
-
dirty = true;
|
|
1069
|
-
status.textContent = '저장하지 않은 변경이 있어요.';
|
|
1070
|
-
};
|
|
1071
|
-
area.addEventListener('input', markDirty);
|
|
1072
|
-
area.addEventListener('change', markDirty);
|
|
1073
|
-
globalThis.addEventListener?.('beforeunload', e => {
|
|
1074
|
-
if (dirty) e.preventDefault();
|
|
1075
|
-
});
|
|
1076
|
-
|
|
1077
|
-
// 지금 완료 정책 (완료 정책 API · ecdk dev 흉내). 지원되지 않으면 저장을 막고 이유를 보여 준다
|
|
1078
|
-
const ready = app.completion.get().then(
|
|
1079
|
-
({ completion_policy: policy }) => {
|
|
1080
|
-
if (policies.includes(policy)) select(policy);
|
|
1081
|
-
status.textContent = '';
|
|
1082
|
-
button.disabled = false;
|
|
1083
|
-
},
|
|
1084
|
-
e => {
|
|
1085
|
-
status.textContent = '';
|
|
1086
|
-
error.textContent = e.message;
|
|
1087
|
-
}
|
|
1088
|
-
);
|
|
1089
|
-
|
|
1090
|
-
const savedText = () =>
|
|
1091
|
-
app.sdkKind === 'mock'
|
|
1092
|
-
? '저장했어요 (mock · 이 브라우저에만).'
|
|
1093
|
-
: '저장했어요. 다음 제출부터 이 완료 정책을 씁니다.';
|
|
1094
|
-
|
|
1095
|
-
button.addEventListener('click', async () => {
|
|
1096
|
-
if (current === 'on_graded' && !graderInfo) {
|
|
1097
|
-
error.textContent = t.noGrader;
|
|
1098
|
-
return;
|
|
1099
|
-
}
|
|
1100
|
-
error.textContent = '';
|
|
1101
|
-
button.disabled = true;
|
|
1102
|
-
button.setAttribute('aria-busy', 'true');
|
|
1103
|
-
try {
|
|
1104
|
-
await app.completion.set(current);
|
|
1105
|
-
dirty = false;
|
|
1106
|
-
status.textContent = savedText();
|
|
1107
|
-
} catch (e) {
|
|
1108
|
-
status.textContent = '';
|
|
1109
|
-
error.textContent = e.message;
|
|
1110
|
-
} finally {
|
|
1111
|
-
button.disabled = false;
|
|
1112
|
-
button.removeAttribute('aria-busy');
|
|
1113
|
-
}
|
|
1114
|
-
});
|
|
1115
|
-
return {
|
|
1116
|
-
element: bar,
|
|
1117
|
-
/** 지금 완료 정책을 불러온 뒤 끝나는 Promise */
|
|
1118
|
-
ready,
|
|
1119
|
-
get policy() {
|
|
1120
|
-
return current;
|
|
1121
|
-
},
|
|
1122
|
-
markDirty,
|
|
1123
|
-
get dirty() {
|
|
1124
|
-
return dirty;
|
|
1125
|
-
},
|
|
1126
|
-
};
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
924
|
function showBanner(error) {
|
|
1130
925
|
if (typeof document === 'undefined') return;
|
|
1131
926
|
let el = document.getElementById('elice-banner');
|
|
@@ -9,17 +9,19 @@ Elice Custom HTML 학습자료 프로젝트입니다.
|
|
|
9
9
|
| `screens/learn.js` · `index.html` | 학생 화면 |
|
|
10
10
|
| `screens/instructor.js` · `instructor.html` | 교육자 화면 |
|
|
11
11
|
| `screens/edit.js` · `edit.html` | 내용 편집 화면 (CMS) |
|
|
12
|
-
| `screens/completion.js` · `completion.html` | 완료 정책 화면 (교육자가 고름, 고칠 일 거의 없음) |
|
|
13
|
-
| `content.json` | 처음 내용. 편집 화면에서 저장하면 저장한 내용을 씁니다 |
|
|
14
12
|
| `styles.css` | 이 콘텐츠의 스타일 |
|
|
15
|
-
| `
|
|
13
|
+
| `metadata.json` | 화면 구성(`screens`) · 학습 참고 내용(`commentary`). `ecdk build`가 `build`만 채움 |
|
|
14
|
+
| `package.json` | SDK 버전(`@eliceio/cdk`) · 빌드 옵션 `"ecdk"` (`minify` 등). zip에 들어가지 않음 |
|
|
16
15
|
|
|
17
|
-
`
|
|
16
|
+
이 프로젝트는 **템플릿(화면 · 코드)만** 만듭니다. 실제 내용과 정답은 LXP에 올린 뒤 편집 화면에서 입력합니다. `ecdk dev`의 내용 편집에서 넣은 것은 화면을 시험하는 견본이고 `.ecdk/settings.json`에만 남으며 올라가지 않습니다. 내용은 편집 화면이 저장한 것(`settings`)뿐입니다. 기본 내용 파일은 없어서, 편집 화면에서 저장하기 전에는 학생 · 교육자 화면이 "아직 내용이 없습니다" 안내를 보입니다 (`app.hasContent` · `app.emptyState()`).
|
|
17
|
+
|
|
18
|
+
`lib/`(화면 키트)는 플랫폼 연결 로직이라 고치지 않습니다. SDK(`lib/cdk.js`)는 프로젝트에 없고 `ecdk build` · `ecdk dev`가 `node_modules/@eliceio/cdk`에서 넣습니다 (처음 한 번 `npm install`, 올리기 `npm update @eliceio/cdk`). 화면은 **누가 보는지(학생 · 교육자 · 튜터)나 미리보기인지 몰라도 됩니다.**
|
|
18
19
|
|
|
19
20
|
```js
|
|
20
21
|
// 학생 화면: 문항을 그리고 답을 모으고 채우는 방법만 알려 준다
|
|
21
22
|
const app = await start({ screen: 'learn' });
|
|
22
|
-
render(app.content);
|
|
23
|
+
if (app.hasContent) render(app.content);
|
|
24
|
+
else root.replaceChildren(app.emptyState()); // 편집 화면에서 아직 저장하지 않음
|
|
23
25
|
app.useSubmit({ getAnswer, setAnswer, validate });
|
|
24
26
|
|
|
25
27
|
// 여러 단계(슬라이드 · STEP)인 자료: 양옆 화살표와 n / N을 키트가 그린다.
|
|
@@ -48,8 +50,8 @@ app.useSave({ getContent, validate });
|
|
|
48
50
|
|
|
49
51
|
| 언제 | SDK | 채점 · 저장 |
|
|
50
52
|
| --------------------------------------------- | -------------------------------- | ----------------------------------------------------------------------------- |
|
|
51
|
-
| 플랫폼에서 열 때 (`#token=`, 편집기 draft) | real (`lib/cdk.js
|
|
52
|
-
| 그 밖 (로컬) | mock (`lib/cdk-mock.js`) |
|
|
53
|
+
| 플랫폼에서 열 때 (`#token=`, 편집기 draft) | real (`lib/cdk.js`, build가 넣음) | 서버 |
|
|
54
|
+
| 그 밖 (로컬) | mock (`lib/cdk-mock.js`) | 편집 화면이 저장한 정답으로 로컬 채점 (정답이 없으면 제출만 받음), 저장 내용·제출은 이 브라우저에 (프로젝트 폴더를 열면 `.ecdk/settings.json`으로 시작) |
|
|
53
55
|
|
|
54
56
|
- 강제로 바꾸기: 주소에 `?sdk=mock` 또는 `?sdk=real`
|
|
55
57
|
- 보는 사람 바꾸기 (mock): `#viewer=tutor` (`student` · `instructor` · `tutor`), 편집기 draft 흉내: `#preview=1` · `#edit=1`
|
|
@@ -58,11 +60,11 @@ app.useSave({ getContent, validate });
|
|
|
58
60
|
|
|
59
61
|
## 정답
|
|
60
62
|
|
|
61
|
-
정답은 zip에 넣지 않습니다 (ADR 0009, `
|
|
63
|
+
정답은 zip에 넣지 않습니다 (ADR 0009, 개발 가이드 스킬 `elice-content-guide`의 `topics/02-design-the-material.md` · `05-screen-code.md`).
|
|
62
64
|
|
|
63
65
|
- **채점 방식 · 답**: 답을 채점하는 자료면 편집 화면에 키트의 채점 블록을 붙입니다: `const grading = app.useGradingBlock();` 후 `app.useSave({ …, getGrading: () => grading.getGrading() })`. LXP와 같은 문구로 기준 답안(정규표현식) · 평가 기준을 받아 `settings.grading`에 저장합니다 (학생에게는 내려가지 않음).
|
|
64
|
-
- **완료 정책**:
|
|
65
|
-
-
|
|
66
|
+
- **완료 정책**: 완료 정책은 LXP에 올린 뒤 설정 탭에서 교육자가 고릅니다 (열면 완료 · 제출하면 완료 · 채점해 통과하면 완료, ADR 0012). 프로젝트에는 적지 않습니다. 교육자가 '제출하면 완료' · '채점해 완료'를 고를 수 있게 하려면 학생 화면에 제출(`app.useSubmit`)을, '채점해 완료'까지 고를 수 있게 하려면 편집 화면에 채점 블록(위)을 둡니다.
|
|
67
|
+
- `ecdk dev`의 내용 편집에서 저장한 내용 · 채점 설정(`{ "type": "pattern", "answer_key": "^…$" }` · `{ "type": "rubric", "rubric": "…" }`)은 `.ecdk/settings.json`에 남고 로컬 채점에 쓰입니다 (채점 설정이 없으면 제출만 받음). `ecdk build`가 zip에서 뺍니다. 정답 파일은 없습니다 (ADR 0011).
|
|
66
68
|
|
|
67
69
|
## 명령
|
|
68
70
|
|
|
@@ -15,7 +15,7 @@ const message = Object.assign(document.createElement('textarea'), {
|
|
|
15
15
|
});
|
|
16
16
|
root.replaceChildren(title, message);
|
|
17
17
|
|
|
18
|
-
// 답을 채점하는 자료면 채점 방식 · 답 블록을 붙이고 getGrading을 넘깁니다 (ADR 0009,
|
|
18
|
+
// 답을 채점하는 자료면 채점 방식 · 답 블록을 붙이고 getGrading을 넘깁니다 (ADR 0009, 개발 가이드 스킬 elice-content-guide topics/05-screen-code.md):
|
|
19
19
|
// const grading = app.useGradingBlock();
|
|
20
20
|
// app.useSave({ getContent, validate, getGrading: () => grading.getGrading() });
|
|
21
21
|
app.useSave({
|
|
@@ -2,8 +2,15 @@
|
|
|
2
2
|
import { start } from '../lib/elice-content.js';
|
|
3
3
|
|
|
4
4
|
const app = await start({ screen: 'instructor' });
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const root = document.getElementById('app');
|
|
6
|
+
// 편집 화면에서 아직 내용을 저장하지 않았으면 안내만 보인다
|
|
7
|
+
if (app.hasContent) show();
|
|
8
|
+
else root.replaceChildren(app.emptyState());
|
|
9
|
+
|
|
10
|
+
function show() {
|
|
11
|
+
const title = document.createElement('h1');
|
|
12
|
+
title.textContent = `${app.content.title ?? ''} · 교육자 화면`;
|
|
13
|
+
const message = document.createElement('p');
|
|
14
|
+
message.textContent = app.content.message ?? '';
|
|
15
|
+
root.replaceChildren(title, message);
|
|
16
|
+
}
|
|
@@ -4,16 +4,21 @@ import { start } from '../lib/elice-content.js';
|
|
|
4
4
|
|
|
5
5
|
const app = await start({ screen: 'learn' });
|
|
6
6
|
const root = document.getElementById('app');
|
|
7
|
+
// 편집 화면에서 아직 내용을 저장하지 않았으면 안내만 보인다 (기본 내용은 없음)
|
|
8
|
+
if (app.hasContent) show();
|
|
9
|
+
else root.replaceChildren(app.emptyState());
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
function show() {
|
|
12
|
+
const title = Object.assign(document.createElement('h1'), { textContent: app.content.title ?? '' });
|
|
13
|
+
const message = Object.assign(document.createElement('p'), {
|
|
14
|
+
textContent: app.content.message ?? '',
|
|
15
|
+
});
|
|
16
|
+
const answer = Object.assign(document.createElement('textarea'), { ariaLabel: '답' });
|
|
17
|
+
root.replaceChildren(title, message, answer);
|
|
14
18
|
|
|
15
|
-
app.useSubmit({
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
19
|
+
app.useSubmit({
|
|
20
|
+
getAnswer: () => ({ text: answer.value }),
|
|
21
|
+
setAnswer: (a) => (answer.value = a?.text ?? ''),
|
|
22
|
+
validate: (a) => a.text.trim() !== '' || '답을 입력해 주세요.',
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blank",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"title": "빈 자료",
|
|
5
|
-
"description": "퀴즈가 아닌 모든 자료(시뮬레이션 · 시각화 · 활동 · 설명 · 플래시카드 · 설문)를 직접 만들 때. 학생 · 교육자 · 편집
|
|
5
|
+
"description": "퀴즈가 아닌 모든 자료(시뮬레이션 · 시각화 · 활동 · 설명 · 플래시카드 · 설문)를 직접 만들 때. 학생 · 교육자 · 편집 화면 골격 (완료 정책은 LXP 설정 탭에서 교육자가 고름)"
|
|
6
6
|
}
|