@exercode/problem-utils 4.4.0 → 5.0.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/dist/cli/checkAllProblems.cjs.map +1 -1
- package/dist/cli/checkAllProblems.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/learningMaterial/schemas.cjs +1 -1
- package/dist/learningMaterial/schemas.cjs.map +1 -1
- package/dist/learningMaterial/schemas.d.ts +1 -3
- package/dist/learningMaterial/schemas.js +1 -1
- package/dist/learningMaterial/schemas.js.map +1 -1
- package/dist/learningMaterial/validateContest.cjs +1 -1
- package/dist/learningMaterial/validateContest.cjs.map +1 -1
- package/dist/learningMaterial/validateContest.d.ts +0 -2
- package/dist/learningMaterial/validateContest.js +1 -1
- package/dist/learningMaterial/validateContest.js.map +1 -1
- package/dist/learningMaterial/validateCourse.cjs +1 -1
- package/dist/learningMaterial/validateCourse.cjs.map +1 -1
- package/dist/learningMaterial/validateCourse.js +1 -1
- package/dist/learningMaterial/validateCourse.js.map +1 -1
- package/dist/learningMaterial/validateMaterial.cjs +3 -3
- package/dist/learningMaterial/validateMaterial.cjs.map +1 -1
- package/dist/learningMaterial/validateMaterial.d.ts +0 -7
- package/dist/learningMaterial/validateMaterial.js +3 -3
- package/dist/learningMaterial/validateMaterial.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateMaterial.js","names":["parseYaml","QUESTION_CODE_BLOCK_REGEX","QUESTION_CODE_BLOCK_OPENER_REGEX","PROBLEM_LINK_REGEX","TURTLE_GRAPHICS_QUESTION_LINK_REGEX","PROBLEM_ASSIGNMENT_REGEX","QUESTION_LINK_REGEX","TURTLE_GRAPHICS_ASSIGNMENT_REGEX","STANDALONE_CHAT_MARKER_REGEX","validateMaterialFile","errors","result","materialId","basename","materialFilePath","LEARNING_MATERIAL_ID_REGEX","markdown","readFile","attributes","body","parseFrontmatter","error","getErrorMessage","parsedFrontmatter","materialFrontmatterSchema","formatZodIssues","frontmatter","questionsInCodeBlocks","parseQuestionCodeBlocks","questionBlockIds","question","questions","validateQuestion","reportDuplicateIds","bodyWithoutQuestionBlocks","collectLinkedIds","linkedTurtleGraphicsQuestionIds","problemIds","problem","reportForeignProblemCourseIds","options","availableProblemIds","collectProblemIdsFromDirectory","reportDanglingProblemReferences","reportExcessChatMarkers","validateSubmissionPeriods","mergeSubmissionPeriods","linkRegex","match","id","own","courseDefaults","chatMarkerCount","courseId","problems","matches","leftoverOpenerCount","blockIndex","yamlText","\"yaml\"","rawQuestion","parse","parsed","questionInCodeBlockSchema","isSurvey","answerFieldName","isAnswerDefined","answerIndices","answerIndex","answerPattern","answerRegExp","rawAnswerRegExp","periods","earlierName","laterName","earlierValue","laterValue","ownPeriods"],"sources":["../../src/learningMaterial/validateMaterial.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { basename } from 'node:path';\n\nimport { getErrorMessage } from '@willbooster/shared-lib';\nimport { parse as parseYaml } from 'yaml';\n\nimport { parseFrontmatter } from './frontmatter.js';\nimport { collectProblemIdsFromDirectory, reportDanglingProblemReferences } from './fsHelpers.js';\nimport {\n LEARNING_MATERIAL_ID_REGEX,\n materialFrontmatterSchema,\n type MaterialQuestion,\n questionInCodeBlockSchema,\n} from './schemas.js';\nimport { formatZodIssues, reportDuplicateIds, type ValidationResult } from './validationResult.js';\n\n// Same patterns the judge uses to extract embedded questions and problem links from material bodies.\n// The block regex intentionally requires LF line endings and a trailing newline after the closing\n// fence, exactly like the judge parser; blocks it misses are reported by detecting leftover openers.\nconst QUESTION_CODE_BLOCK_REGEX = /(?:^|\\n)(?<fence>`{3,}|~{3,})ya?ml +question\\n(?<yaml>[\\s\\S]+?)\\n\\k<fence>\\n/g;\n// Strictly laxer than the parser regex (tolerates CRLF, indentation, and stray whitespace) so\n// question-looking blocks the judge parser would silently skip surface as leftover openers.\nconst QUESTION_CODE_BLOCK_OPENER_REGEX = /^[ \\t]*(?:`{3,}|~{3,})[ \\t]*ya?ml[ \\t]+question[ \\t]*\\r?$/gm;\nconst PROBLEM_LINK_REGEX = /\\[.*?]\\(problems\\/([0-9_a-z-]+?)\\)/g;\nconst TURTLE_GRAPHICS_QUESTION_LINK_REGEX = /\\[.*?]\\(turtle-graphics-questions\\/([0-9_a-z-]+?)\\)/g;\n// Exercode's duplicate-assignment check scans the body with these patterns, whose link text may\n// span lines (unlike the judge's reference collection above).\nconst PROBLEM_ASSIGNMENT_REGEX = /\\[[^\\]]*]\\(problems\\/([0-9_a-z-]+)\\)/g;\nconst QUESTION_LINK_REGEX = /@\\[question]\\(([0-9_a-z-]+)\\)/g;\nconst TURTLE_GRAPHICS_ASSIGNMENT_REGEX = /\\[[^\\]]*]\\(turtle-graphics-questions\\/([0-9_a-z-]+)\\)/g;\nconst CHAT_MARKER = '<!-- chat -->';\n// exercode only counts the marker when it stands alone on a line, so fenced or inline mentions don't count.\nconst STANDALONE_CHAT_MARKER_REGEX = /(^|\\r?\\n)<!-- chat -->[ \\t]*(?=\\r?\\n|$)/g;\n\nexport interface SubmissionPeriods {\n submissionOpenedAt?: string;\n submissionSoftClosedAt?: string;\n submissionHardClosedAt?: string;\n}\n\nexport interface MaterialValidationOptions {\n /** Problem IDs already collected for the enclosing course; collected from `problemsDirectoryPath` otherwise. */\n availableProblemIds?: ReadonlySet<string>;\n /** When set, every referenced problem ID must be a problem discovered under this path. */\n problemsDirectoryPath?: string;\n /** Enclosing course ID; the judge rejects problem references whose `courseId` differs from it. */\n courseId?: string;\n /** Course-level submission periods; the judge merges them as `material[field] ?? course[field]`. */\n courseSubmissionPeriods?: SubmissionPeriods;\n}\n\n/** Validates an exercode markdown material file (frontmatter, embedded questions, problem references). */\nexport async function validateMaterialFile(\n materialFilePath: string,\n options: MaterialValidationOptions = {}\n): Promise<ValidationResult> {\n const errors: string[] = [];\n const warnings: string[] = [];\n const result = { errors, warnings };\n\n const materialId = basename(materialFilePath).replace(/\\.[^/.]+$/, '');\n if (!LEARNING_MATERIAL_ID_REGEX.test(materialId)) {\n errors.push(`material ID \"${materialId}\" (file name without extension) must match ${LEARNING_MATERIAL_ID_REGEX}`);\n }\n\n let markdown: string;\n try {\n markdown = await readFile(materialFilePath, 'utf8');\n } catch {\n errors.push(`material file not found: ${materialFilePath}`);\n return result;\n }\n\n let attributes: unknown;\n let body: string;\n try {\n ({ attributes, body } = parseFrontmatter(markdown));\n } catch (error) {\n errors.push(`invalid YAML frontmatter: ${getErrorMessage(error)}`);\n return result;\n }\n\n const parsedFrontmatter = materialFrontmatterSchema.safeParse(attributes);\n if (!parsedFrontmatter.success) {\n errors.push(...formatZodIssues(parsedFrontmatter.error, 'frontmatter'));\n }\n const frontmatter = parsedFrontmatter.success ? parsedFrontmatter.data : undefined;\n\n const questionsInCodeBlocks = parseQuestionCodeBlocks(body, errors);\n const questionBlockIds = questionsInCodeBlocks.map((question) => question.id);\n const questions = [...(frontmatter?.questions ?? []), ...questionsInCodeBlocks];\n for (const question of questions) {\n validateQuestion(question, errors);\n }\n reportDuplicateIds(\n questions.map((question) => question.id),\n 'question',\n errors\n );\n // Turtle-graphics links in the body merge into the frontmatter list like problem links do,\n // and exercode rejects duplicates in the merged list; deferred until after the question blocks\n // are removed below so links inside question text don't count.\n\n // Exercode's import validation runs two checks: the body must not link the same problem,\n // question or turtle-graphics question twice (every occurrence of the lax link pattern counts),\n // and the generated reference list (frontmatter entries plus the judge's deduplicated body links)\n // must not repeat an ID. The judge replaces recognized question blocks with @[question](id) links\n // before collecting links, so links that appear only inside question text must not count, while\n // each block counts as one question link next to explicit @[question](id) links.\n const bodyWithoutQuestionBlocks = body.replaceAll(QUESTION_CODE_BLOCK_REGEX, '\\n');\n reportDuplicateIds(\n [...questionBlockIds, ...collectLinkedIds(bodyWithoutQuestionBlocks, QUESTION_LINK_REGEX)],\n 'question link',\n errors\n );\n reportDuplicateIds(collectLinkedIds(bodyWithoutQuestionBlocks, PROBLEM_ASSIGNMENT_REGEX), 'problem link', errors);\n reportDuplicateIds(\n collectLinkedIds(bodyWithoutQuestionBlocks, TURTLE_GRAPHICS_ASSIGNMENT_REGEX),\n 'turtle-graphics question link',\n errors\n );\n const linkedTurtleGraphicsQuestionIds = new Set(\n collectLinkedIds(bodyWithoutQuestionBlocks, TURTLE_GRAPHICS_QUESTION_LINK_REGEX)\n );\n reportDuplicateIds(\n [\n ...(frontmatter?.turtleGraphicsQuestions ?? []).map((question) => question.id),\n ...linkedTurtleGraphicsQuestionIds,\n ],\n 'turtleGraphicsQuestion',\n errors\n );\n // Only the links the judge collects become references, and it deduplicates them before merging.\n const problemIds = [\n ...(frontmatter?.problems ?? []).map((problem) => problem.id),\n ...new Set(collectLinkedIds(bodyWithoutQuestionBlocks, PROBLEM_LINK_REGEX)),\n ];\n reportDuplicateIds(problemIds, 'problem', errors);\n reportForeignProblemCourseIds(frontmatter?.problems ?? [], options.courseId, errors);\n const availableProblemIds =\n options.availableProblemIds ??\n (options.problemsDirectoryPath === undefined\n ? undefined\n : await collectProblemIdsFromDirectory(options.problemsDirectoryPath, errors));\n if (availableProblemIds !== undefined) {\n reportDanglingProblemReferences(problemIds, availableProblemIds, options.problemsDirectoryPath, errors);\n }\n\n reportExcessChatMarkers(body, errors);\n\n if (frontmatter) {\n validateSubmissionPeriods(\n mergeSubmissionPeriods(frontmatter, options.courseSubmissionPeriods),\n errors,\n frontmatter\n );\n }\n return result;\n}\n\nfunction collectLinkedIds(body: string, linkRegex: RegExp): string[] {\n return [...body.matchAll(linkRegex)].map((match) => match[1]).filter((id) => id !== undefined);\n}\n\n/** Applies the judge's course→material config merge (`material[field] ?? course[field]`). */\nexport function mergeSubmissionPeriods(\n own: SubmissionPeriods,\n courseDefaults: SubmissionPeriods | undefined\n): SubmissionPeriods {\n return {\n submissionOpenedAt: own.submissionOpenedAt ?? courseDefaults?.submissionOpenedAt,\n submissionSoftClosedAt: own.submissionSoftClosedAt ?? courseDefaults?.submissionSoftClosedAt,\n submissionHardClosedAt: own.submissionHardClosedAt ?? courseDefaults?.submissionHardClosedAt,\n };\n}\n\n/** exercode rejects more than one standalone chat delimiter line in material and problem bodies. */\nexport function reportExcessChatMarkers(body: string, errors: string[]): void {\n const chatMarkerCount = [...body.matchAll(STANDALONE_CHAT_MARKER_REGEX)].length;\n if (chatMarkerCount > 1) {\n errors.push(`at most one \\`${CHAT_MARKER}\\` marker is allowed, but found ${chatMarkerCount}`);\n }\n}\n\n/** The judge's resolveProblemCourseId throws when a problem reference names a different course. */\nexport function reportForeignProblemCourseIds(\n problems: readonly { id: string; courseId?: string }[],\n courseId: string | undefined,\n errors: string[]\n): void {\n if (courseId === undefined) return;\n for (const problem of problems) {\n if (problem.courseId !== undefined && problem.courseId !== courseId) {\n errors.push(`problem \"${problem.id}\": courseId must be \"${courseId}\" but is \"${problem.courseId}\"`);\n }\n }\n}\n\nfunction parseQuestionCodeBlocks(body: string, errors: string[]): MaterialQuestion[] {\n const questions: MaterialQuestion[] = [];\n const matches = [...body.matchAll(QUESTION_CODE_BLOCK_REGEX)];\n // The judge silently renders unparsed question blocks as plain code blocks, so a block the\n // strict regex misses (CRLF line endings, or no newline after the closing fence) would break\n // in production while looking fine here; flag it instead of validating a lie. Openers inside a\n // recognized block (e.g. an example fence in a question's text) are consumed with that block.\n const leftoverOpenerCount = [\n ...body.replaceAll(QUESTION_CODE_BLOCK_REGEX, '\\n').matchAll(QUESTION_CODE_BLOCK_OPENER_REGEX),\n ].length;\n if (leftoverOpenerCount > 0) {\n errors.push(\n `${leftoverOpenerCount} question code block(s) will not be recognized by the judge parser; separate consecutive question blocks with a blank line, use LF line endings, no indentation or trailing whitespace on the fence line, and end the closing fence with a newline`\n );\n }\n for (const [blockIndex, match] of matches.entries()) {\n const yamlText = match.groups?.['yaml'] ?? '';\n let rawQuestion: unknown;\n try {\n rawQuestion = parseYaml(yamlText);\n } catch (error) {\n errors.push(`question block ${blockIndex + 1}: invalid YAML: ${getErrorMessage(error)}`);\n continue;\n }\n const parsed = questionInCodeBlockSchema.safeParse(rawQuestion);\n if (parsed.success) {\n questions.push(parsed.data);\n } else {\n errors.push(...formatZodIssues(parsed.error, `question block ${blockIndex + 1}`));\n }\n }\n return questions;\n}\n\nfunction validateQuestion(question: MaterialQuestion, errors: string[]): void {\n const isSurvey = question.isSurvey === true;\n const [answerFieldName, isAnswerDefined] =\n question.type === 'select'\n ? (['answerIndex', question.answerIndex !== undefined] as const)\n : question.type === 'select_multiple'\n ? (['answerIndices', question.answerIndices !== undefined] as const)\n : (['answerPattern', question.answerPattern !== undefined] as const);\n if (isSurvey && isAnswerDefined) {\n errors.push(`question ${question.id}: \\`${answerFieldName}\\` must not be set when \\`isSurvey\\` is true`);\n }\n if (!isSurvey && !isAnswerDefined) {\n errors.push(`question ${question.id}: \\`${answerFieldName}\\` is required when \\`isSurvey\\` is not true`);\n }\n\n if (question.type === 'select' || question.type === 'select_multiple') {\n const answerIndices =\n question.type === 'select'\n ? Array.isArray(question.answerIndex)\n ? question.answerIndex\n : question.answerIndex === undefined\n ? []\n : [question.answerIndex]\n : (question.answerIndices ?? []);\n // An empty answer set is broken at runtime (select: never correct; select_multiple: an empty\n // submission grades as correct), and exercode's material editor rejects it as well.\n if (!isSurvey && isAnswerDefined && answerIndices.length === 0) {\n errors.push(`question ${question.id}: \\`${answerFieldName}\\` must contain at least one correct answer`);\n }\n for (const answerIndex of answerIndices) {\n if (!Number.isInteger(answerIndex) || answerIndex < 0 || answerIndex >= question.options.length) {\n errors.push(\n `question ${question.id}: ${answerFieldName} out of bounds: ${answerIndex}; expected 0 <= index < options length ${question.options.length}`\n );\n }\n }\n return;\n }\n\n if (isSurvey || question.answerPattern === undefined) return;\n const answerPattern = question.answerPattern.trim();\n let answerRegExp: RegExp;\n let rawAnswerRegExp: RegExp;\n try {\n answerRegExp = new RegExp(`^(?:${answerPattern})$`);\n // Compiled inside the same guard: a pattern like `a)(b` is valid only once wrapped above,\n // so an unguarded raw compile would crash the CLI instead of reporting an error.\n rawAnswerRegExp = new RegExp(question.answerPattern);\n } catch {\n errors.push(\n `question ${question.id}: \\`answerPattern\\` is not a valid regular expression: ${question.answerPattern}`\n );\n return;\n }\n // Mirrors the judge heuristic: a pattern that doesn't match itself likely uses RegExp syntax,\n // so a modelAnswer is required to prove that some concrete answer is accepted.\n // Like the judge, an empty modelAnswer counts as missing.\n // The judge runs this heuristic on the untrimmed pattern and trims only for the anchored match.\n if (!question.modelAnswer && !rawAnswerRegExp.test(question.answerPattern)) {\n errors.push(`question ${question.id}: \\`answerPattern\\` seems a RegExp but \\`modelAnswer\\` is missing`);\n }\n if (question.modelAnswer && !answerRegExp.test(question.modelAnswer.trim())) {\n errors.push(`question ${question.id}: \\`modelAnswer\\` doesn't match \\`answerPattern\\``);\n }\n}\n\n/**\n * Reports inverted submission periods; shared by material, course.yaml, and contest validation.\n * When `ownPeriods` is given (the merged-values case), pairs whose both values are inherited from\n * the course are skipped: they are the course's mistake and are already reported against\n * course.yaml, so repeating them per material would send agents to files with nothing to fix.\n */\nexport function validateSubmissionPeriods(\n periods: SubmissionPeriods,\n errors: string[],\n ownPeriods: SubmissionPeriods = periods\n): void {\n const pairs = [\n ['submissionOpenedAt', 'submissionSoftClosedAt'],\n ['submissionSoftClosedAt', 'submissionHardClosedAt'],\n ['submissionOpenedAt', 'submissionHardClosedAt'],\n ] as const satisfies readonly (readonly [keyof SubmissionPeriods, keyof SubmissionPeriods])[];\n for (const [earlierName, laterName] of pairs) {\n const earlierValue = periods[earlierName];\n const laterValue = periods[laterName];\n if (earlierValue === undefined || laterValue === undefined) continue;\n if (ownPeriods[earlierName] === undefined && ownPeriods[laterName] === undefined) continue;\n if (new Date(laterValue).getTime() < new Date(earlierValue).getTime()) {\n errors.push(`${earlierName} (${earlierValue}) must be <= ${laterName} (${laterValue})`);\n }\n }\n}\n"],"mappings":"A,ygBAmBA,MAAMC,EAA4B,gFAG5BC,EAAmC,8DACnCC,EAAqB,sCACrBC,EAAsC,uDAGtCC,EAA2B,wCAC3BC,E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KAAK,CAAC,GACxEpB,EAAO,KAAK,YAAYoB,EAAS,GAAG,kDAAkD,CAE1F,CAQA,SAAgBe,EACd,EACA,EACA,EAAgC2B,EAC1B,CAMN,IAAK,GAAM,CAACC,EAAaC,IAAc,CAJrC,CAAC,qBAAsB,wBAAwB,EAC/C,CAAC,yBAA0B,wBAAwB,EACnD,CAAC,qBAAsB,wBAAwB,CAEN,EAAG,CAC5C,IAAMC,EAAeH,EAAQC,GACvBG,EAAaJ,EAAQE,GACvBC,IAAiB,IAAA,IAAaC,IAAe,IAAA,KAC7CC,EAAWJ,KAAiB,IAAA,IAAaI,EAAWH,KAAe,IAAA,KACnE,IAAI,KAAKE,CAAU,CAAC,CAAC,QAAQ,EAAI,IAAI,KAAKD,CAAY,CAAC,CAAC,QAAQ,GAClEjE,EAAO,KAAK,GAAG+D,EAAY,IAAIE,EAAa,eAAeD,EAAU,IAAIE,EAAW,EAAE,CAE1F,CACF,C"}
|
|
1
|
+
{"version":3,"file":"validateMaterial.js","names":["parseYaml","QUESTION_CODE_BLOCK_REGEX","QUESTION_CODE_BLOCK_OPENER_REGEX","PROBLEM_LINK_REGEX","TURTLE_GRAPHICS_QUESTION_LINK_REGEX","PROBLEM_ASSIGNMENT_REGEX","QUESTION_LINK_REGEX","TURTLE_GRAPHICS_ASSIGNMENT_REGEX","STANDALONE_CHAT_MARKER_REGEX","validateMaterialFile","errors","result","materialId","basename","materialFilePath","LEARNING_MATERIAL_ID_REGEX","markdown","readFile","attributes","body","parseFrontmatter","error","getErrorMessage","parsedFrontmatter","materialFrontmatterSchema","formatZodIssues","frontmatter","questionsInCodeBlocks","parseQuestionCodeBlocks","questionBlockIds","question","questions","validateQuestion","reportDuplicateIds","bodyWithoutQuestionBlocks","collectLinkedIds","linkedTurtleGraphicsQuestionIds","problemIds","problem","availableProblemIds","options","collectProblemIdsFromDirectory","reportDanglingProblemReferences","reportExcessChatMarkers","validateSubmissionPeriods","mergeSubmissionPeriods","linkRegex","match","id","own","courseDefaults","chatMarkerCount","matches","leftoverOpenerCount","blockIndex","yamlText","\"yaml\"","rawQuestion","parse","parsed","questionInCodeBlockSchema","isSurvey","answerFieldName","isAnswerDefined","answerIndices","answerIndex","answerPattern","answerRegExp","rawAnswerRegExp","periods","earlierName","laterName","earlierValue","laterValue","ownPeriods"],"sources":["../../src/learningMaterial/validateMaterial.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { basename } from 'node:path';\n\nimport { getErrorMessage } from '@willbooster/shared-lib';\nimport { parse as parseYaml } from 'yaml';\n\nimport { parseFrontmatter } from './frontmatter.js';\nimport { collectProblemIdsFromDirectory, reportDanglingProblemReferences } from './fsHelpers.js';\nimport {\n LEARNING_MATERIAL_ID_REGEX,\n materialFrontmatterSchema,\n type MaterialQuestion,\n questionInCodeBlockSchema,\n} from './schemas.js';\nimport { formatZodIssues, reportDuplicateIds, type ValidationResult } from './validationResult.js';\n\n// Same patterns the judge uses to extract embedded questions and problem links from material bodies.\n// The block regex intentionally requires LF line endings and a trailing newline after the closing\n// fence, exactly like the judge parser; blocks it misses are reported by detecting leftover openers.\nconst QUESTION_CODE_BLOCK_REGEX = /(?:^|\\n)(?<fence>`{3,}|~{3,})ya?ml +question\\n(?<yaml>[\\s\\S]+?)\\n\\k<fence>\\n/g;\n// Strictly laxer than the parser regex (tolerates CRLF, indentation, and stray whitespace) so\n// question-looking blocks the judge parser would silently skip surface as leftover openers.\nconst QUESTION_CODE_BLOCK_OPENER_REGEX = /^[ \\t]*(?:`{3,}|~{3,})[ \\t]*ya?ml[ \\t]+question[ \\t]*\\r?$/gm;\nconst PROBLEM_LINK_REGEX = /\\[.*?]\\(problems\\/([0-9_a-z-]+?)\\)/g;\nconst TURTLE_GRAPHICS_QUESTION_LINK_REGEX = /\\[.*?]\\(turtle-graphics-questions\\/([0-9_a-z-]+?)\\)/g;\n// Exercode's duplicate-assignment check scans the body with these patterns, whose link text may\n// span lines (unlike the judge's reference collection above).\nconst PROBLEM_ASSIGNMENT_REGEX = /\\[[^\\]]*]\\(problems\\/([0-9_a-z-]+)\\)/g;\nconst QUESTION_LINK_REGEX = /@\\[question]\\(([0-9_a-z-]+)\\)/g;\nconst TURTLE_GRAPHICS_ASSIGNMENT_REGEX = /\\[[^\\]]*]\\(turtle-graphics-questions\\/([0-9_a-z-]+)\\)/g;\nconst CHAT_MARKER = '<!-- chat -->';\n// exercode only counts the marker when it stands alone on a line, so fenced or inline mentions don't count.\nconst STANDALONE_CHAT_MARKER_REGEX = /(^|\\r?\\n)<!-- chat -->[ \\t]*(?=\\r?\\n|$)/g;\n\nexport interface SubmissionPeriods {\n submissionOpenedAt?: string;\n submissionSoftClosedAt?: string;\n submissionHardClosedAt?: string;\n}\n\nexport interface MaterialValidationOptions {\n /** Problem IDs already collected for the enclosing course; collected from `problemsDirectoryPath` otherwise. */\n availableProblemIds?: ReadonlySet<string>;\n /** When set, every referenced problem ID must be a problem discovered under this path. */\n problemsDirectoryPath?: string;\n /** Course-level submission periods; the judge merges them as `material[field] ?? course[field]`. */\n courseSubmissionPeriods?: SubmissionPeriods;\n}\n\n/** Validates an exercode markdown material file (frontmatter, embedded questions, problem references). */\nexport async function validateMaterialFile(\n materialFilePath: string,\n options: MaterialValidationOptions = {}\n): Promise<ValidationResult> {\n const errors: string[] = [];\n const warnings: string[] = [];\n const result = { errors, warnings };\n\n const materialId = basename(materialFilePath).replace(/\\.[^/.]+$/, '');\n if (!LEARNING_MATERIAL_ID_REGEX.test(materialId)) {\n errors.push(`material ID \"${materialId}\" (file name without extension) must match ${LEARNING_MATERIAL_ID_REGEX}`);\n }\n\n let markdown: string;\n try {\n markdown = await readFile(materialFilePath, 'utf8');\n } catch {\n errors.push(`material file not found: ${materialFilePath}`);\n return result;\n }\n\n let attributes: unknown;\n let body: string;\n try {\n ({ attributes, body } = parseFrontmatter(markdown));\n } catch (error) {\n errors.push(`invalid YAML frontmatter: ${getErrorMessage(error)}`);\n return result;\n }\n\n const parsedFrontmatter = materialFrontmatterSchema.safeParse(attributes);\n if (!parsedFrontmatter.success) {\n errors.push(...formatZodIssues(parsedFrontmatter.error, 'frontmatter'));\n }\n const frontmatter = parsedFrontmatter.success ? parsedFrontmatter.data : undefined;\n\n const questionsInCodeBlocks = parseQuestionCodeBlocks(body, errors);\n const questionBlockIds = questionsInCodeBlocks.map((question) => question.id);\n const questions = [...(frontmatter?.questions ?? []), ...questionsInCodeBlocks];\n for (const question of questions) {\n validateQuestion(question, errors);\n }\n reportDuplicateIds(\n questions.map((question) => question.id),\n 'question',\n errors\n );\n // Turtle-graphics links in the body merge into the frontmatter list like problem links do,\n // and exercode rejects duplicates in the merged list; deferred until after the question blocks\n // are removed below so links inside question text don't count.\n\n // Exercode's import validation runs two checks: the body must not link the same problem,\n // question or turtle-graphics question twice (every occurrence of the lax link pattern counts),\n // and the generated reference list (frontmatter entries plus the judge's deduplicated body links)\n // must not repeat an ID. The judge replaces recognized question blocks with @[question](id) links\n // before collecting links, so links that appear only inside question text must not count, while\n // each block counts as one question link next to explicit @[question](id) links.\n const bodyWithoutQuestionBlocks = body.replaceAll(QUESTION_CODE_BLOCK_REGEX, '\\n');\n reportDuplicateIds(\n [...questionBlockIds, ...collectLinkedIds(bodyWithoutQuestionBlocks, QUESTION_LINK_REGEX)],\n 'question link',\n errors\n );\n reportDuplicateIds(collectLinkedIds(bodyWithoutQuestionBlocks, PROBLEM_ASSIGNMENT_REGEX), 'problem link', errors);\n reportDuplicateIds(\n collectLinkedIds(bodyWithoutQuestionBlocks, TURTLE_GRAPHICS_ASSIGNMENT_REGEX),\n 'turtle-graphics question link',\n errors\n );\n const linkedTurtleGraphicsQuestionIds = new Set(\n collectLinkedIds(bodyWithoutQuestionBlocks, TURTLE_GRAPHICS_QUESTION_LINK_REGEX)\n );\n reportDuplicateIds(\n [\n ...(frontmatter?.turtleGraphicsQuestions ?? []).map((question) => question.id),\n ...linkedTurtleGraphicsQuestionIds,\n ],\n 'turtleGraphicsQuestion',\n errors\n );\n // Only the links the judge collects become references, and it deduplicates them before merging.\n const problemIds = [\n ...(frontmatter?.problems ?? []).map((problem) => problem.id),\n ...new Set(collectLinkedIds(bodyWithoutQuestionBlocks, PROBLEM_LINK_REGEX)),\n ];\n reportDuplicateIds(problemIds, 'problem', errors);\n const availableProblemIds =\n options.availableProblemIds ??\n (options.problemsDirectoryPath === undefined\n ? undefined\n : await collectProblemIdsFromDirectory(options.problemsDirectoryPath, errors));\n if (availableProblemIds !== undefined) {\n reportDanglingProblemReferences(problemIds, availableProblemIds, options.problemsDirectoryPath, errors);\n }\n\n reportExcessChatMarkers(body, errors);\n\n if (frontmatter) {\n validateSubmissionPeriods(\n mergeSubmissionPeriods(frontmatter, options.courseSubmissionPeriods),\n errors,\n frontmatter\n );\n }\n return result;\n}\n\nfunction collectLinkedIds(body: string, linkRegex: RegExp): string[] {\n return [...body.matchAll(linkRegex)].map((match) => match[1]).filter((id) => id !== undefined);\n}\n\n/** Applies the judge's course→material config merge (`material[field] ?? course[field]`). */\nexport function mergeSubmissionPeriods(\n own: SubmissionPeriods,\n courseDefaults: SubmissionPeriods | undefined\n): SubmissionPeriods {\n return {\n submissionOpenedAt: own.submissionOpenedAt ?? courseDefaults?.submissionOpenedAt,\n submissionSoftClosedAt: own.submissionSoftClosedAt ?? courseDefaults?.submissionSoftClosedAt,\n submissionHardClosedAt: own.submissionHardClosedAt ?? courseDefaults?.submissionHardClosedAt,\n };\n}\n\n/** exercode rejects more than one standalone chat delimiter line in material and problem bodies. */\nexport function reportExcessChatMarkers(body: string, errors: string[]): void {\n const chatMarkerCount = [...body.matchAll(STANDALONE_CHAT_MARKER_REGEX)].length;\n if (chatMarkerCount > 1) {\n errors.push(`at most one \\`${CHAT_MARKER}\\` marker is allowed, but found ${chatMarkerCount}`);\n }\n}\n\nfunction parseQuestionCodeBlocks(body: string, errors: string[]): MaterialQuestion[] {\n const questions: MaterialQuestion[] = [];\n const matches = [...body.matchAll(QUESTION_CODE_BLOCK_REGEX)];\n // The judge silently renders unparsed question blocks as plain code blocks, so a block the\n // strict regex misses (CRLF line endings, or no newline after the closing fence) would break\n // in production while looking fine here; flag it instead of validating a lie. Openers inside a\n // recognized block (e.g. an example fence in a question's text) are consumed with that block.\n const leftoverOpenerCount = [\n ...body.replaceAll(QUESTION_CODE_BLOCK_REGEX, '\\n').matchAll(QUESTION_CODE_BLOCK_OPENER_REGEX),\n ].length;\n if (leftoverOpenerCount > 0) {\n errors.push(\n `${leftoverOpenerCount} question code block(s) will not be recognized by the judge parser; separate consecutive question blocks with a blank line, use LF line endings, no indentation or trailing whitespace on the fence line, and end the closing fence with a newline`\n );\n }\n for (const [blockIndex, match] of matches.entries()) {\n const yamlText = match.groups?.['yaml'] ?? '';\n let rawQuestion: unknown;\n try {\n rawQuestion = parseYaml(yamlText);\n } catch (error) {\n errors.push(`question block ${blockIndex + 1}: invalid YAML: ${getErrorMessage(error)}`);\n continue;\n }\n const parsed = questionInCodeBlockSchema.safeParse(rawQuestion);\n if (parsed.success) {\n questions.push(parsed.data);\n } else {\n errors.push(...formatZodIssues(parsed.error, `question block ${blockIndex + 1}`));\n }\n }\n return questions;\n}\n\nfunction validateQuestion(question: MaterialQuestion, errors: string[]): void {\n const isSurvey = question.isSurvey === true;\n const [answerFieldName, isAnswerDefined] =\n question.type === 'select'\n ? (['answerIndex', question.answerIndex !== undefined] as const)\n : question.type === 'select_multiple'\n ? (['answerIndices', question.answerIndices !== undefined] as const)\n : (['answerPattern', question.answerPattern !== undefined] as const);\n if (isSurvey && isAnswerDefined) {\n errors.push(`question ${question.id}: \\`${answerFieldName}\\` must not be set when \\`isSurvey\\` is true`);\n }\n if (!isSurvey && !isAnswerDefined) {\n errors.push(`question ${question.id}: \\`${answerFieldName}\\` is required when \\`isSurvey\\` is not true`);\n }\n\n if (question.type === 'select' || question.type === 'select_multiple') {\n const answerIndices =\n question.type === 'select'\n ? Array.isArray(question.answerIndex)\n ? question.answerIndex\n : question.answerIndex === undefined\n ? []\n : [question.answerIndex]\n : (question.answerIndices ?? []);\n // An empty answer set is broken at runtime (select: never correct; select_multiple: an empty\n // submission grades as correct), and exercode's material editor rejects it as well.\n if (!isSurvey && isAnswerDefined && answerIndices.length === 0) {\n errors.push(`question ${question.id}: \\`${answerFieldName}\\` must contain at least one correct answer`);\n }\n for (const answerIndex of answerIndices) {\n if (!Number.isInteger(answerIndex) || answerIndex < 0 || answerIndex >= question.options.length) {\n errors.push(\n `question ${question.id}: ${answerFieldName} out of bounds: ${answerIndex}; expected 0 <= index < options length ${question.options.length}`\n );\n }\n }\n return;\n }\n\n if (isSurvey || question.answerPattern === undefined) return;\n const answerPattern = question.answerPattern.trim();\n let answerRegExp: RegExp;\n let rawAnswerRegExp: RegExp;\n try {\n answerRegExp = new RegExp(`^(?:${answerPattern})$`);\n // Compiled inside the same guard: a pattern like `a)(b` is valid only once wrapped above,\n // so an unguarded raw compile would crash the CLI instead of reporting an error.\n rawAnswerRegExp = new RegExp(question.answerPattern);\n } catch {\n errors.push(\n `question ${question.id}: \\`answerPattern\\` is not a valid regular expression: ${question.answerPattern}`\n );\n return;\n }\n // Mirrors the judge heuristic: a pattern that doesn't match itself likely uses RegExp syntax,\n // so a modelAnswer is required to prove that some concrete answer is accepted.\n // Like the judge, an empty modelAnswer counts as missing.\n // The judge runs this heuristic on the untrimmed pattern and trims only for the anchored match.\n if (!question.modelAnswer && !rawAnswerRegExp.test(question.answerPattern)) {\n errors.push(`question ${question.id}: \\`answerPattern\\` seems a RegExp but \\`modelAnswer\\` is missing`);\n }\n if (question.modelAnswer && !answerRegExp.test(question.modelAnswer.trim())) {\n errors.push(`question ${question.id}: \\`modelAnswer\\` doesn't match \\`answerPattern\\``);\n }\n}\n\n/**\n * Reports inverted submission periods; shared by material, course.yaml, and contest validation.\n * When `ownPeriods` is given (the merged-values case), pairs whose both values are inherited from\n * the course are skipped: they are the course's mistake and are already reported against\n * course.yaml, so repeating them per material would send agents to files with nothing to fix.\n */\nexport function validateSubmissionPeriods(\n periods: SubmissionPeriods,\n errors: string[],\n ownPeriods: SubmissionPeriods = periods\n): void {\n const pairs = [\n ['submissionOpenedAt', 'submissionSoftClosedAt'],\n ['submissionSoftClosedAt', 'submissionHardClosedAt'],\n ['submissionOpenedAt', 'submissionHardClosedAt'],\n ] as const satisfies readonly (readonly [keyof SubmissionPeriods, keyof SubmissionPeriods])[];\n for (const [earlierName, laterName] of pairs) {\n const earlierValue = periods[earlierName];\n const laterValue = periods[laterName];\n if (earlierValue === undefined || laterValue === undefined) continue;\n if (ownPeriods[earlierName] === undefined && ownPeriods[laterName] === undefined) continue;\n if (new Date(laterValue).getTime() < new Date(earlierValue).getTime()) {\n errors.push(`${earlierName} (${earlierValue}) must be <= ${laterName} (${laterValue})`);\n }\n }\n}\n"],"mappings":"A,ygBAmBA,MAAMC,EAA4B,gFAG5BC,EAAmC,8DACnCC,EAAqB,sCACrBC,EAAsC,uDAGtCC,EAA2B,wCAC3BC,EAAsB,iCACtBC,EAAmC,yDAGnCC,EAA+B,2CAkBrC,eAAsBC,EACpB,EACA,EAAqC,CAAC,EACX,CAC3B,IAAMC,EAAmB,CAAC,EAEpBC,EAAS,CAAE,SAAQ,SAAA,CAAO,CAAE,EAE5BC,EAAaC,EAASC,CAAgB,CAAC,CAAC,QAAQ,YAAa,EAAE,EAChEC,EAA2B,KAAKH,CAAU,GAC7CF,EAAO,KAAK,gBAAgBE,EAAW,6CAA6CG,GAA4B,EAGlH,IAAIC,EACJ,GAAI,CACF,EAAW,MAAMC,EAASH,EAAkB,MAAM,CACpD,MAAQ,CAEN,OADAJ,EAAO,KAAK,4BAA4BI,GAAkB,EACnDH,CACT,CAEA,IAAIO,EACAC,EACJ,GAAI,EACD,sBAAuBC,EAAiBJ,CAAQ,EACnD,OAASK,EAAO,CAEd,OADAX,EAAO,KAAK,6BAA6BY,EAAgBD,CAAK,GAAG,EAC1DV,CACT,CAEA,IAAMY,EAAoBC,EAA0B,UAAUN,CAAU,EACnEK,EAAkB,SACrBb,EAAO,KAAK,GAAGe,EAAgBF,EAAkB,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,OAAOpC,EAAS,aAAa,CACrD,MAAQ,CACNpB,EAAO,KACL,YAAYoB,EAAS,GAAG,yDAAyDA,EAAS,eAC5F,EACA,MACF,CAKI,CAACA,EAAS,aAAe,CAACsC,EAAgB,KAAKtC,EAAS,aAAa,GACvEpB,EAAO,KAAK,YAAYoB,EAAS,GAAG,kEAAkE,EAEpGA,EAAS,aAAe,CAACqC,EAAa,KAAKrC,EAAS,YAAY,KAAK,CAAC,GACxEpB,EAAO,KAAK,YAAYoB,EAAS,GAAG,kDAAkD,CAE1F,CAQA,SAAgBc,EACd,EACA,EACA,EAAgCyB,EAC1B,CAMN,IAAK,GAAM,CAACC,EAAaC,IAAc,CAJrC,CAAC,qBAAsB,wBAAwB,EAC/C,CAAC,yBAA0B,wBAAwB,EACnD,CAAC,qBAAsB,wBAAwB,CAEN,EAAG,CAC5C,IAAMC,EAAeH,EAAQC,GACvBG,EAAaJ,EAAQE,GACvBC,IAAiB,IAAA,IAAaC,IAAe,IAAA,KAC7CC,EAAWJ,KAAiB,IAAA,IAAaI,EAAWH,KAAe,IAAA,KACnE,IAAI,KAAKE,CAAU,CAAC,CAAC,QAAQ,EAAI,IAAI,KAAKD,CAAY,CAAC,CAAC,QAAQ,GAClE9D,EAAO,KAAK,GAAG4D,EAAY,IAAIE,EAAa,eAAeD,EAAU,IAAIE,EAAW,EAAE,CAE1F,CACF,C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exercode/problem-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": ":100: A set of utilities for judging programs on Exercode (https://exercode.willbooster.com/).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"exercode",
|
|
@@ -53,19 +53,19 @@
|
|
|
53
53
|
"verify-full": "bun wb verify --full"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@willbooster/shared-lib": "10.
|
|
56
|
+
"@willbooster/shared-lib": "10.24.0",
|
|
57
57
|
"front-matter": "4.0.2",
|
|
58
58
|
"yaml": "2.9.1",
|
|
59
59
|
"zod": "4.6.7"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@tsconfig/bun": "1.0.11",
|
|
63
|
-
"@types/bun": "1.4.
|
|
63
|
+
"@types/bun": "1.4.4",
|
|
64
64
|
"@willbooster/oxlint-config": "1.4.9",
|
|
65
|
-
"@willbooster/wb": "
|
|
65
|
+
"@willbooster/wb": "23.0.0",
|
|
66
66
|
"build-ts": "21.0.29",
|
|
67
|
-
"oxlint": "1.
|
|
68
|
-
"oxlint-tsgolint": "7.0.
|
|
67
|
+
"oxlint": "1.89.0",
|
|
68
|
+
"oxlint-tsgolint": "7.0.2005",
|
|
69
69
|
"undici-types": "8.12.2"
|
|
70
70
|
},
|
|
71
71
|
"prettier": "@willbooster/prettier-config",
|