@eliceio/cdk-cli 0.1.0-alpha.6 → 0.1.0-alpha.7

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.
Files changed (59) hide show
  1. package/README.md +70 -71
  2. package/es/cli.js +7 -22
  3. package/es/commands/build/index.d.ts +5 -3
  4. package/es/commands/build/index.js +16 -7
  5. package/es/commands/create/scaffold.d.ts +2 -0
  6. package/es/commands/create/scaffold.js +15 -1
  7. package/es/commands/doctor/index.d.ts +1 -1
  8. package/es/commands/doctor/index.js +4 -5
  9. package/es/commands/setup/index.d.ts +4 -7
  10. package/es/commands/setup/index.js +41 -70
  11. package/es/commands/uninstall/index.d.ts +9 -8
  12. package/es/commands/uninstall/index.js +41 -47
  13. package/es/commands/update/index.d.ts +4 -2
  14. package/es/commands/update/index.js +27 -18
  15. package/es/core/config.d.ts +1 -1
  16. package/es/core/config.js +2 -2
  17. package/es/{commands/mcp/index.d.ts → core/mcp.d.ts} +11 -18
  18. package/es/{commands/mcp/index.js → core/mcp.js} +29 -51
  19. package/es/core/minify.js +31 -2
  20. package/es/core/sandbox.d.ts +25 -0
  21. package/es/core/sandbox.js +104 -5
  22. package/es/{commands/skill/index.d.ts → core/skills.d.ts} +1 -17
  23. package/es/{commands/skill/index.js → core/skills.js} +6 -22
  24. package/es/dev/grading.d.ts +1 -1
  25. package/es/dev/grading.js +1 -1
  26. package/es/dev/host-page.js +2 -2
  27. package/es/rules/check.js +3 -3
  28. package/es/rules/csp.d.ts +1 -1
  29. package/es/rules/csp.js +1 -1
  30. package/es/rules/index.d.ts +1 -1
  31. package/es/rules/index.js +1 -1
  32. package/es/rules/unused.d.ts +2 -0
  33. package/es/rules/unused.js +4 -3
  34. package/package.json +2 -2
  35. package/skills/elice-content-create/SKILL.md +2 -1
  36. package/skills/elice-content-guide/topics/01-check-the-environment.md +2 -2
  37. package/skills/elice-content-guide/topics/02-design-the-material.md +2 -0
  38. package/skills/elice-content-guide/topics/03-create-the-project.md +2 -2
  39. package/skills/elice-content-guide/topics/05-screen-code.md +44 -13
  40. package/skills/elice-content-guide/topics/10-build.md +1 -1
  41. package/skills/elice-content-guide/topics/12-upload-with-the-material-mcp.md +2 -2
  42. package/skills/elice-content-publish/SKILL.md +1 -1
  43. package/templates/_shared/lib/cdk-mock.js +2 -2
  44. package/templates/_shared/lib/elice-content-editor.d.ts +80 -0
  45. package/templates/_shared/lib/elice-content-editor.js +1062 -0
  46. package/templates/_shared/lib/elice-content.css +332 -0
  47. package/templates/_shared/lib/elice-content.js +10 -3
  48. package/templates/blank/README.md +27 -2
  49. package/templates/blank/commentary.txt +5 -0
  50. package/templates/blank/screens/edit.js +38 -17
  51. package/templates/blank/screens/instructor.js +20 -8
  52. package/templates/blank/screens/learn.js +151 -13
  53. package/templates/blank/styles.css +171 -0
  54. package/templates/blank/template.json +2 -2
  55. package/templates/quiz/core/model.js +1 -1
  56. package/templates/quiz/screens/edit.js +14 -2
  57. package/templates/quiz/styles.css +11 -0
  58. package/templates/quiz/template.json +1 -1
  59. package/templates/quiz/ui/texts.js +1 -1
@@ -544,3 +544,335 @@ button.ec-text-button {
544
544
  text-align: center;
545
545
  }
546
546
  }
