@eliceio/cdk-cli 1.5.4 → 1.6.0-entryqa.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 +31 -29
- package/es/commands/create/index.js +1 -0
- package/es/commands/create/scaffold.d.ts +1 -1
- package/es/commands/create/scaffold.js +1 -1
- package/es/core/config.d.ts +61 -2
- package/es/core/config.js +309 -3
- package/es/dev/grading.d.ts +31 -2
- package/es/dev/grading.js +68 -1
- package/es/dev/mock-api.d.ts +3 -1
- package/es/dev/mock-api.js +34 -4
- package/es/dev/server.js +5 -4
- package/es/rules/answers.d.ts +1 -0
- package/es/rules/answers.js +3 -0
- package/es/rules/check.js +8 -1
- package/es/rules/csp.d.ts +7 -0
- package/es/rules/csp.js +24 -3
- package/es/rules/index.d.ts +1 -1
- package/es/rules/index.js +1 -1
- package/es/rules/types.d.ts +4 -3
- package/es/rules.json.js +1 -1
- package/package.json +2 -2
- package/rules.json +5 -4
- package/skills/_shared/references/02-design-the-material.md +2 -1
- package/skills/_shared/references/05-screen-code.md +1 -0
- package/skills/_shared/references/12-upload-with-the-material-mcp.md +1 -1
- package/templates/_shared/lib/cdk-mock.d.ts +33 -2
- package/templates/_shared/lib/cdk-mock.js +171 -5
- package/templates/_shared/lib/elice-content.d.ts +38 -0
- package/templates/_shared/lib/elice-content.js +85 -2
- package/templates/blank/template.json +1 -1
- package/templates/document/template.json +3 -2
- package/templates/entry/README.md +117 -0
- package/templates/entry/commentary.txt +2 -0
- package/templates/entry/core/autosave.d.ts +13 -0
- package/templates/entry/core/autosave.js +69 -0
- package/templates/entry/core/default-project.d.ts +2 -0
- package/templates/entry/core/default-project.js +139 -0
- package/templates/entry/core/dom.d.ts +13 -0
- package/templates/entry/core/dom.js +83 -0
- package/templates/entry/core/grading.d.ts +52 -0
- package/templates/entry/core/grading.js +139 -0
- package/templates/entry/core/pack.d.ts +12 -0
- package/templates/entry/core/pack.js +71 -0
- package/templates/entry/core/settings.d.ts +33 -0
- package/templates/entry/core/settings.js +79 -0
- package/templates/entry/core/workspace.d.ts +40 -0
- package/templates/entry/core/workspace.js +320 -0
- package/templates/entry/docs/storage.md +44 -0
- package/templates/entry/edit.html +17 -0
- package/templates/entry/gitignore +4 -0
- package/templates/entry/index.html +17 -0
- package/templates/entry/metadata.json +9 -0
- package/templates/entry/package.json +13 -0
- package/templates/entry/screens/edit/panels/answer-project.js +15 -0
- package/templates/entry/screens/edit/panels/grading.d.ts +18 -0
- package/templates/entry/screens/edit/panels/grading.js +627 -0
- package/templates/entry/screens/edit/panels/index.js +25 -0
- package/templates/entry/screens/edit/panels/preference.js +56 -0
- package/templates/entry/screens/edit/panels/project-panel.js +93 -0
- package/templates/entry/screens/edit/panels/start-project.js +6 -0
- package/templates/entry/screens/edit.js +293 -0
- package/templates/entry/screens/learn.js +268 -0
- package/templates/entry/styles.css +1037 -0
- package/templates/entry/template.json +6 -0
- package/templates/entry/ui/templates/page.js +106 -0
- package/templates/entry/ui/texts.d.ts +3 -0
- package/templates/entry/ui/texts.js +160 -0
- package/templates/entry/ui/theme.css +17 -0
- package/templates/quiz/README.md +1 -1
- package/templates/quiz/template.json +3 -2
- package/templates/steps/template.json +1 -1
- package/templates/survey/README.md +1 -0
- package/templates/survey/template.json +3 -2
- package/templates/video/template.json +3 -2
|
@@ -0,0 +1,627 @@
|
|
|
1
|
+
// 패널: 채점 방식 ('채점 설정' 탭). 일반 채점 · AI 채점과 AI 채점 기준(오브젝트 · 채점 기준 · 부분 점수)을 고릅니다.
|
|
2
|
+
// secret: settings.grading에 저장합니다 (학생에게 안 감). 모양은 core/grading.js, 정답 작품은 answer-project.js 패널.
|
|
3
|
+
// 화면 배치: 정답 작품 워크스페이스 → 채점 방식 줄 → AI 채점 기준 상자 (styles.css의 order). 정답 블록을 만든 뒤 채점 방식을 고르는 흐름.
|
|
4
|
+
// 검사: 저장을 누르면 칸마다 아래에 빨간 글(오브젝트 · 채점 기준 · 점수, 마지막 줄 점수 칸에 총점)을 띄우고 첫 칸으로 옮기며,
|
|
5
|
+
// 저장 바에는 요약 한 줄. 그 뒤로는 고칠 때마다 다시 그림. 총점이 100을 넘으면 저장 전에도 보임.
|
|
6
|
+
// 오브젝트 목록은 정답 작품에서 받습니다(ctx.objects: 정답 작품 워크스페이스의 TO_GET_OBJECTS, 띄우기 전이면 저장된 정답 → 시작 화면).
|
|
7
|
+
// 정답 작품은 시작 화면을 복사해 시작하므로 학생 작품과 같은 오브젝트 id를 가집니다. 작품 전체("공통") 기준은 없습니다(서버가 받지 않음):
|
|
8
|
+
// 새 줄은 오브젝트를 고르지 않은 채로 시작하고, 고르지 않거나 정답 작품에 없는 오브젝트면 저장을 막습니다.
|
|
9
|
+
import { html } from '../../../core/dom.js';
|
|
10
|
+
import { equalScores, readGrading, RUBRIC_LIMITS, rubricTotal, rubricsProblem } from '../../../core/grading.js';
|
|
11
|
+
import { texts } from '../../../ui/texts.js';
|
|
12
|
+
|
|
13
|
+
const t = texts.edit.grading;
|
|
14
|
+
const fe = t.fieldErrors;
|
|
15
|
+
/** 아직 고르지 않은 오브젝트 칸 */
|
|
16
|
+
const UNSET = '';
|
|
17
|
+
const emptyRow = () => ({ object: UNSET, criteria: '', score: null });
|
|
18
|
+
/** 그린 패널과 validate를 잇는 것 (패널은 화면에 하나): 칸 아래 오류를 띄우고 첫 칸으로 옮김. 오류가 있으면 true */
|
|
19
|
+
const view = { reveal: null };
|
|
20
|
+
const reduceMotion = () => globalThis.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false;
|
|
21
|
+
|
|
22
|
+
/** 요소 만들기: class · on* (이벤트) · 그 밖은 속성. false · null 속성과 null 자식은 뺌 */
|
|
23
|
+
function node(tag, attrs = {}, ...children) {
|
|
24
|
+
const e = document.createElement(tag);
|
|
25
|
+
for (const [k, v] of Object.entries(attrs)) {
|
|
26
|
+
if (v === false || v === null || v === undefined) continue;
|
|
27
|
+
if (k === 'class') e.className = v;
|
|
28
|
+
else if (k.startsWith('on')) e.addEventListener(k.slice(2), v);
|
|
29
|
+
else e.setAttribute(k, v === true ? '' : v);
|
|
30
|
+
}
|
|
31
|
+
e.append(...children.flat().filter(c => c !== null && c !== undefined));
|
|
32
|
+
return e;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const icon = {
|
|
36
|
+
close: () =>
|
|
37
|
+
html`<span aria-hidden="true"
|
|
38
|
+
><svg
|
|
39
|
+
width="18"
|
|
40
|
+
height="18"
|
|
41
|
+
viewBox="0 0 24 24"
|
|
42
|
+
fill="none"
|
|
43
|
+
stroke="currentColor"
|
|
44
|
+
stroke-width="2"
|
|
45
|
+
stroke-linecap="round"
|
|
46
|
+
>
|
|
47
|
+
<path d="M6 6l12 12M18 6 6 18" /></svg
|
|
48
|
+
></span>`,
|
|
49
|
+
plus: () =>
|
|
50
|
+
html`<span aria-hidden="true"
|
|
51
|
+
><svg
|
|
52
|
+
width="16"
|
|
53
|
+
height="16"
|
|
54
|
+
viewBox="0 0 24 24"
|
|
55
|
+
fill="none"
|
|
56
|
+
stroke="currentColor"
|
|
57
|
+
stroke-width="2.5"
|
|
58
|
+
stroke-linecap="round"
|
|
59
|
+
>
|
|
60
|
+
<path d="M12 5v14M5 12h14" /></svg
|
|
61
|
+
></span>`,
|
|
62
|
+
info: () =>
|
|
63
|
+
html`<span aria-hidden="true"
|
|
64
|
+
><svg
|
|
65
|
+
width="16"
|
|
66
|
+
height="16"
|
|
67
|
+
viewBox="0 0 24 24"
|
|
68
|
+
fill="none"
|
|
69
|
+
stroke="currentColor"
|
|
70
|
+
stroke-width="2"
|
|
71
|
+
stroke-linecap="round"
|
|
72
|
+
>
|
|
73
|
+
<circle cx="12" cy="12" r="9" />
|
|
74
|
+
<path d="M12 11v5M12 8h.01" /></svg
|
|
75
|
+
></span>`,
|
|
76
|
+
chevron: () =>
|
|
77
|
+
html`<span aria-hidden="true"
|
|
78
|
+
><svg
|
|
79
|
+
width="16"
|
|
80
|
+
height="16"
|
|
81
|
+
viewBox="0 0 24 24"
|
|
82
|
+
fill="none"
|
|
83
|
+
stroke="currentColor"
|
|
84
|
+
stroke-width="2.5"
|
|
85
|
+
stroke-linecap="round"
|
|
86
|
+
stroke-linejoin="round"
|
|
87
|
+
>
|
|
88
|
+
<path d="m6 9 6 6 6-6" /></svg
|
|
89
|
+
></span>`,
|
|
90
|
+
sparkle: () =>
|
|
91
|
+
html`<span aria-hidden="true"
|
|
92
|
+
><svg
|
|
93
|
+
width="16"
|
|
94
|
+
height="16"
|
|
95
|
+
viewBox="0 0 24 24"
|
|
96
|
+
fill="none"
|
|
97
|
+
stroke="currentColor"
|
|
98
|
+
stroke-width="2"
|
|
99
|
+
stroke-linejoin="round"
|
|
100
|
+
>
|
|
101
|
+
<path d="M10 3l1.9 5.1L17 10l-5.1 1.9L10 17l-1.9-5.1L3 10l5.1-1.9z" />
|
|
102
|
+
<path d="M18 14l.9 2.1L21 17l-2.1.9L18 20l-.9-2.1L15 17l2.1-.9z" /></svg
|
|
103
|
+
></span>`,
|
|
104
|
+
caret: () =>
|
|
105
|
+
html`<span class="en-select-caret" aria-hidden="true"
|
|
106
|
+
><svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor">
|
|
107
|
+
<path d="M2 4h8L6 9z" /></svg
|
|
108
|
+
></span>`,
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 그림 주소를 이 화면에서 띄울 수 있나: data: · blob: · 콘텐츠와 같은 출처만.
|
|
113
|
+
* 워크스페이스가 주는 그림은 워크스페이스 출처(예: http://localhost:9000/renderer/…/thumb/…)라 콘텐츠 CSP img-src가 막는다 → 빈 칸
|
|
114
|
+
*/
|
|
115
|
+
const showable = src => {
|
|
116
|
+
try {
|
|
117
|
+
const url = new URL(src, location.href);
|
|
118
|
+
return url.protocol === 'data:' || url.protocol === 'blob:' || url.origin === location.origin;
|
|
119
|
+
} catch {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/** 오브젝트 그림 칸 (그림이 없거나 띄울 수 없으면 빈 칸) */
|
|
125
|
+
function thumb(src) {
|
|
126
|
+
const box = node('span', { class: 'en-thumb', 'aria-hidden': 'true' });
|
|
127
|
+
if (src && showable(src)) {
|
|
128
|
+
const img = node('img', { src, alt: '', onerror: () => img.remove() });
|
|
129
|
+
box.append(img);
|
|
130
|
+
}
|
|
131
|
+
return box;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export default {
|
|
135
|
+
id: 'grading',
|
|
136
|
+
title: t.title,
|
|
137
|
+
tab: 'answer',
|
|
138
|
+
secret: true,
|
|
139
|
+
/** app.grading → { mode, rubrics } */
|
|
140
|
+
normalize(raw) {
|
|
141
|
+
const { mode, rubrics } = readGrading(raw);
|
|
142
|
+
return { mode, rubrics };
|
|
143
|
+
},
|
|
144
|
+
render(el, ctx) {
|
|
145
|
+
const get = () => ctx.value;
|
|
146
|
+
const update = patch => ctx.set({ ...get(), ...patch });
|
|
147
|
+
|
|
148
|
+
// 채점 방식 줄 (정답 작품 아래): 일반 채점 · AI 채점 + 완료 정책 안내
|
|
149
|
+
const modeCard = (mode, label) =>
|
|
150
|
+
node(
|
|
151
|
+
'label',
|
|
152
|
+
{ class: 'en-radio-card' },
|
|
153
|
+
node('input', {
|
|
154
|
+
class: 'ec-visually-hidden',
|
|
155
|
+
type: 'radio',
|
|
156
|
+
name: 'en-grading-mode',
|
|
157
|
+
value: mode,
|
|
158
|
+
checked: get().mode === mode,
|
|
159
|
+
onchange: e => {
|
|
160
|
+
if (!e.target.checked) return;
|
|
161
|
+
update({ mode });
|
|
162
|
+
showMode(true);
|
|
163
|
+
},
|
|
164
|
+
}),
|
|
165
|
+
node('span', { class: 'en-radio-card-title' }, label)
|
|
166
|
+
);
|
|
167
|
+
const modeRow = node(
|
|
168
|
+
'div',
|
|
169
|
+
{ class: 'en-grading-mode' },
|
|
170
|
+
node('p', { class: 'en-field-title' }, t.method),
|
|
171
|
+
node(
|
|
172
|
+
'fieldset',
|
|
173
|
+
{ class: 'en-modes' },
|
|
174
|
+
node('legend', { class: 'ec-visually-hidden' }, t.method),
|
|
175
|
+
modeCard('general', t.modes.general),
|
|
176
|
+
modeCard('ai', t.modes.ai)
|
|
177
|
+
),
|
|
178
|
+
// 완료 정책 안내: 채점 결과로 완료하려면 LXP 설정에서 '답안 확인 후 완료'(on_graded)
|
|
179
|
+
node('p', { class: 'en-grading-note' }, icon.info(), node('span', {}, t.policyNote))
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
// 채점 기준 예시 (팝오버)
|
|
183
|
+
const exampleButton = node(
|
|
184
|
+
'button',
|
|
185
|
+
{
|
|
186
|
+
type: 'button',
|
|
187
|
+
class: 'en-link-button en-example-button',
|
|
188
|
+
'aria-haspopup': 'true',
|
|
189
|
+
'aria-expanded': 'false',
|
|
190
|
+
onclick: e => {
|
|
191
|
+
e.stopPropagation();
|
|
192
|
+
togglePopover();
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
node('span', {}, t.exampleToggle),
|
|
196
|
+
icon.chevron()
|
|
197
|
+
);
|
|
198
|
+
const popover = node(
|
|
199
|
+
'div',
|
|
200
|
+
{ class: 'en-popover', role: 'dialog', 'aria-label': t.exampleToggle, hidden: true },
|
|
201
|
+
node(
|
|
202
|
+
'ul',
|
|
203
|
+
{},
|
|
204
|
+
t.examples.map(x => node('li', {}, x))
|
|
205
|
+
)
|
|
206
|
+
);
|
|
207
|
+
const popWrap = node('span', { class: 'en-pop-wrap' }, exampleButton, popover);
|
|
208
|
+
function togglePopover(force) {
|
|
209
|
+
const open = force ?? popover.hidden;
|
|
210
|
+
popover.hidden = !open;
|
|
211
|
+
exampleButton.setAttribute('aria-expanded', String(open));
|
|
212
|
+
}
|
|
213
|
+
document.addEventListener('click', e => popWrap.contains(e.target) || togglePopover(false));
|
|
214
|
+
document.addEventListener('keydown', e => e.key === 'Escape' && togglePopover(false));
|
|
215
|
+
|
|
216
|
+
const required = () => node('span', { class: 'en-required', 'aria-hidden': 'true' }, '*');
|
|
217
|
+
// 부분 점수 안내: 마우스를 올리거나 포커스하면 말풍선
|
|
218
|
+
const tooltip = node(
|
|
219
|
+
'span',
|
|
220
|
+
{ class: 'en-tooltip', role: 'tooltip', id: 'en-score-tip', hidden: true },
|
|
221
|
+
t.scoreInfo
|
|
222
|
+
);
|
|
223
|
+
const showTip = on => {
|
|
224
|
+
tooltip.hidden = !on;
|
|
225
|
+
};
|
|
226
|
+
const scoreInfo = node(
|
|
227
|
+
'span',
|
|
228
|
+
{
|
|
229
|
+
class: 'en-info',
|
|
230
|
+
role: 'img',
|
|
231
|
+
'aria-label': t.scoreInfo,
|
|
232
|
+
'aria-describedby': 'en-score-tip',
|
|
233
|
+
tabindex: '0',
|
|
234
|
+
onmouseenter: () => showTip(true),
|
|
235
|
+
onmouseleave: () => showTip(false),
|
|
236
|
+
onfocus: () => showTip(true),
|
|
237
|
+
onblur: () => showTip(false),
|
|
238
|
+
onkeydown: e => e.key === 'Escape' && showTip(false),
|
|
239
|
+
},
|
|
240
|
+
icon.info(),
|
|
241
|
+
tooltip
|
|
242
|
+
);
|
|
243
|
+
const list = node('div', { class: 'en-criteria' });
|
|
244
|
+
const addButton = node(
|
|
245
|
+
'button',
|
|
246
|
+
{ type: 'button', class: 'en-add-button', onclick: () => addRow() },
|
|
247
|
+
icon.plus(),
|
|
248
|
+
node('span', {}, t.add)
|
|
249
|
+
);
|
|
250
|
+
// 자동 배점: 기준 수로 100점을 고르게 나눔 (core/grading.js equalScores)
|
|
251
|
+
const autoButton = node(
|
|
252
|
+
'button',
|
|
253
|
+
{ type: 'button', class: 'en-link-button en-auto-button', onclick: () => autoScore() },
|
|
254
|
+
icon.sparkle(),
|
|
255
|
+
node('span', {}, t.autoScore)
|
|
256
|
+
);
|
|
257
|
+
const ai = node(
|
|
258
|
+
'div',
|
|
259
|
+
{ class: 'en-ai' },
|
|
260
|
+
node(
|
|
261
|
+
'div',
|
|
262
|
+
{ class: 'en-ai-head' },
|
|
263
|
+
node(
|
|
264
|
+
'div',
|
|
265
|
+
{ class: 'en-ai-title' },
|
|
266
|
+
node('p', { class: 'en-ai-title-text' }, t.aiTitle),
|
|
267
|
+
node('p', { class: 'en-ai-desc-text' }, t.aiDescription)
|
|
268
|
+
),
|
|
269
|
+
popWrap
|
|
270
|
+
),
|
|
271
|
+
node(
|
|
272
|
+
'div',
|
|
273
|
+
{ class: 'en-criteria-form' },
|
|
274
|
+
node(
|
|
275
|
+
'div',
|
|
276
|
+
{ class: 'en-criteria-head' },
|
|
277
|
+
node('span', {}, t.columns.object, required()),
|
|
278
|
+
node('span', {}, t.columns.criterion, required()),
|
|
279
|
+
node('span', {}, t.columns.score, required(), scoreInfo),
|
|
280
|
+
node('span', {})
|
|
281
|
+
),
|
|
282
|
+
list,
|
|
283
|
+
node('div', { class: 'en-criteria-actions' }, addButton, autoButton)
|
|
284
|
+
)
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
// 오브젝트 목록 (정답 작품). 고를 때마다 새로 받음
|
|
288
|
+
let objects = [];
|
|
289
|
+
let loaded = false;
|
|
290
|
+
const loadObjects = async () => {
|
|
291
|
+
try {
|
|
292
|
+
objects = (await ctx.objects())
|
|
293
|
+
.filter(o => o && typeof o.id === 'string' && o.id)
|
|
294
|
+
.map(o => ({
|
|
295
|
+
id: o.id,
|
|
296
|
+
name: typeof o.name === 'string' && o.name ? o.name : o.id,
|
|
297
|
+
thumbnail: typeof o.thumbnail === 'string' ? o.thumbnail : '',
|
|
298
|
+
}));
|
|
299
|
+
loaded = true;
|
|
300
|
+
} catch {
|
|
301
|
+
// 워크스페이스가 아직 준비 전이면 이전 목록
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
const objectOf = id => objects.find(o => o.id === id);
|
|
305
|
+
// 목록을 받기 전에는 '불러오는 중'
|
|
306
|
+
const labelOf = id =>
|
|
307
|
+
id === UNSET ? t.selectObject : (objectOf(id)?.name ?? (loaded ? t.unknownObject : texts.page.loading));
|
|
308
|
+
|
|
309
|
+
// 열린 오브젝트 메뉴 닫기 (바깥 클릭 · 스크롤 · 크기 바뀜)
|
|
310
|
+
let closeOpenMenu = null;
|
|
311
|
+
const closeAny = () => closeOpenMenu?.();
|
|
312
|
+
document.addEventListener('click', closeAny);
|
|
313
|
+
document.addEventListener('scroll', closeAny, true);
|
|
314
|
+
addEventListener('resize', closeAny);
|
|
315
|
+
|
|
316
|
+
/** 오브젝트 고르기 (목록 상자) */
|
|
317
|
+
const objectSelect = index => {
|
|
318
|
+
const button = node('button', {
|
|
319
|
+
type: 'button',
|
|
320
|
+
class: 'en-field en-select-button',
|
|
321
|
+
'aria-haspopup': 'listbox',
|
|
322
|
+
'aria-expanded': 'false',
|
|
323
|
+
'aria-label': t.columns.object,
|
|
324
|
+
// 고른 값 표시 · 메뉴 그리기는 내용 변경이 아님 (키트 저장 바의 '저장하지 않은 변경' 감지에서 뺌)
|
|
325
|
+
'data-ec-quiet': true,
|
|
326
|
+
});
|
|
327
|
+
const paint = id => {
|
|
328
|
+
button.replaceChildren(
|
|
329
|
+
...(id === UNSET ? [] : [thumb(objectOf(id)?.thumbnail)]),
|
|
330
|
+
node('span', { class: 'en-select-value', 'data-empty': id === UNSET }, labelOf(id)),
|
|
331
|
+
icon.caret()
|
|
332
|
+
);
|
|
333
|
+
};
|
|
334
|
+
const repaint = () => paint(get().rubrics[index]?.object ?? UNSET);
|
|
335
|
+
repaint();
|
|
336
|
+
repaints.push(repaint);
|
|
337
|
+
const menu = node('ul', {
|
|
338
|
+
class: 'en-menu',
|
|
339
|
+
role: 'listbox',
|
|
340
|
+
hidden: true,
|
|
341
|
+
'aria-label': t.columns.object,
|
|
342
|
+
'data-ec-quiet': true,
|
|
343
|
+
});
|
|
344
|
+
const options = () => [...menu.querySelectorAll('[role="option"]')];
|
|
345
|
+
const close = (focus = false) => {
|
|
346
|
+
if (menu.hidden) return;
|
|
347
|
+
menu.hidden = true;
|
|
348
|
+
button.setAttribute('aria-expanded', 'false');
|
|
349
|
+
if (closeOpenMenu === close) closeOpenMenu = null;
|
|
350
|
+
if (focus) button.focus();
|
|
351
|
+
};
|
|
352
|
+
const choose = id => {
|
|
353
|
+
updateRow(index, { object: id });
|
|
354
|
+
paint(id);
|
|
355
|
+
close(true);
|
|
356
|
+
};
|
|
357
|
+
const open = async () => {
|
|
358
|
+
closeAny();
|
|
359
|
+
await loadObjects();
|
|
360
|
+
const current = get().rubrics[index]?.object ?? UNSET;
|
|
361
|
+
const items = [...objects];
|
|
362
|
+
// 저장된 기준의 오브젝트가 정답 작품에 없으면 '없는 오브젝트'로 보여 줌 (고르면 바뀌고, 그대로면 저장을 막음)
|
|
363
|
+
if (current !== UNSET && !items.some(o => o.id === current))
|
|
364
|
+
items.push({ id: current, name: t.unknownObject, thumbnail: '' });
|
|
365
|
+
menu.replaceChildren(
|
|
366
|
+
...items.map(o =>
|
|
367
|
+
node(
|
|
368
|
+
'li',
|
|
369
|
+
{
|
|
370
|
+
class: 'en-menu-item',
|
|
371
|
+
role: 'option',
|
|
372
|
+
tabindex: '-1',
|
|
373
|
+
'aria-selected': String(o.id === current),
|
|
374
|
+
onclick: e => {
|
|
375
|
+
e.stopPropagation();
|
|
376
|
+
choose(o.id);
|
|
377
|
+
},
|
|
378
|
+
},
|
|
379
|
+
thumb(o.thumbnail),
|
|
380
|
+
node('span', {}, o.name)
|
|
381
|
+
)
|
|
382
|
+
),
|
|
383
|
+
...(items.length ? [] : [node('li', { class: 'en-menu-empty' }, t.noObjects)])
|
|
384
|
+
);
|
|
385
|
+
menu.hidden = false;
|
|
386
|
+
button.setAttribute('aria-expanded', 'true');
|
|
387
|
+
const box = button.getBoundingClientRect();
|
|
388
|
+
menu.style.minWidth = `${box.width}px`;
|
|
389
|
+
menu.style.left = `${box.left}px`;
|
|
390
|
+
const height = menu.getBoundingClientRect().height;
|
|
391
|
+
const above = box.bottom + height + 8 > innerHeight && box.top > height + 8;
|
|
392
|
+
menu.style.top = `${above ? box.top - height - 4 : box.bottom + 4}px`;
|
|
393
|
+
closeOpenMenu = close;
|
|
394
|
+
(options().find(o => o.getAttribute('aria-selected') === 'true') ?? options()[0])?.focus();
|
|
395
|
+
};
|
|
396
|
+
button.addEventListener('click', e => {
|
|
397
|
+
e.stopPropagation();
|
|
398
|
+
if (menu.hidden) void open();
|
|
399
|
+
else close();
|
|
400
|
+
});
|
|
401
|
+
button.addEventListener('keydown', e => {
|
|
402
|
+
if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp') return;
|
|
403
|
+
e.preventDefault();
|
|
404
|
+
void open();
|
|
405
|
+
});
|
|
406
|
+
menu.addEventListener('keydown', e => {
|
|
407
|
+
const all = options();
|
|
408
|
+
const at = all.indexOf(document.activeElement);
|
|
409
|
+
if (e.key === 'ArrowDown') all[Math.min(at + 1, all.length - 1)]?.focus();
|
|
410
|
+
else if (e.key === 'ArrowUp') all[Math.max(at - 1, 0)]?.focus();
|
|
411
|
+
else if (e.key === 'Home') all[0]?.focus();
|
|
412
|
+
else if (e.key === 'End') all[all.length - 1]?.focus();
|
|
413
|
+
else if (e.key === 'Enter' || e.key === ' ') all[at]?.click();
|
|
414
|
+
else if (e.key === 'Escape') close(true);
|
|
415
|
+
else if (e.key === 'Tab') close();
|
|
416
|
+
else return;
|
|
417
|
+
e.preventDefault();
|
|
418
|
+
e.stopPropagation();
|
|
419
|
+
});
|
|
420
|
+
return node('div', { class: 'en-select' }, button, menu);
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
const updateRow = (index, patch) => {
|
|
424
|
+
update({ rubrics: get().rubrics.map((r, i) => (i === index ? { ...r, ...patch } : r)) });
|
|
425
|
+
paintErrors();
|
|
426
|
+
};
|
|
427
|
+
const addRow = () => {
|
|
428
|
+
if (get().rubrics.length >= RUBRIC_LIMITS.max) return;
|
|
429
|
+
update({ rubrics: [...get().rubrics, emptyRow()] });
|
|
430
|
+
paintRows();
|
|
431
|
+
cells.at(-1)?.selectButton.focus();
|
|
432
|
+
};
|
|
433
|
+
const removeRow = index => {
|
|
434
|
+
if (index === 0 || get().rubrics.length <= 1) return;
|
|
435
|
+
update({ rubrics: get().rubrics.filter((_, i) => i !== index) });
|
|
436
|
+
paintRows();
|
|
437
|
+
};
|
|
438
|
+
/** 자동 배점: 기준 수로 100점을 고르게 (합은 늘 100, 나머지는 앞 기준부터) */
|
|
439
|
+
const autoScore = () => {
|
|
440
|
+
const scores = equalScores(get().rubrics.length);
|
|
441
|
+
if (!scores.length) return;
|
|
442
|
+
update({ rubrics: get().rubrics.map((r, i) => ({ ...r, score: scores[i] })) });
|
|
443
|
+
paintRows();
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
// 칸 아래 오류: 저장을 누른 뒤부터(revealed) 칸마다. 총점이 100을 넘는 것은 늘 (마지막 줄 점수 칸 아래)
|
|
447
|
+
let revealed = false;
|
|
448
|
+
/** 줄마다 칸 요소 { selectBox, selectButton, selectMessage, criteria, criteriaMessage, scoreBox, score, scoreMessage } */
|
|
449
|
+
let cells = [];
|
|
450
|
+
const errorLine = () => node('p', { class: 'en-field-error', hidden: true });
|
|
451
|
+
/** 줄마다 칸의 문제 (문구, 없으면 '') */
|
|
452
|
+
const rowProblems = () => {
|
|
453
|
+
const rows = get().rubrics;
|
|
454
|
+
const total = rubricTotal(rows);
|
|
455
|
+
const filled = rows.length > 0 && rows.every(r => r.score !== null);
|
|
456
|
+
return rows.map((r, i) => {
|
|
457
|
+
const last = i === rows.length - 1;
|
|
458
|
+
const scoreOk = Number.isInteger(r.score) && r.score >= RUBRIC_LIMITS.scoreMin && r.score <= RUBRIC_LIMITS.total;
|
|
459
|
+
let totalError = '';
|
|
460
|
+
if (last && total > RUBRIC_LIMITS.total) totalError = fe.over;
|
|
461
|
+
else if (last && revealed && filled && total !== RUBRIC_LIMITS.total) totalError = fe.under;
|
|
462
|
+
const object =
|
|
463
|
+
r.object === UNSET ? fe.object : loaded && !objectOf(r.object) ? fe.unknownObject : '';
|
|
464
|
+
return {
|
|
465
|
+
object: revealed ? object : '',
|
|
466
|
+
criteria: revealed && !r.criteria.trim() ? fe.criterion : '',
|
|
467
|
+
score: revealed && r.score === null ? fe.score : revealed && !scoreOk ? fe.scoreRange(RUBRIC_LIMITS.scoreMin, RUBRIC_LIMITS.total) : '',
|
|
468
|
+
total: totalError,
|
|
469
|
+
};
|
|
470
|
+
});
|
|
471
|
+
};
|
|
472
|
+
const mark = (box, message, text, invalid, input) => {
|
|
473
|
+
box.dataset.invalid = String(invalid);
|
|
474
|
+
message.textContent = text;
|
|
475
|
+
message.hidden = !text;
|
|
476
|
+
input.setAttribute('aria-invalid', String(invalid));
|
|
477
|
+
};
|
|
478
|
+
function paintErrors() {
|
|
479
|
+
const problems = rowProblems();
|
|
480
|
+
cells.forEach((c, i) => {
|
|
481
|
+
const p = problems[i];
|
|
482
|
+
if (!p) return;
|
|
483
|
+
mark(c.selectBox, c.selectMessage, p.object, Boolean(p.object), c.selectButton);
|
|
484
|
+
mark(c.criteria, c.criteriaMessage, p.criteria, Boolean(p.criteria), c.criteria);
|
|
485
|
+
mark(c.scoreBox, c.scoreMessage, p.score || p.total, Boolean(p.score || p.total), c.score);
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
/** 저장 직전 (validate): 오류를 띄우고 첫 문제 칸으로 옮김. 문제가 있으면 true */
|
|
489
|
+
view.reveal = () => {
|
|
490
|
+
if (get().mode !== 'ai') return false;
|
|
491
|
+
if (!get().rubrics.length) {
|
|
492
|
+
update({ rubrics: [emptyRow()] });
|
|
493
|
+
paintRows();
|
|
494
|
+
}
|
|
495
|
+
revealed = true;
|
|
496
|
+
paintErrors();
|
|
497
|
+
const problems = rowProblems();
|
|
498
|
+
let target = null;
|
|
499
|
+
problems.forEach((p, i) => {
|
|
500
|
+
if (target) return;
|
|
501
|
+
if (p.object) target = cells[i].selectButton;
|
|
502
|
+
else if (p.criteria) target = cells[i].criteria;
|
|
503
|
+
else if (p.score || p.total) target = cells[i].score;
|
|
504
|
+
});
|
|
505
|
+
if (!target) return false;
|
|
506
|
+
ctx.showTab?.();
|
|
507
|
+
requestAnimationFrame(() => {
|
|
508
|
+
ai.scrollIntoView?.({ behavior: reduceMotion() ? 'auto' : 'smooth', block: 'start' });
|
|
509
|
+
target.focus({ preventScroll: true });
|
|
510
|
+
});
|
|
511
|
+
return true;
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
/** 오브젝트 칸마다 다시 그리기 (오브젝트 이름 · 그림을 받은 뒤) */
|
|
515
|
+
let repaints = [];
|
|
516
|
+
function paintRows() {
|
|
517
|
+
const rows = get().rubrics;
|
|
518
|
+
repaints = [];
|
|
519
|
+
cells = [];
|
|
520
|
+
list.replaceChildren(
|
|
521
|
+
...rows.map((row, index) => {
|
|
522
|
+
const criteria = node('input', {
|
|
523
|
+
class: 'en-field',
|
|
524
|
+
type: 'text',
|
|
525
|
+
value: row.criteria,
|
|
526
|
+
maxlength: String(RUBRIC_LIMITS.criteriaMax),
|
|
527
|
+
placeholder: t.criterionPlaceholder,
|
|
528
|
+
'aria-label': t.columns.criterion,
|
|
529
|
+
oninput: e => updateRow(index, { criteria: e.target.value }),
|
|
530
|
+
});
|
|
531
|
+
const score = node('input', {
|
|
532
|
+
class: 'en-score-input',
|
|
533
|
+
type: 'number',
|
|
534
|
+
inputmode: 'numeric',
|
|
535
|
+
min: String(RUBRIC_LIMITS.scoreMin),
|
|
536
|
+
max: String(RUBRIC_LIMITS.total),
|
|
537
|
+
step: '1',
|
|
538
|
+
value: row.score === null ? '' : String(row.score),
|
|
539
|
+
placeholder: t.scorePlaceholder,
|
|
540
|
+
'aria-label': t.columns.score,
|
|
541
|
+
oninput: e => {
|
|
542
|
+
const n = e.target.value === '' ? null : Number(e.target.value);
|
|
543
|
+
updateRow(index, { score: Number.isInteger(n) ? n : null });
|
|
544
|
+
},
|
|
545
|
+
});
|
|
546
|
+
const scoreBox = node(
|
|
547
|
+
'label',
|
|
548
|
+
{ class: 'en-field en-score-field' },
|
|
549
|
+
score,
|
|
550
|
+
node('span', { class: 'en-unit' }, t.unit)
|
|
551
|
+
);
|
|
552
|
+
const selectBox = objectSelect(index);
|
|
553
|
+
const cell = {
|
|
554
|
+
selectBox,
|
|
555
|
+
selectButton: selectBox.querySelector('button'),
|
|
556
|
+
selectMessage: errorLine(),
|
|
557
|
+
criteria,
|
|
558
|
+
criteriaMessage: errorLine(),
|
|
559
|
+
scoreBox,
|
|
560
|
+
score,
|
|
561
|
+
scoreMessage: errorLine(),
|
|
562
|
+
};
|
|
563
|
+
cells.push(cell);
|
|
564
|
+
// 첫 줄은 지우지 않음 (기준은 하나 이상): 자리만 둠
|
|
565
|
+
const remove =
|
|
566
|
+
index === 0
|
|
567
|
+
? node('span', {
|
|
568
|
+
class: 'en-icon-button en-icon-button--placeholder',
|
|
569
|
+
'aria-hidden': 'true',
|
|
570
|
+
})
|
|
571
|
+
: node(
|
|
572
|
+
'button',
|
|
573
|
+
{
|
|
574
|
+
type: 'button',
|
|
575
|
+
class: 'en-icon-button',
|
|
576
|
+
'aria-label': t.remove,
|
|
577
|
+
title: t.remove,
|
|
578
|
+
onclick: () => removeRow(index),
|
|
579
|
+
},
|
|
580
|
+
icon.close()
|
|
581
|
+
);
|
|
582
|
+
return node(
|
|
583
|
+
'div',
|
|
584
|
+
{ class: 'en-criterion' },
|
|
585
|
+
node('div', { class: 'en-cell' }, selectBox, cell.selectMessage),
|
|
586
|
+
node('div', { class: 'en-cell' }, criteria, cell.criteriaMessage),
|
|
587
|
+
node('div', { class: 'en-cell' }, scoreBox, cell.scoreMessage),
|
|
588
|
+
remove
|
|
589
|
+
);
|
|
590
|
+
})
|
|
591
|
+
);
|
|
592
|
+
addButton.disabled = rows.length >= RUBRIC_LIMITS.max;
|
|
593
|
+
autoButton.disabled = rows.length < 1;
|
|
594
|
+
paintErrors();
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/** 방식에 맞게 보이기. AI로 바꿨는데 기준이 없으면 빈 줄 하나, 바꾼 뒤에는 기준 상자가 보이게 스크롤 */
|
|
598
|
+
function showMode(changed = false) {
|
|
599
|
+
const isAi = get().mode === 'ai';
|
|
600
|
+
ai.hidden = !isAi;
|
|
601
|
+
if (changed && isAi && !get().rubrics.length) update({ rubrics: [emptyRow()] });
|
|
602
|
+
if (isAi) paintRows();
|
|
603
|
+
if (changed && isAi)
|
|
604
|
+
requestAnimationFrame(() =>
|
|
605
|
+
ai.scrollIntoView?.({ behavior: reduceMotion() ? 'auto' : 'smooth', block: 'nearest' })
|
|
606
|
+
);
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
el.append(modeRow, ai);
|
|
610
|
+
showMode();
|
|
611
|
+
// 오브젝트 이름 · 그림을 받으면 다시 그림 (저장된 기준의 오브젝트 이름 · 없는 오브젝트 표시)
|
|
612
|
+
void loadObjects().then(() => {
|
|
613
|
+
repaints.forEach(repaint => repaint());
|
|
614
|
+
paintErrors();
|
|
615
|
+
});
|
|
616
|
+
},
|
|
617
|
+
/** AI 채점 기준 검사. 칸 문제는 칸 아래에 띄우고 저장 바에는 요약 한 줄 */
|
|
618
|
+
validate(value) {
|
|
619
|
+
if (value.mode !== 'ai') return true;
|
|
620
|
+
const shown = view.reveal?.() ?? false;
|
|
621
|
+
const problem = rubricsProblem(value.rubrics);
|
|
622
|
+
if (!problem) return shown ? t.errors.summary : true;
|
|
623
|
+
if (problem.code === 'tooLong') return t.errors.tooLong(RUBRIC_LIMITS.criteriaMax);
|
|
624
|
+
if (problem.code === 'tooMany') return t.errors.tooMany(RUBRIC_LIMITS.max);
|
|
625
|
+
return t.errors.summary;
|
|
626
|
+
},
|
|
627
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// 편집 화면 패널 목록. 위에서부터 순서대로 그립니다. 새 기능 = 패널 파일 하나 + 이 목록에 한 줄.
|
|
2
|
+
//
|
|
3
|
+
// 패널 하나의 약속 (preference.js · grading.js · project-panel.js가 예):
|
|
4
|
+
// export default {
|
|
5
|
+
// id: 'blocks', // settings.entry.blocks 에 저장 (패널은 자기 칸만 읽고 씀)
|
|
6
|
+
// title: '쓸 블록',
|
|
7
|
+
// tab: 'start', // (선택) 이 탭 안에 그림: 'start'(시작 화면) · 'answer'(채점 설정). 없으면 탭 위
|
|
8
|
+
// secret: true, // (선택) settings.entry가 아니라 settings.grading으로 (학생에게 안 감).
|
|
9
|
+
// // normalize는 app.grading을 받고, screens/edit.js가 core/grading.js buildGrading으로 합침
|
|
10
|
+
// normalize(raw) { … }, // 저장된 값 → 패널 값 (없거나 틀리면 기본값)
|
|
11
|
+
// render(el, ctx) { … }, // el에 입력을 그림. ctx: { value, set(v), markDirty(), workspace(), objects(), onShow(cb), opened, app, texts }
|
|
12
|
+
// async collect(ctx) { … }, // (선택) 저장 직전에 값을 정함 (예: 워크스페이스에서 작품 꺼내기)
|
|
13
|
+
// validate(value, info) { … }, // (선택) true 또는 막을 문구. info.settingsBytes: 저장할 settings 전체 크기
|
|
14
|
+
// toPreference(value) { … }, // (선택) 워크스페이스 설정(GET_ELICE_PREFERENCE)에 합칠 값
|
|
15
|
+
// };
|
|
16
|
+
//
|
|
17
|
+
// 워크스페이스는 탭마다 하나 (ctx.workspace(): 'start' 탭 패널은 시작 화면, 'answer' 탭 패널은 정답 작품).
|
|
18
|
+
// 워크스페이스가 지금 받는 설정은 workspaceMode 하나뿐입니다. 숨길 블록 같은 새 설정은 워크스페이스에 받는 코드가 필요합니다.
|
|
19
|
+
// 채점 설정 탭의 배치(채점 방식 → 정답 작품 → AI 채점 기준)는 styles.css의 order가 정합니다.
|
|
20
|
+
import answerProject from './answer-project.js';
|
|
21
|
+
import grading from './grading.js';
|
|
22
|
+
import preference from './preference.js';
|
|
23
|
+
import startProject from './start-project.js';
|
|
24
|
+
|
|
25
|
+
export default [preference, startProject, grading, answerProject];
|