@eliceio/cdk-cli 1.2.0 → 1.3.0-contenttypes.0

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 (104) hide show
  1. package/README.md +69 -60
  2. package/es/cli.js +11 -2
  3. package/es/commands/build/index.js +12 -0
  4. package/es/commands/create/index.js +2 -1
  5. package/es/commands/create/scaffold.d.ts +2 -2
  6. package/es/commands/create/scaffold.js +3 -3
  7. package/es/commands/dev/index.d.ts +10 -1
  8. package/es/commands/dev/index.js +47 -7
  9. package/es/core/config.d.ts +20 -9
  10. package/es/core/config.js +53 -12
  11. package/es/core/project-check.d.ts +3 -2
  12. package/es/core/project-check.js +14 -3
  13. package/es/core/regex.d.ts +11 -0
  14. package/es/core/regex.js +41 -0
  15. package/es/core/sandbox.d.ts +26 -0
  16. package/es/core/sandbox.js +240 -30
  17. package/es/dev/check.d.ts +30 -0
  18. package/es/dev/check.js +224 -34
  19. package/es/dev/grading.d.ts +20 -1
  20. package/es/dev/grading.js +38 -7
  21. package/es/dev/host-page.js +1 -1
  22. package/es/dev/mock-api.d.ts +3 -1
  23. package/es/dev/mock-api.js +20 -11
  24. package/es/engines/vite/index.js +1 -1
  25. package/es/engines/vite/plugin.d.ts +2 -0
  26. package/es/engines/vite/plugin.js +33 -5
  27. package/es/rules/answers.d.ts +13 -0
  28. package/es/rules/answers.js +94 -0
  29. package/es/rules/check.js +70 -1
  30. package/es/rules/index.d.ts +1 -0
  31. package/es/rules/index.js +1 -0
  32. package/es/rules/size.d.ts +31 -0
  33. package/es/rules/size.js +58 -0
  34. package/es/rules/types.d.ts +12 -0
  35. package/es/rules.json.js +2 -2
  36. package/package.json +2 -2
  37. package/rules.json +32 -3
  38. package/skills/_shared/always.md +3 -3
  39. package/skills/_shared/references/00-what-the-person-decides.md +1 -1
  40. package/skills/_shared/references/02-design-the-material.md +10 -7
  41. package/skills/_shared/references/03-create-the-project.md +2 -1
  42. package/skills/_shared/references/05-screen-code.md +49 -22
  43. package/skills/_shared/references/06-using-the-quiz-template.md +7 -6
  44. package/skills/_shared/references/08-fix-check-errors.md +23 -22
  45. package/skills/_shared/references/09-check.md +7 -6
  46. package/skills/_shared/references/12-upload-with-the-material-mcp.md +13 -13
  47. package/skills/_shared/references/13-edit-screen-design.md +122 -0
  48. package/skills/_shared/references/14-layouts.md +96 -0
  49. package/skills/elice-content-check/SKILL.md +2 -2
  50. package/skills/elice-content-create/SKILL.md +1 -1
  51. package/skills/elice-content-migrate/SKILL.md +1 -1
  52. package/templates/_shared/lib/cdk-mock.d.ts +30 -3
  53. package/templates/_shared/lib/cdk-mock.js +88 -15
  54. package/templates/_shared/lib/elice-content-editor.js +89 -58
  55. package/templates/_shared/lib/elice-content.css +1313 -126
  56. package/templates/_shared/lib/elice-content.d.ts +162 -23
  57. package/templates/_shared/lib/elice-content.js +865 -84
  58. package/templates/_shared/lib/icons/empty-content.d.ts +2 -0
  59. package/templates/_shared/lib/icons/empty-content.js +11 -0
  60. package/templates/_shared/lib/icons/file-video.d.ts +2 -0
  61. package/templates/_shared/lib/icons/file-video.js +11 -0
  62. package/templates/_shared/lib/icons/file.d.ts +2 -0
  63. package/templates/_shared/lib/icons/file.js +11 -0
  64. package/templates/blank/README.md +5 -3
  65. package/templates/blank/edit.html +8 -2
  66. package/templates/blank/index.html +6 -1
  67. package/templates/blank/instructor.html +6 -1
  68. package/templates/blank/template.json +1 -1
  69. package/templates/quiz/README.md +28 -12
  70. package/templates/quiz/core/behaviors.d.ts +13 -7
  71. package/templates/quiz/core/behaviors.js +36 -51
  72. package/templates/quiz/core/editor.d.ts +10 -0
  73. package/templates/quiz/core/editor.js +471 -8
  74. package/templates/quiz/core/markdown.d.ts +4 -0
  75. package/templates/quiz/core/markdown.js +65 -11
  76. package/templates/quiz/core/model.d.ts +34 -1
  77. package/templates/quiz/core/model.js +89 -7
  78. package/templates/quiz/core/rich-text.d.ts +19 -0
  79. package/templates/quiz/core/rich-text.js +521 -0
  80. package/templates/quiz/edit.html +12 -3
  81. package/templates/quiz/index.html +12 -3
  82. package/templates/quiz/screens/edit.js +848 -168
  83. package/templates/quiz/screens/learn.js +90 -14
  84. package/templates/quiz/styles.css +889 -213
  85. package/templates/quiz/template.json +9 -2
  86. package/templates/quiz/ui/templates/edit.d.ts +19 -6
  87. package/templates/quiz/ui/templates/edit.js +666 -87
  88. package/templates/quiz/ui/templates/group.js +19 -8
  89. package/templates/quiz/ui/templates/order.js +25 -24
  90. package/templates/quiz/ui/templates/page.js +19 -8
  91. package/templates/quiz/ui/templates/question.js +2 -2
  92. package/templates/quiz/ui/texts.js +104 -35
  93. package/templates/quiz/ui/theme.css +8 -9
  94. package/templates/steps/README.md +77 -0
  95. package/templates/steps/commentary.txt +7 -0
  96. package/templates/steps/edit.html +21 -0
  97. package/templates/steps/gitignore +4 -0
  98. package/templates/steps/index.html +69 -0
  99. package/templates/steps/metadata.json +9 -0
  100. package/templates/steps/package.json +13 -0
  101. package/templates/steps/screens/edit.js +32 -0
  102. package/templates/steps/screens/learn.js +108 -0
  103. package/templates/steps/styles.css +54 -0
  104. package/templates/steps/template.json +6 -0