547
+
548
+ /* 내용 편집기 (lib/elice-content-editor.js useContentEditor): 폼 보기 · 코드 보기 탭.
549
+ 칸은 EDS OutlinedInput(위 input 규칙), 목록 줄 · 카드는 개발 가이드 5 UI 패턴(⠿ 손잡이 · 빨간 ✕ · 휴지통) */
550
+ .ec-json {
551
+ display: flex;
552
+ flex-direction: column;
553
+ gap: 16px;
554
+ }
555
+ .ec-json-note {
556
+ padding: 10px 12px;
557
+ border-radius: var(--ec-radius);
558
+ background: var(--ec-info-bg);
559
+ color: var(--ec-info);
560
+ font-size: var(--eds-fs-body2);
561
+ word-break: keep-all;
562
+ }
563
+ /* 탭: EDS ToggleButton 모양, 고른 쪽은 primary */
564
+ .ec-json-tabs {
565
+ display: inline-flex;
566
+ align-self: flex-start;
567
+ gap: 2px;
568
+ padding: 2px;
569
+ border: 1px solid var(--ec-border);
570
+ border-radius: calc(var(--ec-radius) + 2px);
571
+ }
572
+ .ec-json-tabs button {
573
+ min-height: 36px;
574
+ padding: 4px 14px;
575
+ border: 0;
576
+ color: var(--ec-muted);
577
+ }
578
+ .ec-json-tabs button[aria-selected='true'] {
579
+ background: var(--ec-accent-bg);
580
+ color: var(--ec-accent);
581
+ }
582
+ .ec-json-form {
583
+ display: flex;
584
+ flex-direction: column;
585
+ gap: 16px;
586
+ }
587
+ .ec-json-field {
588
+ display: flex;
589
+ flex-direction: column;
590
+ gap: 6px;
591
+ min-width: 0;
592
+ }
593
+ .ec-json-field > label,
594
+ .ec-json-group > legend,
595
+ .ec-json-list > legend {
596
+ font-weight: var(--eds-fw-semibold);
597
+ }
598
+ .ec-json-required {
599
+ color: var(--ec-no);
600
+ }
601
+ .ec-json-hint {
602
+ color: var(--ec-muted);
603
+ font-size: var(--eds-fs-caption);
604
+ word-break: keep-all;
605
+ }
606
+ .ec-json-error {
607
+ font-size: var(--eds-fs-caption);
608
+ }
609
+ .ec-json [aria-invalid='true'] {
610
+ border-color: var(--ec-no);
611
+ }
612
+ /* 켜고 끄기: 체크박스를 스위치 모양으로 */
613
+ .ec-json-switch {
614
+ flex-direction: row;
615
+ flex-wrap: wrap;
616
+ align-items: center;
617
+ gap: 10px;
618
+ }
619
+ .ec-json-switch input {
620
+ appearance: none;
621
+ position: relative;
622
+ flex: none;
623
+ width: 40px;
624
+ height: 24px;
625
+ padding: 0;
626
+ border: 0;
627
+ border-radius: 12px;
628
+ background: var(--eds-action-disabled-background);
629
+ cursor: pointer;
630
+ transition: background-color 150ms ease-in-out;
631
+ }
632
+ .ec-json-switch input::after {
633
+ content: '';
634
+ position: absolute;
635
+ top: 3px;
636
+ left: 3px;
637
+ width: 18px;
638
+ height: 18px;
639
+ border-radius: 50%;
640
+ background: var(--eds-common-white, #fff);
641
+ box-shadow: 0 1px 2px rgb(0 0 0 / 0.3);
642
+ transition: translate 150ms ease-in-out;
643
+ }
644
+ .ec-json-switch input:checked {
645
+ background: var(--ec-accent);
646
+ }
647
+ .ec-json-switch input:checked::after {
648
+ translate: 16px 0;
649
+ }
650
+ .ec-json-switch .ec-json-hint {
651
+ flex-basis: 100%;
652
+ }
653
+ .ec-json-group,
654
+ .ec-json-list {
655
+ display: flex;
656
+ flex-direction: column;
657
+ gap: 12px;
658
+ min-width: 0;
659
+ margin: 0;
660
+ padding: 0;
661
+ border: 0;
662
+ }
663
+ .ec-json-group {
664
+ padding: 12px 16px 16px;
665
+ border: 1px solid var(--ec-line);
666
+ border-radius: var(--ec-radius);
667
+ }
668
+ .ec-json-group > legend {
669
+ padding: 0 4px;
670
+ }
671
+ .ec-json-list > legend {
672
+ padding: 0;
673
+ margin-bottom: 4px;
674
+ }
675
+ .ec-json-count {
676
+ color: var(--ec-muted);
677
+ font-weight: var(--eds-fw-medium);
678
+ font-size: var(--eds-fs-caption);
679
+ }
680
+ .ec-json-rows,
681
+ .ec-json-cards {
682
+ display: flex;
683
+ flex-direction: column;
684
+ gap: 8px;
685
+ }
686
+ .ec-json-row {
687
+ display: flex;
688
+ align-items: center;
689
+ gap: 6px;
690
+ border-radius: var(--ec-radius);
691
+ transition: transform 150ms ease-in-out;
692
+ }
693
+ .ec-json-row .ec-json-inline {
694
+ flex: 1 1 0;
695
+ }
696
+ .ec-json-no {
697
+ flex: none;
698
+ width: 20px;
699
+ text-align: center;
700
+ color: var(--ec-muted);
701
+ font-weight: var(--eds-fw-bold);
702
+ }
703
+ .ec-json-card {
704
+ border: 1px solid var(--ec-border);
705
+ border-radius: var(--ec-radius);
706
+ background: var(--ec-bg);
707
+ transition: transform 150ms ease-in-out;
708
+ }
709
+ .ec-json-card-head {
710
+ display: flex;
711
+ align-items: center;
712
+ gap: 2px;
713
+ padding: 4px 4px 4px 0;
714
+ border-bottom: 1px solid var(--ec-line);
715
+ }
716
+ .ec-json-card-head strong {
717
+ flex: 1;
718
+ min-width: 0;
719
+ overflow: hidden;
720
+ text-overflow: ellipsis;
721
+ white-space: nowrap;
722
+ }
723
+ .ec-json-card-sub {
724
+ color: var(--ec-muted);
725
+ font-weight: var(--eds-fw-medium);
726
+ }
727
+ .ec-json-card-body {
728
+ display: flex;
729
+ flex-direction: column;
730
+ gap: 12px;
731
+ padding: 12px 16px 16px;
732
+ }
733
+ /* 끄는 줄 · 카드는 손가락을 바로 따라오고(전환 없음) 위에 뜬다 */
734
+ .ec-json [data-dragging] {
735
+ position: relative;
736
+ z-index: 1;
737
+ transition: none;
738
+ background: var(--eds-background-paper);
739
+ box-shadow: var(--ec-shadow);
740
+ }
741
+ button.ec-json-handle {
742
+ flex: none;
743
+ width: 32px;
744
+ min-height: 40px;
745
+ padding: 0;
746
+ border: 0;
747
+ background: none;
748
+ color: var(--eds-text-tertiary);
749
+ font-size: 18px;
750
+ cursor: grab;
751
+ touch-action: none;
752
+ }
753
+ button.ec-json-handle:hover {
754
+ background: var(--eds-action-hover);
755
+ color: var(--ec-muted);
756
+ }
757
+ .ec-json [data-dragging] .ec-json-handle {
758
+ cursor: grabbing;
759
+ }
760
+ button.ec-json-add {
761
+ align-self: flex-start;
762
+ border-style: dashed;
763
+ }
764
+ .ec-visually-hidden {
765
+ position: absolute;
766
+ width: 1px;
767
+ height: 1px;
768
+ margin: -1px;
769
+ overflow: hidden;
770
+ clip-path: inset(50%);
771
+ white-space: nowrap;
772
+ }
773
+ /* 코드 보기: 글 칸(글자 투명) 아래에 색칠한 같은 글을 겹친다. 둘이 같은 칸(grid 1/1)이라 크기가 늘 같다 */
774
+ .ec-json-code-view {
775
+ display: flex;
776
+ flex-direction: column;
777
+ gap: 8px;
778
+ }
779
+ .ec-json-toolbar {
780
+ display: flex;
781
+ align-items: center;
782
+ gap: 8px;
783
+ min-height: 32px;
784
+ }
785
+ .ec-json-status {
786
+ flex: 1;
787
+ min-width: 0;
788
+ color: var(--ec-ok);
789
+ font-size: var(--eds-fs-caption);
790
+ word-break: keep-all;
791
+ }
792
+ .ec-json-status.ec-error {
793
+ color: var(--ec-no);
794
+ }
795
+ .ec-json-code {
796
+ --ec-code-font: 14px;
797
+ display: grid;
798
+ max-height: 65vh;
799
+ overflow: auto;
800
+ border: 1px solid var(--ec-border);
801
+ border-radius: var(--ec-radius);
802
+ background: var(--eds-background-input);
803
+ }
804
+ .ec-json-code:focus-within {
805
+ outline: 2px solid var(--ec-accent);
806
+ outline-offset: -1px;
807
+ }
808
+ .ec-json-code > pre,
809
+ .ec-json-code > textarea {
810
+ grid-area: 1 / 1;
811
+ margin: 0;
812
+ padding: 12px;
813
+ border: 0;
814
+ border-radius: 0;
815
+ font-family: var(--eds-font-family-code, ui-monospace, Menlo, Consolas, monospace);
816
+ font-size: var(--ec-code-font);
817
+ font-weight: 400;
818
+ line-height: 1.6;
819
+ letter-spacing: 0;
820
+ tab-size: 2;
821
+ white-space: pre;
822
+ overflow: hidden;
823
+ }
824
+ .ec-json-code > pre {
825
+ color: var(--ec-fg);
826
+ pointer-events: none;
827
+ }
828
+ .ec-json-code > textarea {
829
+ width: 100%;
830
+ height: 100%;
831
+ min-height: 240px;
832
+ resize: none;
833
+ background: transparent;
834
+ color: transparent;
835
+ caret-color: var(--ec-fg);
836
+ }
837
+ .ec-json-code > textarea:focus {
838
+ outline: 0;
839
+ }
840
+ .ec-json-code > textarea::selection {
841
+ background: var(--eds-primary-opacity04);
842
+ }
843
+ .ec-json-key {
844
+ color: var(--eds-primary-dark);
845
+ }
846
+ .ec-json-str {
847
+ color: var(--eds-success-dark);
848
+ }
849
+ .ec-json-num {
850
+ color: var(--eds-info-dark);
851
+ }
852
+ .ec-json-lit {
853
+ color: var(--eds-warning-dark);
854
+ }
855
+ .ec-json-punc {
856
+ color: var(--ec-muted);
857
+ }
858
+ .ec-json-bad {
859
+ background: var(--ec-no-bg);
860
+ color: var(--ec-no);
861
+ text-decoration: underline wavy var(--ec-no);
862
+ }
863
+ :root[data-eds-theme='dark'] .ec-json-key {
864
+ color: var(--eds-primary-main);
865
+ }
866
+ :root[data-eds-theme='dark'] .ec-json-str {
867
+ color: var(--eds-success-main);
868
+ }
869
+ /* 모바일: 입력 글자 16px 규칙 (확대 방지) */
870
+ @media (max-width: 511.98px) {
871
+ .ec-json-code {
872
+ --ec-code-font: 16px;
873
+ }
874
+ .ec-json-group,
875
+ .ec-json-card-body {
876
+ padding-inline: 12px;
877
+ }
878
+ }
@@ -4,6 +4,7 @@
4
4
  * 화면은 누가 보는지(학생 · 교육자 · 튜터)나 미리보기인지 몰라도 됩니다.
5
5
  * 학생 화면: app.useSubmit({ getAnswer, setAnswer, validate })
6
6
  * 편집 화면: app.useSave({ getContent, getGrading, validate }) · 채점 방식과 답: app.useGradingBlock() (퀴즈가 아닌 자료)
7
+ * 내용(JSON)을 폼 · 코드로 고치는 편집기: lib/elice-content-editor.js의 useContentEditor(app, { initial, schema })
7
8
  * 여러 단계: app.usePaging({ count, onChange }) (옆 화살표 · n / N, 첫 · 마지막 단계에서 이전 · 다음 자료)
8
9
  * 읽기 전용 잠금, 답 복원, 결과·오류 안내, 저장 문구, 로컬 mock 표시는 키트가 합니다.
9
10
  *
@@ -100,7 +101,7 @@ const MATERIAL_PATH = /\/materials\/[0-9a-f-]{36}\//i;
100
101
 
101
102
  /**
102
103
  * 저장된 채점 설정을 서버 모양(2026-11-11 결정)으로: `{ type: 'pattern', answer_key }` · `{ type: 'rubric', rubric }`.
103
- * 실제 SDK는 응답 키를 camelCase로 바꿔 answer_key가 answerKey로 온다 (보낼 때는 snake_case로, progress G129).
104
+ * 실제 SDK는 응답 키를 camelCase로 바꿔 answer_key가 answerKey로 온다 (보낼 때는 snake_case로).
104
105
  * 채점 방식이 아닌 값(옛 on_access · on_submit 등)이면 null
105
106
  */
106
107
  export function normalizeGrading(grading) {
@@ -681,11 +682,17 @@ function mountSave(app, { getContent, getGrading, validate, root, label = '저
681
682
  const inBlock = e => e.target instanceof Element && e.target.closest('.ec-grading');
682
683
  scope?.addEventListener('input', e => inBlock(e) && markDirty());
683
684
  scope?.addEventListener('change', e => inBlock(e) && markDirty());
684
- // 문항 추가 · 삭제처럼 입력 없이 화면이 바뀌는 경우
685
+ // 문항 추가 · 삭제처럼 입력 없이 화면이 바뀌는 경우.
686
+ // data-ec-quiet 안(안내 · 오류 문구, 코드 보기 색칠)이 바뀐 것은 내용 변경이 아니다
685
687
  if (typeof MutationObserver !== 'undefined') {
686
688
  let ready = false;
687
689
  queueMicrotask(() => (ready = true));
688
- new MutationObserver(() => ready && markDirty()).observe(area, {
690
+ const quiet = r =>
691
+ (r.target instanceof Element && r.target.closest('[data-ec-quiet]')) ||
692
+ [...r.addedNodes, ...r.removedNodes].every(
693
+ n => n instanceof Element && n.hasAttribute('data-ec-quiet')
694
+ );
695
+ new MutationObserver(records => ready && !records.every(quiet) && markDirty()).observe(area, {
689
696
  childList: true,
690
697
  subtree: true,
691
698
  });
@@ -8,7 +8,7 @@ Elice Custom HTML 학습자료 프로젝트입니다.
8
8
  | ------------------------------------------- | ------------------------------------------------------ |
9
9
  | `screens/learn.js` · `index.html` | 학생 화면 |
10
10
  | `screens/instructor.js` · `instructor.html` | 교육자 화면 |
11
- | `screens/edit.js` · `edit.html` | 내용 편집 화면 (CMS) |
11
+ | `screens/edit.js` · `edit.html` | 내용 편집 화면 (CMS): 내용 JSON 모양(`schema`) · 견본(`sample`) |
12
12
  | `styles.css` | 이 콘텐츠의 스타일 |
13
13
  | `metadata.json` | 화면 구성(`screens`) · 학습 참고 내용(`commentary`). `ecdk build`가 `build`만 채움 |
14
14
  | `package.json` | SDK 버전(`@eliceio/cdk`) · 빌드 옵션 `"ecdk"` (`minify` 등). zip에 들어가지 않음 |
@@ -28,7 +28,7 @@ app.useSubmit({ getAnswer, setAnswer, validate });
28
28
  // 첫 · 마지막 단계에서는 LXP 이전 · 다음 수업 자료로 가는 버튼(이전 자료 · 다음 자료). 아래 이전 · 다음 막대는 만들지 않는다
29
29
  app.usePaging({ count: steps.length, onChange: i => showStep(i) });
30
30
 
31
- // 편집 화면(CMS): 고칠 칸을 그리고 저장할 내용만 알려 준다
31
+ // 편집 화면(CMS): 고칠 칸을 그리고 저장할 내용만 알려 준다 (칸을 직접 그리지 않으려면 아래 예제의 useContentEditor)
32
32
  const app = await start({ screen: 'edit' });
33
33
  renderForm(app.content);
34
34
  app.useSave({ getContent, validate });
@@ -41,9 +41,34 @@ app.useSave({ getContent, validate });
41
41
  | 제출 | 검증 문구, 중복 클릭 방지, 결과·오류 안내 |
42
42
  | 다시 열기 | 마지막 답 복원, 지난 점수 |
43
43
  | 저장 (편집) | 저장하지 않은 변경 표시, 검증, 저장 문구, 나가기 경고 |
44
+ | 내용 편집기 | 내용 JSON을 폼 보기 · 코드 보기로 고침, 스키마 검사 (`lib/elice-content-editor.js`, 편집 화면만 부름) |
44
45
 
45
46
  필요하면 `app.viewer` · `app.readOnly` · `app.records` · `app.navigation` · `app.submit()` · `app.saveContent()`를 직접 써도 됩니다.
46
47
 
48
+ ## 예제: 예측하고 확인하기
49
+
50
+ 처음 화면은 바꿔 쓰라고 넣은 작은 예제입니다. 코드에서 `// 이 자료에 맞게 바꿀 곳`을 찾아 이 자료에 맞게 바꾸고, `commentary.txt`도 다시 씁니다.
51
+
52
+ | 화면 | 예제 |
53
+ | ------ | ------------------------------------------------------------------------------------------------------------------------------- |
54
+ | 편집 | 키트 내용 편집기(`lib/elice-content-editor.js`)가 `schema`로 칸을 그림. 폼 보기(항목 추가 · 삭제 · 되돌리기 · 끌어서 순서) · 코드 보기(JSON 붙여 넣기 · 정렬 · 오류 위치) |
55
+ | 학생 | 항목마다 막대를 끌거나(← → 키) 숫자를 넣어 예측 → 합계 · 큰 순서가 바로 바뀜 → '정답 보기'로 실제 값 · 차이, '다시 예측'. 제출은 없음 (주석의 `useSubmit`을 풀면 예측을 제출) |
56
+ | 교육자 | 항목 표 |
57
+
58
+ 내용 모양을 먼저 정하고(`{ title, intro, unit, items: [{ name, value, note }] }`), 학생 화면은 그 모양만 읽습니다. 모양을 바꾸면 `screens/edit.js`의 `schema` · `sample`과 `screens/learn.js`를 같이 고칩니다. 예제의 값은 '정답 보기'로 보여 주는 공개 자료라 내용에 둡니다. 채점할 답은 내용에 넣지 않습니다(아래 "정답").
59
+
60
+ ```js
61
+ // 편집 화면: 내용 모양과 칸 설명만 적으면 키트가 폼 보기 · 코드 보기를 그린다
62
+ import { useContentEditor } from '../lib/elice-content-editor.js';
63
+ const editor = useContentEditor(app, {
64
+ initial: sample, // 저장한 내용이 없을 때 시작할 견본 (기본 내용 파일은 없음)
65
+ schema: { title: { label: '제목', required: true }, items: { label: '항목', min: 2, item: { value: { type: 'number' } } } },
66
+ });
67
+ app.useSave({ getContent: editor.getContent, validate: editor.validate });
68
+ ```
69
+
70
+ 스키마 칸: `label` · `type`(string · number · boolean · object · array) · `required` · `min` · `max`(숫자 범위, 목록은 개수) · `multiline` · `enum`(고르기) · `hint` · `item`(목록 항목) · `fields`(묶음 안 칸). 없으면 이름은 키, 종류는 견본 값에서 정합니다.
71
+
47
72
  ## SDK: mock ↔ real
48
73
 
49
74
  키트가 자동으로 고릅니다. 화면 코드는 바꿀 필요가 없습니다.
@@ -1,2 +1,7 @@
1
1
  이 자료에서 다루는 핵심 개념, 학생이 하는 활동, 문제의 의도를 적어 주세요. LXP AI 헬피가 이 내용을 참고해 답합니다.
2
2
  정답은 적지 않습니다: zip 안 파일이라 학생도 읽을 수 있습니다.
3
+
4
+ (아래는 템플릿 예제 "예측하고 확인하기"의 설명입니다. 자료를 만들면 이 자료에 맞게 모두 다시 씁니다.)
5
+ 핵심 개념: 여러 대상의 크기(예: 지구형 행성의 지름)를 서로 비교해 감을 잡는다.
6
+ 학생 활동: 항목마다 막대를 끌거나 숫자를 넣어 값을 예측하고, 예측 합계와 큰 순서를 보며 고친 뒤 '정답 보기'로 실제 값과 차이를 확인한다. '다시 예측'으로 처음부터 다시 할 수 있다.
7
+ 의도: 정확한 숫자를 외우기보다 대상 사이의 상대적인 크기와 순서를 스스로 추정해 보게 한다. 채점하지 않는다.
@@ -1,24 +1,45 @@
1
- // 내용 편집 화면(CMS). 고칠 칸만 그립니다. 저장 버튼과 저장 문구는 키트(useSave)가 합니다.
2
- // 여기서 저장한 값이 학생·교육자 화면의 app.content가 됩니다. 정답은 넣지 마세요(학생에게 공개).
1
+ // 내용 편집 화면(CMS). 내용(JSON)의 모양과 칸 설명만 적으면 키트 편집기가 폼 보기 · 코드 보기를 그립니다.
2
+ // 저장 버튼과 저장 문구는 키트(useSave)가 합니다. 여기서 저장한 값이 학생 · 교육자 화면의 app.content가 됩니다.
3
+ // 정답은 넣지 마세요(학생에게 공개). 이 예제의 값은 학생 화면 '정답 보기'가 보여 주는 공개 자료라 채점하지 않습니다.
3
4
  import { start } from '../lib/elice-content.js';
5
+ import { useContentEditor } from '../lib/elice-content-editor.js';
4
6
 
5
7
  const app = await start({ screen: 'edit' });
6
- const root = document.getElementById('app');
7
8
 
8
- const title = Object.assign(document.createElement('input'), {
9
- value: app.content.title ?? '',
10
- ariaLabel: '제목',
11
- });
12
- const message = Object.assign(document.createElement('textarea'), {
13
- value: app.content.message ?? '',
14
- ariaLabel: '내용',
15
- });
16
- root.replaceChildren(title, message);
9
+ // 이 자료에 맞게 바꿀 곳: 내용 모양(학생 화면 screens/learn.js가 읽는 키)과 칸 이름 · 규칙
10
+ const schema = {
11
+ title: { label: '제목', required: true },
12
+ intro: { label: '안내', multiline: true, hint: '학생에게 무엇을 예측할지 알려 줍니다.' },
13
+ unit: { label: '단위', hint: '예: km, 명, %' },
14
+ items: {
15
+ label: '항목',
16
+ min: 2,
17
+ max: 12,
18
+ item: {
19
+ name: { label: '이름', required: true },
20
+ value: { label: '값', type: 'number', required: true, min: 0 },
21
+ note: { label: '설명', hint: '정답 보기 뒤에 보입니다.' },
22
+ },
23
+ },
24
+ };
25
+
26
+ // 이 자료에 맞게 바꿀 곳: 아직 저장한 내용이 없을 때 편집기가 보여 줄 견본 (기본 내용 파일은 없음).
27
+ // 행성 평균 지름 km (NASA Planetary Fact Sheet 평균 반지름 × 2)
28
+ const sample = {
29
+ title: '행성의 크기 예측하기',
30
+ intro: '지구형 행성 네 개의 지름을 막대로 예측해 보세요. 다 했으면 정답 보기를 누릅니다.',
31
+ unit: 'km',
32
+ items: [
33
+ { name: '수성', value: 4879, note: '태양계에서 가장 작은 행성' },
34
+ { name: '금성', value: 12104, note: '지구와 크기가 거의 같다' },
35
+ { name: '지구', value: 12742, note: '지구형 행성 가운데 가장 크다' },
36
+ { name: '화성', value: 6779, note: '지구 지름의 약 절반' },
37
+ ],
38
+ };
39
+
40
+ const editor = useContentEditor(app, { initial: sample, schema });
17
41
 
18
42
  // 답을 채점하는 자료면 채점 방식 · 답 블록을 붙이고 getGrading을 넘깁니다 (ADR 0009, 개발 가이드 스킬 elice-content-guide topics/05-screen-code.md):
19
43
  // const grading = app.useGradingBlock();
20
- // app.useSave({ getContent, validate, getGrading: () => grading.getGrading() });
21
- app.useSave({
22
- getContent: () => ({ ...app.content, title: title.value, message: message.value }),
23
- validate: (c) => c.title.trim() !== '' || '제목을 입력해 주세요.',
24
- });
44
+ // app.useSave({ getContent: editor.getContent, validate: editor.validate, getGrading: () => grading.getGrading() });
45
+ app.useSave({ getContent: editor.getContent, validate: editor.validate });
@@ -1,16 +1,28 @@
1
- // 교육자 화면. 정답·해설처럼 교육자에게만 보여 줄 화면을 만드세요. 정답 값은 콘텐츠로 내려오지 않습니다.
1
+ // 교육자 화면. 정답 · 해설처럼 교육자에게만 보여 줄 화면을 만드세요. 정답 값은 콘텐츠로 내려오지 않습니다.
2
+ // 예제: 편집 화면이 저장한 항목을 표로 보여 줍니다. 이 자료에 맞게 바꿀 곳: show()
2
3
  import { start } from '../lib/elice-content.js';
3
4
 
4
5
  const app = await start({ screen: 'instructor' });
5
6
  const root = document.getElementById('app');
6
7
  // 편집 화면에서 아직 내용을 저장하지 않았으면 안내만 보인다
7
- if (app.hasContent) show();
8
+ if (app.hasContent) show(app.content);
8
9
  else root.replaceChildren(app.emptyState());
9
10
 
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);
11
+ function show({ title = '', intro = '', unit = '', items = [] }) {
12
+ const cell = (tag, text) => Object.assign(document.createElement(tag), { textContent: text });
13
+ const table = document.createElement('table');
14
+ table.className = 'predict-table';
15
+ const head = table.createTHead().insertRow();
16
+ head.append(cell('th', '이름'), cell('th', unit ? `값 (${unit})` : '값'), cell('th', '설명'));
17
+ const body = table.createTBody();
18
+ for (const it of items) {
19
+ const row = body.insertRow();
20
+ const value = Number.isFinite(it?.value) ? it.value.toLocaleString('ko-KR') : '';
21
+ row.append(cell('td', it?.name ?? ''), cell('td', value), cell('td', it?.note ?? ''));
22
+ }
23
+ root.replaceChildren(
24
+ cell('h1', `${title} · 교육자 화면`),
25
+ Object.assign(cell('p', intro), { className: 'ec-muted' }),
26
+ table
27
+ );
16
28
  }