@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
package/es/core/config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFile, writeFile, unlink } from 'node:fs/promises';
|
|
2
2
|
import { join, resolve, basename } from 'node:path';
|
|
3
|
+
import { gunzipSync } from 'node:zlib';
|
|
3
4
|
import 'fflate';
|
|
4
5
|
import { rules } from '../rules/spec.js';
|
|
5
6
|
import { LEGACY_COMPLETION_SCREENS, LEGACY_COMPLETION_FIELDS, parseManifest, serializeManifest, COMPLETION_POLICIES_IGNORED, graderTypeError } from '../rules/manifest.js';
|
|
@@ -7,10 +8,11 @@ import { toJsRegex } from './regex.js';
|
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* 채점 방식 = `settings.grading.type`. 원본은 rules.json `manifest.graderTypes`.
|
|
10
|
-
* pattern: 정답 정규식 · partial_pattern: 문항별 정답 정규식 + 점수 (부분 점수) · rubric: AI 평가
|
|
11
|
+
* pattern: 정답 정규식 · partial_pattern: 문항별 정답 정규식 + 점수 (부분 점수) · rubric: AI 평가 기준 ·
|
|
12
|
+
* entry: 엔트리 템플릿 전용 (일반 · AI 두 방식, 정답 작품 + AI 채점 기준). code_exec는 이번 범위 밖.
|
|
11
13
|
* 완료 정책(on_access · on_submit · on_graded)은 LXP에 올린 뒤 자료 편집 화면의 '설정'에서 교육자가 고른다 (ADR 0012). 패키지 · CLI는 다루지 않는다
|
|
12
14
|
*/
|
|
13
|
-
const GRADER_TYPES = ['pattern', 'partial_pattern', 'rubric'];
|
|
15
|
+
const GRADER_TYPES = ['pattern', 'partial_pattern', 'rubric', 'entry'];
|
|
14
16
|
/** 완료 정책 값 (LXP 설정). grading에 잘못 적었을 때 알려 주려고만 쓴다 */
|
|
15
17
|
const COMPLETION_POLICY_VALUES = ['on_access', 'on_submit', 'on_graded', 'manual', 'none'];
|
|
16
18
|
/** 정답 정규식 길이 상한 (서버와 같게) */
|
|
@@ -32,6 +34,16 @@ const RUBRIC_QUESTIONS_MAX = 10;
|
|
|
32
34
|
const RUBRIC_QUESTION_MAX = 2000;
|
|
33
35
|
/** 1.11.0 개발 중 쓴 제안 이름. 서버는 받지 않는다 (422 union_tag_invalid) */
|
|
34
36
|
const ITEMS_TYPE = 'items';
|
|
37
|
+
/** 엔트리 템플릿 채점 (rules.json graderTypes에 있음) */
|
|
38
|
+
const ENTRY_TYPE = 'entry';
|
|
39
|
+
/** 엔트리 채점 방식 (서버 GradingEntry.mode): general = 정답 작품과 비교해 0 · 100점, ai = 채점 기준별 AI 점수의 합 */
|
|
40
|
+
const ENTRY_MODES = ['general', 'ai'];
|
|
41
|
+
/** 엔트리 작품 묶음 형식 (엔트리 템플릿 core/pack.js): gzip 뒤 base64 글자, 줄이지 않은 JSON 글자 */
|
|
42
|
+
const ENTRY_PROJECT_ENCODINGS = ['gzip+base64', 'json'];
|
|
43
|
+
/** 엔트리 AI 채점 기준 수 상한 */
|
|
44
|
+
const ENTRY_RUBRICS_MAX = 10;
|
|
45
|
+
/** 엔트리 AI 채점 기준 글(criteria) 최대 글자 수 */
|
|
46
|
+
const ENTRY_CRITERIA_MAX = 1000;
|
|
35
47
|
/**
|
|
36
48
|
* 로컬 settings (dev 전용): `ecdk dev` 편집 화면의 saveSettings(PATCH /draft settings)를 흉내 서버가 통째로(내용 + grading) 여기에 쓴다.
|
|
37
49
|
* 운영은 서버 material_version.settings. 프로젝트의 점(.) 폴더라 zip에 들어가지 않는다. build · check는 읽지 않는다
|
|
@@ -50,6 +62,7 @@ function parseGrading(data) {
|
|
|
50
62
|
if (record.completion_policy !== undefined || record.grader_type !== undefined) return `completion_policy · grader_type은 쓰지 않습니다 (2026-11-11 결정: grading은 type 모양 그대로). ${example}`;
|
|
51
63
|
if (record.match !== undefined || record.type !== 'partial_pattern' && record.answer_key !== undefined && typeof record.answer_key !== 'string') return `옛 형식입니다 (match · 객체 정답). 정답은 정규식 문자열 하나입니다: { "type": "pattern", "answer_key": "^q1=b;q2=a,d$" }. 퀴즈는 ecdk dev의 내용 편집에서 정답을 다시 고르면 새 형식으로 저장됩니다.`;
|
|
52
64
|
if (record.type === ITEMS_TYPE) return ITEMS_REJECTED;
|
|
65
|
+
if (record.type === ENTRY_TYPE) return parseEntryGrading(record);
|
|
53
66
|
const unknown = Object.keys(record).filter(k => !GRADING_DATA_KEYS.includes(k));
|
|
54
67
|
if (unknown.length > 0) return `알 수 없는 필드입니다: ${unknown.join(', ')} (가능: ${GRADING_DATA_KEYS.join(', ')})`;
|
|
55
68
|
const {
|
|
@@ -190,6 +203,140 @@ function parsePerQuestionGrading(questions, record) {
|
|
|
190
203
|
questions: out
|
|
191
204
|
};
|
|
192
205
|
}
|
|
206
|
+
/** 엔트리 채점 설정에 쓰는 키 (일반은 rubrics 없이) */
|
|
207
|
+
const ENTRY_KEYS = ['type', 'mode', 'answer_project', 'rubrics'];
|
|
208
|
+
const ENTRY_RUBRIC_KEYS = ['object', 'criteria', 'score'];
|
|
209
|
+
/** 서버가 푸는 작품 크기 한도 (풀린 JSON 1MB) */
|
|
210
|
+
const ENTRY_PROJECT_MAX_BYTES = 1024 * 1024;
|
|
211
|
+
/**
|
|
212
|
+
* 묶은 엔트리 작품을 푼다 (서버 순서: enc → base64 → gzip → JSON → objects 배열). 풀지 못하면 null.
|
|
213
|
+
* CLI 검사는 풀 수 있을 때만 작품 안(오브젝트 id · 채점거리)을 본다
|
|
214
|
+
*/
|
|
215
|
+
function decodeEntryProject(project) {
|
|
216
|
+
if (typeof project !== 'object' || project === null) return null;
|
|
217
|
+
const {
|
|
218
|
+
enc,
|
|
219
|
+
data
|
|
220
|
+
} = project;
|
|
221
|
+
if (typeof data !== 'string' || data === '') return null;
|
|
222
|
+
try {
|
|
223
|
+
const json = enc === 'json' ? data : enc === 'gzip+base64' ? gunzipSync(Buffer.from(data, 'base64'), {
|
|
224
|
+
maxOutputLength: ENTRY_PROJECT_MAX_BYTES
|
|
225
|
+
}).toString('utf8') : null;
|
|
226
|
+
if (json === null) return null;
|
|
227
|
+
const parsed = JSON.parse(json);
|
|
228
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) return null;
|
|
229
|
+
const {
|
|
230
|
+
objects
|
|
231
|
+
} = parsed;
|
|
232
|
+
return Array.isArray(objects) ? parsed : null;
|
|
233
|
+
} catch {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/** 작품의 오브젝트 id들 */
|
|
238
|
+
function entryObjectIds(project) {
|
|
239
|
+
const ids = new Set();
|
|
240
|
+
for (const o of project.objects) if (o && typeof o === 'object' && typeof o.id === 'string') ids.add(o.id);
|
|
241
|
+
return ids;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* 일반 채점의 채점거리가 있나 (서버 entry_answer_project_empty와 같은 규칙): 블록 묶음(스크립트)이 하나 이상 있는
|
|
245
|
+
* 오브젝트나 전역 리스트(variableType list, object 없음)가 하나 이상
|
|
246
|
+
*/
|
|
247
|
+
function entryHasGradable(project) {
|
|
248
|
+
const hasScript = project.objects.some(o => {
|
|
249
|
+
if (!o || typeof o !== 'object') return false;
|
|
250
|
+
let script = o.script;
|
|
251
|
+
if (typeof script === 'string') {
|
|
252
|
+
try {
|
|
253
|
+
script = JSON.parse(script);
|
|
254
|
+
} catch {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return Array.isArray(script) && script.some(thread => Array.isArray(thread) && thread.length > 0);
|
|
259
|
+
});
|
|
260
|
+
if (hasScript) return true;
|
|
261
|
+
const variables = Array.isArray(project.variables) ? project.variables : [];
|
|
262
|
+
return variables.some(v => v && typeof v === 'object' && v.variableType === 'list' && !v.object);
|
|
263
|
+
}
|
|
264
|
+
/** 정답 작품 검사: { enc: 'gzip+base64' | 'json', data: 비어 있지 않은 글자 }. 문제가 있으면 문장 */
|
|
265
|
+
function entryProjectError(project) {
|
|
266
|
+
if (typeof project !== 'object' || project === null || Array.isArray(project)) return 'entry 채점에는 정답 작품 answer_project({ "enc": "gzip+base64" | "json", "data": "…" })가 필요합니다. 엔트리 편집 화면에서 정답 작품을 저장하세요.';
|
|
267
|
+
const {
|
|
268
|
+
enc,
|
|
269
|
+
data
|
|
270
|
+
} = project;
|
|
271
|
+
if (!ENTRY_PROJECT_ENCODINGS.includes(enc)) return `answer_project.enc는 ${ENTRY_PROJECT_ENCODINGS.map(e => `"${e}"`).join(' 또는 ')}입니다 (지금 ${JSON.stringify(enc)}).`;
|
|
272
|
+
if (typeof data !== 'string' || data === '') return 'answer_project.data: 묶은 정답 작품(글자)이 필요합니다.';
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* entry 설정 검사 (엔트리 템플릿 전용, 서버 GradingEntry와 같은 규칙, 어기면 서버는 422):
|
|
277
|
+
* mode general | ai · 정답 작품 answer_project. general은 다른 키가 없어야 하고(rubrics도 안 됨),
|
|
278
|
+
* ai는 기준 rubrics 1~10개({ object: 글자, criteria: 1~1,000자, score: 1~100 정수 }) · 배점 합 100
|
|
279
|
+
*/
|
|
280
|
+
function parseEntryGrading(record) {
|
|
281
|
+
const example = '예: { "type": "entry", "mode": "ai", "answer_project": { "enc": "gzip+base64", "data": "…" }, "rubrics": [{ "object": "ik8o", "criteria": "…", "score": 100 }] }';
|
|
282
|
+
const {
|
|
283
|
+
mode
|
|
284
|
+
} = record;
|
|
285
|
+
if (!ENTRY_MODES.includes(mode)) return `entry 채점 방식 mode는 "general"(일반, 정답 작품과 비교) 또는 "ai"(AI 채점)입니다 (지금 ${JSON.stringify(mode)}). ${example}`;
|
|
286
|
+
const unknown = Object.keys(record).filter(k => !ENTRY_KEYS.includes(k));
|
|
287
|
+
if (unknown.length > 0) return `entry 채점에 알 수 없는 필드입니다: ${unknown.join(', ')} (가능: ${ENTRY_KEYS.join(', ')})`;
|
|
288
|
+
const projectError = entryProjectError(record.answer_project);
|
|
289
|
+
if (projectError) return projectError;
|
|
290
|
+
const {
|
|
291
|
+
enc,
|
|
292
|
+
data
|
|
293
|
+
} = record.answer_project;
|
|
294
|
+
const answerProject = {
|
|
295
|
+
enc,
|
|
296
|
+
data
|
|
297
|
+
};
|
|
298
|
+
// 풀 수 있으면 작품 안도 본다 (서버는 풀어서 검사, 풀지 못하면 서버가 422)
|
|
299
|
+
const decoded = decodeEntryProject(answerProject);
|
|
300
|
+
if (mode === 'general') {
|
|
301
|
+
if (record.rubrics !== undefined) return 'entry 일반 채점(mode "general")에는 채점 기준 rubrics를 넣지 않습니다 (서버 422). AI 채점이면 mode를 "ai"로 하세요.';
|
|
302
|
+
if (decoded && !entryHasGradable(decoded)) return '정답 작품에 블록(스크립트)도 전역 리스트도 없습니다 (서버 422 entry_answer_project_empty). 정답으로 인정할 블록을 만들어 저장하세요.';
|
|
303
|
+
return {
|
|
304
|
+
type: 'entry',
|
|
305
|
+
mode: 'general',
|
|
306
|
+
answer_project: answerProject
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
const list = record.rubrics;
|
|
310
|
+
if (!Array.isArray(list)) return `entry AI 채점(mode "ai")에는 채점 기준 배열 rubrics가 필요합니다. ${example}`;
|
|
311
|
+
if (list.length < 1 || list.length > ENTRY_RUBRICS_MAX) return `entry AI 채점 기준은 1~${ENTRY_RUBRICS_MAX}개입니다 (지금 ${list.length}개).`;
|
|
312
|
+
const rubrics = [];
|
|
313
|
+
for (const [i, item] of list.entries()) {
|
|
314
|
+
if (typeof item !== 'object' || item === null || Array.isArray(item)) return `rubrics[${i}]: 객체여야 합니다. ${example}`;
|
|
315
|
+
const r = item;
|
|
316
|
+
const extra = Object.keys(r).filter(k => !ENTRY_RUBRIC_KEYS.includes(k));
|
|
317
|
+
if (extra.length > 0) return `rubrics[${i}]: 알 수 없는 필드입니다: ${extra.join(', ')} (가능: ${ENTRY_RUBRIC_KEYS.join(', ')})`;
|
|
318
|
+
if (typeof r.object !== 'string') return `rubrics[${i}].object: 기준이 보는 오브젝트 id(글자)가 필요합니다.`;
|
|
319
|
+
// 작품 전체 기준은 없다: 기준마다 정답 작품의 오브젝트 하나 (서버 422 entry_rubric_object_not_found)
|
|
320
|
+
if (r.object === '') return `rubrics[${i}].object: 오브젝트를 골라 주세요. 작품 전체 기준은 없고, 정답 작품에 있는 오브젝트 id여야 합니다 (서버 422 entry_rubric_object_not_found).`;
|
|
321
|
+
if (decoded && !entryObjectIds(decoded).has(r.object)) return `rubrics[${i}].object: 정답 작품에 없는 오브젝트 id입니다 (${JSON.stringify(r.object)}, 서버 422 entry_rubric_object_not_found). 정답 작품의 오브젝트를 다시 고르세요.`;
|
|
322
|
+
if (typeof r.criteria !== 'string' || r.criteria.trim() === '') return `rubrics[${i}].criteria: 채점 기준 글이 필요합니다.`;
|
|
323
|
+
if (r.criteria.length > ENTRY_CRITERIA_MAX) return `rubrics[${i}].criteria: 채점 기준이 너무 깁니다 (${r.criteria.length}자, 최대 ${ENTRY_CRITERIA_MAX}자).`;
|
|
324
|
+
if (!isStrictInt(r.score) || r.score < 1 || r.score > 100) return `rubrics[${i}].score: 배점은 1~100 정수입니다 (지금 ${JSON.stringify(r.score)}).`;
|
|
325
|
+
rubrics.push({
|
|
326
|
+
object: r.object,
|
|
327
|
+
criteria: r.criteria,
|
|
328
|
+
score: r.score
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
const total = rubrics.reduce((sum, r) => sum + r.score, 0);
|
|
332
|
+
if (total !== 100) return `entry AI 채점 기준 배점 합계가 100이어야 합니다 (지금 ${total}).`;
|
|
333
|
+
return {
|
|
334
|
+
type: 'entry',
|
|
335
|
+
mode: 'ai',
|
|
336
|
+
answer_project: answerProject,
|
|
337
|
+
rubrics
|
|
338
|
+
};
|
|
339
|
+
}
|
|
193
340
|
/**
|
|
194
341
|
* parseGrading이 거절한 채점 설정을 서버(elice-material app/core/grading.py)가 낼 pydantic 오류 type으로 옮긴다.
|
|
195
342
|
* 서버 type: regex_answer_key_invalid(정규식 500자 초과 · 컴파일 안 됨) · partial_pattern_length_mismatch ·
|
|
@@ -244,6 +391,7 @@ function serverGradingError(data) {
|
|
|
244
391
|
};
|
|
245
392
|
}
|
|
246
393
|
if (type === PER_QUESTION_TYPE) return perQuestionServerError(record, at, regexIssue);
|
|
394
|
+
if (type === ENTRY_TYPE) return entryServerError(record, at);
|
|
247
395
|
if (type === 'rubric') {
|
|
248
396
|
if (typeof record.rubric !== 'string') return {
|
|
249
397
|
type: record.rubric === undefined ? 'missing' : 'string_type',
|
|
@@ -338,6 +486,164 @@ function serverGradingError(data) {
|
|
|
338
486
|
loc: at
|
|
339
487
|
};
|
|
340
488
|
}
|
|
489
|
+
/**
|
|
490
|
+
* entry의 서버 pydantic 오류 하나 (serverGradingError). 서버 모델의 오류 이름을 받지 못해 pydantic 기본 이름으로 흉내 낸다:
|
|
491
|
+
* literal_error(mode · enc) · missing · extra_forbidden · string_type · string_too_short · string_too_long ·
|
|
492
|
+
* too_short · too_long · int_type · greater_than_equal · less_than_equal, 배점 합이 100이 아니면 value_error.
|
|
493
|
+
* 작품 안 검사(정답 작품을 풀 수 있을 때)는 서버 이름 그대로: 일반의 채점거리 없음 entry_answer_project_empty,
|
|
494
|
+
* AI 기준의 오브젝트가 ''이거나 정답 작품에 없음 entry_rubric_object_not_found (ctx { field: 'grading.rubrics.0.object', object })
|
|
495
|
+
*/
|
|
496
|
+
function entryServerError(record, at) {
|
|
497
|
+
if (record.mode === undefined) return {
|
|
498
|
+
type: 'missing',
|
|
499
|
+
loc: [...at, 'mode']
|
|
500
|
+
};
|
|
501
|
+
if (!ENTRY_MODES.includes(record.mode)) return {
|
|
502
|
+
type: 'literal_error',
|
|
503
|
+
loc: [...at, 'mode'],
|
|
504
|
+
ctx: {
|
|
505
|
+
expected: ENTRY_MODES.join(' | ')
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
const extra = Object.keys(record).find(k => !ENTRY_KEYS.includes(k) || record.mode === 'general' && k === 'rubrics');
|
|
509
|
+
if (extra) return {
|
|
510
|
+
type: 'extra_forbidden',
|
|
511
|
+
loc: [...at, extra]
|
|
512
|
+
};
|
|
513
|
+
const pl = [...at, 'answer_project'];
|
|
514
|
+
const project = record.answer_project;
|
|
515
|
+
if (project === undefined) return {
|
|
516
|
+
type: 'missing',
|
|
517
|
+
loc: pl
|
|
518
|
+
};
|
|
519
|
+
if (typeof project !== 'object' || project === null || Array.isArray(project)) return {
|
|
520
|
+
type: 'model_attributes_type',
|
|
521
|
+
loc: pl
|
|
522
|
+
};
|
|
523
|
+
const {
|
|
524
|
+
enc,
|
|
525
|
+
data
|
|
526
|
+
} = project;
|
|
527
|
+
if (!ENTRY_PROJECT_ENCODINGS.includes(enc)) return {
|
|
528
|
+
type: enc === undefined ? 'missing' : 'literal_error',
|
|
529
|
+
loc: [...pl, 'enc']
|
|
530
|
+
};
|
|
531
|
+
if (typeof data !== 'string') return {
|
|
532
|
+
type: data === undefined ? 'missing' : 'string_type',
|
|
533
|
+
loc: [...pl, 'data']
|
|
534
|
+
};
|
|
535
|
+
if (data === '') return {
|
|
536
|
+
type: 'string_too_short',
|
|
537
|
+
loc: [...pl, 'data'],
|
|
538
|
+
ctx: {
|
|
539
|
+
min_length: 1
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
const decoded = decodeEntryProject(project);
|
|
543
|
+
if (record.mode === 'general') return decoded && !entryHasGradable(decoded) ? {
|
|
544
|
+
type: 'entry_answer_project_empty',
|
|
545
|
+
loc: [...at, 'answer_project']
|
|
546
|
+
} : {
|
|
547
|
+
type: 'value_error',
|
|
548
|
+
loc: at
|
|
549
|
+
};
|
|
550
|
+
const rl = [...at, 'rubrics'];
|
|
551
|
+
const list = record.rubrics;
|
|
552
|
+
if (list === undefined) return {
|
|
553
|
+
type: 'missing',
|
|
554
|
+
loc: rl
|
|
555
|
+
};
|
|
556
|
+
if (!Array.isArray(list)) return {
|
|
557
|
+
type: 'list_type',
|
|
558
|
+
loc: rl
|
|
559
|
+
};
|
|
560
|
+
if (list.length < 1) return {
|
|
561
|
+
type: 'too_short',
|
|
562
|
+
loc: rl,
|
|
563
|
+
ctx: {
|
|
564
|
+
min_length: 1
|
|
565
|
+
}
|
|
566
|
+
};
|
|
567
|
+
if (list.length > ENTRY_RUBRICS_MAX) return {
|
|
568
|
+
type: 'too_long',
|
|
569
|
+
loc: rl,
|
|
570
|
+
ctx: {
|
|
571
|
+
max_length: ENTRY_RUBRICS_MAX
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
for (const [i, item] of list.entries()) {
|
|
575
|
+
const loc = [...rl, i];
|
|
576
|
+
if (typeof item !== 'object' || item === null || Array.isArray(item)) return {
|
|
577
|
+
type: 'model_type',
|
|
578
|
+
loc
|
|
579
|
+
};
|
|
580
|
+
const r = item;
|
|
581
|
+
const unknownKey = Object.keys(r).find(k => !ENTRY_RUBRIC_KEYS.includes(k));
|
|
582
|
+
if (unknownKey) return {
|
|
583
|
+
type: 'extra_forbidden',
|
|
584
|
+
loc: [...loc, unknownKey]
|
|
585
|
+
};
|
|
586
|
+
for (const name of ['object', 'criteria']) if (typeof r[name] !== 'string') return {
|
|
587
|
+
type: r[name] === undefined ? 'missing' : 'string_type',
|
|
588
|
+
loc: [...loc, name]
|
|
589
|
+
};
|
|
590
|
+
const criteria = r.criteria;
|
|
591
|
+
if (criteria.trim() === '') return {
|
|
592
|
+
type: 'string_too_short',
|
|
593
|
+
loc: [...loc, 'criteria'],
|
|
594
|
+
ctx: {
|
|
595
|
+
min_length: 1
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
if (criteria.length > ENTRY_CRITERIA_MAX) return {
|
|
599
|
+
type: 'string_too_long',
|
|
600
|
+
loc: [...loc, 'criteria'],
|
|
601
|
+
ctx: {
|
|
602
|
+
max_length: ENTRY_CRITERIA_MAX
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
if (r.score === undefined) return {
|
|
606
|
+
type: 'missing',
|
|
607
|
+
loc: [...loc, 'score']
|
|
608
|
+
};
|
|
609
|
+
if (!isStrictInt(r.score)) return {
|
|
610
|
+
type: 'int_type',
|
|
611
|
+
loc: [...loc, 'score']
|
|
612
|
+
};
|
|
613
|
+
if (r.score < 1) return {
|
|
614
|
+
type: 'greater_than_equal',
|
|
615
|
+
loc: [...loc, 'score'],
|
|
616
|
+
ctx: {
|
|
617
|
+
ge: 1
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
if (r.score > 100) return {
|
|
621
|
+
type: 'less_than_equal',
|
|
622
|
+
loc: [...loc, 'score'],
|
|
623
|
+
ctx: {
|
|
624
|
+
le: 100
|
|
625
|
+
}
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
const ids = decoded ? entryObjectIds(decoded) : null;
|
|
629
|
+
for (const [i, item] of list.entries()) {
|
|
630
|
+
const {
|
|
631
|
+
object
|
|
632
|
+
} = item;
|
|
633
|
+
if (object === '' || ids && !ids.has(object)) return {
|
|
634
|
+
type: 'entry_rubric_object_not_found',
|
|
635
|
+
loc: [...rl, i, 'object'],
|
|
636
|
+
ctx: {
|
|
637
|
+
field: `grading.rubrics.${i}.object`,
|
|
638
|
+
object
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
return {
|
|
643
|
+
type: 'value_error',
|
|
644
|
+
loc: at
|
|
645
|
+
};
|
|
646
|
+
}
|
|
341
647
|
/** per_question의 서버 pydantic 오류 하나 (serverGradingError). 서버 검사 순서: 필드 모양 → 배점 합 → AI 채점 수 */
|
|
342
648
|
function perQuestionServerError(record, at, regexIssue) {
|
|
343
649
|
const intIssue = (n, loc, min) => {
|
|
@@ -768,4 +1074,4 @@ const LEGACY_FILES = Object.freeze({
|
|
|
768
1074
|
grading: 'grading.json'
|
|
769
1075
|
});
|
|
770
1076
|
|
|
771
|
-
export { ANSWER_KEY_MAX, BUILD_OPTION_KEYS, CONFIG_FILE, GRADER_TYPES, ITEMS_REJECTED, ITEMS_TYPE, LEGACY_FILES, PACKAGE_CONFIG_KEY, PACKAGE_FILE, PARTIAL_ITEMS_MAX, PER_QUESTION_MAX, PER_QUESTION_TYPE, PLATFORM_KEYS, RUBRIC_MAX, RUBRIC_QUESTIONS_MAX, RUBRIC_QUESTION_MAX, SETTINGS_DATA_FILE, applyLegacyMigration, legacyCompletionWarning, legacyGradingTypesWarning, loadConfig, loadGrading, loadSavedSettings, parseGrading, planLegacyMigration, readPackageJson, savedGrading, savedGradingProblem, serverGradingError };
|
|
1077
|
+
export { ANSWER_KEY_MAX, BUILD_OPTION_KEYS, CONFIG_FILE, ENTRY_CRITERIA_MAX, ENTRY_MODES, ENTRY_PROJECT_ENCODINGS, ENTRY_RUBRICS_MAX, GRADER_TYPES, ITEMS_REJECTED, ITEMS_TYPE, LEGACY_FILES, PACKAGE_CONFIG_KEY, PACKAGE_FILE, PARTIAL_ITEMS_MAX, PER_QUESTION_MAX, PER_QUESTION_TYPE, PLATFORM_KEYS, RUBRIC_MAX, RUBRIC_QUESTIONS_MAX, RUBRIC_QUESTION_MAX, SETTINGS_DATA_FILE, applyLegacyMigration, decodeEntryProject, entryHasGradable, entryObjectIds, legacyCompletionWarning, legacyGradingTypesWarning, loadConfig, loadGrading, loadSavedSettings, parseGrading, planLegacyMigration, readPackageJson, savedGrading, savedGradingProblem, serverGradingError };
|
package/es/dev/grading.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GradingQuestion, LocalGrading } from '../core/config.js';
|
|
1
|
+
import type { EntryProject, EntryRubric, GradingQuestion, LocalGrading } from '../core/config.js';
|
|
2
2
|
/**
|
|
3
3
|
* `ecdk dev` 흉내 채점. 서버 elice-material(`sprint/custom-material-2`)과 같은 규칙이다:
|
|
4
4
|
* `app/core/grading.py`(get_effective_completion · get_completion_score · build_*_outcome),
|
|
@@ -27,8 +27,20 @@ export interface GradeResult {
|
|
|
27
27
|
score: number | null;
|
|
28
28
|
/** partial_pattern · per_question 문항별 맞음 (문항 순서, 없는 답은 false). 그 밖은 서버처럼 [] */
|
|
29
29
|
answerCorrectness: boolean[];
|
|
30
|
-
/** partial_pattern · per_question 문항별 결과 (서버 #65 question_results)
|
|
30
|
+
/** partial_pattern · per_question 문항별 결과 (서버 #65 question_results), entry ai는 기준별. 그 밖은 서버처럼 [] */
|
|
31
31
|
questionResults: QuestionResult[];
|
|
32
|
+
/**
|
|
33
|
+
* entry만: 응답 `grading_feedback` (제출 · 미리보기 · /submissions/me). AI는 { message, criteria: [{ feedback }] }
|
|
34
|
+
* (criteria는 기준 순서, questionResults와 같은 길이), 일반은 { message: '', criteria: [] }. 그 밖은 없음
|
|
35
|
+
*/
|
|
36
|
+
gradingFeedback?: GradingFeedback;
|
|
37
|
+
}
|
|
38
|
+
/** entry 채점 피드백 (응답 `grading_feedback`) */
|
|
39
|
+
export interface GradingFeedback {
|
|
40
|
+
message: string;
|
|
41
|
+
criteria: {
|
|
42
|
+
feedback: string;
|
|
43
|
+
}[];
|
|
32
44
|
}
|
|
33
45
|
/** pattern: 정답 정규식(문자열 하나)이 답 문자열(앞뒤 공백을 자름) 전체와 맞는지. 정규식이 틀리거나 없으면 오답 */
|
|
34
46
|
export declare function matchesPattern(answerKey: unknown, answer: string): boolean;
|
|
@@ -59,6 +71,22 @@ export declare function hasRubricAnswers(questions: GradingQuestion[], answer: u
|
|
|
59
71
|
* (완료는 completionScore의 pass_score). 문항별 is_correct는 채점기 점수가 100일 때만. 없는 답 · 남는 답은 partial_pattern과 같다
|
|
60
72
|
*/
|
|
61
73
|
export declare function gradePerQuestion(questions: GradingQuestion[], answer: unknown): GradeResult;
|
|
74
|
+
/**
|
|
75
|
+
* 엔트리 제출 답에서 작품 `{ enc, data }`를 꺼낸다. 답은 엔트리 템플릿 모양 `{ v: 1, project: { enc, data } }`
|
|
76
|
+
* (작품만 `{ enc, data }`이거나 그 JSON 글자여도 받는다). 없으면 null. 템플릿 mock(cdk-mock.js entryProjectOf)과 같다
|
|
77
|
+
*/
|
|
78
|
+
export declare function entryProjectOf(answer: unknown): {
|
|
79
|
+
enc: string;
|
|
80
|
+
data: string;
|
|
81
|
+
} | null;
|
|
82
|
+
/**
|
|
83
|
+
* entry 채점 흉내 (블록을 비교하지 않음, 같은 답이면 늘 같은 결과). 템플릿 mock(cdk-mock.js gradeEntry)과 같은 규칙:
|
|
84
|
+
* - general: 제출 작품의 enc · data가 정답 작품과 글자까지 같으면 100, 아니면 0. question_results [],
|
|
85
|
+
* grading_feedback { message: '', criteria: [] }
|
|
86
|
+
* - ai: 기준마다 floor(mockRubricScore(작품 data) × 배점 / 100) (빈 작품 0), 합은 100에서 자름. question_results는 기준 순서
|
|
87
|
+
* { score, isCorrect: 배점을 다 받았을 때 }, grading_feedback { message, criteria: [{ feedback }] }(기준 순서)도 흉내 문구로
|
|
88
|
+
*/
|
|
89
|
+
export declare function gradeEntry(answerProject: EntryProject, rubrics: EntryRubric[] | null, answer: unknown): GradeResult;
|
|
62
90
|
/**
|
|
63
91
|
* 제출 하나를 서버처럼 채점한다 (`_grade`). 답 모양은 answerError가 먼저 본다.
|
|
64
92
|
* - `on_access`: 채점하지 않음 `{ null, null }` (열면 완료)
|
|
@@ -68,6 +96,7 @@ export declare function gradePerQuestion(questions: GradingQuestion[], answer: u
|
|
|
68
96
|
* 주는데 dev는 부를 수 없고, 지어낸 점수는 진짜처럼 읽힌다 (SDK 미리보기 채점과 같음)
|
|
69
97
|
* - `on_graded` + per_question: pattern 문항 + rubric 흉내 점수(mockRubricScore)의 합. rubric 단독과 달리 흉내 점수를 준다:
|
|
70
98
|
* 정규식 · AI 채점을 섞은 퀴즈의 흐름(점수 상자 · 문항별 표시)을 dev에서 보려고. 흉내 값이라고 로그에 남긴다
|
|
99
|
+
* - `on_graded` + entry: 블록을 비교하지 않는 흉내 (gradeEntry). AI도 흉내 점수를 준다 (엔트리 채점 흐름을 dev에서 보려고)
|
|
71
100
|
* - `on_graded` + 채점 설정 없음: `{ false, 0 }` (서버도 0점이라 완료되지 않음)
|
|
72
101
|
*/
|
|
73
102
|
export declare function grade(local: LocalGrading | undefined, answer: unknown, policy: CompletionPolicy): GradeResult;
|
package/es/dev/grading.js
CHANGED
|
@@ -105,6 +105,70 @@ function gradePerQuestion(questions, answer) {
|
|
|
105
105
|
questionResults
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* 엔트리 제출 답에서 작품 `{ enc, data }`를 꺼낸다. 답은 엔트리 템플릿 모양 `{ v: 1, project: { enc, data } }`
|
|
110
|
+
* (작품만 `{ enc, data }`이거나 그 JSON 글자여도 받는다). 없으면 null. 템플릿 mock(cdk-mock.js entryProjectOf)과 같다
|
|
111
|
+
*/
|
|
112
|
+
function entryProjectOf(answer) {
|
|
113
|
+
let value = answer;
|
|
114
|
+
if (typeof value === 'string') {
|
|
115
|
+
try {
|
|
116
|
+
value = JSON.parse(value);
|
|
117
|
+
} catch {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const record = value && typeof value === 'object' ? value : null;
|
|
122
|
+
const project = record?.project && typeof record.project === 'object' ? record.project : record;
|
|
123
|
+
return project && typeof project.enc === 'string' && typeof project.data === 'string' ? {
|
|
124
|
+
enc: project.enc,
|
|
125
|
+
data: project.data
|
|
126
|
+
} : null;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* entry 채점 흉내 (블록을 비교하지 않음, 같은 답이면 늘 같은 결과). 템플릿 mock(cdk-mock.js gradeEntry)과 같은 규칙:
|
|
130
|
+
* - general: 제출 작품의 enc · data가 정답 작품과 글자까지 같으면 100, 아니면 0. question_results [],
|
|
131
|
+
* grading_feedback { message: '', criteria: [] }
|
|
132
|
+
* - ai: 기준마다 floor(mockRubricScore(작품 data) × 배점 / 100) (빈 작품 0), 합은 100에서 자름. question_results는 기준 순서
|
|
133
|
+
* { score, isCorrect: 배점을 다 받았을 때 }, grading_feedback { message, criteria: [{ feedback }] }(기준 순서)도 흉내 문구로
|
|
134
|
+
*/
|
|
135
|
+
function gradeEntry(answerProject, rubrics, answer) {
|
|
136
|
+
const project = entryProjectOf(answer);
|
|
137
|
+
if (rubrics) {
|
|
138
|
+
const graderScore = mockRubricScore(project?.data);
|
|
139
|
+
const questionResults = rubrics.map(r => {
|
|
140
|
+
const score = Math.floor(graderScore * r.score / SCORE_MAX);
|
|
141
|
+
return {
|
|
142
|
+
score,
|
|
143
|
+
isCorrect: score === r.score
|
|
144
|
+
};
|
|
145
|
+
});
|
|
146
|
+
const score = Math.min(SCORE_MAX, questionResults.reduce((sum, r) => sum + r.score, 0));
|
|
147
|
+
return {
|
|
148
|
+
isCorrect: score === SCORE_MAX,
|
|
149
|
+
score,
|
|
150
|
+
answerCorrectness: [],
|
|
151
|
+
questionResults,
|
|
152
|
+
gradingFeedback: {
|
|
153
|
+
message: '흉내 채점입니다 (AI를 부르지 않고 작품 크기로 점수를 냈습니다).',
|
|
154
|
+
criteria: rubrics.map((r, i) => ({
|
|
155
|
+
feedback: `흉내 채점: ${questionResults[i]?.score ?? 0} / ${r.score}점`
|
|
156
|
+
}))
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const ok = project !== null && project.enc === answerProject.enc && project.data === answerProject.data;
|
|
161
|
+
return {
|
|
162
|
+
isCorrect: ok,
|
|
163
|
+
score: ok ? SCORE_MAX : 0,
|
|
164
|
+
answerCorrectness: [],
|
|
165
|
+
questionResults: [],
|
|
166
|
+
gradingFeedback: {
|
|
167
|
+
message: '',
|
|
168
|
+
criteria: []
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
108
172
|
/**
|
|
109
173
|
* 제출 하나를 서버처럼 채점한다 (`_grade`). 답 모양은 answerError가 먼저 본다.
|
|
110
174
|
* - `on_access`: 채점하지 않음 `{ null, null }` (열면 완료)
|
|
@@ -114,6 +178,7 @@ function gradePerQuestion(questions, answer) {
|
|
|
114
178
|
* 주는데 dev는 부를 수 없고, 지어낸 점수는 진짜처럼 읽힌다 (SDK 미리보기 채점과 같음)
|
|
115
179
|
* - `on_graded` + per_question: pattern 문항 + rubric 흉내 점수(mockRubricScore)의 합. rubric 단독과 달리 흉내 점수를 준다:
|
|
116
180
|
* 정규식 · AI 채점을 섞은 퀴즈의 흐름(점수 상자 · 문항별 표시)을 dev에서 보려고. 흉내 값이라고 로그에 남긴다
|
|
181
|
+
* - `on_graded` + entry: 블록을 비교하지 않는 흉내 (gradeEntry). AI도 흉내 점수를 준다 (엔트리 채점 흐름을 dev에서 보려고)
|
|
117
182
|
* - `on_graded` + 채점 설정 없음: `{ false, 0 }` (서버도 0점이라 완료되지 않음)
|
|
118
183
|
*/
|
|
119
184
|
function grade(local, answer, policy) {
|
|
@@ -152,6 +217,8 @@ function grade(local, answer, policy) {
|
|
|
152
217
|
};
|
|
153
218
|
case 'per_question':
|
|
154
219
|
return gradePerQuestion(grading.questions, answer);
|
|
220
|
+
case 'entry':
|
|
221
|
+
return gradeEntry(grading.answer_project, grading.mode === 'ai' ? grading.rubrics : null, answer);
|
|
155
222
|
default:
|
|
156
223
|
return {
|
|
157
224
|
isCorrect: false,
|
|
@@ -173,4 +240,4 @@ function completionScore(local, policy) {
|
|
|
173
240
|
return SCORE_MAX;
|
|
174
241
|
}
|
|
175
242
|
|
|
176
|
-
export { COMPLETION_POLICIES, answerError, completionScore, grade, gradePartial, gradePerQuestion, hasRubricAnswers, isCompletionPolicy, matchesPattern, mockRubricScore, recommendedCompletionPolicy };
|
|
243
|
+
export { COMPLETION_POLICIES, answerError, completionScore, entryProjectOf, grade, gradeEntry, gradePartial, gradePerQuestion, hasRubricAnswers, isCompletionPolicy, matchesPattern, mockRubricScore, recommendedCompletionPolicy };
|
package/es/dev/mock-api.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type LocalGrading } from '../core/config.js';
|
|
2
|
-
import { type CompletionPolicy } from './grading.js';
|
|
2
|
+
import { type CompletionPolicy, type GradingFeedback } from './grading.js';
|
|
3
3
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
4
4
|
/**
|
|
5
5
|
* elice-material API 흉내 (서버 설계 v25, @eliceio/cdk 1.x가 부르는 것만).
|
|
@@ -55,6 +55,8 @@ interface Submission {
|
|
|
55
55
|
score: number;
|
|
56
56
|
is_correct: boolean;
|
|
57
57
|
}[];
|
|
58
|
+
/** entry만: 채점 피드백 { message, criteria: [{ feedback }] } (일반은 { message: '', criteria: [] }) */
|
|
59
|
+
grading_feedback?: GradingFeedback;
|
|
58
60
|
}
|
|
59
61
|
interface Result {
|
|
60
62
|
score: number | null;
|
package/es/dev/mock-api.js
CHANGED
|
@@ -16,6 +16,12 @@ const MANAGER = {
|
|
|
16
16
|
anonymous_id: 'dev-manager',
|
|
17
17
|
fullname: '교육자 (dev)'
|
|
18
18
|
};
|
|
19
|
+
/** settings.entry.startProject가 묶은 작품 모양 { enc, data }인가 (엔트리 AI 채점 저장 조건) */
|
|
20
|
+
function hasEntryStartProject(settings) {
|
|
21
|
+
const entry = settings.entry;
|
|
22
|
+
const start = entry && typeof entry === 'object' ? entry.startProject : undefined;
|
|
23
|
+
return typeof start === 'object' && start !== null && typeof start.data === 'string' && start.data !== '';
|
|
24
|
+
}
|
|
19
25
|
const TOKEN_SCENARIOS = Object.freeze({
|
|
20
26
|
edit: {
|
|
21
27
|
scope: 'edit',
|
|
@@ -335,6 +341,18 @@ async function handleMockApi(req, res, path, opts) {
|
|
|
335
341
|
msg: parsed
|
|
336
342
|
}]);
|
|
337
343
|
}
|
|
344
|
+
// 서버처럼 엔트리 AI 채점은 시작 작품(settings.entry.startProject)이 있어야 저장된다 (422 entry_project_invalid)
|
|
345
|
+
if (parsed.type === 'entry' && parsed.mode === 'ai' && !hasEntryStartProject(rest)) {
|
|
346
|
+
const msg = 'grading: 엔트리 AI 채점에는 시작 작품(settings.entry.startProject)이 필요합니다. 편집 화면 시작 화면 탭에서 작품을 저장하세요.';
|
|
347
|
+
return fail(res, 422, 'VALIDATION_ERROR', msg, [{
|
|
348
|
+
type: 'entry_project_invalid',
|
|
349
|
+
loc: ['body', 'settings', 'entry', 'startProject'],
|
|
350
|
+
ctx: {
|
|
351
|
+
field: 'entry.startProject'
|
|
352
|
+
},
|
|
353
|
+
msg
|
|
354
|
+
}]);
|
|
355
|
+
}
|
|
338
356
|
next = {
|
|
339
357
|
...rest,
|
|
340
358
|
grading: parsed
|
|
@@ -375,6 +393,8 @@ async function handleMockApi(req, res, path, opts) {
|
|
|
375
393
|
completion_policy: policy,
|
|
376
394
|
// 서버처럼 on_graded이고 채점 설정이 있을 때만
|
|
377
395
|
grading_type: policy === 'on_graded' ? local?.grading?.type ?? null : null,
|
|
396
|
+
// entry 채점 방식 (elice-material !91): grading_type과 같이 on_graded이고 entry 채점일 때만 'general' · 'ai'
|
|
397
|
+
grading_mode: policy === 'on_graded' && local?.grading?.type === 'entry' ? local.grading.mode : null,
|
|
378
398
|
user: {
|
|
379
399
|
anonymous_id: user.anonymous_id,
|
|
380
400
|
fullname: user.fullname
|
|
@@ -440,7 +460,8 @@ async function handleMockApi(req, res, path, opts) {
|
|
|
440
460
|
isCorrect,
|
|
441
461
|
score,
|
|
442
462
|
answerCorrectness,
|
|
443
|
-
questionResults
|
|
463
|
+
questionResults,
|
|
464
|
+
gradingFeedback
|
|
444
465
|
} = grade(local, answer, policy);
|
|
445
466
|
// 서버처럼 문항별 결과 question_results도 준다 (partial_pattern · per_question, 그 밖은 []).
|
|
446
467
|
// SDK는 submit 결과 · 제출 기록(GET /submissions/me) 모두 questionResults로 넘긴다
|
|
@@ -452,9 +473,15 @@ async function handleMockApi(req, res, path, opts) {
|
|
|
452
473
|
is_correct: isCorrect,
|
|
453
474
|
score,
|
|
454
475
|
answer_correctness: answerCorrectness,
|
|
455
|
-
question_results: questionResultsBody
|
|
476
|
+
question_results: questionResultsBody,
|
|
477
|
+
// entry만 grading_feedback (일반 { message: '', criteria: [] }, AI 흉내 { message, criteria }).
|
|
478
|
+
// 실제 SDK submit은 아직 넘기지 않는다 (history의 gradingFeedback으로 읽음)
|
|
479
|
+
...(gradingFeedback ? {
|
|
480
|
+
grading_feedback: gradingFeedback
|
|
481
|
+
} : {})
|
|
456
482
|
};
|
|
457
|
-
const
|
|
483
|
+
const entryAi = policy === 'on_graded' && local?.grading?.type === 'entry' && local.grading.mode === 'ai';
|
|
484
|
+
const graded = policy === 'on_graded' && local?.grading?.type === 'rubric' ? '채점 안 함: rubric(AI)은 dev에서 채점하지 않음' : entryAi ? `entry AI 채점 기준별 [${questionResults.map(r => r.score).join(', ')}], 흉내 점수(실제 AI 아님)` : perQuestion ? `per_question 문항별 [${questionResults.map(r => r.score).join(', ')}], AI 채점 문항은 흉내 점수(실제 AI 아님), ${(score ?? 0) >= (completionScore(local, policy) ?? 100) ? '통과' : '미통과'}` : isCorrect === null ? `채점 안 함: ${policy}` : isCorrect ? '정답' : '오답';
|
|
458
485
|
if (claims.viewer !== 'student') {
|
|
459
486
|
log(`${claims.viewer} 제출: 채점만 (${score ?? '-'}점, ${graded}, 기록 안 함)`);
|
|
460
487
|
return send(res, 200, response);
|
|
@@ -468,7 +495,10 @@ async function handleMockApi(req, res, path, opts) {
|
|
|
468
495
|
is_correct: isCorrect,
|
|
469
496
|
score,
|
|
470
497
|
answer_correctness: answerCorrectness,
|
|
471
|
-
question_results: questionResultsBody
|
|
498
|
+
question_results: questionResultsBody,
|
|
499
|
+
...(gradingFeedback ? {
|
|
500
|
+
grading_feedback: gradingFeedback
|
|
501
|
+
} : {})
|
|
472
502
|
});
|
|
473
503
|
recordSubmission(state, subject, score, completionScore(local, policy));
|
|
474
504
|
log(`학생 제출: ${score ?? '-'}점 (${graded}, 완료 정책 ${policy})`);
|
package/es/dev/server.js
CHANGED
|
@@ -9,7 +9,7 @@ import { missingSdkMessage } from '../core/sdk.js';
|
|
|
9
9
|
import '../engines/vite/plugin.js';
|
|
10
10
|
import { viteDevServer } from '../engines/vite/run.js';
|
|
11
11
|
import { checkFiles } from '../rules/check.js';
|
|
12
|
-
import { contentCsp } from '../rules/csp.js';
|
|
12
|
+
import { withDevSources, contentCsp } from '../rules/csp.js';
|
|
13
13
|
import '../rules/spec.js';
|
|
14
14
|
import 'fflate';
|
|
15
15
|
import { DEV_BLOB_PREFIX, handleBlobPut, ASSET_SIGNED_PATH, serveAsset, createUploadUrl, MOCK_UPLOAD_URL_PATH, removeAssets, assetStoragePath } from './assets.js';
|
|
@@ -127,12 +127,13 @@ async function startDevServer(opts) {
|
|
|
127
127
|
const content = createServer(async (req, res) => {
|
|
128
128
|
const url = new URL(req.url ?? '/', 'http://x');
|
|
129
129
|
// CONTENT_HOST: 콘텐츠 출처, MATERIAL_API: 흉내 API · dev 기록이 있는 호스트 출처, LXP_ORIGINS: 흉내 화면 출처
|
|
130
|
-
// connect-src에는 Vite HMR 웹소켓(콘텐츠 출처의 ws://)과 자료 파일 경로(devOnlyConnectSrc)만 dev에서
|
|
131
|
-
|
|
130
|
+
// connect-src에는 Vite HMR 웹소켓(콘텐츠 출처의 ws://)과 자료 파일 경로(devOnlyConnectSrc)만 dev에서 더한다.
|
|
131
|
+
// frame-src에는 로컬 엔트리 워크스페이스(DEV_ONLY_SOURCES, entry 템플릿)를 더한다
|
|
132
|
+
const csp = withDevSources(contentCsp({
|
|
132
133
|
contentHost: contentOrigin,
|
|
133
134
|
materialApi: hostOrigin,
|
|
134
135
|
lxpOrigins: hostOrigin
|
|
135
|
-
}).replace(/(connect-src [^;]*)/, [`$1`, contentOrigin.replace(/^http/, 'ws'), ...devOnlyConnectSrc(contentOrigin)].join(' '));
|
|
136
|
+
})).replace(/(connect-src [^;]*)/, [`$1`, contentOrigin.replace(/^http/, 'ws'), ...devOnlyConnectSrc(contentOrigin)].join(' '));
|
|
136
137
|
const headers = {
|
|
137
138
|
'Content-Security-Policy': csp,
|
|
138
139
|
'X-Content-Type-Options': 'nosniff',
|
package/es/rules/answers.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* - partial_pattern: 문항마다 정답 정규식 배열이라 원소마다 위와 같이
|
|
8
8
|
* - rubric: 평가 기준 글 전체
|
|
9
9
|
* - per_question: 문항마다 grader가 pattern이면 위 정규식처럼, rubric이면 채점 기준 글 전체 (문제 글 question은 학생에게도 보이는 글이라 뺀다)
|
|
10
|
+
* - entry: AI 채점(rubrics)이면 기준마다 채점 기준 글 criteria 전체 (정답 작품 answer_project는 묶은 글자라 보지 않음)
|
|
10
11
|
* 흔한 글과 겹치는 짧은 글은 뺀다: 한글이 든 글은 2자 미만, 그 밖(영문 · 숫자 등)은 3자 미만, 숫자만 3자 이하(100 · 0.5)
|
|
11
12
|
*/
|
|
12
13
|
export declare function answerNeedles(grading: unknown): string[];
|