@eliceio/cdk-cli 1.1.0 → 1.2.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 +65 -38
- package/es/cli.js +35 -2
- package/es/commands/create/index.js +2 -2
- package/es/commands/dev/index.d.ts +8 -3
- package/es/commands/dev/index.js +72 -3
- package/es/commands/doctor/index.d.ts +1 -1
- package/es/commands/doctor/index.js +10 -13
- package/es/commands/setup/index.d.ts +1 -1
- package/es/commands/setup/index.js +4 -3
- package/es/commands/uninstall/index.d.ts +1 -1
- package/es/commands/uninstall/index.js +7 -30
- package/es/core/config.d.ts +2 -2
- package/es/core/config.js +2 -2
- package/es/core/skills.d.ts +22 -4
- package/es/core/skills.js +89 -17
- package/es/dev/browser.d.ts +22 -0
- package/es/dev/browser.js +105 -0
- package/es/dev/check.d.ts +84 -0
- package/es/dev/check.js +326 -0
- package/es/dev/host-page.js +10 -0
- package/es/dev/mock-api.js +1 -1
- package/es/dev/server.d.ts +2 -0
- package/es/dev/server.js +1 -0
- package/es/rules/check.js +1 -1
- package/es/rules/manifest.d.ts +1 -1
- package/es/rules/manifest.js +2 -2
- package/es/test-old-skill.d.ts +5 -0
- package/package.json +3 -2
- package/skills/_shared/always.md +13 -5
- package/skills/{elice-content-guide/topics → _shared/references}/00-what-the-person-decides.md +2 -2
- package/skills/{elice-content-guide/topics → _shared/references}/02-design-the-material.md +13 -4
- package/skills/{elice-content-guide/topics → _shared/references}/03-create-the-project.md +2 -2
- package/skills/_shared/references/05-screen-code.md +169 -0
- package/skills/{elice-content-guide/topics → _shared/references}/06-using-the-quiz-template.md +4 -3
- package/skills/{elice-content-guide/topics → _shared/references}/07-move-existing-html.md +1 -1
- package/skills/_shared/references/08-fix-check-errors.md +28 -0
- package/skills/_shared/references/09-check.md +29 -0
- package/skills/_shared/references/10-build.md +8 -0
- package/skills/_shared/references/12-upload-with-the-material-mcp.md +83 -0
- package/skills/elice-content-check/SKILL.md +7 -9
- package/skills/elice-content-create/SKILL.md +12 -10
- package/skills/elice-content-migrate/SKILL.md +10 -8
- package/skills/elice-content-publish/SKILL.md +10 -8
- package/templates/_shared/lib/cdk-mock.d.ts +1 -1
- package/templates/_shared/lib/cdk-mock.js +2 -2
- package/templates/_shared/lib/elice-content.css +1 -1
- package/templates/_shared/lib/elice-content.d.ts +1 -1
- package/templates/_shared/lib/elice-content.js +35 -18
- package/templates/blank/README.md +24 -21
- package/templates/blank/screens/edit.js +1 -1
- package/templates/blank/template.json +1 -1
- package/templates/quiz/README.md +8 -7
- package/templates/quiz/core/editor.js +141 -4
- package/templates/quiz/core/model.js +4 -3
- package/templates/quiz/metadata.json +1 -1
- package/templates/quiz/screens/edit.js +673 -162
- package/templates/quiz/screens/learn.js +1 -1
- package/templates/quiz/styles.css +557 -73
- package/templates/quiz/template.json +2 -2
- package/templates/quiz/ui/templates/edit.d.ts +1 -1
- package/templates/quiz/ui/templates/edit.js +417 -76
- package/templates/quiz/ui/templates/page.js +2 -17
- package/templates/quiz/ui/templates/question.js +1 -1
- package/templates/quiz/ui/texts.js +40 -27
- package/skills/elice-content-guide/SKILL.md +0 -42
- package/skills/elice-content-guide/topics/05-screen-code.md +0 -132
- package/skills/elice-content-guide/topics/08-fix-check-errors.md +0 -27
- package/skills/elice-content-guide/topics/09-check.md +0 -11
- package/skills/elice-content-guide/topics/10-build.md +0 -8
- package/skills/elice-content-guide/topics/12-upload-with-the-material-mcp.md +0 -41
- package/templates/quiz/instructor.html +0 -17
- package/templates/quiz/screens/instructor.js +0 -33
- /package/skills/{elice-content-guide/topics → _shared/references}/01-check-the-environment.md +0 -0
- /package/skills/{elice-content-guide/topics → _shared/references}/04-rules.md +0 -0
- /package/skills/{elice-content-guide/topics → _shared/references}/11-more.md +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: elice-content-publish
|
|
3
|
-
description: Upload an Elice Custom HTML learning material to LXP with the elice-material MCP - build the zip with ecdk, pick or create the lecture page, upload, check the draft and save it as a new version after the person approves. Use when the person asks to upload, publish, deploy or update an Elice or LXP material made with ecdk.
|
|
3
|
+
description: Upload an Elice Custom HTML learning material to LXP with the elice-material MCP - build the zip with ecdk, pick or create the lecture page, upload (with the content, answers and completion policy when the person agrees), check the draft and save it as a new version after the person approves. Use when the person asks to upload, publish, deploy or update an Elice or LXP material made with ecdk.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Upload an Elice learning material
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Reference files are in `references/` in this skill's folder (see Always). Read `references/12-upload-with-the-material-mcp.md` first. It has the tool order, arguments and error handling.
|
|
9
9
|
|
|
10
10
|
{{always}}
|
|
11
11
|
|
|
@@ -13,11 +13,13 @@ Read guide topics with the Read tool from the sibling `elice-content-guide` skil
|
|
|
13
13
|
|
|
14
14
|
1. **MCP ready?** The `elice-material` tools must be available. If not, ask the person to run `ecdk setup --only mcp` and log in (Claude Code `/mcp` → elice-material → Authenticate, Helpy Code `⌘ ;`), then stop.
|
|
15
15
|
2. **Build.** `ecdk build --json` must return `ok: true`. Keep `zip` and `zipBytes`.
|
|
16
|
-
3. **
|
|
17
|
-
4. **
|
|
18
|
-
5. **
|
|
19
|
-
6. **
|
|
20
|
-
7. **
|
|
21
|
-
8. **
|
|
16
|
+
3. **Content and answers.** Check whether the input schema of `save_draft` (or `update_material`) lists `settings` as a key of `payload` (on an older server, a top-level parameter). If it does and this project has `.ecdk/settings.json`: make sure the edit screen saved it (the person saves the edit view in `ecdk dev`; a file you wrote by hand must go through that save), show a short summary (title, number of questions or items, answers included or not and `grading.type`, never the answer values) and ask for an explicit yes to send it with the upload. `settings` replaces the page's settings as a whole: on a page that already has a version, compare `get_material`'s settings with the file first, and if keys would disappear or the LXP content differs (an instructor edited it in LXP), show the difference briefly and ask before overwriting (a new page needs no comparison). No file: suggest filling the edit view in `ecdk dev` first, or skip it. No `settings` key, or the person says no: zip only (the fallback). Details: `references/12-upload-with-the-material-mcp.md` "Content and answers (settings)".
|
|
17
|
+
4. **Completion policy.** If `save_draft` (or `update_material`) lists `completion_policy` in its input schema (in `payload`), propose one (`references/12-upload-with-the-material-mcp.md` "Completion policy"): graded (the quiz template, or settings with `grading`) → `on_graded`, submits without grading → `on_submit`, no submission → `on_access`. `on_graded` only when the same save carries `settings` with `grading` (or the page already has grading); otherwise no policy at the first save, or `on_submit` if the person wants it (ask). Tell the person that only `on_graded` grades: `on_submit` completes on any submission without grading ("제출했어요."), `on_access` completes on open. The policy is a page setting and applies at once.
|
|
18
|
+
5. **Pick the page and confirm it.** Candidates: `.ecdk/link.json`, the LXP edit URL the person gives (`https://{org}.…/lecturepages/{id}/edit`), or the person's choice from `list_my_organizations` → `list_courses` → `list_lectures` → `list_custom_pages`. Never pick a page yourself (not the first in a list, not a guess by title, not a page from another project); if the answer is ambiguous, ask again. Before any upload call (`create_package_upload`, `submit_package`), show the full target, 기관 · 과목 · 수업 · 페이지 with names and ids, its LXP edit URL, whether content and answers go with it and the completion policy to set (the page's current one too), then wait for an explicit yes. Do this every time: also for `.ecdk/link.json` (and compare its `version_id` with `get_material`) and for a URL the person gave (confirm the names it resolves to). `.ecdk/link.json` and an edit URL give only the org's `name_short`: get the 기관 name from `list_my_organizations` and the 과목 · 수업 · 페이지 names from `get_material`. A new page (`create_custom_page`) needs its own yes that names the 수업 it goes into. If the page already has content or answers saved in LXP, say that sending settings replaces them and ask again.
|
|
19
|
+
6. **Upload.** `get_material` (keep `current_version.id`) → `create_package_upload` with `size_bytes = zipBytes` → run its `curl_command` with `package.zip` replaced by the zip path → `submit_package` → poll `get_draft` until ready or failed. On failure, report the server's reason with `ecdk validate dist/content.zip` and stop.
|
|
20
|
+
7. **Approve.** Show what changes (page, title, whether the content and answers go with it or are entered on the LXP edit screen after saving, the completion policy) and the draft `preview_urls`. Saving is visible to learners at once if the page is open. Wait for an explicit yes.
|
|
21
|
+
8. **Save.** One `save_draft` with `material_draft_id`, `expected_current_version_id` and `payload` holding only keys its schema lists: `settings` (the content of `.ecdk/settings.json`) only when step 3 got a yes, `completion_policy` only when step 4 got a yes, and `title` · `icon` when the page has none (a new page; icon: `references/12-upload-with-the-material-mcp.md` "Icon"), all in this one save so no extra version is made. On `MATERIAL_CHANGED` or `MATERIAL_GRADING_REQUIRED`, stop and tell the person (`references/12-upload-with-the-material-mcp.md` "Errors and warnings").
|
|
22
|
+
9. **Check.** Show any `warnings` in the result to the person close to word for word. `get_material` must show what was sent: the settings (same keys, item count and `grading.type` as the summary), the completion policy, the title. If not, tell the person and use the fallback. Without settings: tell the person to enter the content and answers in the LXP edit screen, save with its own button, then press '수업 자료에 반영' at the top of the LXP edit page (`references/12-upload-with-the-material-mcp.md` "Fallback"); for a graded material, then pick 답안 확인 후 완료 in the '설정' panel at the top of the LXP edit page, or offer to set `on_graded` with `update_material` (when it takes `completion_policy`) once `get_material` shows the grading. No `completion_policy` key: tell the person which policy to pick in that '설정' panel. `update_material` stopping with `MATERIAL_DRAFT_PENDING`: someone's upload is not saved; explain and ask whether to save it (`save_draft`) or discard it (`discard_draft`), never pick for them.
|
|
23
|
+
10. **Finish.** Write `.ecdk/link.json` as `{ "org": …, "lecture_page_id": …, "version_id": … }` so the next upload goes to the same page. Report 기관 · 과목 · 수업 · 페이지 (names and ids), the LXP URL, the saved version, whether content and answers were sent, the completion policy (only `on_graded` grades: a quiz with `on_submit` completes on any submission and shows "제출했어요.", not a score), any `warnings`, and whether the page is closed to learners (a new page stays closed until the person opens it in LXP). Later changes to the title, icon, settings or policy of this page without a new zip go through `update_material`.
|
|
22
24
|
|
|
23
25
|
{{version}}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export type Scope = 'learn' | 'edit';
|
|
3
3
|
export type Viewer = 'student' | 'instructor' | 'tutor';
|
|
4
4
|
export type Screen = 'learn' | 'instructor' | 'edit';
|
|
5
|
-
/** 완료 정책 (LXP 설정
|
|
5
|
+
/** 완료 정책 (LXP 자료 편집 화면의 '설정'에서 교육자가 고름, ADR 0012). mock은 흉내 내지 않아 늘 null */
|
|
6
6
|
export type CompletionPolicy = 'on_access' | 'on_submit' | 'on_graded';
|
|
7
7
|
|
|
8
8
|
export declare const ErrorCode: Readonly<{
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* 서버 없이 화면을 시험할 때 키트가 대신 씁니다. 실제 SDK와 다른 점:
|
|
5
5
|
* - 채점: 편집 화면이 저장한 채점 설정(settings.grading { type: pattern | rubric })이 있으면 로컬 채점, 없으면 제출만 받음.
|
|
6
6
|
* pattern 답은 정규식 하나, 답 문자열 전체 일치. 프로젝트 폴더를 그대로 열면 ecdk dev가 저장한 .ecdk/settings.json으로 시작
|
|
7
|
-
* - 완료 정책: 흉내 내지 않는다 (LXP에 올린 뒤 설정
|
|
7
|
+
* - 완료 정책: 흉내 내지 않는다 (LXP에 올린 뒤 자료 편집 화면의 '설정'에서 교육자가 고름, ADR 0012). material.completionPolicy는 null
|
|
8
8
|
* - 저장: 설정 화면이 저장한 내용과 제출 기록을 브라우저에 남겨 다른 화면에서도 보임
|
|
9
9
|
* (sandbox라 저장소가 막히면 이 페이지 안에서만)
|
|
10
10
|
* - 보는 사람: 주소에 #viewer=student | instructor | tutor (mock 전용, 기본 student)
|
|
@@ -455,7 +455,7 @@ export class MockEliceCDK {
|
|
|
455
455
|
const prev = this.#store.get('result', null);
|
|
456
456
|
const score = res.score ?? prev?.score ?? null;
|
|
457
457
|
// 기록의 완료 시각: 채점 설정이 있으면 통과(pattern 100점 · rubric 흉내 점수)해야, 없으면 제출만으로
|
|
458
|
-
// (운영에서 완료 여부는 LXP 설정
|
|
458
|
+
// (운영에서 완료 여부는 LXP '설정'의 완료 정책이 정한다)
|
|
459
459
|
const completed = res.isCorrect === true || !this.#effectiveGrading();
|
|
460
460
|
this.#store.set('result', {
|
|
461
461
|
score,
|
|
@@ -265,7 +265,7 @@ button:disabled {
|
|
|
265
265
|
max-width: 720px;
|
|
266
266
|
margin-inline: auto;
|
|
267
267
|
}
|
|
268
|
-
/* 편집 화면 채점 방식 블록 (useGradingBlock): LXP
|
|
268
|
+
/* 편집 화면 채점 방식 블록 (useGradingBlock): LXP 채점 설정과 같은 모양.
|
|
269
269
|
제목 h6 · 설명 body2 secondary, 방식마다 EDS 라디오 카드(테두리 1px, 고르면 primary 테두리 · primary-opacity02 바탕) */
|
|
270
270
|
.ec-grading {
|
|
271
271
|
display: flex;
|
|
@@ -81,7 +81,7 @@ export interface GradingBlockOptions {
|
|
|
81
81
|
root?: Element;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
/** 채점 방식 문구 (LXP 설정
|
|
84
|
+
/** 채점 방식 문구 (LXP 채점 설정 문구 그대로) */
|
|
85
85
|
export declare const GRADER_TYPES: Readonly<Record<GraderType, { label: string; description: string }>>;
|
|
86
86
|
/** '작성 예시 보기' 기본 예시 [정규식, 뜻] */
|
|
87
87
|
export declare const GRADING_EXAMPLES: ReadonlyArray<[string, string]>;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* real @eliceio/cdk 1.x (package.json) 플랫폼에서 열 때 (#token=, 편집기 #preview=1 · #edit=1)
|
|
15
15
|
* ecdk build가 이 화면 코드와 함께 번들로 묶음
|
|
16
16
|
* 편집 화면은 edit 토큰으로 열려 '저장'이 자료의 draft에 저장.
|
|
17
|
-
* 학생에게는 LXP 편집 페이지의 '
|
|
17
|
+
* 학생에게는 LXP 편집 페이지의 '수업 자료에 반영'(새 버전)부터 보임
|
|
18
18
|
* mock lib/cdk-mock.js (같은 인터페이스) 그 밖 (로컬): 로컬 채점, 화면 사이 저장 공유
|
|
19
19
|
*
|
|
20
20
|
* 바꾸기: 주소에 ?sdk=mock 또는 ?sdk=real, 또는 start({ screen, sdk: 'mock' })
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
* 정답은 콘텐츠(zip)에 넣지 않습니다. 채점은 서버가 채점 설정(settings.grading)으로 합니다 (ADR 0009).
|
|
31
31
|
* 채점 설정 { type: pattern | rubric, answer_key | rubric }은 편집 화면이 edit 토큰으로 저장하고, 서버는 학생에게
|
|
32
32
|
* settings.grading을 내려주지 않습니다. 완료 정책(on_access · on_submit · on_graded)은 콘텐츠가 다루지 않습니다:
|
|
33
|
-
* LXP에 올린 뒤 설정
|
|
33
|
+
* LXP에 올린 뒤 자료 편집 화면의 '설정'에서 교육자가 고릅니다 (ADR 0012).
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
36
|
/**
|
|
@@ -405,7 +405,7 @@ export async function start(options) {
|
|
|
405
405
|
},
|
|
406
406
|
|
|
407
407
|
/**
|
|
408
|
-
* 편집 화면의 채점 방식 · 답 블록 (퀴즈가 아닌 자료, ADR 0009). LXP
|
|
408
|
+
* 편집 화면의 채점 방식 · 답 블록 (퀴즈가 아닌 자료, ADR 0009). LXP 채점 설정과 같은 문구로 채점 방식(기준 답안 정규식 ·
|
|
409
409
|
* 평가 기준)을 고르고 입력한다. 돌려준 getGrading을 useSave({ getGrading })에 넘기면 내용과 함께 저장된다.
|
|
410
410
|
* 퀴즈처럼 문항 구조가 있는 화면은 이 블록 대신 문항별로 답을 받아 정규식을 만든다
|
|
411
411
|
* @param {GradingBlockOptions} [opts]
|
|
@@ -487,6 +487,8 @@ function showStatus(app) {
|
|
|
487
487
|
function resultText(r) {
|
|
488
488
|
// 점수 없는 채점(manual · none): 교육자가 매긴 점수는 나중에 결과로 보인다
|
|
489
489
|
if (r.score === null || r.score === undefined) return '제출했어요.';
|
|
490
|
+
// 채점하지 않는 완료 정책(열람 · 제출 시 완료): 서버가 isCorrect null과 완료 점수를 준다. 맞고 틀림을 말하지 않는다
|
|
491
|
+
if (r.isCorrect === null) return '제출했어요.';
|
|
490
492
|
return r.isCorrect
|
|
491
493
|
? `모두 맞았어요. ${r.score}점`
|
|
492
494
|
: `${r.score}점이에요. 다시 풀어 볼 수 있어요.`;
|
|
@@ -501,8 +503,13 @@ function mountSubmit(app, { getAnswer, setAnswer, validate, onResult, root, labe
|
|
|
501
503
|
bar.append(error, button);
|
|
502
504
|
area.after(result, bar);
|
|
503
505
|
|
|
504
|
-
const show = (r,
|
|
505
|
-
|
|
506
|
+
const show = (r, past = false) => {
|
|
507
|
+
const ungraded = r.isCorrect === null || r.score === null || r.score === undefined;
|
|
508
|
+
result.textContent = past
|
|
509
|
+
? ungraded
|
|
510
|
+
? '이미 제출했어요.'
|
|
511
|
+
: `지난 점수: ${resultText(r)}`
|
|
512
|
+
: resultText(r);
|
|
506
513
|
result.className = `ec-result ${r.isCorrect ? 'ok' : r.isCorrect === false ? 'no' : ''}`;
|
|
507
514
|
result.hidden = false;
|
|
508
515
|
};
|
|
@@ -513,22 +520,31 @@ function mountSubmit(app, { getAnswer, setAnswer, validate, onResult, root, labe
|
|
|
513
520
|
button.hidden = true;
|
|
514
521
|
error.textContent = '보기 전용이라 제출할 수 없습니다.';
|
|
515
522
|
}
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
523
|
+
// 지난 점수: app.result에는 점수만 있어 채점했는지(isCorrect)는 마지막 제출에서 읽는다 (못 읽으면 점수로 짐작)
|
|
524
|
+
const past =
|
|
525
|
+
app.result && app.result.score !== null && app.result.score !== undefined
|
|
526
|
+
? { score: app.result.score, isCorrect: app.result.score === 100 }
|
|
527
|
+
: null;
|
|
528
|
+
if (past && !app.readOnly) button.textContent = `다시 ${label}`;
|
|
529
|
+
// 다시 열면 마지막 제출의 답을 채우고, 채점 결과({ isCorrect, score })도 화면에 알려 준다.
|
|
530
|
+
// 복원 응답보다 먼저 제출했으면 늦게 온 복원은 버린다 (방금 낸 답 · 결과를 덮지 않게)
|
|
531
|
+
let submitted = false;
|
|
521
532
|
const restored =
|
|
522
|
-
setAnswer || onResult
|
|
533
|
+
setAnswer || onResult || past
|
|
523
534
|
? app
|
|
524
535
|
.lastSubmission()
|
|
525
536
|
.then(last => {
|
|
537
|
+
if (submitted) return;
|
|
538
|
+
// 마지막 제출이 채점하지 않은 것(isCorrect null)이면 '이미 제출', 아니면 지난 점수
|
|
539
|
+
if (past) show(last && last.isCorrect === null ? { ...past, isCorrect: null } : past, true);
|
|
526
540
|
if (!last) return;
|
|
527
541
|
if (setAnswer && last.answer !== null && last.answer !== undefined)
|
|
528
542
|
setAnswer(last.answer);
|
|
529
543
|
onResult?.(last, { restored: true });
|
|
530
544
|
})
|
|
531
|
-
.catch(() =>
|
|
545
|
+
.catch(() => {
|
|
546
|
+
if (past && !submitted) show(past, true);
|
|
547
|
+
})
|
|
532
548
|
: Promise.resolve();
|
|
533
549
|
|
|
534
550
|
button.addEventListener('click', async () => {
|
|
@@ -539,6 +555,7 @@ function mountSubmit(app, { getAnswer, setAnswer, validate, onResult, root, labe
|
|
|
539
555
|
return;
|
|
540
556
|
}
|
|
541
557
|
error.textContent = '';
|
|
558
|
+
submitted = true;
|
|
542
559
|
button.disabled = true;
|
|
543
560
|
button.setAttribute('aria-busy', 'true');
|
|
544
561
|
try {
|
|
@@ -697,11 +714,11 @@ function mountSave(app, { getContent, getGrading, validate, root, label = '저
|
|
|
697
714
|
if (dirty) e.preventDefault();
|
|
698
715
|
});
|
|
699
716
|
|
|
700
|
-
// 실제 SDK의 saveSettings는 edit 토큰으로 자료의 draft에 저장한다. 학생에게는 LXP 편집 페이지의
|
|
717
|
+
// 실제 SDK의 saveSettings는 edit 토큰으로 자료의 draft에 저장한다. 학생에게는 LXP 편집 페이지의 '수업 자료에 반영'(새 버전)부터 보인다
|
|
701
718
|
const savedText = () =>
|
|
702
719
|
app.sdkKind === 'mock'
|
|
703
720
|
? '저장했어요 (mock · 이 브라우저에만).'
|
|
704
|
-
: "저장했어요. 학생에게는 편집
|
|
721
|
+
: "저장했어요. 학생에게는 편집 페이지 위쪽 '수업 자료에 반영'을 누르면 보입니다.";
|
|
705
722
|
|
|
706
723
|
button.addEventListener('click', async () => {
|
|
707
724
|
const next = getContent();
|
|
@@ -747,7 +764,7 @@ function mountSave(app, { getContent, getGrading, validate, root, label = '저
|
|
|
747
764
|
*/
|
|
748
765
|
|
|
749
766
|
|
|
750
|
-
/** 채점 방식 문구 (settings.grading.type, LXP 설정
|
|
767
|
+
/** 채점 방식 문구 (settings.grading.type, LXP 채점 설정 문구 그대로) */
|
|
751
768
|
export const GRADER_TYPES = Object.freeze({
|
|
752
769
|
pattern: {
|
|
753
770
|
label: '기준 답안과 비교해 채점',
|
|
@@ -780,8 +797,8 @@ const GRADING_TEXT = {
|
|
|
780
797
|
emptyRubric: '평가 기준을 입력해 주세요.',
|
|
781
798
|
};
|
|
782
799
|
|
|
783
|
-
/** 정답 정규식 길이
|
|
784
|
-
export const ANSWER_KEY_MAX =
|
|
800
|
+
/** 정답 정규식 길이 상한. 서버(elice-material grading.py _REGEX_MAX_LENGTH)와 같게: 넘으면 서버가 저장을 거절한다 */
|
|
801
|
+
export const ANSWER_KEY_MAX = 500;
|
|
785
802
|
/** 정답 정규식 한 번 맞춰 보는 시간 상한(ms). 넘으면 ReDoS 위험으로 막는다 */
|
|
786
803
|
const REGEX_TIME_LIMIT_MS = 50;
|
|
787
804
|
|
|
@@ -822,7 +839,7 @@ export function validateAnswerRegex(regex, samples = []) {
|
|
|
822
839
|
return null;
|
|
823
840
|
}
|
|
824
841
|
|
|
825
|
-
/** 라디오 카드 하나 (LXP 설정
|
|
842
|
+
/** 라디오 카드 하나 (LXP 설정 모양) */
|
|
826
843
|
function radioCard(name, value, info, checked) {
|
|
827
844
|
const card = h('label', { className: 'ec-grading-type' });
|
|
828
845
|
const input = h('input', { type: 'radio', name, value, checked });
|
|
@@ -4,15 +4,15 @@ Elice Custom HTML 학습자료 프로젝트입니다.
|
|
|
4
4
|
|
|
5
5
|
## 고치는 곳
|
|
6
6
|
|
|
7
|
-
| 파일 | 화면
|
|
8
|
-
| ------------------------------------------- |
|
|
9
|
-
| `screens/learn.js` · `index.html` | 학생 화면
|
|
10
|
-
| `screens/instructor.js` · `instructor.html` | 교육자 화면
|
|
11
|
-
| `screens/edit.js` · `edit.html` | 내용 편집 화면 (CMS): 내용 JSON 모양(`schema`) · 견본(`sample`)
|
|
12
|
-
| `styles.css` | 이 콘텐츠의 스타일
|
|
7
|
+
| 파일 | 화면 |
|
|
8
|
+
| ------------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
9
|
+
| `screens/learn.js` · `index.html` | 학생 화면 |
|
|
10
|
+
| `screens/instructor.js` · `instructor.html` | 교육자 화면 |
|
|
11
|
+
| `screens/edit.js` · `edit.html` | 내용 편집 화면 (CMS): 내용 JSON 모양(`schema`) · 견본(`sample`) |
|
|
12
|
+
| `styles.css` | 이 콘텐츠의 스타일 |
|
|
13
13
|
| `metadata.json` | 화면 구성(`screens`) · 학습 참고 내용(`commentary`). `ecdk build`가 `build`만 채움 |
|
|
14
14
|
| `package.json` | SDK 버전(`@eliceio/cdk`) · 빌드 옵션 `"ecdk"` (`minify` 등). zip에 들어가지 않음 |
|
|
15
|
-
|
|
15
|
+
실제 내용과 정답은 편집 화면에서 입력합니다. `ecdk dev`의 내용 편집에서 저장한 것은 `.ecdk/settings.json`에 남습니다 (zip에는 들어가지 않음). 기본으로는 로컬에만 있고, publish 스킬로 올릴 때 동의하면 업로드와 함께 보냅니다. 보내지 않으면 LXP에 올린 뒤 편집 화면에서 입력합니다. 내용은 편집 화면이 저장한 것(`settings`)뿐입니다. 기본 내용 파일은 없어서, 편집 화면에서 저장하기 전에는 학생 · 교육자 화면이 "아직 내용이 없습니다" 안내를 보입니다 (`app.hasContent` · `app.emptyState()`).
|
|
16
16
|
|
|
17
17
|
`lib/`(화면 키트)는 플랫폼 연결 로직이라 고치지 않습니다. SDK는 `package.json` 의존성(`@eliceio/cdk`)이고 키트가 import하며, `ecdk build`(Vite)가 화면 코드와 함께 번들로 묶습니다 (처음 한 번 `npm install`, 올리기 `npm update @eliceio/cdk`). 화면은 **누가 보는지(학생 · 교육자 · 튜터)나 미리보기인지 몰라도 됩니다.**
|
|
18
18
|
|
|
@@ -33,13 +33,13 @@ renderForm(app.content);
|
|
|
33
33
|
app.useSave({ getContent, validate });
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
| 키트가 하는 일 |
|
|
37
|
-
| -------------- |
|
|
38
|
-
| 상태 표시 | 로컬 mock SDK일 때만 화면 맨 위에 한 줄 (미리보기 · 교육자 · 튜터링 안내는 LXP 화면이 맡음)
|
|
39
|
-
| 튜터링 | 화면을 읽기 전용으로 잠그고 학생 답을 채움, 제출 버튼 없음
|
|
40
|
-
| 제출 | 검증 문구, 중복 클릭 방지, 결과·오류 안내
|
|
41
|
-
| 다시 열기 | 마지막 답 복원, 지난 점수
|
|
42
|
-
| 저장 (편집) | 저장하지 않은 변경 표시, 검증, 저장 문구, 나가기 경고
|
|
36
|
+
| 키트가 하는 일 | |
|
|
37
|
+
| -------------- | ----------------------------------------------------------------------------------------------------- |
|
|
38
|
+
| 상태 표시 | 로컬 mock SDK일 때만 화면 맨 위에 한 줄 (미리보기 · 교육자 · 튜터링 안내는 LXP 화면이 맡음) |
|
|
39
|
+
| 튜터링 | 화면을 읽기 전용으로 잠그고 학생 답을 채움, 제출 버튼 없음 |
|
|
40
|
+
| 제출 | 검증 문구, 중복 클릭 방지, 결과·오류 안내 |
|
|
41
|
+
| 다시 열기 | 마지막 답 복원, 지난 점수 |
|
|
42
|
+
| 저장 (편집) | 저장하지 않은 변경 표시, 검증, 저장 문구, 나가기 경고 |
|
|
43
43
|
| 내용 편집기 | 내용 JSON을 폼 보기 · 코드 보기로 고침, 스키마 검사 (`lib/elice-content-editor.js`, 편집 화면만 부름) |
|
|
44
44
|
|
|
45
45
|
필요하면 `app.viewer` · `app.readOnly` · `app.records` · `app.navigation` · `app.submit()` · `app.saveContent()`를 직접 써도 됩니다.
|
|
@@ -48,11 +48,11 @@ app.useSave({ getContent, validate });
|
|
|
48
48
|
|
|
49
49
|
처음 화면은 바꿔 쓰라고 넣은 작은 예제입니다. 코드에서 `// 이 자료에 맞게 바꿀 곳`을 찾아 이 자료에 맞게 바꾸고, `commentary.txt`도 다시 씁니다.
|
|
50
50
|
|
|
51
|
-
| 화면 | 예제
|
|
52
|
-
| ------ |
|
|
53
|
-
| 편집 | 키트 내용 편집기(`lib/elice-content-editor.js`)가 `schema`로 칸을 그림. 폼 보기(항목 추가 · 삭제 · 되돌리기 · 끌어서 순서) · 코드 보기(JSON 붙여 넣기 · 정렬 · 오류 위치)
|
|
51
|
+
| 화면 | 예제 |
|
|
52
|
+
| ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
53
|
+
| 편집 | 키트 내용 편집기(`lib/elice-content-editor.js`)가 `schema`로 칸을 그림. 폼 보기(항목 추가 · 삭제 · 되돌리기 · 끌어서 순서) · 코드 보기(JSON 붙여 넣기 · 정렬 · 오류 위치) |
|
|
54
54
|
| 학생 | 항목마다 막대를 끌거나(← → 키) 숫자를 넣어 예측 → 합계 · 큰 순서가 바로 바뀜 → '정답 보기'로 실제 값 · 차이, '다시 예측'. 제출은 없음 (주석의 `useSubmit`을 풀면 예측을 제출) |
|
|
55
|
-
| 교육자 | 항목 표
|
|
55
|
+
| 교육자 | 항목 표 |
|
|
56
56
|
|
|
57
57
|
내용 모양을 먼저 정하고(`{ title, intro, unit, items: [{ name, value, note }] }`), 학생 화면은 그 모양만 읽습니다. 모양을 바꾸면 `screens/edit.js`의 `schema` · `sample`과 `screens/learn.js`를 같이 고칩니다. 예제의 값은 '정답 보기'로 보여 주는 공개 자료라 내용에 둡니다. 채점할 답은 내용에 넣지 않습니다(아래 "정답").
|
|
58
58
|
|
|
@@ -61,7 +61,10 @@ app.useSave({ getContent, validate });
|
|
|
61
61
|
import { useContentEditor } from '../lib/elice-content-editor.js';
|
|
62
62
|
const editor = useContentEditor(app, {
|
|
63
63
|
initial: sample, // 저장한 내용이 없을 때 시작할 견본 (기본 내용 파일은 없음)
|
|
64
|
-
schema: {
|
|
64
|
+
schema: {
|
|
65
|
+
title: { label: '제목', required: true },
|
|
66
|
+
items: { label: '항목', min: 2, item: { value: { type: 'number' } } },
|
|
67
|
+
},
|
|
65
68
|
});
|
|
66
69
|
app.useSave({ getContent: editor.getContent, validate: editor.validate });
|
|
67
70
|
```
|
|
@@ -84,10 +87,10 @@ app.useSave({ getContent: editor.getContent, validate: editor.validate });
|
|
|
84
87
|
|
|
85
88
|
## 정답
|
|
86
89
|
|
|
87
|
-
정답은 zip에 넣지 않습니다 (ADR 0009,
|
|
90
|
+
정답은 zip에 넣지 않습니다 (ADR 0009, ecdk 스킬의 `references/02-design-the-material.md` · `05-screen-code.md`).
|
|
88
91
|
|
|
89
92
|
- **채점 방식 · 답**: 답을 채점하는 자료면 편집 화면에 키트의 채점 블록을 붙입니다: `const grading = app.useGradingBlock();` 후 `app.useSave({ …, getGrading: () => grading.getGrading() })`. LXP와 같은 문구로 기준 답안(정규표현식) · 평가 기준을 받아 `settings.grading`에 저장합니다 (학생에게는 내려가지 않음).
|
|
90
|
-
- **완료 정책**:
|
|
93
|
+
- **완료 정책**: LXP 페이지 설정입니다 (열면 완료 · 제출하면 완료 · 채점해 통과하면 완료, ADR 0012). publish 스킬이 동의를 받아 업로드 때 정하거나 교육자가 LXP 편집 페이지 위쪽 '설정' 패널에서 고릅니다. 채점은 채점해 통과하면 완료(on_graded)일 때만 합니다. 제출하면 완료(on_submit)는 제출만으로 완료되고 채점하지 않으며(키트는 "제출했어요."), 열면 완료(on_access)는 열면 완료됩니다. 프로젝트에는 적지 않습니다. 교육자가 '제출하면 완료' · '채점해 완료'를 고를 수 있게 하려면 학생 화면에 제출(`app.useSubmit`)을, '채점해 완료'까지 고를 수 있게 하려면 편집 화면에 채점 블록(위)을 둡니다.
|
|
91
94
|
- `ecdk dev`의 내용 편집에서 저장한 내용 · 채점 설정(`{ "type": "pattern", "answer_key": "^…$" }` · `{ "type": "rubric", "rubric": "…" }`)은 `.ecdk/settings.json`에 남고 로컬 채점에 쓰입니다 (채점 설정이 없으면 제출만 받음). `ecdk build`가 zip에서 뺍니다. 정답 파일은 없습니다 (ADR 0011).
|
|
92
95
|
|
|
93
96
|
## 명령
|
|
@@ -39,7 +39,7 @@ const sample = {
|
|
|
39
39
|
|
|
40
40
|
const editor = useContentEditor(app, { initial: sample, schema });
|
|
41
41
|
|
|
42
|
-
// 답을 채점하는 자료면 채점 방식 · 답 블록을 붙이고 getGrading을 넘깁니다 (ADR 0009,
|
|
42
|
+
// 답을 채점하는 자료면 채점 방식 · 답 블록을 붙이고 getGrading을 넘깁니다 (ADR 0009, ecdk 스킬의 references/05-screen-code.md):
|
|
43
43
|
// const grading = app.useGradingBlock();
|
|
44
44
|
// app.useSave({ getContent: editor.getContent, validate: editor.validate, getGrading: () => grading.getGrading() });
|
|
45
45
|
app.useSave({ getContent: editor.getContent, validate: editor.validate });
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
"name": "blank",
|
|
3
3
|
"version": "1.2.0",
|
|
4
4
|
"title": "빈 자료",
|
|
5
|
-
"description": "퀴즈가 아닌 모든 자료(시뮬레이션 · 시각화 · 활동 · 설명 · 플래시카드 · 설문)를 직접 만들 때. 예제 \"예측하고 확인하기\"(막대 예측 · 정답 보기)와 내용 JSON 편집기(폼 보기 · 코드 보기)로 시작 (완료 정책은 LXP 설정
|
|
5
|
+
"description": "퀴즈가 아닌 모든 자료(시뮬레이션 · 시각화 · 활동 · 설명 · 플래시카드 · 설문)를 직접 만들 때. 예제 \"예측하고 확인하기\"(막대 예측 · 정답 보기)와 내용 JSON 편집기(폼 보기 · 코드 보기)로 시작 (완료 정책은 LXP 자료 편집 화면의 '설정'에서 교육자가 고름)"
|
|
6
6
|
}
|
package/templates/quiz/README.md
CHANGED
|
@@ -7,7 +7,6 @@ Elice Custom HTML 학습자료 프로젝트입니다.
|
|
|
7
7
|
| 파일 | 화면 |
|
|
8
8
|
| ------------------------------------------- | ------------------------------------------------------ |
|
|
9
9
|
| `screens/learn.js` · `index.html` | 학생 화면 (무엇을 어떤 순서로 놓을지) |
|
|
10
|
-
| `screens/instructor.js` · `instructor.html` | 교육자 화면 |
|
|
11
10
|
| `screens/edit.js` · `edit.html` | 내용 편집 화면 (CMS) |
|
|
12
11
|
| `ui/` | 퀴즈의 모양: 색 · 간격 · 문구 · 마크업 (아래 표) |
|
|
13
12
|
| `styles.css` | 이 콘텐츠의 스타일 (값은 `ui/theme.css`의 변수) |
|
|
@@ -18,7 +17,7 @@ Elice Custom HTML 학습자료 프로젝트입니다.
|
|
|
18
17
|
```
|
|
19
18
|
ui/ 모양 — 마음대로 고칩니다
|
|
20
19
|
├─ theme.css 색 · 간격 · 모서리 · 보기 카드 (EDS 토큰 위의 --qz-* 변수)
|
|
21
|
-
├─ texts.js 화면에 보이는 문구 전부 (탭 제목 · 불러오는 중 · 학생 ·
|
|
20
|
+
├─ texts.js 화면에 보이는 문구 전부 (탭 제목 · 불러오는 중 · 학생 · 편집 · 검증 문구)
|
|
22
21
|
└─ templates/ HTML 조각 (question · choice · text · order · group · page · edit)
|
|
23
22
|
screens/ 배치 — 어떤 블록을 어떤 순서로 보일지
|
|
24
23
|
core/ 동작 — 고치지 않습니다 (답 문자열 · 채점 약속, 고르기 · 끌어 놓기 · 순서 바꾸기). ui/를 부르지 않고, 템플릿 · 문구는 screens/가 넘깁니다
|
|
@@ -27,7 +26,7 @@ core/ 동작 — 고치지 않습니다 (답 문자열 · 채점 약속,
|
|
|
27
26
|
| 바꾸고 싶은 것 | 고치는 곳 |
|
|
28
27
|
| -------------------------------------------- | ------------------------------------------------------------------------- |
|
|
29
28
|
| 색 · 간격 · 모서리 | `ui/theme.css`의 `--qz-*` 변수 (예: `--qz-accent`, `--qz-option-padding`) |
|
|
30
|
-
| 문구 ("정답", "
|
|
29
|
+
| 문구 ("정답", "초안에 반영", 탭 제목 등) | `ui/texts.js` (HTML의 제목 · "불러오는 중"은 스크립트가 돌기 전 대비용) |
|
|
31
30
|
| 보기 카드 마크업 | `ui/templates/choice.js` (모양은 `styles.css`의 `.qz-option`) |
|
|
32
31
|
| 문항 겉모양 · 결과 · 해설 자리 | `ui/templates/question.js` |
|
|
33
32
|
| 순서 맞추기 · 그룹 분류 배치 | `ui/templates/order.js` · `ui/templates/group.js` |
|
|
@@ -48,7 +47,9 @@ core/ 동작 — 고치지 않습니다 (답 문자열 · 채점 약속,
|
|
|
48
47
|
|
|
49
48
|
보기 · 칸 · 그룹 · 문항 요소의 `data-role` · `data-option` · `data-slot` · `data-group` · `data-id`, 상태 표시 `data-result`(`correct` · `wrong`) · `data-dragging` · `data-ghost`는 동작이 붙입니다. CSS에서 이 속성으로 상태를 꾸밀 수 있습니다.
|
|
50
49
|
|
|
51
|
-
|
|
50
|
+
실제 내용과 정답은 편집 화면에서 입력합니다. `ecdk dev`의 내용 편집에서 저장한 것은 `.ecdk/settings.json`에 남습니다 (zip에는 들어가지 않음). 기본으로는 로컬에만 있고, publish 스킬로 올릴 때 동의하면 업로드와 함께 보냅니다. 보내지 않으면 LXP에 올린 뒤 편집 화면에서 입력합니다. 내용은 편집 화면이 저장한 것(`settings`)뿐입니다. 기본 문항은 없어서, 편집 화면에서 저장하기 전에는 학생 화면이 "아직 내용이 없습니다" 안내를 보입니다 (`app.hasContent` · `app.emptyState()`).
|
|
51
|
+
|
|
52
|
+
교육자 화면은 없습니다 (`metadata.json` `screens.instructor.enabled: false`). LXP에서 교육자가 열면 학생 화면이 열려 직접 풀고 제출해 볼 수 있고, 교육자의 제출은 채점만 하고 기록되지 않습니다. 교육자 화면이 필요하면 `instructor.html` · `screens/instructor.js`를 만들고 `metadata.json`에서 켭니다.
|
|
52
53
|
|
|
53
54
|
`lib/`(화면 키트)는 플랫폼 연결 로직이라 고치지 않습니다. SDK는 `package.json` 의존성(`@eliceio/cdk`)이고 키트가 import하며, `ecdk build`(Vite)가 화면 코드와 함께 번들로 묶습니다 (처음 한 번 `npm install`, 올리기 `npm update @eliceio/cdk`). 화면은 **누가 보는지(학생 · 교육자 · 튜터)나 미리보기인지 몰라도 됩니다.**
|
|
54
55
|
|
|
@@ -91,11 +92,11 @@ app.useSave({ getContent, validate });
|
|
|
91
92
|
|
|
92
93
|
## 퀴즈 데이터와 정답
|
|
93
94
|
|
|
94
|
-
- 문항은 편집 화면에서 만들어 저장한 내용(`settings`)뿐입니다. 처음에는 문항이 없어 편집 화면은 **문항 추가**로 시작하고, 저장하기 전 학생
|
|
95
|
-
- 퀴즈 하나에 문항은
|
|
95
|
+
- 문항은 편집 화면에서 만들어 저장한 내용(`settings`)뿐입니다. 처음에는 문항이 없어 편집 화면은 **문항 추가**로 시작하고, 저장하기 전 학생 화면은 "아직 내용이 없습니다" 안내를 보입니다. 형식은 ecdk 문서 ADR 0006.
|
|
96
|
+
- 퀴즈 하나에 문항은 **20개까지** 넣습니다. **모든 문항을 맞혀야 100점**이고 부분 점수는 없습니다 (정답 하나가 `^q1=…;q2=…$` 정규식 하나라서). 20개가 차면 "문항 추가" 대신 안내가 보입니다. 정답 정규식은 퀴즈 전체가 500자(서버 한도)까지라, 한글 주관식은 한 글자가 9자로 늘어 정답 · 유사 정답이 많으면 4~5문항에서 한도에 닿습니다. 넘으면 저장할 때 가장 긴 문항에 "정답이 너무 깁니다"가 보입니다.
|
|
96
97
|
- 문항 유형: 단일 선택 · 복수 선택 · 순서 맞추기 · 주관식 · 그룹 분류
|
|
97
98
|
- 학생 답은 문자열 하나로 제출합니다: 문항 순서대로 `문항id=답`을 `;`로 잇고 주관식은 URL 인코딩 (`q1=b;q2=a,d;q4=%EA%B0%80…`).
|
|
98
|
-
- 퀴즈는 채점 방식 **기준 답안(pattern)** 고정이고, 모든 문항을 맞혀야 100점입니다 (문항별 점수 없음, ADR 0009). 편집 화면은 답(`settings.grading`)만 저장합니다. 완료 정책은 LXP
|
|
99
|
+
- 퀴즈는 채점 방식 **기준 답안(pattern)** 고정이고, 모든 문항을 맞혀야 100점입니다 (문항별 점수 없음, ADR 0009). 편집 화면은 답(`settings.grading`)만 저장합니다. 완료 정책은 LXP 페이지 설정입니다 (ADR 0012): publish 스킬이 동의를 받아 업로드 때 정하거나 교육자가 LXP 편집 페이지 위쪽 '설정' 패널에서 고릅니다. 퀴즈는 **채점해 통과하면 완료(on_graded)**여야 채점합니다. 제출하면 완료(on_submit)면 서버가 채점하지 않고 제출만으로 완료되어 점수 없이 "제출했어요."가 보입니다.
|
|
99
100
|
|
|
100
101
|
## 정답
|
|
101
102
|
|
|
@@ -28,6 +28,34 @@ export function createEditor({ rerender, root, templates, labels }) {
|
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* 라벨 없는 바로 쓰는 칸 (ui.inlineField). field와 같이 값을 넣고 고치면 onInput(값).
|
|
33
|
+
* 여러 줄 칸은 글에 맞춰 높이가 늘고, 필수 칸은 글을 쓰면 오류 표시(aria-invalid)를 지운다
|
|
34
|
+
* @param {{ placeholder: string, size?: 'title' | 'question' | 'body', required?: boolean, max?: number, multiline?: boolean }} opts
|
|
35
|
+
*/
|
|
36
|
+
function inlineField(label, value, onInput, opts) {
|
|
37
|
+
const node = bindField(ui.inlineField({ label, ...opts }), value, onInput, opts.max);
|
|
38
|
+
const input = part(node, 'input');
|
|
39
|
+
input.addEventListener('input', () => input.removeAttribute('aria-invalid'));
|
|
40
|
+
if (opts.multiline) {
|
|
41
|
+
const fit = () => {
|
|
42
|
+
input.style.height = 'auto';
|
|
43
|
+
input.style.height = `${input.scrollHeight}px`;
|
|
44
|
+
};
|
|
45
|
+
input.addEventListener('input', fit);
|
|
46
|
+
// 화면에 붙은 뒤에야 높이를 잴 수 있다
|
|
47
|
+
requestAnimationFrame(fit);
|
|
48
|
+
}
|
|
49
|
+
return node;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** 비어 있는 필수 바로 쓰는 칸에 오류 표시를 붙이고 첫 칸을 돌려준다 (저장 전 검증에 걸렸을 때) */
|
|
53
|
+
function markEmptyRequired() {
|
|
54
|
+
const empty = [...root.querySelectorAll('[data-required]')].filter((i) => !i.value.trim());
|
|
55
|
+
for (const input of empty) input.setAttribute('aria-invalid', 'true');
|
|
56
|
+
return empty[0] ?? null;
|
|
57
|
+
}
|
|
58
|
+
|
|
31
59
|
function bindField(node, value, onInput, max) {
|
|
32
60
|
const input = part(node, 'input');
|
|
33
61
|
const count = part(node, 'count');
|
|
@@ -52,15 +80,66 @@ export function createEditor({ rerender, root, templates, labels }) {
|
|
|
52
80
|
return node;
|
|
53
81
|
}
|
|
54
82
|
|
|
55
|
-
/** 켜고
|
|
56
|
-
function toggle(label, checked, onChange) {
|
|
57
|
-
const node = ui.toggle({ label });
|
|
83
|
+
/** 켜고 끄기. title: 마우스를 올리면 보이는 보충 설명 */
|
|
84
|
+
function toggle(label, checked, onChange, title, icon) {
|
|
85
|
+
const node = ui.toggle({ label, title, icon });
|
|
58
86
|
const input = part(node, 'input');
|
|
59
87
|
input.checked = Boolean(checked);
|
|
60
88
|
input.addEventListener('change', () => onChange(input.checked));
|
|
61
89
|
return node;
|
|
62
90
|
}
|
|
63
91
|
|
|
92
|
+
/**
|
|
93
|
+
* 필요할 때만 여는 칸. open이 아니면 "+ …" 버튼만 보이고, 누르면 칸이 열려 초점이 간다.
|
|
94
|
+
* 비운 채 칸을 벗어나면 다시 닫는다. 여닫는 것만으로는 다시 그리거나 "변경" 표시를 만들지 않는다
|
|
95
|
+
* @param {string} label 열기 버튼 글
|
|
96
|
+
* @param {Element} node 칸 (inlineField가 만든 요소)
|
|
97
|
+
* @param {{ open?: boolean, onOpen?: () => void, onClose?: () => void, title?: string, icon?: string, hint?: string }} [opts]
|
|
98
|
+
* title가 있으면 열린 칸을 머리줄(아이콘 · 제목 · 지우기)이 있는 카드로 보인다
|
|
99
|
+
*/
|
|
100
|
+
function revealable(label, node, { open = false, onOpen, onClose, title, icon, hint } = {}) {
|
|
101
|
+
const wrap = ui.reveal({ label, field: node, title, icon, hint });
|
|
102
|
+
const button = part(wrap, 'reveal');
|
|
103
|
+
const body = part(wrap, 'reveal-body');
|
|
104
|
+
const input = part(node, 'input');
|
|
105
|
+
const fit = () => {
|
|
106
|
+
if (input.tagName !== 'TEXTAREA') return;
|
|
107
|
+
input.style.height = 'auto';
|
|
108
|
+
input.style.height = `${input.scrollHeight}px`;
|
|
109
|
+
};
|
|
110
|
+
const show = () => {
|
|
111
|
+
button.hidden = true;
|
|
112
|
+
body.hidden = false;
|
|
113
|
+
fit();
|
|
114
|
+
};
|
|
115
|
+
const hide = () => {
|
|
116
|
+
body.hidden = true;
|
|
117
|
+
button.hidden = false;
|
|
118
|
+
};
|
|
119
|
+
button.addEventListener('click', () => {
|
|
120
|
+
show();
|
|
121
|
+
onOpen?.();
|
|
122
|
+
input.focus();
|
|
123
|
+
});
|
|
124
|
+
input.addEventListener('blur', () => {
|
|
125
|
+
// 창을 옮겨 초점을 잃은 경우(초점 요소가 그대로)는 닫지 않는다
|
|
126
|
+
if (input.value.trim() || document.activeElement === input) return;
|
|
127
|
+
hide();
|
|
128
|
+
onClose?.();
|
|
129
|
+
});
|
|
130
|
+
// 내용이 있어도 지우고 닫는다 (비우는 입력을 흘려 보내 데이터에도 반영)
|
|
131
|
+
part(wrap, 'reveal-close').addEventListener('click', () => {
|
|
132
|
+
input.value = '';
|
|
133
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
134
|
+
hide();
|
|
135
|
+
onClose?.();
|
|
136
|
+
button.focus();
|
|
137
|
+
});
|
|
138
|
+
if (open) button.hidden = true;
|
|
139
|
+
else body.hidden = true;
|
|
140
|
+
return wrap;
|
|
141
|
+
}
|
|
142
|
+
|
|
64
143
|
/**
|
|
65
144
|
* 보기 · 그룹 목록 (단일 · 복수 · 순서 · 그룹 공통). 손잡이를 끌어 순서 바꾸기
|
|
66
145
|
* answer가 있으면 줄마다 정답 칸(data-role="answer")을 둔다: radio(단일) · checkbox(복수) · select(그룹 고르기).
|
|
@@ -75,7 +154,7 @@ export function createEditor({ rerender, root, templates, labels }) {
|
|
|
75
154
|
* onAdd: 추가한 뒤 할 일 (예: 순서 맞추기 칸 수 늘리기) ·
|
|
76
155
|
* onDelete: 지운 뒤 할 일 (예: 순서 맞추기 칸 수 줄이기, 정답에서 빼기) · onInput: 글을 고친 뒤 할 일
|
|
77
156
|
*/
|
|
78
|
-
function itemList(kind, items, key, { onAdd, onDelete, onInput, answer } = {}) {
|
|
157
|
+
function itemList(kind, items, key, { onAdd, onDelete, onInput, answer, numbered = true } = {}) {
|
|
79
158
|
const isGroup = kind === 'group';
|
|
80
159
|
const text = isGroup ? 'name' : 'text';
|
|
81
160
|
const min = isGroup ? LIMITS.groupsMin : LIMITS.optionsMin;
|
|
@@ -86,6 +165,7 @@ export function createEditor({ rerender, root, templates, labels }) {
|
|
|
86
165
|
index: i,
|
|
87
166
|
canDelete: items.length > min,
|
|
88
167
|
min,
|
|
168
|
+
numbered,
|
|
89
169
|
answer: answer && { type: answer.type, name: answer.name, choices: answer.choices },
|
|
90
170
|
});
|
|
91
171
|
row.dataset.role = 'row';
|
|
@@ -193,6 +273,59 @@ export function createEditor({ rerender, root, templates, labels }) {
|
|
|
193
273
|
});
|
|
194
274
|
}
|
|
195
275
|
|
|
276
|
+
/**
|
|
277
|
+
* 상자 사이로 끌어 옮기는 손잡이 (마우스 · 터치 공용 Pointer Events). 끄는 동안 놓을 수 있는 상자에 data-over가 붙고,
|
|
278
|
+
* 놓으면 onDrop(상자, 그 앞에 둘 행 또는 null). 키보드: 손잡이에서 ↑ · ↓ → onKey(-1 | 1)
|
|
279
|
+
* @param {Element} handle 끌기 손잡이
|
|
280
|
+
* @param {Element} row 옮기는 행 (끄는 동안 data-dragging)
|
|
281
|
+
* @param {{ boxSelector: string, onDrop: (box: Element, before: Element | null) => void, onKey: (dir: -1 | 1) => void }} on
|
|
282
|
+
*/
|
|
283
|
+
function dragAcross(handle, row, { boxSelector, onDrop, onKey }) {
|
|
284
|
+
handle.addEventListener('keydown', (e) => {
|
|
285
|
+
const d = { ArrowUp: -1, ArrowDown: 1 }[e.key];
|
|
286
|
+
if (!d) return;
|
|
287
|
+
e.preventDefault();
|
|
288
|
+
onKey(d);
|
|
289
|
+
});
|
|
290
|
+
handle.addEventListener('pointerdown', (down) => {
|
|
291
|
+
if (down.button !== 0) return;
|
|
292
|
+
down.preventDefault();
|
|
293
|
+
handle.setPointerCapture(down.pointerId);
|
|
294
|
+
row.dataset.dragging = '';
|
|
295
|
+
let over = null;
|
|
296
|
+
const boxAt = (e) => {
|
|
297
|
+
const hit = document.elementsFromPoint(e.clientX, e.clientY).find((el) => !row.contains(el));
|
|
298
|
+
return hit?.closest(boxSelector) ?? null;
|
|
299
|
+
};
|
|
300
|
+
const onMove = (e) => {
|
|
301
|
+
row.style.transform = `translate(${e.clientX - down.clientX}px, ${e.clientY - down.clientY}px)`;
|
|
302
|
+
const box = boxAt(e);
|
|
303
|
+
if (box === over) return;
|
|
304
|
+
over?.removeAttribute('data-over');
|
|
305
|
+
over = box;
|
|
306
|
+
over?.setAttribute('data-over', '');
|
|
307
|
+
};
|
|
308
|
+
const end = (e) => {
|
|
309
|
+
handle.removeEventListener('pointermove', onMove);
|
|
310
|
+
handle.removeEventListener('pointerup', end);
|
|
311
|
+
handle.removeEventListener('pointercancel', end);
|
|
312
|
+
delete row.dataset.dragging;
|
|
313
|
+
row.style.transform = '';
|
|
314
|
+
over?.removeAttribute('data-over');
|
|
315
|
+
if (e.type !== 'pointerup' || !over) return;
|
|
316
|
+
const rows = [...over.querySelectorAll('[data-role="row"]')].filter((r) => r !== row);
|
|
317
|
+
const before = rows.find((r) => {
|
|
318
|
+
const b = r.getBoundingClientRect();
|
|
319
|
+
return e.clientY < b.top + b.height / 2;
|
|
320
|
+
});
|
|
321
|
+
onDrop(over, before ?? null);
|
|
322
|
+
};
|
|
323
|
+
handle.addEventListener('pointermove', onMove);
|
|
324
|
+
handle.addEventListener('pointerup', end);
|
|
325
|
+
handle.addEventListener('pointercancel', end);
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
|
|
196
329
|
/**
|
|
197
330
|
* 문항 카드: 유형 바꾸기 · 위로 · 아래로 · 삭제를 붙인다. on: { type(값), up(), down(), remove() }
|
|
198
331
|
*/
|
|
@@ -218,9 +351,13 @@ export function createEditor({ rerender, root, templates, labels }) {
|
|
|
218
351
|
return {
|
|
219
352
|
ui,
|
|
220
353
|
field,
|
|
354
|
+
inlineField,
|
|
355
|
+
markEmptyRequired,
|
|
221
356
|
numberField,
|
|
222
357
|
toggle,
|
|
358
|
+
revealable,
|
|
223
359
|
itemList,
|
|
360
|
+
dragAcross,
|
|
224
361
|
card,
|
|
225
362
|
addQuestion,
|
|
226
363
|
/** 검증에 걸린 문항 카드 */
|