@@ -3,54 +3,118 @@
3
3
  // 모양은 ui/(templates · texts · theme.css), 동작은 core/에 있습니다.
4
4
  import { start } from '../lib/elice-content.js';
5
5
  import { renderQuestion } from '../core/behaviors.js';
6
- import { decodeAnswer, isAnswered, joinAnswers, splitAnswers } from '../core/model.js';
6
+ import { setImages } from '../core/markdown.js';
7
+ import {
8
+ decodeAnswer,
9
+ isAnswered,
10
+ joinAnswerList,
11
+ joinAnswers,
12
+ PARTIAL,
13
+ splitAnswers,
14
+ } from '../core/model.js';
7
15
  import { labels, templates } from '../ui/templates/index.js';
8
- import { learnHeader, loading } from '../ui/templates/page.js';
16
+ import { loading, someWrong } from '../ui/templates/page.js';
9
17
  import { texts } from '../ui/texts.js';
10
18
 
11
19
  const root = document.getElementById('app');
12
20
  document.title = texts.page.learn;
13
21
  root.replaceChildren(loading());
14
22
  const app = await start({ screen: 'learn' });
15
- // 편집 화면에서 아직 내용을 저장하지 않았으면 안내만 보인다 (기본 문항은 없음)
23
+ // 편집 화면에서 아직 내용을 저장하지 않았으면 키트 빈 안내만 보인다 (기본 문항은 없음, 모든 템플릿 공통 모양 · 문구,
24
+ // 교육자 · 튜터도 같은 문구 — 연주님 최종 수정본)
16
25
  if (app.hasContent) show();
17
26
  else root.replaceChildren(app.emptyState());
27
+ // 불러오는 자리에서 내용으로 바뀔 때 살짝 나타나게 (styles.css .qz-enter)
28
+ root.classList.add('qz-enter');
18
29
 
