@eliceio/cdk-cli 1.4.1 → 1.5.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.
Files changed (79) hide show
  1. package/README.md +17 -16
  2. package/es/cli.js +1 -1
  3. package/es/commands/create/index.js +1 -0
  4. package/es/commands/create/scaffold.d.ts +1 -1
  5. package/es/commands/create/scaffold.js +1 -1
  6. package/es/core/config.d.ts +36 -0
  7. package/es/core/config.js +234 -6
  8. package/es/core/quiz-check.js +123 -4
  9. package/es/dev/grading.d.ts +26 -4
  10. package/es/dev/grading.js +66 -11
  11. package/es/dev/mock-api.d.ts +6 -1
  12. package/es/dev/mock-api.js +45 -6
  13. package/es/rules/answers.d.ts +1 -0
  14. package/es/rules/answers.js +8 -0
  15. package/es/rules.json.js +1 -1
  16. package/package.json +2 -2
  17. package/rules.json +1 -1
  18. package/skills/_shared/always.md +1 -1
  19. package/skills/_shared/references/02-design-the-material.md +8 -7
  20. package/skills/_shared/references/03-create-the-project.md +10 -9
  21. package/skills/_shared/references/12-upload-with-the-material-mcp.md +5 -5
  22. package/skills/_shared/references/16-using-the-survey-template.md +158 -0
  23. package/skills/elice-content-create/SKILL.md +2 -2
  24. package/skills/elice-content-edit/SKILL.md +2 -2
  25. package/skills/elice-content-publish/SKILL.md +1 -1
  26. package/templates/_shared/lib/cdk-mock.d.ts +22 -3
  27. package/templates/_shared/lib/cdk-mock.js +78 -11
  28. package/templates/_shared/lib/elice-content.d.ts +17 -1
  29. package/templates/_shared/lib/elice-content.js +47 -5
  30. package/templates/blank/template.json +1 -1
  31. package/templates/document/template.json +2 -2
  32. package/templates/quiz/README.md +26 -1
  33. package/templates/quiz/core/behaviors.d.ts +5 -0
  34. package/templates/quiz/core/behaviors.js +16 -1
  35. package/templates/quiz/core/model.d.ts +78 -1
  36. package/templates/quiz/core/model.js +219 -4
  37. package/templates/quiz/screens/edit.js +244 -55
  38. package/templates/quiz/screens/learn.js +137 -27
  39. package/templates/quiz/styles.css +258 -5
  40. package/templates/quiz/template.json +1 -1
  41. package/templates/quiz/ui/templates/edit.d.ts +1 -0
  42. package/templates/quiz/ui/templates/edit.js +67 -8
  43. package/templates/quiz/ui/templates/page.js +34 -0
  44. package/templates/quiz/ui/templates/text.js +15 -2
  45. package/templates/quiz/ui/texts.js +61 -0
  46. package/templates/steps/template.json +1 -1
  47. package/templates/survey/README.md +112 -0
  48. package/templates/survey/commentary.txt +2 -0
  49. package/templates/survey/core/behaviors.d.ts +14 -0
  50. package/templates/survey/core/behaviors.js +115 -0
  51. package/templates/survey/core/dom.d.ts +13 -0
  52. package/templates/survey/core/dom.js +83 -0
  53. package/templates/survey/core/editor.d.ts +80 -0
  54. package/templates/survey/core/editor.js +720 -0
  55. package/templates/survey/core/markdown.d.ts +21 -0
  56. package/templates/survey/core/markdown.js +298 -0
  57. package/templates/survey/core/model.d.ts +83 -0
  58. package/templates/survey/core/model.js +209 -0
  59. package/templates/survey/core/rich-text.d.ts +18 -0
  60. package/templates/survey/core/rich-text.js +469 -0
  61. package/templates/survey/edit.html +26 -0
  62. package/templates/survey/gitignore +4 -0
  63. package/templates/survey/index.html +26 -0
  64. package/templates/survey/metadata.json +9 -0
  65. package/templates/survey/package.json +13 -0
  66. package/templates/survey/screens/edit.js +345 -0
  67. package/templates/survey/screens/learn.js +100 -0
  68. package/templates/survey/styles.css +1264 -0
  69. package/templates/survey/template.json +12 -0
  70. package/templates/survey/ui/templates/edit.d.ts +27 -0
  71. package/templates/survey/ui/templates/edit.js +656 -0
  72. package/templates/survey/ui/templates/index.d.ts +3 -0
  73. package/templates/survey/ui/templates/index.js +3 -0
  74. package/templates/survey/ui/templates/learn.js +147 -0
  75. package/templates/survey/ui/templates/page.js +19 -0
  76. package/templates/survey/ui/texts.d.ts +3 -0
  77. package/templates/survey/ui/texts.js +116 -0
  78. package/templates/survey/ui/theme.css +42 -0
  79. package/templates/video/template.json +1 -1
