@eliceio/cdk-cli 0.1.0-alpha.3 → 0.1.0-alpha.4
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 +196 -144
- package/es/cli.js +6 -1
- package/es/commands/build/index.d.ts +1 -1
- package/es/commands/build/index.js +11 -12
- package/es/commands/check/index.d.ts +5 -2
- package/es/commands/check/index.js +15 -9
- package/es/commands/create/index.d.ts +4 -0
- package/es/commands/create/index.js +30 -7
- package/es/commands/create/install.d.ts +17 -0
- package/es/commands/create/install.js +53 -0
- package/es/commands/create/scaffold.d.ts +4 -1
- package/es/commands/create/scaffold.js +19 -13
- package/es/commands/dev/index.d.ts +1 -1
- package/es/commands/dev/index.js +4 -4
- package/es/commands/doctor/index.d.ts +11 -1
- package/es/commands/doctor/index.js +124 -36
- package/es/core/collect.d.ts +5 -2
- package/es/core/config.d.ts +95 -29
- package/es/core/config.js +253 -47
- package/es/core/manifest.d.ts +2 -1
- package/es/core/manifest.js +2 -1
- package/es/core/minify.js +2 -2
- package/es/core/prepare.d.ts +18 -2
- package/es/core/prepare.js +46 -15
- package/es/core/project-check.d.ts +18 -7
- package/es/core/project-check.js +35 -8
- package/es/core/sandbox.js +2 -2
- package/es/core/sdk.d.ts +39 -0
- package/es/core/sdk.js +95 -0
- package/es/core/templates.d.ts +3 -3
- package/es/core/templates.js +4 -4
- package/es/dev/grading.d.ts +1 -1
- package/es/dev/grading.js +1 -1
- package/es/dev/host-page.js +2 -2
- package/es/dev/mock-api.d.ts +7 -8
- package/es/dev/mock-api.js +18 -13
- package/es/dev/server.js +62 -43
- package/es/rules/check.js +45 -9
- package/es/rules/manifest.d.ts +1 -1
- package/es/rules/manifest.js +1 -1
- package/es/rules/types.d.ts +18 -8
- package/es/rules.json.js +2 -2
- package/es/test-packages.d.ts +7 -0
- package/guides/content-development.md +63 -55
- package/package.json +2 -2
- package/rules.json +18 -3
- package/skills/_shared/always.md +2 -2
- package/skills/elice-content-check/SKILL.md +3 -1
- package/skills/elice-content-create/SKILL.md +5 -4
- package/skills/elice-content-migrate/SKILL.md +2 -2
- package/skills/elice-content-publish/SKILL.md +4 -3
- package/templates/_shared/lib/cdk-mock.js +17 -17
- package/templates/_shared/lib/elice-content.css +8 -0
- package/templates/_shared/lib/elice-content.d.ts +5 -1
- package/templates/_shared/lib/elice-content.js +20 -12
- package/templates/blank/README.md +11 -8
- package/templates/blank/metadata.json +11 -0
- package/templates/blank/package.json +13 -0
- package/templates/blank/screens/completion.js +2 -2
- package/templates/blank/screens/instructor.js +12 -5
- package/templates/blank/screens/learn.js +16 -11
- package/templates/quiz/README.md +14 -11
- package/templates/quiz/core/editor.d.ts +12 -1
- package/templates/quiz/core/editor.js +28 -5
- package/templates/quiz/core/model.d.ts +14 -0
- package/templates/quiz/core/model.js +73 -1
- package/templates/quiz/metadata.json +11 -0
- package/templates/quiz/package.json +13 -0
- package/templates/quiz/screens/edit.js +85 -29
- package/templates/quiz/screens/instructor.js +18 -12
- package/templates/quiz/screens/learn.js +42 -36
- package/templates/quiz/styles.css +47 -0
- package/templates/quiz/template.json +2 -2
- package/templates/quiz/ui/templates/edit.d.ts +1 -0
- package/templates/quiz/ui/templates/edit.js +37 -5
- package/templates/quiz/ui/texts.js +9 -7
- package/templates/_shared/lib/cdk.js +0 -3
- package/templates/blank/content.json +0 -4
- package/templates/blank/elice.config.json +0 -10
- package/templates/quiz/content.json +0 -35
- package/templates/quiz/elice.config.json +0 -9
- package/templates/quiz/grading.json +0 -4
|
@@ -71,23 +71,46 @@ export function createEditor({ rerender, root, templates, labels }) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
* 보기 · 그룹 목록 (단일 · 복수 · 순서 · 그룹 공통).
|
|
74
|
+
* 보기 · 그룹 목록 (단일 · 복수 · 순서 · 그룹 공통). 손잡이를 끌어 순서 바꾸기
|
|
75
|
+
* answer가 있으면 줄마다 정답 칸(data-role="answer")을 둔다: radio(단일) · checkbox(복수) · select(그룹 고르기).
|
|
76
|
+
* 정답 칸을 바꿔도 다시 그리지 않는다 (방향키로 radio를 옮기는 동안 초점이 그대로 있게)
|
|
75
77
|
* @param {'option' | 'group'} kind
|
|
76
78
|
* @param {object[]} items q.options 또는 q.groups (직접 고침)
|
|
77
79
|
* @param {string} key 키보드로 옮긴 뒤 초점을 찾을 이름 (화면에서 겹치지 않게)
|
|
78
|
-
* @param {{ onDelete?: () => void
|
|
80
|
+
* @param {{ onDelete?: () => void, onInput?: (item: object) => void,
|
|
81
|
+
* answer?: { type: 'radio' | 'checkbox' | 'select', name: string, choices?: [string, string][],
|
|
82
|
+
* get: (item: object) => boolean | string, set: (item: object, value: boolean | string) => void } }} [opts]
|
|
83
|
+
* onDelete: 지운 뒤 할 일 (예: 순서 맞추기 칸 수 줄이기, 정답에서 빼기) · onInput: 글을 고친 뒤 할 일
|
|
79
84
|
*/
|
|
80
|
-
function itemList(kind, items, key, { onDelete } = {}) {
|
|
85
|
+
function itemList(kind, items, key, { onDelete, onInput, answer } = {}) {
|
|
81
86
|
const isGroup = kind === 'group';
|
|
82
87
|
const text = isGroup ? 'name' : 'text';
|
|
83
88
|
const min = isGroup ? LIMITS.groupsMin : LIMITS.optionsMin;
|
|
84
89
|
const max = isGroup ? LIMITS.groupsMax : LIMITS.optionsMax;
|
|
85
90
|
const rows = items.map((item, i) => {
|
|
86
|
-
const row = ui.row({
|
|
91
|
+
const row = ui.row({
|
|
92
|
+
kind,
|
|
93
|
+
index: i,
|
|
94
|
+
canDelete: items.length > min,
|
|
95
|
+
min,
|
|
96
|
+
answer: answer && { type: answer.type, name: answer.name, choices: answer.choices },
|
|
97
|
+
});
|
|
87
98
|
row.dataset.role = 'row';
|
|
88
99
|
const input = part(row, 'input');
|
|
89
100
|
input.value = item[text];
|
|
90
|
-
input.addEventListener('input', () =>
|
|
101
|
+
input.addEventListener('input', () => {
|
|
102
|
+
item[text] = input.value;
|
|
103
|
+
onInput?.(item);
|
|
104
|
+
});
|
|
105
|
+
const pick = answer && part(row, 'answer');
|
|
106
|
+
if (pick) {
|
|
107
|
+
const value = answer.get(item);
|
|
108
|
+
if (answer.type === 'select') pick.value = String(value ?? '');
|
|
109
|
+
else pick.checked = Boolean(value);
|
|
110
|
+
pick.addEventListener('change', () =>
|
|
111
|
+
answer.set(item, answer.type === 'select' ? pick.value : pick.checked),
|
|
112
|
+
);
|
|
113
|
+
}
|
|
91
114
|
part(row, 'delete').addEventListener('click', () => {
|
|
92
115
|
items.splice(i, 1);
|
|
93
116
|
onDelete?.();
|
|
@@ -6,6 +6,7 @@ export interface DefaultNames {
|
|
|
6
6
|
group(letter: string): string;
|
|
7
7
|
}
|
|
8
8
|
export declare const LIMITS: Record<string, number>;
|
|
9
|
+
export declare function canAddQuestion(questions: unknown[] | undefined): boolean;
|
|
9
10
|
export declare function nextId(used: string[], prefix?: string): string;
|
|
10
11
|
export declare function newQuestion(type: string, usedIds: string[], names: DefaultNames): any;
|
|
11
12
|
export declare function convertType(q: any, type: string, names: DefaultNames): any;
|
|
@@ -34,6 +35,19 @@ export declare function validateAnswerKey(
|
|
|
34
35
|
key: Record<string, any>,
|
|
35
36
|
messages: Record<string, any>
|
|
36
37
|
): { questionIndex: number; message: string } | null;
|
|
38
|
+
/** 보기 줄에서 정답을 고르는 유형 (단일 · 복수 · 그룹) */
|
|
39
|
+
export declare const INLINE_ANSWER_TYPES: string[];
|
|
40
|
+
/** 보기 하나의 정답 표시: 단일 · 복수는 true/false, 그룹은 속한 그룹 id('' = 없음) */
|
|
41
|
+
export declare function optionAnswer(q: any, value: any, optionId: string): boolean | string | undefined;
|
|
42
|
+
/** 보기 하나의 정답 표시를 바꾼 새 정답 (화면 값 모양 그대로) */
|
|
43
|
+
export declare function withOptionAnswer(
|
|
44
|
+
q: any,
|
|
45
|
+
value: any,
|
|
46
|
+
optionId: string,
|
|
47
|
+
choice: boolean | string
|
|
48
|
+
): any;
|
|
49
|
+
/** 지운 보기 · 그룹을 정답에서 뺀다 (단일 · 복수 · 그룹) */
|
|
50
|
+
export declare function pruneAnswer(q: any, value: any): any;
|
|
37
51
|
/** 정답(화면 값)을 다른 답으로 하나 바꾼 값. 바꿀 수 없으면 undefined */
|
|
38
52
|
export declare function wrongValue(q: any, value: any): any;
|
|
39
53
|
/** 정답 검증 2: 왕복(정답 → 제출 문자열이 맞음) · 오답(하나 바꾸면 안 맞음) */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// 퀴즈 데이터 모델. 학생 · 교육자 · 편집 화면이 같이 씁니다. (기존 퀴즈 material 명세: docs/quiz-spec.md)
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// 편집 화면이 저장하는 settings (학생에게 공개, 정답 없음)
|
|
4
4
|
// { title, description, questions: [{ id, type, title, description, options?, groups?, slots?,
|
|
5
5
|
// shuffle?, placeholder?, explanation: { enabled, text } }] }
|
|
6
6
|
// 제출하는 답: 문자열 하나 (ADR 0008). 문항 순서대로 `문항id=답`을 `;`로 잇고, 주관식 답은 encodeURIComponent
|
|
@@ -18,8 +18,13 @@ export const LIMITS = {
|
|
|
18
18
|
optionsMax: 20,
|
|
19
19
|
groupsMin: 2,
|
|
20
20
|
groupsMax: 6,
|
|
21
|
+
// 퀴즈 하나에 문항 하나 (기존 LXP처럼). 여러 문항은 퀴즈 페이지를 여러 개로 → 부분 점수가 필요 없음
|
|
22
|
+
questionsMax: 1,
|
|
21
23
|
};
|
|
22
24
|
|
|
25
|
+
/** 편집 화면에서 문항을 더 넣을 수 있는지. 이미 여러 문항으로 저장된 퀴즈도 그대로 보이고 저장되며, 더 넣는 것만 막는다 */
|
|
26
|
+
export const canAddQuestion = (questions) => (questions?.length ?? 0) < LIMITS.questionsMax;
|
|
27
|
+
|
|
23
28
|
const hasOptions = (type) => type !== 'text';
|
|
24
29
|
|
|
25
30
|
/** 보기·그룹 id는 답 문자열에 그대로 들어가므로 영문 소문자·숫자만 (구분자 , | : 를 쓰지 않음) */
|
|
@@ -282,6 +287,73 @@ export function validateAnswerKey(questions, key, v) {
|
|
|
282
287
|
return null;
|
|
283
288
|
}
|
|
284
289
|
|
|
290
|
+
// ---------- 편집 화면: 보기 줄에서 바로 고르는 정답 (단일 · 복수 · 그룹) ----------
|
|
291
|
+
|
|
292
|
+
/** 보기 줄에서 정답을 고르는 유형. 순서 · 주관식은 따로 고른다 */
|
|
293
|
+
export const INLINE_ANSWER_TYPES = ['select_one', 'select_multiple', 'group'];
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* 보기 하나의 정답 표시: 단일 · 복수는 정답인지(true/false), 그룹은 속한 그룹 id(없으면 '')
|
|
297
|
+
*/
|
|
298
|
+
export function optionAnswer(q, value, optionId) {
|
|
299
|
+
switch (q.type) {
|
|
300
|
+
case 'select_one':
|
|
301
|
+
return value === optionId;
|
|
302
|
+
case 'select_multiple':
|
|
303
|
+
return (value ?? []).includes(optionId);
|
|
304
|
+
case 'group':
|
|
305
|
+
return (q.groups ?? []).find((g) => (value?.[g.id] ?? []).includes(optionId))?.id ?? '';
|
|
306
|
+
default:
|
|
307
|
+
return undefined;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* 보기 하나의 정답 표시를 바꾼 새 정답 (화면 값 모양 그대로).
|
|
313
|
+
* 단일: on이면 그 보기 · 복수: on/off · 그룹: choice 그룹으로 옮김('' = 어느 그룹에도 넣지 않음)
|
|
314
|
+
*/
|
|
315
|
+
export function withOptionAnswer(q, value, optionId, choice) {
|
|
316
|
+
switch (q.type) {
|
|
317
|
+
case 'select_one':
|
|
318
|
+
return choice ? optionId : value === optionId ? null : value;
|
|
319
|
+
case 'select_multiple': {
|
|
320
|
+
const rest = (value ?? []).filter((id) => id !== optionId);
|
|
321
|
+
if (!choice) return rest;
|
|
322
|
+
// 보기 순서대로 둔다 (저장하는 답 문자열은 어차피 정렬)
|
|
323
|
+
const set = new Set([...rest, optionId]);
|
|
324
|
+
return q.options.map((o) => o.id).filter((id) => set.has(id));
|
|
325
|
+
}
|
|
326
|
+
case 'group': {
|
|
327
|
+
const out = Object.fromEntries(
|
|
328
|
+
q.groups.map((g) => [g.id, (value?.[g.id] ?? []).filter((id) => id !== optionId)]),
|
|
329
|
+
);
|
|
330
|
+
if (choice && choice in out) out[choice].push(optionId);
|
|
331
|
+
return out;
|
|
332
|
+
}
|
|
333
|
+
default:
|
|
334
|
+
return value;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* 보기 · 그룹을 지운 뒤 정답에서 지금 없는 보기 · 그룹을 뺀다 (단일 · 복수 · 그룹).
|
|
340
|
+
* 보기 순서를 바꿔도 id가 그대로라 정답은 그대로다. 다른 유형은 그대로 돌려준다
|
|
341
|
+
*/
|
|
342
|
+
export function pruneAnswer(q, value) {
|
|
343
|
+
if (value === undefined || !INLINE_ANSWER_TYPES.includes(q.type)) return value;
|
|
344
|
+
const ids = new Set((q.options ?? []).map((o) => o.id));
|
|
345
|
+
switch (q.type) {
|
|
346
|
+
case 'select_one':
|
|
347
|
+
return ids.has(value) ? value : null;
|
|
348
|
+
case 'select_multiple':
|
|
349
|
+
return (value ?? []).filter((id) => ids.has(id));
|
|
350
|
+
default:
|
|
351
|
+
return Object.fromEntries(
|
|
352
|
+
q.groups.map((g) => [g.id, (value?.[g.id] ?? []).filter((id) => ids.has(id))]),
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
285
357
|
/** 정답(화면 값)을 다른 답으로 하나 바꾼 값. 바꿀 수 없으면 undefined (오답 검증용) */
|
|
286
358
|
export function wrongValue(q, value) {
|
|
287
359
|
const ids = (q.options ?? []).map((o) => o.id);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "material",
|
|
3
|
+
"screens": {
|
|
4
|
+
"learn": { "enabled": true, "entry": "index.html" },
|
|
5
|
+
"instructor": { "enabled": true, "entry": "instructor.html" },
|
|
6
|
+
"edit": { "enabled": true, "entry": "edit.html" },
|
|
7
|
+
"completionPolicy": { "enabled": false }
|
|
8
|
+
},
|
|
9
|
+
"completionPolicies": ["on_graded"],
|
|
10
|
+
"commentary": "commentary.txt"
|
|
11
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// 내용 편집 화면(CMS). 기존 퀴즈 편집 폼을 옮김 (docs/quiz-spec.md §3). 저장 버튼 · 변경 표시는 키트(useSave)가 합니다.
|
|
2
|
-
// 퀴즈는 완료 정책 on_graded + 채점 방식 pattern 고정 (ADR 0009,
|
|
3
|
-
//
|
|
2
|
+
// 퀴즈는 완료 정책 on_graded + 채점 방식 pattern 고정 (ADR 0009, metadata.json completionPolicies ["on_graded"]): 문항 카드마다 정답을
|
|
3
|
+
// 고르고 (단일 · 복수 · 그룹은 보기 줄에서 바로, 순서 · 주관식은 아래 "정답"에서), 저장할 때 고른 답으로 정답 정규식 하나를 만들어 검증한 뒤 settings.grading에 함께 저장합니다.
|
|
4
4
|
// 문제 내용(content)은 학생에게도 내려가므로 정답을 넣지 않습니다 (정답은 grading에만, 서버가 학생에게 내려주지 않음).
|
|
5
5
|
// 여기서는 어떤 칸을 어떤 순서로 놓을지만 정합니다. 모양은 ui/(templates/edit.js · texts · theme.css), 동작은 core/.
|
|
6
6
|
import { start, validateAnswerRegex } from '../lib/elice-content.js';
|
|
@@ -8,14 +8,19 @@ import { renderAnswerBody } from '../core/behaviors.js';
|
|
|
8
8
|
import { createEditor } from '../core/editor.js';
|
|
9
9
|
import {
|
|
10
10
|
buildAnswerKey,
|
|
11
|
+
canAddQuestion,
|
|
11
12
|
checkAnswerKey,
|
|
12
13
|
convertType,
|
|
14
|
+
INLINE_ANSWER_TYPES,
|
|
13
15
|
joinAnswers,
|
|
14
16
|
LIMITS,
|
|
15
17
|
newQuestion,
|
|
18
|
+
optionAnswer,
|
|
16
19
|
parseAnswerKey,
|
|
20
|
+
pruneAnswer,
|
|
17
21
|
validateAnswerKey,
|
|
18
22
|
validateQuiz,
|
|
23
|
+
withOptionAnswer,
|
|
19
24
|
} from '../core/model.js';
|
|
20
25
|
import * as templates from '../ui/templates/edit.js';
|
|
21
26
|
import { templates as quizTemplates } from '../ui/templates/index.js';
|
|
@@ -57,7 +62,7 @@ const swap = (list, i, j) => {
|
|
|
57
62
|
render();
|
|
58
63
|
};
|
|
59
64
|
|
|
60
|
-
/** 문항 카드의 "정답": 학생 화면과 같은 보기 ·
|
|
65
|
+
/** 순서 · 주관식 문항 카드의 "정답": 학생 화면과 같은 보기 · 칸으로 고른다 (주관식은 허용 답 여러 개) */
|
|
61
66
|
function answerField(q) {
|
|
62
67
|
if (q.type === 'text') {
|
|
63
68
|
const node = templates.textAnswers({ placeholder: a.textPlaceholder });
|
|
@@ -81,6 +86,34 @@ function answerField(q) {
|
|
|
81
86
|
return form.ui.section({ label: a.label, hint: a.hint[q.type], body: view.el });
|
|
82
87
|
}
|
|
83
88
|
|
|
89
|
+
/**
|
|
90
|
+
* 단일 · 복수 · 그룹 문항의 보기 줄 정답 칸 (radio · checkbox · 그룹 select). 정답은 보기 id로 두므로
|
|
91
|
+
* 순서를 바꿔도 그대로이고, 보기를 지우면 정답에서 뺀다 (optionsOpts의 onDelete)
|
|
92
|
+
*/
|
|
93
|
+
function inlineAnswer(q) {
|
|
94
|
+
const types = { select_one: 'radio', select_multiple: 'checkbox', group: 'select' };
|
|
95
|
+
return {
|
|
96
|
+
type: types[q.type],
|
|
97
|
+
// 문항마다 다른 이름 (같은 문항의 radio끼리만 묶임)
|
|
98
|
+
name: `answer-${q.id}`,
|
|
99
|
+
choices: q.type === 'group' ? q.groups.map(g => [g.id, g.name]) : undefined,
|
|
100
|
+
get: option => optionAnswer(q, answers[q.id], option.id),
|
|
101
|
+
set: (option, value) => (answers[q.id] = withOptionAnswer(q, answers[q.id], option.id, value)),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** 보기 목록 옵션: 지우면 정답에서 빼고, 단일 · 복수 · 그룹은 줄마다 정답 칸 */
|
|
106
|
+
function optionsOpts(q) {
|
|
107
|
+
const inline = INLINE_ANSWER_TYPES.includes(q.type);
|
|
108
|
+
return {
|
|
109
|
+
onDelete: () => {
|
|
110
|
+
if (q.type === 'order') q.slots = Math.min(q.slots, q.options.length);
|
|
111
|
+
if (answers[q.id] !== undefined) answers[q.id] = pruneAnswer(q, answers[q.id]);
|
|
112
|
+
},
|
|
113
|
+
answer: inline ? inlineAnswer(q) : undefined,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
84
117
|
/** 문항 카드 안의 칸들. 유형마다 보이는 칸이 다르다 */
|
|
85
118
|
function questionFields(q, i) {
|
|
86
119
|
const body = [
|
|
@@ -88,12 +121,14 @@ function questionFields(q, i) {
|
|
|
88
121
|
form.markdownField(t.description, q.description, v => (q.description = v)),
|
|
89
122
|
];
|
|
90
123
|
if (q.type === 'select_one' || q.type === 'select_multiple' || q.type === 'order') {
|
|
91
|
-
const options = form.itemList('option', q.options, `${i}o`,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
124
|
+
const options = form.itemList('option', q.options, `${i}o`, optionsOpts(q));
|
|
125
|
+
body.push(
|
|
126
|
+
form.ui.section({
|
|
127
|
+
label: t.options,
|
|
128
|
+
hint: q.type === 'order' ? undefined : a.hint[q.type],
|
|
129
|
+
body: options,
|
|
130
|
+
})
|
|
131
|
+
);
|
|
97
132
|
}
|
|
98
133
|
if (q.type === 'order') {
|
|
99
134
|
const slots = form.numberField(
|
|
@@ -107,15 +142,27 @@ function questionFields(q, i) {
|
|
|
107
142
|
slots.querySelector('[data-role="input"]')?.addEventListener('change', render);
|
|
108
143
|
body.push(slots);
|
|
109
144
|
}
|
|
110
|
-
if (q.type === 'group')
|
|
145
|
+
if (q.type === 'group') {
|
|
146
|
+
const groups = form.itemList('group', q.groups, `${i}g`, {
|
|
147
|
+
// 지운 그룹에 넣은 보기는 "그룹 없음"으로
|
|
148
|
+
onDelete: () => {
|
|
149
|
+
if (answers[q.id] !== undefined) answers[q.id] = pruneAnswer(q, answers[q.id]);
|
|
150
|
+
},
|
|
151
|
+
// 그룹 이름을 고치면 보기 줄의 그룹 고르기 이름도 바로 바꾼다 (다시 그리면 입력 중 초점을 잃음)
|
|
152
|
+
onInput: g => {
|
|
153
|
+
for (const select of root.querySelectorAll(`select[name="answer-${q.id}"]`))
|
|
154
|
+
for (const option of select.options) if (option.value === g.id) option.textContent = g.name;
|
|
155
|
+
},
|
|
156
|
+
});
|
|
111
157
|
body.push(
|
|
112
|
-
form.ui.section({ label: t.groups, body:
|
|
158
|
+
form.ui.section({ label: t.groups, body: groups }),
|
|
113
159
|
form.ui.section({
|
|
114
160
|
label: t.options,
|
|
115
|
-
hint:
|
|
116
|
-
body: form.itemList('option', q.options, `${i}o
|
|
161
|
+
hint: a.hint.group,
|
|
162
|
+
body: form.itemList('option', q.options, `${i}o`, optionsOpts(q)),
|
|
117
163
|
})
|
|
118
164
|
);
|
|
165
|
+
}
|
|
119
166
|
if (q.type === 'text')
|
|
120
167
|
body.push(
|
|
121
168
|
form.field(t.placeholder, q.placeholder, v => (q.placeholder = v), {
|
|
@@ -123,7 +170,7 @@ function questionFields(q, i) {
|
|
|
123
170
|
hint: t.placeholderHint,
|
|
124
171
|
})
|
|
125
172
|
);
|
|
126
|
-
body.push(answerField(q));
|
|
173
|
+
if (!INLINE_ANSWER_TYPES.includes(q.type)) body.push(answerField(q));
|
|
127
174
|
if (q.type !== 'text') body.push(form.toggle(t.shuffle, q.shuffle, v => (q.shuffle = v)));
|
|
128
175
|
body.push(
|
|
129
176
|
form.toggle(t.explanationOn, q.explanation?.enabled, v => {
|
|
@@ -169,23 +216,32 @@ function render() {
|
|
|
169
216
|
form.field(t.quizTitle, draft.title, v => (draft.title = v), { required: true }),
|
|
170
217
|
form.markdownField(t.quizDescription, draft.description, v => (draft.description = v)),
|
|
171
218
|
...draft.questions.map(questionCard),
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
219
|
+
// 퀴즈 하나에 문항 하나: 문항이 있으면 "문항 추가" 대신 안내 (이미 여러 문항으로 저장된 퀴즈도 편집 · 저장은 됨)
|
|
220
|
+
canAddQuestion(draft.questions)
|
|
221
|
+
? form.addQuestion(() => {
|
|
222
|
+
draft.questions.push(
|
|
223
|
+
newQuestion(
|
|
224
|
+
'select_one',
|
|
225
|
+
draft.questions.map(q => q.id),
|
|
226
|
+
texts.defaults
|
|
227
|
+
)
|
|
228
|
+
);
|
|
229
|
+
render();
|
|
230
|
+
})
|
|
231
|
+
: templates.singleQuestion({ text: t.singleQuestion })
|
|
182
232
|
);
|
|
183
233
|
save?.markDirty();
|
|
184
234
|
}
|
|
185
235
|
|
|
186
|
-
/**
|
|
187
|
-
|
|
188
|
-
|
|
236
|
+
/**
|
|
237
|
+
* 문제가 있는 문항 카드로 옮기고 문장을 돌려준다.
|
|
238
|
+
* 정답 문제(answer)면 보기 줄에서 고르는 문항은 보기 목록의 첫 정답 칸으로 옮겨 초점을 둔다
|
|
239
|
+
*/
|
|
240
|
+
const problemAt = (problem, { answer = false } = {}) => {
|
|
241
|
+
const card = form.cardAt(problem.questionIndex);
|
|
242
|
+
const pick = answer ? card?.querySelector('[data-role="answer"]') : null;
|
|
243
|
+
(pick ?? card)?.scrollIntoView({ block: 'center' });
|
|
244
|
+
pick?.focus({ preventScroll: true });
|
|
189
245
|
return problem.message;
|
|
190
246
|
};
|
|
191
247
|
|
|
@@ -201,13 +257,13 @@ save = app.useSave({
|
|
|
201
257
|
getGrading: () => {
|
|
202
258
|
const { questions } = draft;
|
|
203
259
|
const missing = validateAnswerKey(questions, answers, a.validation);
|
|
204
|
-
if (missing) return problemAt(missing);
|
|
260
|
+
if (missing) return problemAt(missing, { answer: true });
|
|
205
261
|
const answerKey = buildAnswerKey(questions, answers);
|
|
206
262
|
const base = questions.map(q => (q.type === 'text' ? (answers[q.id] ?? [])[0] : answers[q.id]));
|
|
207
263
|
const regexProblem = validateAnswerRegex(answerKey, [joinAnswers(questions, base)]);
|
|
208
264
|
if (regexProblem) return regexProblem;
|
|
209
265
|
const keyProblem = checkAnswerKey(questions, answers, answerKey, a.validation);
|
|
210
|
-
if (keyProblem) return problemAt(keyProblem);
|
|
266
|
+
if (keyProblem) return problemAt(keyProblem, { answer: true });
|
|
211
267
|
return { type: 'pattern', answer_key: answerKey };
|
|
212
268
|
},
|
|
213
269
|
});
|
|
@@ -11,17 +11,23 @@ const root = document.getElementById('app');
|
|
|
11
11
|
document.title = texts.page.instructor;
|
|
12
12
|
root.replaceChildren(loading());
|
|
13
13
|
const app = await start({ screen: 'instructor' });
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
// 편집 화면에서 아직 내용을 저장하지 않았으면 안내만 보인다
|
|
15
|
+
if (app.hasContent) show();
|
|
16
|
+
else root.replaceChildren(app.emptyState());
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
function show() {
|
|
19
|
+
const { title, questions = [] } = app.content;
|
|
20
|
+
const counts = questions.reduce((m, q) => ({ ...m, [q.type]: (m[q.type] ?? 0) + 1 }), {});
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
22
|
+
const views = questions.map((q, i) => renderQuestion(q, i, { templates, labels, disabled: true }));
|
|
23
|
+
views.forEach((v) => v.showExplanation());
|
|
24
|
+
|
|
25
|
+
root.replaceChildren(
|
|
26
|
+
instructorHeader({
|
|
27
|
+
title: title ?? '',
|
|
28
|
+
count: questions.length,
|
|
29
|
+
byType: Object.entries(counts).map(([t, n]) => [texts.types[t] ?? t, n]),
|
|
30
|
+
}),
|
|
31
|
+
...views.map((v) => v.el),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -12,43 +12,49 @@ const root = document.getElementById('app');
|
|
|
12
12
|
document.title = texts.page.learn;
|
|
13
13
|
root.replaceChildren(loading());
|
|
14
14
|
const app = await start({ screen: 'learn' });
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
renderQuestion(q, i, {
|
|
19
|
-
templates,
|
|
20
|
-
labels: { ...labels, types: null },
|
|
21
|
-
seed: app.account?.anonymousId ?? '',
|
|
22
|
-
}),
|
|
23
|
-
);
|
|
15
|
+
// 편집 화면에서 아직 내용을 저장하지 않았으면 안내만 보인다 (기본 문항은 없음)
|
|
16
|
+
if (app.hasContent) show();
|
|
17
|
+
else root.replaceChildren(app.emptyState());
|
|
24
18
|
|
|
25
|
-
|
|
19
|
+
function show() {
|
|
20
|
+
const { title, description, questions = [] } = app.content;
|
|
21
|
+
// 학생 화면에는 문항 유형을 보이지 않는다 (무엇을 할지는 질문 문장이 알려 줌). 교육자 화면에는 보인다
|
|
22
|
+
const views = questions.map((q, i) =>
|
|
23
|
+
renderQuestion(q, i, {
|
|
24
|
+
templates,
|
|
25
|
+
labels: { ...labels, types: null },
|
|
26
|
+
seed: app.account?.anonymousId ?? '',
|
|
27
|
+
}),
|
|
28
|
+
);
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
app.useSubmit({
|
|
29
|
-
getAnswer: () => joinAnswers(questions, views.map((v) => v.getValue())),
|
|
30
|
-
setAnswer: (answer) => {
|
|
31
|
-
const byId = splitAnswers(questions, answer);
|
|
32
|
-
questions.forEach((q, i) => views[i].setValue(decodeAnswer(q, byId[q.id])));
|
|
33
|
-
},
|
|
34
|
-
validate: () => {
|
|
35
|
-
const left = questions.findIndex((q, i) => !isAnswered(q, views[i].getValue()));
|
|
36
|
-
return left < 0 || texts.learn.unanswered(left + 1);
|
|
37
|
-
},
|
|
38
|
-
// 서버 채점 결과는 전체 { isCorrect, score }뿐이라 모두 맞았을 때만 문항마다 정답 표시. 해설은 한 번이라도 제출하면
|
|
39
|
-
onResult: (res) => {
|
|
40
|
-
views.forEach((v) => {
|
|
41
|
-
v.setResult(res.isCorrect === true ? true : null);
|
|
42
|
-
v.showExplanation();
|
|
43
|
-
});
|
|
44
|
-
},
|
|
45
|
-
});
|
|
30
|
+
root.replaceChildren(learnHeader({ title: title ?? '', description }), ...views.map((v) => v.el));
|
|
46
31
|
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
32
|
+
// 답은 문자열 하나로 낸다 (편집 화면이 만든 정답 정규식과 전체 비교, ADR 0008 · 0009): "q1=b;q2=a,d;…"
|
|
33
|
+
app.useSubmit({
|
|
34
|
+
getAnswer: () => joinAnswers(questions, views.map((v) => v.getValue())),
|
|
35
|
+
setAnswer: (answer) => {
|
|
36
|
+
const byId = splitAnswers(questions, answer);
|
|
37
|
+
questions.forEach((q, i) => views[i].setValue(decodeAnswer(q, byId[q.id])));
|
|
38
|
+
},
|
|
39
|
+
validate: () => {
|
|
40
|
+
const left = questions.findIndex((q, i) => !isAnswered(q, views[i].getValue()));
|
|
41
|
+
return left < 0 || texts.learn.unanswered(left + 1);
|
|
42
|
+
},
|
|
43
|
+
// 서버 채점 결과는 전체 { isCorrect, score }뿐이라 모두 맞았을 때만 문항마다 정답 표시. 해설은 한 번이라도 제출하면
|
|
44
|
+
onResult: (res) => {
|
|
45
|
+
views.forEach((v) => {
|
|
46
|
+
v.setResult(res.isCorrect === true ? true : null);
|
|
47
|
+
v.showExplanation();
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// 다시 고치면 그 문항의 결과 색을 지운다 (기존 동작)
|
|
53
|
+
root.addEventListener('input', (e) => clearResult(e.target));
|
|
54
|
+
root.addEventListener('click', (e) => clearResult(e.target));
|
|
55
|
+
function clearResult(target) {
|
|
56
|
+
const card = target instanceof Element ? target.closest('[data-role="question"]') : null;
|
|
57
|
+
const i = card ? questions.findIndex((q) => q.id === card.dataset.id) : -1;
|
|
58
|
+
if (i >= 0 && !app.readOnly) views[i].setResult(null);
|
|
59
|
+
}
|
|
54
60
|
}
|
|
@@ -421,6 +421,19 @@
|
|
|
421
421
|
.qz-group-pool {
|
|
422
422
|
order: -1;
|
|
423
423
|
}
|
|
424
|
+
/* 좁은 화면: 그룹 고르기는 보기 글 아래 줄로 (보기 글 칸이 좁아지지 않게) */
|
|
425
|
+
.qe-option:has(.qe-answer-group) {
|
|
426
|
+
display: grid;
|
|
427
|
+
grid-template-columns: auto auto minmax(0, 1fr) auto;
|
|
428
|
+
}
|
|
429
|
+
.qe-option:has(.qe-answer-group) [data-role='delete'] {
|
|
430
|
+
grid-row: 1;
|
|
431
|
+
grid-column: 4;
|
|
432
|
+
}
|
|
433
|
+
.qe-answer-group {
|
|
434
|
+
grid-row: 2;
|
|
435
|
+
grid-column: 3;
|
|
436
|
+
}
|
|
424
437
|
}
|
|
425
438
|
|
|
426
439
|
/* ---------- 편집 ---------- */
|
|
@@ -525,6 +538,40 @@
|
|
|
525
538
|
color: var(--qz-text-muted);
|
|
526
539
|
font-weight: var(--eds-fw-bold);
|
|
527
540
|
}
|
|
541
|
+
.qe-option-text {
|
|
542
|
+
flex: 1 1 0;
|
|
543
|
+
min-width: 0;
|
|
544
|
+
}
|
|
545
|
+
/* 보기 줄의 정답 칸: radio · checkbox + "정답" (누르는 영역 40px) */
|
|
546
|
+
.qe-answer {
|
|
547
|
+
flex: none;
|
|
548
|
+
display: flex;
|
|
549
|
+
align-items: center;
|
|
550
|
+
gap: 4px;
|
|
551
|
+
min-height: 40px;
|
|
552
|
+
padding: 0 4px;
|
|
553
|
+
color: var(--eds-text-secondary);
|
|
554
|
+
font-size: var(--eds-fs-caption);
|
|
555
|
+
font-weight: var(--eds-fw-bold);
|
|
556
|
+
cursor: pointer;
|
|
557
|
+
}
|
|
558
|
+
.qe-answer input {
|
|
559
|
+
width: 18px;
|
|
560
|
+
height: 18px;
|
|
561
|
+
margin: 0;
|
|
562
|
+
padding: 0;
|
|
563
|
+
accent-color: var(--qz-accent);
|
|
564
|
+
cursor: pointer;
|
|
565
|
+
}
|
|
566
|
+
.qe-answer:has(input:checked) {
|
|
567
|
+
color: var(--qz-accent);
|
|
568
|
+
}
|
|
569
|
+
/* 그룹 분류 보기 줄의 정답 그룹 고르기 */
|
|
570
|
+
.qe-answer-group {
|
|
571
|
+
flex: 0 1 160px;
|
|
572
|
+
width: auto;
|
|
573
|
+
min-width: 0;
|
|
574
|
+
}
|
|
528
575
|
/* IconButton outlined */
|
|
529
576
|
.qe-icon {
|
|
530
577
|
flex: none;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quiz",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"title": "퀴즈",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "한 문항 퀴즈 (여러 문항은 페이지를 여러 개로). 문항 없이 시작해 편집 화면 \"문항 추가\"로 선택 · 순서 · 주관식 · 그룹 분류 문항 하나를 만듦. 정답은 편집 화면에서 정하고 채점해 완료(on_graded) 고정"
|
|
6
6
|
}
|