@eliceio/cdk-cli 1.4.1 → 1.5.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.
- package/README.md +17 -16
- package/es/cli.js +1 -1
- 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 +36 -0
- package/es/core/config.js +234 -6
- package/es/core/quiz-check.js +123 -4
- package/es/dev/grading.d.ts +26 -4
- package/es/dev/grading.js +66 -11
- package/es/dev/mock-api.d.ts +6 -1
- package/es/dev/mock-api.js +45 -6
- package/es/rules/answers.d.ts +1 -0
- package/es/rules/answers.js +8 -0
- package/es/rules.json.js +1 -1
- package/package.json +2 -2
- package/rules.json +1 -1
- package/skills/_shared/always.md +1 -1
- package/skills/_shared/references/02-design-the-material.md +8 -7
- package/skills/_shared/references/03-create-the-project.md +10 -9
- package/skills/_shared/references/12-upload-with-the-material-mcp.md +5 -5
- package/skills/_shared/references/16-using-the-survey-template.md +158 -0
- package/skills/elice-content-create/SKILL.md +2 -2
- package/skills/elice-content-edit/SKILL.md +2 -2
- package/skills/elice-content-publish/SKILL.md +1 -1
- package/templates/_shared/lib/cdk-mock.d.ts +22 -3
- package/templates/_shared/lib/cdk-mock.js +78 -11
- package/templates/_shared/lib/elice-content.d.ts +17 -1
- package/templates/_shared/lib/elice-content.js +47 -5
- package/templates/blank/template.json +1 -1
- package/templates/document/template.json +1 -1
- package/templates/quiz/README.md +26 -1
- package/templates/quiz/core/behaviors.d.ts +5 -0
- package/templates/quiz/core/behaviors.js +16 -1
- package/templates/quiz/core/model.d.ts +78 -1
- package/templates/quiz/core/model.js +219 -4
- package/templates/quiz/screens/edit.js +244 -55
- package/templates/quiz/screens/learn.js +137 -27
- package/templates/quiz/styles.css +258 -5
- package/templates/quiz/template.json +1 -1
- package/templates/quiz/ui/templates/edit.d.ts +1 -0
- package/templates/quiz/ui/templates/edit.js +67 -8
- package/templates/quiz/ui/templates/page.js +34 -0
- package/templates/quiz/ui/templates/text.js +15 -2
- package/templates/quiz/ui/texts.js +61 -0
- package/templates/steps/template.json +1 -1
- package/templates/survey/README.md +112 -0
- package/templates/survey/commentary.txt +2 -0
- package/templates/survey/core/behaviors.d.ts +14 -0
- package/templates/survey/core/behaviors.js +115 -0
- package/templates/survey/core/dom.d.ts +13 -0
- package/templates/survey/core/dom.js +83 -0
- package/templates/survey/core/editor.d.ts +80 -0
- package/templates/survey/core/editor.js +720 -0
- package/templates/survey/core/markdown.d.ts +21 -0
- package/templates/survey/core/markdown.js +298 -0
- package/templates/survey/core/model.d.ts +83 -0
- package/templates/survey/core/model.js +209 -0
- package/templates/survey/core/rich-text.d.ts +18 -0
- package/templates/survey/core/rich-text.js +469 -0
- package/templates/survey/edit.html +26 -0
- package/templates/survey/gitignore +4 -0
- package/templates/survey/index.html +26 -0
- package/templates/survey/metadata.json +9 -0
- package/templates/survey/package.json +13 -0
- package/templates/survey/screens/edit.js +345 -0
- package/templates/survey/screens/learn.js +100 -0
- package/templates/survey/styles.css +1264 -0
- package/templates/survey/template.json +6 -0
- package/templates/survey/ui/templates/edit.d.ts +27 -0
- package/templates/survey/ui/templates/edit.js +656 -0
- package/templates/survey/ui/templates/index.d.ts +3 -0
- package/templates/survey/ui/templates/index.js +3 -0
- package/templates/survey/ui/templates/learn.js +147 -0
- package/templates/survey/ui/templates/page.js +19 -0
- package/templates/survey/ui/texts.d.ts +3 -0
- package/templates/survey/ui/texts.js +116 -0
- package/templates/survey/ui/theme.css +42 -0
- package/templates/video/template.json +1 -1
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
// - 끔 · 문제 하나: pattern, 정답 정규식 하나 (모두 맞혀야 100점)
|
|
6
6
|
// - 켬: partial_pattern, 문항마다 정규식 + 배점 (맞은 문항 배점의 합, 최대 100). 배점은 자동(똑같이 나눔) 또는 카드 머리에서 직접.
|
|
7
7
|
// 학생 화면이 답을 배열로 내도록 settings에 gradingType을, 배점 표시용으로 pointsMode · 문제별 points도 같이 저장 (배점은 정답이 아님)
|
|
8
|
+
// - AI 채점 문제가 하나라도 있음 (1.11.0): per_question, 문항마다 배점 + 채점기(정규식 · AI 채점 기준) + 통과 점수 pass_score.
|
|
9
|
+
// 부분 채점 스위치는 켜진 채 잠기고, 답 형식 answerFormat 3 · requires 1.11.0으로 1.10 편집 화면이 덮어쓰지 못하게 한다
|
|
8
10
|
// 문제 내용(content)은 학생에게도 내려가므로 정답을 넣지 않습니다 (정답은 grading에만, 서버가 학생에게 내려주지 않음).
|
|
9
11
|
// 여기서는 어떤 칸을 어떤 순서로 놓을지만 정합니다. 모양은 ui/(templates/edit.js · texts · theme.css), 동작은 core/.
|
|
10
12
|
import {
|
|
@@ -28,6 +30,19 @@ import {
|
|
|
28
30
|
buildAnswerKeys,
|
|
29
31
|
compileTextRegex,
|
|
30
32
|
isRegexMode,
|
|
33
|
+
isRubricMode,
|
|
34
|
+
ANSWER_FORMAT_MAX,
|
|
35
|
+
ANSWER_FORMAT_PER_QUESTION,
|
|
36
|
+
buildPerQuestionGrading,
|
|
37
|
+
isPerQuestionType,
|
|
38
|
+
parsePerQuestionGrading,
|
|
39
|
+
PER_QUESTION,
|
|
40
|
+
PER_QUESTION_MAX,
|
|
41
|
+
REQUIRES_PER_QUESTION,
|
|
42
|
+
RUBRIC_QUESTION_MAX,
|
|
43
|
+
RUBRIC_QUESTIONS_MAX,
|
|
44
|
+
usesPerQuestion,
|
|
45
|
+
validatePerQuestionGrading,
|
|
31
46
|
listToRegex,
|
|
32
47
|
regexToList,
|
|
33
48
|
REQUIRES,
|
|
@@ -128,16 +143,31 @@ const startedEmpty = draft.questions.length === 0;
|
|
|
128
143
|
if (startedEmpty)
|
|
129
144
|
draft.questions.push(newQuestion("select_one", [], texts.defaults));
|
|
130
145
|
|
|
131
|
-
// 채점 방식: 저장된 settings.grading.type (없으면 settings.gradingType, 그것도 없으면 pattern). "부분 채점 허용"으로
|
|
132
|
-
|
|
146
|
+
// 채점 방식: 저장된 settings.grading.type (없으면 settings.gradingType, 그것도 없으면 pattern). "부분 채점 허용"으로 바꾼다.
|
|
147
|
+
// per_question(AI 채점 문제가 있음, 1.11.0 · 개발 중 제안 items도)은 문제별 채점이라 부분 채점이 켜진 것으로 연다
|
|
148
|
+
const savedType = gradingTypeOf(app.content, app.grading);
|
|
149
|
+
let partialOn = savedType === PARTIAL || savedType === PER_QUESTION;
|
|
133
150
|
/** 부분 채점이 실제로 걸리는지: 켜져 있고 문제가 2개 이상 (문제 하나면 설정이 보이지 않고 pattern으로 저장) */
|
|
134
151
|
const partialActive = () => partialOn && draft.questions.length > 1;
|
|
152
|
+
/** AI 채점 문제가 하나라도 있으면 per_question으로 저장한다 (1.11.0) */
|
|
153
|
+
const perQuestionActive = () => usesPerQuestion(draft.questions);
|
|
154
|
+
/** 문제별 배점을 쓰는지: 부분 채점이나 per_question이고 문제가 2개 이상 (per_question 문제 하나면 배점 100) */
|
|
155
|
+
const scoringActive = () => (partialOn || perQuestionActive()) && draft.questions.length > 1;
|
|
156
|
+
// 저장된 per_question(옛 제안 items도) 채점 설정 → 문항별 정답 · 배점 · 통과 점수 (자리 = 문항 순서). 못 읽으면 null
|
|
157
|
+
const savedPerQuestion = isPerQuestionType(app.grading?.type)
|
|
158
|
+
? parsePerQuestionGrading(draft.questions, app.grading)
|
|
159
|
+
: undefined;
|
|
160
|
+
// 통과 점수 (AI 채점 문제가 있는 퀴즈만, grading.pass_score). 칸이 비었거나 숫자가 아니면 undefined · NaN.
|
|
161
|
+
// 저장할 때는 늘 보낸다: 비었으면 100 (서버 기본값과 같음, 1.11.0 per_question 합의)
|
|
162
|
+
let passScore = Number.isInteger(app.grading?.pass_score) ? app.grading.pass_score : undefined;
|
|
135
163
|
// 배점: 저장된 grading.scores가 원본 (정규식의 문제 id로 맞춰 지금 순서로). 맞추지 못하면(문제를 더하거나 지움) 자동 배점.
|
|
136
164
|
// 자동 · 직접은 공개 값 pointsMode, 없으면(1.7.x에 저장했거나 직접 쓴 settings) 저장된 배점이 자동 배점 값과 같을 때만 자동.
|
|
137
165
|
// 1.7.x가 똑같이 나눠 저장한 33 · 33 · 34는 직접 배점으로 열어 고치지 않으면 그대로 저장된다
|
|
138
166
|
if (partialOn) {
|
|
139
167
|
const saved = app.grading?.type === PARTIAL ? app.grading : undefined;
|
|
140
|
-
const { scores, resplit } =
|
|
168
|
+
const { scores, resplit } = savedPerQuestion
|
|
169
|
+
? { scores: savedPerQuestion.scores, resplit: false }
|
|
170
|
+
: scoresFor(draft.questions, saved, equalPoints);
|
|
141
171
|
draft.questions.forEach((q, i) => (q.points = scores[i]));
|
|
142
172
|
const even = JSON.stringify(scores) === JSON.stringify(equalPoints(draft.questions.length));
|
|
143
173
|
draft.pointsMode =
|
|
@@ -146,22 +176,30 @@ if (partialOn) {
|
|
|
146
176
|
: "equal";
|
|
147
177
|
}
|
|
148
178
|
|
|
149
|
-
// 답 형식 (ADR 0013): 이 판은 ANSWER_FORMAT(2, 주관식 원문)
|
|
150
|
-
//
|
|
151
|
-
|
|
179
|
+
// 답 형식 (ADR 0013): 이 판은 ANSWER_FORMAT(2, 주관식 원문)으로, per_question 퀴즈는 ANSWER_FORMAT_PER_QUESTION(3, 인코딩은 2와 같음)으로
|
|
180
|
+
// 저장한다. 옛 자료(answerFormat 없음)는 옛 정답을 읽어 두었다가 저장할 때 모두 새 형식으로 다시 쓴다.
|
|
181
|
+
// 이 판이 모르는 더 새 템플릿이 저장한 자료(answerFormat이 ANSWER_FORMAT_MAX보다 큼)는 정답을 저장하지 않고 알린다
|
|
182
|
+
const futureFormat = Number(app.content.answerFormat) > ANSWER_FORMAT_MAX;
|
|
152
183
|
// 주관식 정답 입력 방식(공개 값 answerMode)이 없으면 직접 입력
|
|
153
|
-
for (const q of draft.questions)
|
|
184
|
+
for (const q of draft.questions)
|
|
185
|
+
if (q.type === "text" && q.answerMode !== "regex" && q.answerMode !== "rubric") q.answerMode = "list";
|
|
154
186
|
// 채점 테스트에 적은 답 (문항 id → 글). 저장하지 않는다
|
|
155
187
|
const regexTests = new Map();
|
|
188
|
+
// 주관식 정답 입력 방식을 바꿨다가 돌아올 때 되살릴 글 (문항 id → { rows, regex, rubric }). 저장하지 않는다
|
|
189
|
+
// (AI 채점으로 · 에서 바꾸면 화면을 다시 그려 칸이 새로 만들어지므로 여기 둔다)
|
|
190
|
+
const textDrafts = new Map();
|
|
156
191
|
|
|
157
192
|
// 문항 id → 정답(화면 값: 선택 id · id 목록 · 그룹별 목록, 주관식은 허용 답 목록 또는 정규식 글). 저장된 정규식(partial_pattern은 문항별 배열)을 읽어 채운다
|
|
158
193
|
const rawKey = app.grading?.answer_key;
|
|
159
194
|
const savedKey = Array.isArray(rawKey) && rawKey.length === 0 ? null : rawKey;
|
|
160
|
-
const parsed =
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
195
|
+
const parsed =
|
|
196
|
+
savedPerQuestion !== undefined
|
|
197
|
+
? (savedPerQuestion?.key ?? null)
|
|
198
|
+
: Array.isArray(savedKey)
|
|
199
|
+
? parseAnswerKeys(draft.questions, savedKey)
|
|
200
|
+
: savedKey
|
|
201
|
+
? parseAnswerKey(draft.questions, savedKey)
|
|
202
|
+
: {};
|
|
165
203
|
/** @type {Record<string, unknown>} */
|
|
166
204
|
const answers = parsed ?? {};
|
|
167
205
|
/** 새 문항의 기본 정답: 첫 번째 보기 하나 (단일 · 복수 선택만, 나머지 유형은 직접 고른다) */
|
|
@@ -188,7 +226,7 @@ if (startedEmpty && !savedKey) {
|
|
|
188
226
|
const picked = defaultAnswer(first);
|
|
189
227
|
if (picked !== undefined) answers[first.id] = picked;
|
|
190
228
|
}
|
|
191
|
-
const unreadable = Boolean(savedKey) && parsed === null;
|
|
229
|
+
const unreadable = (Boolean(savedKey) || savedPerQuestion !== undefined) && parsed === null;
|
|
192
230
|
// 순서 맞추기 정답 칸 (문항 id → 화면). 끌어 놓기는 window에서 끝나 이벤트로 읽으면 마지막 놓기를 놓치므로,
|
|
193
231
|
// 값이 필요할 때(저장 · 다시 그리기 · 보기 삭제) 칸에서 바로 읽는다
|
|
194
232
|
const answerViews = new Map();
|
|
@@ -573,24 +611,38 @@ function answerField(q) {
|
|
|
573
611
|
}
|
|
574
612
|
|
|
575
613
|
/**
|
|
576
|
-
* 주관식 "정답" (연주님 2026-11-19): 정답 입력 방식 세그먼트로 직접 입력(허용 답 목록) · 정규
|
|
614
|
+
* 주관식 "정답" (연주님 2026-11-19): 정답 입력 방식 세그먼트로 직접 입력(허용 답 목록) · 정규 표현식 · AI 채점을 고른다.
|
|
577
615
|
* - 직접 입력: 줄마다 밑줄 칸, "+ 정답 추가". 저장하는 값은 앞뒤 공백을 자른 비어 있지 않은 답의 목록
|
|
578
616
|
* - 정규 표현식: 작성자가 쓴 식 그대로 두고(answers[id]는 글), 저장할 때 compileTextRegex가 서버 정답 조각으로 바꾼다.
|
|
579
617
|
* 채점 테스트는 서버(Python regex)와 같게 맞춰 본다. 막는 문법 · 바꾸는 것은 입력할 때 바로 알린다
|
|
580
|
-
*
|
|
618
|
+
* - AI 채점 (1.11.0, 서버 per_question): 채점 기준 글(answers[id], 10,000자까지). 배점은 카드 머리.
|
|
619
|
+
* AI 채점 문제가 하나라도 있으면 퀴즈 전체를 per_question으로 저장한다 (문제별 채점)
|
|
620
|
+
* 방식은 공개 값 q.answerMode에 두어 다시 열어도 그대로 (ADR 0013). 다른 방식으로 바꿔도 적던 글은 이 화면에 남아 되돌아오면 그대로
|
|
581
621
|
*/
|
|
582
622
|
function textAnswerField(q) {
|
|
583
|
-
let
|
|
623
|
+
let mode = isRubricMode(q) ? "rubric" : isRegexMode(q) ? "regex" : "list";
|
|
584
624
|
const saved = answers[q.id];
|
|
625
|
+
const kept = textDrafts.get(q.id);
|
|
585
626
|
// 직접 입력 칸 (정규식 방식이면 정규식을 목록으로 풀 수 있을 때 그 목록)
|
|
586
|
-
const rows =
|
|
587
|
-
|
|
588
|
-
|
|
627
|
+
const rows =
|
|
628
|
+
mode === "list" && Array.isArray(saved) && saved.length
|
|
629
|
+
? [...saved]
|
|
630
|
+
: kept?.rows.length
|
|
631
|
+
? [...kept.rows]
|
|
632
|
+
: [""];
|
|
633
|
+
let regexText = mode === "regex" && typeof saved === "string" ? saved : (kept?.regex ?? "");
|
|
634
|
+
let rubricText = mode === "rubric" && typeof saved === "string" ? saved : (kept?.rubric ?? "");
|
|
635
|
+
if (mode === "regex") {
|
|
589
636
|
const list = regexToList(regexText);
|
|
590
637
|
if (list?.length) rows.splice(0, rows.length, ...list);
|
|
591
638
|
}
|
|
592
639
|
const sync = () => {
|
|
593
|
-
answers[q.id] =
|
|
640
|
+
answers[q.id] =
|
|
641
|
+
mode === "rubric"
|
|
642
|
+
? rubricText
|
|
643
|
+
: mode === "regex"
|
|
644
|
+
? regexText.trim()
|
|
645
|
+
: rows.map((v) => v.trim()).filter(Boolean);
|
|
594
646
|
};
|
|
595
647
|
const listBody = document.createElement("div");
|
|
596
648
|
const paint = (focusAt) => {
|
|
@@ -683,31 +735,61 @@ function textAnswerField(q) {
|
|
|
683
735
|
});
|
|
684
736
|
check();
|
|
685
737
|
|
|
686
|
-
|
|
687
|
-
const
|
|
688
|
-
const
|
|
689
|
-
const
|
|
690
|
-
|
|
738
|
+
// AI 채점: 채점 기준 칸 + 글자 수
|
|
739
|
+
const rubricBox = templates.rubricAnswer({ max: LIMITS.rubricMax });
|
|
740
|
+
const rubricInput = rubricBox.querySelector('[data-role="input"]');
|
|
741
|
+
const rubricCount = rubricBox.querySelector('[data-role="count"]');
|
|
742
|
+
rubricInput.value = rubricText;
|
|
743
|
+
const countRubric = () => {
|
|
744
|
+
rubricCount.textContent = a.rubricCount(rubricText.length, LIMITS.rubricMax);
|
|
745
|
+
rubricCount.dataset.state = rubricText.length > LIMITS.rubricMax ? "over" : "";
|
|
746
|
+
};
|
|
747
|
+
rubricInput.addEventListener("input", () => {
|
|
748
|
+
rubricText = rubricInput.value;
|
|
749
|
+
sync();
|
|
750
|
+
countRubric();
|
|
751
|
+
});
|
|
752
|
+
countRubric();
|
|
753
|
+
paintRubricScore(rubricBox, q);
|
|
754
|
+
|
|
755
|
+
const box = templates.textAnswerBox({ list: listBody, regex: regexBox, rubric: rubricBox });
|
|
756
|
+
const areas = {
|
|
757
|
+
list: box.querySelector('[data-role="list-area"]'),
|
|
758
|
+
regex: box.querySelector('[data-role="regex-area"]'),
|
|
759
|
+
rubric: box.querySelector('[data-role="rubric-area"]'),
|
|
760
|
+
};
|
|
761
|
+
const buttons = {
|
|
762
|
+
list: box.querySelector('[data-role="mode-list"]'),
|
|
763
|
+
regex: box.querySelector('[data-role="mode-regex"]'),
|
|
764
|
+
rubric: box.querySelector('[data-role="mode-rubric"]'),
|
|
765
|
+
};
|
|
766
|
+
const order = ["list", "regex", "rubric"];
|
|
691
767
|
const hint = box.querySelector('[data-role="mode-hint"]');
|
|
692
768
|
const show = () => {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
[
|
|
697
|
-
[regexBtn, regexOn],
|
|
698
|
-
]) {
|
|
699
|
-
btn.setAttribute("aria-checked", String(on));
|
|
700
|
-
btn.tabIndex = on ? 0 : -1;
|
|
769
|
+
for (const m of order) {
|
|
770
|
+
areas[m].hidden = m !== mode;
|
|
771
|
+
buttons[m].setAttribute("aria-checked", String(m === mode));
|
|
772
|
+
buttons[m].tabIndex = m === mode ? 0 : -1;
|
|
701
773
|
}
|
|
702
|
-
hint.textContent =
|
|
774
|
+
hint.textContent = mode === "list" ? a.hint.text : mode === "rubric" ? a.hint.rubric : "";
|
|
703
775
|
};
|
|
704
|
-
/**
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
776
|
+
/**
|
|
777
|
+
* 방식 바꾸기: 목록 → 정규식은 같은 뜻의 식으로, 정규식 → 목록은 풀 수 있으면 목록으로 (못 풀면 지우고 되돌리기 알림).
|
|
778
|
+
* AI 채점으로 · AI 채점에서 바꿀 때는 글을 옮기지 않는다 (적던 정답 · 채점 기준은 그대로 남음).
|
|
779
|
+
* AI 채점이 생기거나 없어지면 채점 방식(per_question)이 바뀌므로 화면 전체를 다시 그린다 (배점 칸 · 맨 위 부분 채점 설정)
|
|
780
|
+
*/
|
|
781
|
+
const setMode = (next, keepRegex = false) => {
|
|
782
|
+
if (next === mode) return;
|
|
783
|
+
// AI 채점 문제는 퀴즈에 RUBRIC_QUESTIONS_MAX개까지 (서버 per_question): 더 고르지 못하게 하고 알린다
|
|
784
|
+
if (next === "rubric" && draft.questions.filter(isRubricMode).length >= RUBRIC_QUESTIONS_MAX) {
|
|
785
|
+
showSnackbar(a.validation.perQuestion.rubricCount(RUBRIC_QUESTIONS_MAX));
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
const prev = mode;
|
|
789
|
+
if (next === "regex" && prev === "list" && !keepRegex) {
|
|
708
790
|
regexText = listToRegex(rows);
|
|
709
791
|
regexInput.value = regexText;
|
|
710
|
-
} else if (
|
|
792
|
+
} else if (next === "list" && prev === "regex") {
|
|
711
793
|
const before = regexText;
|
|
712
794
|
const list = regexToList(before);
|
|
713
795
|
rows.splice(0, rows.length, ...(list?.length ? list : [""]));
|
|
@@ -716,23 +798,28 @@ function textAnswerField(q) {
|
|
|
716
798
|
showSnackbar(a.regexCleared, () => {
|
|
717
799
|
regexText = before;
|
|
718
800
|
regexInput.value = before;
|
|
719
|
-
setMode(
|
|
801
|
+
setMode("regex", true);
|
|
720
802
|
});
|
|
721
803
|
}
|
|
722
|
-
|
|
723
|
-
q.answerMode =
|
|
804
|
+
mode = next;
|
|
805
|
+
q.answerMode = next;
|
|
724
806
|
sync();
|
|
725
807
|
check();
|
|
726
808
|
show();
|
|
809
|
+
if (prev === "rubric" || next === "rubric") {
|
|
810
|
+
textDrafts.set(q.id, { rows: [...rows], regex: regexText, rubric: rubricText });
|
|
811
|
+
render();
|
|
812
|
+
form.cardAt(draft.questions.indexOf(q))?.querySelector(`[data-role="mode-${next}"]`)?.focus();
|
|
813
|
+
}
|
|
727
814
|
};
|
|
728
|
-
|
|
729
|
-
regexBtn.addEventListener("click", () => setMode(true));
|
|
815
|
+
for (const m of order) buttons[m].addEventListener("click", () => setMode(m));
|
|
730
816
|
box.querySelector(".qe-seg").addEventListener("keydown", (e) => {
|
|
731
817
|
if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(e.key)) return;
|
|
732
818
|
e.preventDefault();
|
|
733
|
-
const
|
|
819
|
+
const step = e.key === "ArrowRight" || e.key === "ArrowDown" ? 1 : -1;
|
|
820
|
+
const next = order[(order.indexOf(mode) + step + order.length) % order.length];
|
|
734
821
|
setMode(next);
|
|
735
|
-
|
|
822
|
+
buttons[next].focus();
|
|
736
823
|
});
|
|
737
824
|
show();
|
|
738
825
|
return form.ui.section({ label: a.label, body: box });
|
|
@@ -947,8 +1034,8 @@ function questionCard(q, i) {
|
|
|
947
1034
|
count: draft.questions.length,
|
|
948
1035
|
types: Object.entries(texts.types),
|
|
949
1036
|
body: questionFields(q, i),
|
|
950
|
-
// 부분
|
|
951
|
-
points:
|
|
1037
|
+
// 부분 채점 · per_question일 때만 카드 머리에 배점 칸
|
|
1038
|
+
points: scoringActive() ? (q.points ?? 0) : undefined,
|
|
952
1039
|
},
|
|
953
1040
|
{
|
|
954
1041
|
// 배점을 고치면 직접 배점. 다시 그리지 않고 합계만 고친다 (입력 중 초점 유지)
|
|
@@ -956,6 +1043,7 @@ function questionCard(q, i) {
|
|
|
956
1043
|
q.points = Math.min(100, Math.max(0, Math.round(Number(value) || 0)));
|
|
957
1044
|
draft.pointsMode = "custom";
|
|
958
1045
|
updateScoreSum();
|
|
1046
|
+
paintRubricScore(form.cardAt(draft.questions.indexOf(q)), q);
|
|
959
1047
|
save?.markDirty();
|
|
960
1048
|
},
|
|
961
1049
|
type: (type) => {
|
|
@@ -982,6 +1070,7 @@ function questionCard(q, i) {
|
|
|
982
1070
|
...(q.points === undefined ? {} : { points: q.points }),
|
|
983
1071
|
};
|
|
984
1072
|
delete answers[q.id];
|
|
1073
|
+
textDrafts.delete(q.id);
|
|
985
1074
|
const picked = defaultAnswer(draft.questions[i]);
|
|
986
1075
|
if (picked !== undefined) answers[q.id] = picked;
|
|
987
1076
|
answerViews.delete(q.id);
|
|
@@ -1046,9 +1135,26 @@ function showSnackbar(text, restore) {
|
|
|
1046
1135
|
snackbarTimer = setTimeout(hideSnackbar, SNACKBAR_MS);
|
|
1047
1136
|
}
|
|
1048
1137
|
|
|
1138
|
+
/**
|
|
1139
|
+
* AI 채점 문제의 배점 환산 안내 (채점 기준 칸 아래, 연주님 디자인): 배점 칸이 있고 배점이 100점이 아닐 때만
|
|
1140
|
+
* "이 문제의 배점은 N점입니다. 배점에 맞게 환산되어 채점됩니다." (점수만 굵게). box: 채점 기준 칸이나 그것을 품은 문제 카드
|
|
1141
|
+
*/
|
|
1142
|
+
function paintRubricScore(box, q) {
|
|
1143
|
+
const note = box?.querySelector('[data-role="score-note"]');
|
|
1144
|
+
if (!note) return;
|
|
1145
|
+
const shown = scoringActive() && Number.isInteger(q.points) && q.points !== 100;
|
|
1146
|
+
note.hidden = !shown;
|
|
1147
|
+
if (!shown) return;
|
|
1148
|
+
const strong = document.createElement("strong");
|
|
1149
|
+
strong.textContent = a.rubricScoreNote.points(q.points);
|
|
1150
|
+
note
|
|
1151
|
+
.querySelector('[data-role="score-text"]')
|
|
1152
|
+
.replaceChildren(a.rubricScoreNote.before, strong, a.rubricScoreNote.after);
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1049
1155
|
/** 부분 채점 배점 맞추기: 자동 배점이면 문제마다 ceil(100 / 문제 수)(equalPoints), 직접 배점이면 빈 배점을 0으로 */
|
|
1050
1156
|
function syncPoints() {
|
|
1051
|
-
if (!
|
|
1157
|
+
if (!scoringActive()) return;
|
|
1052
1158
|
if (draft.pointsMode !== "custom") {
|
|
1053
1159
|
const scores = equalPoints(draft.questions.length);
|
|
1054
1160
|
draft.questions.forEach((q, i) => (q.points = scores[i]));
|
|
@@ -1060,9 +1166,12 @@ function syncPoints() {
|
|
|
1060
1166
|
/** 부분 채점 설정 상자 (문제가 2개 이상일 때 맨 위). 켜고 끄기 · 동일 점수로 되돌리기 */
|
|
1061
1167
|
let scoreBox = null;
|
|
1062
1168
|
function scoreSettings() {
|
|
1063
|
-
|
|
1169
|
+
// AI 채점 문제가 있으면 문제별 채점(per_question)이라 스위치는 켜진 채 잠근다 (AI 채점 문제를 모두 바꾸면 원래 값으로)
|
|
1170
|
+
const locked = perQuestionActive();
|
|
1171
|
+
const box = templates.scoreSettings({ partial: partialOn || locked, locked });
|
|
1064
1172
|
const part = (role) => box.querySelector(`[data-role="${role}"]`);
|
|
1065
1173
|
part("partial").addEventListener("change", (e) => {
|
|
1174
|
+
if (locked) return;
|
|
1066
1175
|
partialOn = e.target.checked;
|
|
1067
1176
|
if (!partialOn) delete draft.pointsMode;
|
|
1068
1177
|
render();
|
|
@@ -1108,7 +1217,8 @@ function render() {
|
|
|
1108
1217
|
scoreBox = draft.questions.length > 1 ? scoreSettings() : null;
|
|
1109
1218
|
const cards = draft.questions.map(questionCard);
|
|
1110
1219
|
root.replaceChildren(
|
|
1111
|
-
// 부분 채점 설정은 문제가 2개 이상일 때만 맨
|
|
1220
|
+
// 부분 채점 설정은 문제가 2개 이상일 때만 맨 위에.
|
|
1221
|
+
// 통과 점수 칸은 두지 않는다 (연주님 1.11.1 수정본): 새 퀴즈는 pass_score 100, 예전에 저장한 값은 그대로 저장된다
|
|
1112
1222
|
...(scoreBox ? [scoreBox] : []),
|
|
1113
1223
|
// 저장된 정답을 못 읽었을 때만 맨 위에 경고
|
|
1114
1224
|
...(unreadable ? [templates.answersIntro({ text: a.unreadable })] : []),
|
|
@@ -1127,7 +1237,7 @@ function render() {
|
|
|
1127
1237
|
texts.defaults,
|
|
1128
1238
|
);
|
|
1129
1239
|
// 직접 배점이면 새 문제는 100점까지 남은 배점으로 (자동 배점은 다시 나눔)
|
|
1130
|
-
if (
|
|
1240
|
+
if (scoringActive() && draft.pointsMode === "custom")
|
|
1131
1241
|
added.points = Math.max(0, 100 - totalPoints(draft.questions));
|
|
1132
1242
|
draft.questions.push(added);
|
|
1133
1243
|
const picked = defaultAnswer(added);
|
|
@@ -1237,12 +1347,76 @@ function partialGrading(questions) {
|
|
|
1237
1347
|
return { type: PARTIAL, answer_key: keys, scores };
|
|
1238
1348
|
}
|
|
1239
1349
|
|
|
1350
|
+
/**
|
|
1351
|
+
* per_question 채점 설정 (AI 채점 문제가 있음, 1.11.0 · 서버 #65): 정규식 문제는 partial_pattern과 같은 문항별 정답 정규식과 검증
|
|
1352
|
+
* (길이 · 공통 검사 · 왕복 · 오답), AI 채점 문제는 채점 기준 글과 문제 글(질문 + 지문, 2,000자까지). 배점은 문제 카드 머리
|
|
1353
|
+
* (문제가 하나면 100). 통과 점수는 늘 보낸다 (비우면 100)
|
|
1354
|
+
*/
|
|
1355
|
+
function perQuestionGrading(questions) {
|
|
1356
|
+
const base = sampleAnswers(questions);
|
|
1357
|
+
for (const [i, q] of questions.entries()) {
|
|
1358
|
+
if (isRubricMode(q)) continue;
|
|
1359
|
+
const key = buildAnswerKey([q], answers, ANSWER_FORMAT);
|
|
1360
|
+
if (key.length > ANSWER_KEY_MAX)
|
|
1361
|
+
return problemAt(
|
|
1362
|
+
{
|
|
1363
|
+
questionIndex: i,
|
|
1364
|
+
message: a.validation.at(i + 1, a.validation.tooLongItem(key.length, ANSWER_KEY_MAX)),
|
|
1365
|
+
},
|
|
1366
|
+
{ answer: true },
|
|
1367
|
+
);
|
|
1368
|
+
const regexProblem = validateAnswerRegex(key, [
|
|
1369
|
+
joinAnswerList([q], [base[i]], ANSWER_FORMAT)[0],
|
|
1370
|
+
]);
|
|
1371
|
+
if (regexProblem)
|
|
1372
|
+
return problemAt(
|
|
1373
|
+
{ questionIndex: i, message: a.validation.at(i + 1, regexProblem) },
|
|
1374
|
+
{ answer: true },
|
|
1375
|
+
);
|
|
1376
|
+
}
|
|
1377
|
+
// 왕복 · 오답 검사는 정규식 문제만 (문제 번호는 원래 자리로)
|
|
1378
|
+
const kept = questions.map((q, i) => (isRubricMode(q) ? -1 : i)).filter((i) => i >= 0);
|
|
1379
|
+
const sub = kept.map((i) => questions[i]);
|
|
1380
|
+
const v = { ...a.validation, at: (no, message) => a.validation.at(kept[no - 1] + 1, message) };
|
|
1381
|
+
const subProblem = sub.length
|
|
1382
|
+
? checkAnswerKeys(sub, answers, buildAnswerKeys(sub, answers, ANSWER_FORMAT), v, ANSWER_FORMAT)
|
|
1383
|
+
: null;
|
|
1384
|
+
const keyProblem = subProblem
|
|
1385
|
+
? { ...subProblem, questionIndex: kept[subProblem.questionIndex] ?? -1 }
|
|
1386
|
+
: checkRegexTests(questions);
|
|
1387
|
+
if (keyProblem) return problemAt(keyProblem, { answer: true });
|
|
1388
|
+
const scores = questions.length > 1 ? questions.map((q) => q.points) : [100];
|
|
1389
|
+
const grading = buildPerQuestionGrading(
|
|
1390
|
+
questions,
|
|
1391
|
+
answers,
|
|
1392
|
+
scores,
|
|
1393
|
+
ANSWER_FORMAT,
|
|
1394
|
+
passScore ?? 100,
|
|
1395
|
+
);
|
|
1396
|
+
const problem = validatePerQuestionGrading(grading, ANSWER_KEY_MAX);
|
|
1397
|
+
if (!problem) return grading;
|
|
1398
|
+
const limit = {
|
|
1399
|
+
count: PER_QUESTION_MAX,
|
|
1400
|
+
patternMax: ANSWER_KEY_MAX,
|
|
1401
|
+
rubricMax: LIMITS.rubricMax,
|
|
1402
|
+
questionMax: RUBRIC_QUESTION_MAX,
|
|
1403
|
+
rubricCount: RUBRIC_QUESTIONS_MAX,
|
|
1404
|
+
}[problem.code];
|
|
1405
|
+
const message = a.validation.perQuestion[problem.code](limit);
|
|
1406
|
+
if (problem.index < 0) return message;
|
|
1407
|
+
return problemAt(
|
|
1408
|
+
{ questionIndex: problem.index, message: a.validation.at(problem.index + 1, message) },
|
|
1409
|
+
{ answer: true },
|
|
1410
|
+
);
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1240
1413
|
render();
|
|
1241
1414
|
// 불러오는 자리에서 내용으로 바뀔 때 살짝 나타나게 (styles.css .qz-enter)
|
|
1242
1415
|
root.classList.add("qz-enter");
|
|
1243
1416
|
save = app.useSave({
|
|
1244
1417
|
label: t.done,
|
|
1245
|
-
// partial_pattern이면 학생 화면이 답을 문항별 배열로 내도록 공개 값 gradingType과 배점 표시(pointsMode · points)를 같이 저장 (정답은 아님)
|
|
1418
|
+
// partial_pattern이면 학생 화면이 답을 문항별 배열로 내도록 공개 값 gradingType과 배점 표시(pointsMode · points)를 같이 저장 (정답은 아님).
|
|
1419
|
+
// per_question이면 통과 점수도 공개 값 passScore로 (학생 화면의 "통과" 표시, 정답은 아님)
|
|
1246
1420
|
getContent: () => {
|
|
1247
1421
|
const content = structuredClone(draft);
|
|
1248
1422
|
const images = usedImages();
|
|
@@ -1255,15 +1429,29 @@ save = app.useSave({
|
|
|
1255
1429
|
content.requires = { ...(content.requires ?? {}), ...REQUIRES };
|
|
1256
1430
|
}
|
|
1257
1431
|
for (const q of content.questions) {
|
|
1258
|
-
if (q.type === "text")
|
|
1432
|
+
if (q.type === "text")
|
|
1433
|
+
q.answerMode = q.answerMode === "regex" || q.answerMode === "rubric" ? q.answerMode : "list";
|
|
1259
1434
|
else delete q.answerMode;
|
|
1260
1435
|
}
|
|
1261
|
-
|
|
1436
|
+
// AI 채점 문제가 있으면 per_question: 학생 화면이 답을 배열로(AI 채점 문제는 답 글만) 내도록 공개 값 gradingType,
|
|
1437
|
+
// 답 형식 3(1.10 편집 화면은 정답을 저장하지 않음)과 이 형식을 읽는 템플릿 버전(requires 1.11.0), 통과 점수를 둔다.
|
|
1438
|
+
// 문제가 하나면 배점 표시 없이 100점
|
|
1439
|
+
if (perQuestionActive() && !futureFormat) {
|
|
1440
|
+
content.gradingType = PER_QUESTION;
|
|
1441
|
+
content.answerFormat = ANSWER_FORMAT_PER_QUESTION;
|
|
1442
|
+
content.requires = { ...(content.requires ?? {}), ...REQUIRES_PER_QUESTION };
|
|
1443
|
+
content.passScore = passScore ?? 100;
|
|
1444
|
+
if (content.questions.length < 2) {
|
|
1445
|
+
delete content.pointsMode;
|
|
1446
|
+
for (const q of content.questions) delete q.points;
|
|
1447
|
+
}
|
|
1448
|
+
} else if (partialActive()) content.gradingType = PARTIAL;
|
|
1262
1449
|
else {
|
|
1263
1450
|
delete content.gradingType;
|
|
1264
1451
|
delete content.pointsMode;
|
|
1265
1452
|
for (const q of content.questions) delete q.points;
|
|
1266
1453
|
}
|
|
1454
|
+
if (!perQuestionActive() && !futureFormat) delete content.passScore;
|
|
1267
1455
|
return content;
|
|
1268
1456
|
},
|
|
1269
1457
|
validate: (content) => {
|
|
@@ -1296,6 +1484,7 @@ save = app.useSave({
|
|
|
1296
1484
|
const { questions } = draft;
|
|
1297
1485
|
const missing = validateAnswerKey(questions, answers, a.validation);
|
|
1298
1486
|
if (missing) return problemAt(missing, { answer: true });
|
|
1487
|
+
if (perQuestionActive()) return perQuestionGrading(questions);
|
|
1299
1488
|
if (partialActive()) return partialGrading(questions);
|
|
1300
1489
|
const answerKey = buildAnswerKey(questions, answers, ANSWER_FORMAT);
|
|
1301
1490
|
// 정답 정규식은 서버 한도(ANSWER_KEY_MAX)가 퀴즈 전체에 걸린다. 한글 주관식은 한 글자가 9자로 늘어
|