19
30
  function show() {
20
- const { title, description, questions = [] } = app.content;
31
+ // 퀴즈 제목 · 안내는 보이지 않는다 (연주님 최종 수정본: 문제부터 바로). 예전에 저장한 값은 settings에 그대로
32
+ const { questions = [] } = app.content;
33
+ // 편집 화면에서 지문 · 해설에 올린 그림 (글에는 ![설명](image:아이디)만)
34
+ setImages(app.content.images);
21
35
  // 문항 유형은 보이지 않는다 (무엇을 할지는 질문 문장이 알려 줌). 교육자도 이 화면에서 풀어 본다 (교육자 화면 없음)
22
36
  const views = questions.map((q, i) =>
23
37
  renderQuestion(q, i, {
24
38
  templates,
25
39
  labels: { ...labels, types: null },
40
+ // 문제가 하나면 번호 없이 제목만 (연주님 최종 수정본)
41
+ single: questions.length === 1,
26
42
  seed: app.account?.anonymousId ?? '',
27
43
  }),
28
44
  );
29
45
 
30
- root.replaceChildren(learnHeader({ title: title ?? '', description }), ...views.map((v) => v.el));
46
+ root.replaceChildren(...views.map((v) => v.el));
31
47
 
32
- // 답은 문자열 하나로 낸다 (편집 화면이 만든 정답 정규식과 전체 비교, ADR 0008 · 0009): "q1=b;q2=a,d;…"
48
+ // 답 모양은 채점 방식을 따른다 (학생 화면은 grading을 받지 못해 편집 화면이 같이 저장한 공개 값 gradingType으로 안다):
49
+ // pattern은 문자열 하나 "q1=b;q2=a,d;…" (ADR 0008 · 0009), partial_pattern은 문항별 배열 ["q1=b", "q2=a,d", …]
50
+ const partial = app.content.gradingType === PARTIAL;
51
+ /**
52
+ * 문제별 맞음 (partial_pattern), 지금 문제 순서대로. answerCorrectness[i]는 낸 답 answer[i]의 맞음이고 answer[i]는 "문제id=답"이라
53
+ * 문제 id로 맞춘다 (제출 뒤 교육자가 문제 순서를 바꿔도 표시가 제 문제에). 다시 열 때는 마지막 제출 기록의 answer,
54
+ * 제출 직후에는 지금 답(방금 낸 답과 같음). 낸 답과 지금 문제가 하나라도 맞지 않으면(빠짐 · 더함 · 옛 문자열 답) null → 전체 결과만
55
+ */
56
+ const correctnessOf = (res) => {
57
+ const marks = res.answerCorrectness;
58
+ const answer = res.answer ?? joinAnswerList(questions, views.map((v) => v.getValue()));
59
+ if (!Array.isArray(marks) || !Array.isArray(answer) || marks.length !== answer.length) return null;
60
+ const byId = new Map();
61
+ answer.forEach((piece, i) => {
62
+ const at = typeof piece === 'string' ? piece.indexOf('=') : -1;
63
+ if (at > 0) byId.set(piece.slice(0, at), marks[i] === true);
64
+ });
65
+ if (byId.size !== questions.length || questions.some((q) => !byId.has(q.id))) return null;
66
+ return questions.map((q) => byId.get(q.id));
67
+ };
68
+ // pattern(모두 맞혀야 100점)은 점수 줄을 감추고 문제 카드의 정답 · 오답으로 알린다 (연주님 최종 수정본).
69
+ // 여러 문제 중 틀린 것이 있으면 제출 바 위에 한 줄 (어느 문제인지는 pattern이 알려 주지 않음). partial_pattern은 점수 줄 그대로
70
+ document.body.classList.toggle('qz-score-hidden', !partial);
71
+ const overall = someWrong();
72
+ const showOverall = (wrong) => {
73
+ overall.hidden = !wrong;
74
+ if (wrong) overall.dataset.result = 'wrong';
75
+ else delete overall.dataset.result;
76
+ };
33
77
  app.useSubmit({
34
- getAnswer: () => joinAnswers(questions, views.map((v) => v.getValue())),
78
+ label: texts.learn.submit,
79
+ getAnswer: () => {
80
+ const values = views.map((v) => v.getValue());
81
+ return partial ? joinAnswerList(questions, values) : joinAnswers(questions, values);
82
+ },
35
83
  setAnswer: (answer) => {
36
84
  const byId = splitAnswers(questions, answer);
37
85
  questions.forEach((q, i) => views[i].setValue(decodeAnswer(q, byId[q.id])));
38
86
  },
39
87
  validate: () => {
40
88
  const left = questions.findIndex((q, i) => !isAnswered(q, views[i].getValue()));
41
- return left < 0 || texts.learn.unanswered(left + 1);
89
+ if (left < 0) return true;
90
+ return questions.length === 1 ? texts.learn.unansweredSingle : texts.learn.unanswered(left + 1);
91
+ },
92
+ // 결과 줄(partial_pattern만 보임): 문제별 맞음이 있으면 점수와 틀린 문제 번호. 맞음 · 채점 안 함은 키트 기본 문장
93
+ resultText: (res) => {
94
+ if (res.isCorrect !== false || typeof res.score !== 'number') return undefined;
95
+ const marks = correctnessOf(res);
96
+ if (!marks) return undefined;
97
+ const wrong = marks.flatMap((ok, i) => (ok ? [] : [i + 1]));
98
+ return texts.learn.partial(res.score, marks.length - wrong.length, marks.length, wrong);
42
99
  },
43
- // 서버 채점 결과는 전체 { isCorrect, score }뿐이다. 문항이 하나면 그 결과가 곧 문항의 정답 · 오답이고,
44
- // 여러 문항이면 어느 문항이 틀렸는지 모르므로 모두 맞았을 때만 정답 표시. 해설은 한 번이라도 제출하면
45
- onResult: (res) => {
100
+ // partial_pattern이면 서버가 문항별 맞음 answerCorrectness를 준다 (제출 직후 · 다시 열 때 마지막 제출 기록에서).
101
+ // 문제 id로 맞춘 결과가 있으면 문제마다 정답 · 오답을 표시한다. 없거나([] = pattern · rubric) 맞추지 못하면 전체 결과만:
102
+ // 문항이 하나면 그 결과가 곧 문항의 정답 · 오답, 여러 문항이면 모두 맞았을 때만 정답 표시. 해설은 한 번이라도 제출하면
103
+ onResult: (res, info) => {
46
104
  const single = views.length === 1;
47
- views.forEach((v) => {
105
+ const items = correctnessOf(res);
106
+ views.forEach((v, i) => {
48
107
  const correct = typeof res.isCorrect === 'boolean' ? res.isCorrect : null;
49
- v.setResult(single ? correct : correct === true ? true : null);
108
+ if (items) v.setResult(items[i]);
109
+ else v.setResult(single ? correct : correct === true ? true : null);
50
110
  v.showExplanation();
51
111
  });
112
+ showOverall(!partial && !single && res.isCorrect === false);
113
+ // 방금 낸 답이 만점이면 (다시 열었을 때 지난 기록으로는 아님)
114
+ if (res.isCorrect === true && !info?.restored) onPerfectScore();
52
115
  },
53
116
  });
117
+ document.querySelector('.ec-submitbar')?.before(overall);
54
118
 
55
119
  // 다시 고치면 그 문항의 결과 색을 지운다 (기존 동작)
56
120
  root.addEventListener('input', (e) => clearResult(e.target));
@@ -58,6 +122,18 @@ function show() {
58
122
  function clearResult(target) {
59
123
  const card = target instanceof Element ? target.closest('[data-role="question"]') : null;
60
124
  const i = card ? questions.findIndex((q) => q.id === card.dataset.id) : -1;
61
- if (i >= 0 && !app.readOnly) views[i].setResult(null);
125
+ if (i < 0 || app.readOnly) return;
126
+ views[i].setResult(null);
127
+ showOverall(false);
62
128
  }
63
129
  }
130
+
131
+ /**
132
+ * 방금 낸 답이 만점(100점)일 때 한 번 불린다 (다시 열 때 지난 기록으로는 불리지 않음).
133
+ * 만점 축하 토끼 · 소리는 콘텐츠가 보이지 않고 호스트(elice-web)가 보인다: elice-web에 같은 토끼 애니메이션
134
+ * (MaterialRabbitAnimation) · 소리와 기관별 켜고 끄는 설정이 있다. 콘텐츠가 호스트에 알리는 SDK 이벤트는 아직
135
+ * 정하지 않았으므로 지금은 아무것도 하지 않는다. 정해지면 그 SDK 호출 한 줄을 여기에 넣는다
136
+ */
137
+ function onPerfectScore() {
138
+ // 호스트에 알리는 SDK 이벤트가 정해지면 여기서 부른다 (정하기 전에는 없는 API를 부르지 않는다)
139
+ }