@@ -0,0 +1,345 @@
1
+ // 내용 편집 화면(CMS). 맨 위 설문 안내, 그 아래 문항 카드(유형 · 필수 응답 · 질문 · 설명 · 유형별 칸), 끝에 "+ 문항 추가".
2
+ // 저장 버튼 · 변경 표시는 키트(useSave)가 합니다. 설문은 정답 · 채점이 없어 settings에 grading을 두지 않습니다
3
+ // (getGrading을 넘기지 않음). 저장은 settings.survey 아래에. 완료 정책은 LXP 자료 편집 화면의 '설정'에서 고르며, 설문은 "제출 시 완료"(on_submit)를 권합니다.
4
+ // 여기서는 어떤 칸을 어떤 순서로 놓을지만 정합니다. 모양은 ui/(templates/edit.js · texts · theme.css), 동작은 core/.
5
+ import { start } from '../lib/elice-content.js';
6
+ import { part } from '../core/dom.js';
7
+ import { createEditor } from '../core/editor.js';
8
+ import {
9
+ assetKeysIn,
10
+ loadAsset,
11
+ resolveAssets,
12
+ setAssetFailedText,
13
+ } from '../core/markdown.js';
14
+ import {
15
+ canAddQuestion,
16
+ cleanQuestions,
17
+ convertType,
18
+ isChoice,
19
+ LIMITS,
20
+ makeContent,
21
+ newQuestion,
22
+ normalizeScale,
23
+ SCALE_MAXES,
24
+ SCALE_MINS,
25
+ scaleColumns,
26
+ scaleSteps,
27
+ readSurvey,
28
+ TYPES,
29
+ validateSurvey,
30
+ } from '../core/model.js';
31
+ import * as templates from '../ui/templates/edit.js';
32
+ import { loading } from '../ui/templates/page.js';
33
+ import { texts } from '../ui/texts.js';
34
+
35
+ const t = texts.edit;
36
+ const root = document.getElementById('app');
37
+ document.title = texts.page.edit;
38
+ root.replaceChildren(loading());
39
+ const app = await start({ screen: 'edit' });
40
+ const saved = structuredClone(readSurvey(app.content));
41
+ const draft = {
42
+ ...saved,
43
+ description: saved.description ?? '',
44
+ // 처음 열면 문항 1(단일 선택)이 이미 있는 상태로 시작한다
45
+ questions: saved.questions?.length
46
+ ? saved.questions.map(q => (q.type === 'scale' ? { ...q, scale: normalizeScale(q) } : q))
47
+ : [newQuestion('single', [])],
48
+ };
49
+ /** 설문 안내 · 문항 설명 글들 */
50
+ const richTexts = () =>
51
+ [draft.description, ...draft.questions.map(q => q.description)].filter(Boolean);
52
+ // 서버에 올린 그림 ![설명](asset:파일키)을 받기 시작한다. 기다리지 않고 먼저 그리고, 받으면 그 자리만 그림으로
53
+ // (그림 하나 10초까지, 못 받으면 새로고침 안내)
54
+ setAssetFailedText(texts.learn.imageExpired);
55
+ void resolveAssets(richTexts(), app.assets.url);
56
+
57
+ /**
58
+ * 안내 · 설명에 그림 올리기 (서식 도구의 그림 버튼, 퀴즈 템플릿과 같음). 키트가 그림을 줄여(긴 변 2048px · WebP,
59
+ * EXIF · GPS 제거) 서버에 올리고(app.assets.uploadImage), 글에는 파일 키 ![](asset:파일키)만 둔다.
60
+ * settings에는 키만 들어가 서버 한도(약 64KB)에 걸리지 않는다. 설문 전체 LIMITS.imagesMax개까지.
61
+ * 끄면(false) 버튼이 숨고, 이미 넣은 그림은 그대로 보이고 지울 수 있다
62
+ */
63
+ const IMAGE_UPLOAD = true;
64
+ const imageErrors = {
65
+ upload_bad_type: t.md.imageNotImage,
66
+ upload_bad_file: t.md.imageTooBig,
67
+ image_unreadable: t.md.imageUnreadable,
68
+ };
69
+ /** 그림 올리기: 올리고 그림 칸 참조(asset:파일키)를 돌려준다. 실패는 알림으로 */
70
+ const imageUpload = IMAGE_UPLOAD
71
+ ? {
72
+ async add(file) {
73
+ if (richTexts().flatMap(assetKeysIn).length >= LIMITS.imagesMax)
74
+ throw Object.assign(new Error('total'), { code: 'total' });
75
+ const { asset_key } = await app.assets.uploadImage(file);
76
+ await loadAsset(asset_key, app.assets.url);
77
+ return `asset:${asset_key}`;
78
+ },
79
+ fail: error =>
80
+ showSnackbar(
81
+ error.code === 'total'
82
+ ? t.md.imageTotal(LIMITS.imagesMax)
83
+ : (imageErrors[error.code] ?? error.message ?? t.md.imageUnreadable)
84
+ ),
85
+ }
86
+ : undefined;
87
+ /** 글 칸 사이 그림 칸: 지우면 되돌리기 알림 */
88
+ const imageBlocks = {
89
+ removeLabel: t.md.imageRemove,
90
+ onRemoved: undo => showSnackbar(t.md.imageDeleted, undo),
91
+ };
92
+ const form = createEditor({
93
+ rerender: render,
94
+ root,
95
+ templates,
96
+ labels: { count: t.count, group: () => '' },
97
+ });
98
+ let save = null;
99
+ /** 다시 그린 뒤 초점을 둘 칸 (새 보기 · 새 문항 · 연 설명) */
100
+ let focusNext = null;
101
+
102
+ const changed = () => {
103
+ save?.markDirty();
104
+ render();
105
+ };
106
+
107
+ /** 맨 위 설문 안내 카드: 늘 열린 글 칸 + 서식 도구 */
108
+ function infoCard() {
109
+ const field = form.richField(
110
+ t.surveyDescription,
111
+ draft.description,
112
+ v => (draft.description = v),
113
+ {
114
+ placeholder: t.surveyDescription,
115
+ images: imageBlocks,
116
+ }
117
+ );
118
+ const card = templates.infoCard({ field });
119
+ form.formatTools(field, t.md, imageUpload);
120
+ return card;
121
+ }
122
+
123
+ /** 필수 응답 스위치 */
124
+ function requiredSwitch(q) {
125
+ const node = templates.requiredSwitch();
126
+ const input = part(node, 'input');
127
+ input.checked = Boolean(q.required);
128
+ input.addEventListener('change', () => {
129
+ q.required = input.checked;
130
+ save?.markDirty();
131
+ });
132
+ return node;
133
+ }
134
+
135
+ /** 문항 설명: 필요할 때만 "설명 추가 +"로 연다. 열리면 머리줄(아이콘 · 이름 · 지우기)이 있는 회색 상자 */
136
+ function descriptionField(q) {
137
+ const field = form.richField(t.description, q.description ?? '', v => (q.description = v), {
138
+ placeholder: t.descriptionPlaceholder,
139
+ images: imageBlocks,
140
+ });
141
+ field.dataset.focus = `d-${q.id}`;
142
+ return form.revealable(t.addDescription, field, {
143
+ open: Boolean(q.descOpen || q.description),
144
+ onOpen: () => (q.descOpen = true),
145
+ onClose: () => (q.descOpen = false),
146
+ title: t.description,
147
+ icon: 'comment',
148
+ tools: t.md,
149
+ images: imageUpload,
150
+ });
151
+ }
152
+
153
+ /** 단일 · 다중 선택: 보기 목록 (끌어서 순서 바꾸기) + '기타(자유 입력)' 줄 + "+ 보기 추가" */
154
+ function optionsField(q) {
155
+ const type = q.type === 'multiple' ? 'checkbox' : 'radio';
156
+ const list = form.itemList('option', q.options, `o-${q.id}`, {
157
+ numbered: false,
158
+ // 정답 칸이 아니라 앞 단추 모양만 정한다 (설문은 정답이 없음)
159
+ answer: { type, name: `o-${q.id}`, get: () => false, set: () => undefined },
160
+ onAdd: () => {
161
+ save?.markDirty();
162
+ focusNext = `[data-focus="o-${q.id}-${q.options.length - 1}"]`;
163
+ },
164
+ onDelete: () => save?.markDirty(),
165
+ });
166
+ // 새 보기 칸에 초점을 두려고 줄마다 표시
167
+ list.querySelectorAll('[data-role="row"] [data-role="input"]').forEach((input, i) => {
168
+ input.dataset.focus = `o-${q.id}-${i}`;
169
+ });
170
+ let other;
171
+ if (q.other) {
172
+ other = templates.otherRow({ type });
173
+ part(other, 'other-delete').addEventListener('click', () => {
174
+ delete q.other;
175
+ changed();
176
+ });
177
+ } else {
178
+ other = templates.otherAdd();
179
+ part(other, 'other-add').addEventListener('click', () => {
180
+ q.other = true;
181
+ changed();
182
+ });
183
+ }
184
+ const add = list.querySelector(':scope > .qe-add');
185
+ if (add) add.before(other);
186
+ else list.append(other);
187
+ return templates.section({ label: t.options, body: list });
188
+ }
189
+
190
+ /** 척도: 시작값 · 끝값 고르기, 미리보기, 양 끝 이름 */
191
+ function scaleField(q) {
192
+ const s = q.scale;
193
+ const pick = (key, values, label) =>
194
+ form.picker(
195
+ templates.pickButton({ label, value: String(s[key]) }),
196
+ values.map(v => [String(v), String(v)]),
197
+ () => String(s[key]),
198
+ v => {
199
+ s[key] = Number(v);
200
+ focusNext = `[data-focus="s-${q.id}-${key}"]`;
201
+ changed();
202
+ }
203
+ );
204
+ const min = pick('min', SCALE_MINS, t.scaleMinSelect);
205
+ const max = pick('max', SCALE_MAXES, t.scaleMaxSelect);
206
+ min.dataset.focus = `s-${q.id}-min`;
207
+ max.dataset.focus = `s-${q.id}-max`;
208
+ const end = (no, key, placeholder) => {
209
+ const node = templates.endField({ no, placeholder });
210
+ const input = part(node, 'input');
211
+ input.value = s[key] ?? '';
212
+ input.maxLength = LIMITS.title;
213
+ input.addEventListener('input', () => (s[key] = input.value));
214
+ return node;
215
+ };
216
+ const steps = scaleSteps(s);
217
+ return templates.scaleEditor({
218
+ min,
219
+ max,
220
+ steps,
221
+ columns: scaleColumns(steps.length),
222
+ ends: [
223
+ end(s.min, 'minLabel', t.scaleMinPlaceholder),
224
+ end(s.max, 'maxLabel', t.scaleMaxPlaceholder),
225
+ ],
226
+ });
227
+ }
228
+
229
+ function questionCard(q, i) {
230
+ const count = draft.questions.length;
231
+ const title = form.inlineField(t.titlePlaceholder, q.title, v => (q.title = v), {
232
+ placeholder: t.titlePlaceholder,
233
+ size: 'question',
234
+ required: true,
235
+ max: LIMITS.title,
236
+ showCount: false,
237
+ });
238
+ part(title, 'input').dataset.focus = `q-${q.id}`;
239
+ const body = [
240
+ title,
241
+ descriptionField(q),
242
+ isChoice(q) ? optionsField(q) : q.type === 'scale' ? scaleField(q) : templates.textPreview(),
243
+ ];
244
+ return form.card(
245
+ {
246
+ q,
247
+ index: i,
248
+ count,
249
+ types: TYPES.map(type => [type, texts.types[type]]),
250
+ body,
251
+ required: requiredSwitch(q),
252
+ },
253
+ {
254
+ type: type => {
255
+ draft.questions[i] = convertType(q, type);
256
+ changed();
257
+ },
258
+ up: () => swap(i, i - 1),
259
+ down: () => swap(i, i + 1),
260
+ remove: () => {
261
+ if (draft.questions.length === 1) return;
262
+ draft.questions.splice(i, 1);
263
+ changed();
264
+ },
265
+ }
266
+ );
267
+ }
268
+
269
+ function swap(i, j) {
270
+ const list = draft.questions;
271
+ if (j < 0 || j >= list.length) return;
272
+ [list[i], list[j]] = [list[j], list[i]];
273
+ changed();
274
+ }
275
+
276
+ function render() {
277
+ const full = !canAddQuestion(draft.questions);
278
+ const add = templates.addQuestion({ full, max: LIMITS.questionsMax });
279
+ add.addEventListener('click', () => {
280
+ const added = newQuestion(
281
+ 'single',
282
+ draft.questions.map(q => q.id)
283
+ );
284
+ draft.questions.push(added);
285
+ focusNext = `[data-focus="q-${added.id}"]`;
286
+ changed();
287
+ });
288
+ root.replaceChildren(
289
+ templates.formWrap({ children: [infoCard(), ...draft.questions.map(questionCard), add] })
290
+ );
291
+ if (focusNext) {
292
+ const target = root.querySelector(focusNext);
293
+ focusNext = null;
294
+ target?.focus();
295
+ }
296
+ }
297
+
298
+ /**
299
+ * 스낵바 (그림을 지운 뒤 "되돌리기"). 한 번에 하나만 보이고 화면 영역 밖(body)에 붙인다
300
+ */
301
+ const SNACKBAR_MS = 6000;
302
+ let snackbarNode = null;
303
+ let snackbarTimer = null;
304
+ function hideSnackbar() {
305
+ clearTimeout(snackbarTimer);
306
+ snackbarNode?.remove();
307
+ snackbarNode = null;
308
+ }
309
+ function showSnackbar(text, restore) {
310
+ hideSnackbar();
311
+ const node = templates.snackbar({ text, action: restore ? t.undo : null });
312
+ node.querySelector('[data-role="undo"]')?.addEventListener('click', () => {
313
+ hideSnackbar();
314
+ restore();
315
+ });
316
+ document.body.append(node);
317
+ snackbarNode = node;
318
+ snackbarTimer = setTimeout(hideSnackbar, SNACKBAR_MS);
319
+ }
320
+
321
+ render();
322
+ root.classList.add('qz-enter');
323
+ save = app.useSave({
324
+ label: t.done,
325
+ // 저장할 내용: { survey: { description, questions } } (core/model.js 머리 설명)
326
+ getContent: () =>
327
+ makeContent({
328
+ description: draft.description,
329
+ questions: cleanQuestions(structuredClone(draft.questions)),
330
+ }),
331
+ validate: content => {
332
+ const result = validateSurvey(content.survey, texts.validation);
333
+ if (result === true) return true;
334
+ // 비운 질문 칸에 빨간 밑줄을 긋고 첫 칸에 초점. 질문이 다 있으면 비운 보기 칸으로
335
+ const empty =
336
+ form.markEmptyRequired() ??
337
+ [...root.querySelectorAll('.qe-option-text')].find(input => !input.value.trim()) ??
338
+ null;
339
+ if (empty) {
340
+ empty.scrollIntoView({ block: 'center' });
341
+ empty.focus({ preventScroll: true });
342
+ }
343
+ return result;
344
+ },
345
+ });
@@ -0,0 +1,100 @@
1
+ // 학생 화면. 설문 안내와 문항을 놓고, 답을 모으고 채우는 방법만 키트에 알려 줍니다.
2
+ // 정답 · 채점은 없습니다: 제출하면 "응답해 주셔서 감사합니다" 화면으로 바뀌고, 다시 열면(지난 제출이 있으면) 그 화면부터 보입니다.
3
+ // "응답 확인하고 수정하기"를 누르면 낸 답이 채워진 문항으로 돌아가 고쳐서 다시 낼 수 있습니다.
4
+ // 튜터링 잠금 · 미리보기 안내 · 답 복원 · 오류 표시는 키트(useSubmit)가 합니다.
5
+ // 모양은 ui/(templates · texts · theme.css), 동작은 core/에 있습니다.
6
+ import { start } from '../lib/elice-content.js';
7
+ import { renderQuestion } from '../core/behaviors.js';
8
+ import { resolveAssets, setAssetFailedText } from '../core/markdown.js';
9
+ import { checkAnswer, OTHER_SUFFIX, readSurvey } from '../core/model.js';
10
+ import { part } from '../core/dom.js';
11
+ import { templates } from '../ui/templates/index.js';
12
+ import { loading } from '../ui/templates/page.js';
13
+ import { texts } from '../ui/texts.js';
14
+
15
+ const t = texts.learn;
16
+ const root = document.getElementById('app');
17
+ document.title = texts.page.learn;
18
+ root.replaceChildren(loading());
19
+ const app = await start({ screen: 'learn' });
20
+ // 설문 내용: settings.survey
21
+ const survey = readSurvey(app.content);
22
+ // 편집 화면에서 아직 내용을 저장하지 않았으면 키트 빈 안내만 보인다 (모든 템플릿 공통 모양 · 문구)
23
+ if (app.hasContent) {
24
+ // 편집 화면에서 안내 · 설명에 올린 그림 ![설명](asset:파일키)을 받기 시작한다. 기다리지 않고 문항을 먼저 그리고,
25
+ // 받으면 그 자리만 그림으로 바꾼다 (그림 하나 10초까지, 못 받으면 새로고침 안내)
26
+ setAssetFailedText(t.imageExpired);
27
+ void resolveAssets(
28
+ [survey.description, ...survey.questions.map(q => q.description)],
29
+ app.assets.url
30
+ );
31
+ show();
32
+ } else root.replaceChildren(app.emptyState());
33
+ // 그림이 깨지면(받은 blob이 그림이 아님 등) 그 자리에 새로고침 안내 (error는 거품이 없어 capture로)
34
+ root.addEventListener(
35
+ 'error',
36
+ e => {
37
+ const img = e.target;
38
+ if (!(img instanceof HTMLImageElement) || !img.dataset.asset) return;
39
+ const notice = document.createElement('span');
40
+ notice.className = 'qz-image-missing';
41
+ notice.setAttribute('role', 'alert');
42
+ notice.textContent = t.imageExpired;
43
+ img.replaceWith(notice);
44
+ },
45
+ true
46
+ );
47
+ // 불러오는 자리에서 내용으로 바뀔 때 살짝 나타나게 (styles.css .qz-enter)
48
+ root.classList.add('qz-enter');
49
+
50
+ function show() {
51
+ const { description = '', questions } = survey;
52
+ const views = questions.map((q, i) => renderQuestion(q, i, { templates }));
53
+ const form = templates.survey({
54
+ head: templates.head({ description, hasRequired: questions.some(q => q.required) }),
55
+ questions: views.map(v => v.el),
56
+ });
57
+ const done = templates.done();
58
+ root.replaceChildren(form, done);
59
+
60
+ const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
61
+ // 제출한 뒤: 문항 · 제출 바를 감추고 감사 화면 (styles.css body.sv-is-done)
62
+ const showDone = () => {
63
+ form.hidden = true;
64
+ done.hidden = false;
65
+ document.body.classList.add('sv-is-done');
66
+ window.scrollTo({ top: 0, behavior: 'auto' });
67
+ part(done, 'done-title').focus({ preventScroll: true });
68
+ };
69
+ part(done, 'done-edit').addEventListener('click', () => {
70
+ done.hidden = true;
71
+ form.hidden = false;
72
+ document.body.classList.remove('sv-is-done');
73
+ window.scrollTo({ top: 0, behavior: reduceMotion ? 'auto' : 'smooth' });
74
+ });
75
+
76
+ app.useSubmit({
77
+ label: t.submit,
78
+ // 답: { 문항 id: 값, 문항 id + ':other': '기타' 글 } (core/model.js 머리 설명). 지금 문항만 키로 둔다
79
+ getAnswer: () =>
80
+ Object.fromEntries(
81
+ questions.flatMap((q, i) => {
82
+ const pairs = [[q.id, views[i].getValue()]];
83
+ const other = views[i].getOther();
84
+ if (other) pairs.push([q.id + OTHER_SUFFIX, other]);
85
+ return pairs;
86
+ })
87
+ ),
88
+ // 지난 제출: 문항 id를 키로 한 객체
89
+ setAnswer: answer => {
90
+ questions.forEach((q, i) => views[i].setValue(answer[q.id], answer[q.id + OTHER_SUFFIX]));
91
+ },
92
+ // 필수 응답 · 기타 글, 서버가 거절할 모양(422 not_a_survey_answer)이 아닌지
93
+ validate: answer => checkAnswer(questions, answer, t),
94
+ // 채점이 없어 결과는 "제출했어요." (키트 기본 문장, styles.css에서 감춤). 제출 직후와 다시 열었을 때(지난 제출) 감사 화면으로.
95
+ // 튜터(읽기 전용)는 학생이 낸 답을 문항에서 바로 본다
96
+ onResult: () => {
97
+ if (!app.readOnly) showDone();
98
+ },
99
+ });
100
+ }