feat(exam-homework): add audit report, i18n, error boundaries, and permission hardening

- Add comprehensive audit report for exam and homework module

- Create exam-homework i18n message files (zh-CN + en) and register namespace

- Add permission check to gradeHomeworkSubmissionAction to prevent horizontal privilege escalation

- Add Error Boundary + loading.tsx for 5 key pages (exam build/proctoring, homework assignment/submissions, student assignment)

- Refactor exam-columns to createExamColumns(t) factory for i18n support

- Refactor exam-data-table to manage columns internally via useTranslations

- Replace hardcoded strings with i18n keys in all exam/homework components and pages

- Add getHomeworkSubmissionForGrading data-access for secure grading flow
This commit is contained in:
SpecialX
2026-06-22 16:08:39 +08:00
parent fde711ce46
commit 21c7e65fee
26 changed files with 2059 additions and 463 deletions

View File

@@ -0,0 +1,352 @@
{
"exam": {
"list": {
"title": "Exams",
"create": "Create Exam",
"empty": "No exams yet",
"emptyFiltered": "No exams match your filters",
"emptyDescription": "Create your first exam to start assigning and grading.",
"emptyFilteredDescription": "Try clearing filters or adjusting keywords.",
"clearFilters": "Clear filters",
"showing": "Showing",
"examsUnit": "exams",
"searchPlaceholder": "Search exams..."
},
"form": {
"createTitle": "Create Exam",
"createDescription": "Configure a new exam for your classes.",
"buildTitle": "Build Exam",
"buildDescription": "Assemble questions for your exam.",
"title": "Exam Title",
"subject": "Subject",
"grade": "Grade",
"difficulty": "Difficulty",
"totalScore": "Total Score",
"durationMin": "Duration (minutes)",
"scheduledAt": "Scheduled At",
"questions": "Questions",
"missingSubjectOrGrade": "Missing subject or grade configuration",
"previewBeforeCreate": "Please preview and confirm before creating",
"createSuccess": "Exam draft created",
"redirecting": "Redirecting to exam builder...",
"createFailed": "Failed to create exam",
"loadFormFailed": "Failed to load form data",
"loadSubjectsFailed": "Failed to load subjects",
"loadGradesFailed": "Failed to load grades"
},
"status": {
"draft": "Draft",
"published": "Published",
"archived": "Archived"
},
"difficulty": {
"1": "Easy",
"2": "Easy-Med",
"3": "Medium",
"4": "Med-Hard",
"5": "Hard"
},
"actions": {
"preview": "Preview Exam",
"copyId": "Copy ID",
"edit": "Edit",
"build": "Build",
"duplicate": "Duplicate",
"publish": "Publish",
"moveToDraft": "Move to Draft",
"archive": "Archive",
"delete": "Delete",
"deleteConfirmTitle": "Are you absolutely sure?",
"deleteConfirmDescription": "This action cannot be undone. This will permanently delete the exam \"{{title}}\" and remove all associated data.",
"cancel": "Cancel",
"deleteSuccess": "Exam deleted successfully",
"deleteFailed": "Failed to delete exam",
"publishSuccess": "Exam published",
"archiveSuccess": "Exam archived",
"draftSuccess": "Exam moved to draft",
"duplicateSuccess": "Exam duplicated",
"duplicateFailed": "Failed to duplicate exam",
"updateFailed": "Failed to update exam",
"previewFailed": "Failed to load exam preview",
"idCopied": "Exam ID copied to clipboard",
"openMenu": "Open menu",
"selectRow": "Select row",
"selectAll": "Select all",
"noQuestions": "No questions in this exam.",
"loadingPreview": "Loading preview..."
},
"columns": {
"examInfo": "Exam Info",
"status": "Status",
"stats": "Stats",
"difficulty": "Difficulty",
"date": "Date",
"scheduled": "Scheduled",
"created": "Created",
"questions": "Qs",
"points": "Pts"
},
"filters": {
"status": "Status",
"anyStatus": "Any Status",
"difficulty": "Difficulty",
"anyDifficulty": "Any Difficulty"
},
"error": {
"notFound": "Exam not found",
"loadFailed": "Failed to load exam"
}
},
"homework": {
"list": {
"title": "Assignments",
"description": "Manage assignments, view submission rates and grading progress.",
"create": "Create Assignment",
"empty": "No assignments yet",
"emptyFiltered": "No assignments in this class.",
"emptyDescription": "You haven't created any assignments yet.",
"clearFilters": "Clear filters",
"filterByClass": "Filter by class: {{className}}",
"columns": {
"title": "Title",
"status": "Status",
"dueAt": "Due Date",
"submissionRate": "Submission Rate",
"averageScore": "Average Score",
"overdue": "Overdue",
"sourceExam": "Source Exam",
"createdAt": "Created At"
},
"pagination": {
"itemLabel": "assignments"
}
},
"form": {
"createTitle": "Create Assignment",
"quickMode": "Quick Assignment",
"quickModeDescription": "Enter title and description directly, no questions needed",
"examMode": "Exam-based Assignment",
"examModeDescription": "Derive assignment from an existing exam",
"class": "Class",
"selectClass": "Select a class",
"sourceExam": "Source Exam",
"selectExam": "Select an exam",
"assignmentTitle": "Assignment Title",
"titlePlaceholderQuick": "e.g. Recite Lesson 3",
"titlePlaceholderExam": "Defaults to exam title",
"description": "Description (optional)",
"descriptionPlaceholderQuick": "Enter assignment requirements, question content, or instructions...",
"availableAt": "Available At (optional)",
"dueAt": "Due At (optional)",
"allowLate": "Allow late submissions",
"lateDueAt": "Late Due At (optional)",
"maxAttempts": "Max Attempts",
"submit": "Create Assignment",
"submitting": "Creating...",
"creating": "Creating assignment...",
"selectExamRequired": "Please select an exam",
"titleRequired": "Please enter a title",
"selectClassRequired": "Please select a class",
"createSuccess": "Assignment created",
"createFailed": "Failed to create"
},
"take": {
"questions": "Questions",
"question": "Question {{index}}",
"points": "points",
"startAssignment": "Start Assignment",
"submitAssignment": "Submit Assignment",
"submitAll": "Submit All",
"saveAnswer": "Save Answer",
"saved": "Saved",
"saveFailed": "Failed to save",
"starting": "Starting...",
"submitting": "Submitting...",
"started": "Started",
"submitted": "Submitted",
"notStarted": "Not Started",
"readyToStart": "Ready to start?",
"readyDescription": "Click the \"Start Assignment\" button above to begin. Your answers will be saved when you click \"Save Answer\".",
"startNow": "Start Now",
"back": "Back",
"confirmSubmit": "Confirm Submission",
"confirmSubmitDescription": "All questions have been answered. Submitted answers cannot be changed. Are you sure you want to submit?",
"unansweredWarning": "You have {{count}} unanswered question(s). Submitted answers cannot be changed. Are you sure you want to submit?",
"cancel": "Cancel",
"confirmSubmitAction": "Confirm Submit",
"submitSuccess": "Submitted",
"submitFailed": "Failed to submit",
"startSuccess": "Started",
"startFailed": "Failed to start",
"assignmentInfo": "Assignment Info",
"status": "Status",
"dueDate": "Due Date",
"overdue": "Overdue",
"hoursLeft": "{{hours}} hour(s) left",
"lessThanOneHour": "Less than 1 hour left",
"attempts": "Attempts",
"attemptsUsed": "{{used}} / {{max}} used",
"attemptsRemaining": "· {{remaining}} remaining",
"description": "Description",
"noDescription": "No description provided.",
"progress": "Progress",
"jumpToQuestion": "Jump to question {{index}}",
"yourAnswer": "Your answer",
"answerPlaceholder": "Type your answer here...",
"true": "True",
"false": "False",
"unsupportedType": "Unsupported question type",
"teacherFeedback": "Teacher Feedback",
"noFeedback": "No specific feedback provided.",
"makeSureAnswered": "Make sure you have answered all questions."
},
"grade": {
"title": "Grade",
"submissions": "Submissions",
"student": "Student",
"status": "Status",
"submitted": "Submitted",
"score": "Score",
"action": "Action",
"back": "Back",
"openAssignment": "Open Assignment",
"late": "Late",
"targets": "Targets",
"submittedCount": "Submitted",
"gradedCount": "Graded",
"exam": "Exam",
"gradingSummary": "Grading Summary",
"totalScore": "Total Score",
"correct": "Correct",
"incorrect": "Incorrect",
"partial": "Partial",
"questionStatus": "Question Status",
"studentAnswer": "Student Answer",
"referenceAnswer": "Reference Answer",
"noReferenceAnswer": "No reference answer provided.",
"noQuestionText": "No question text",
"autoGraded": "Auto-graded",
"correctButton": "Correct",
"incorrectButton": "Incorrect",
"scoreLabel": "Score",
"addFeedback": "Add Feedback",
"hideFeedback": "Hide Feedback",
"feedbackPlaceholder": "Provide feedback for {{name}}...",
"submitGrades": "Submit Grades",
"saving": "Saving...",
"gradesSaved": "Grading saved successfully",
"gradesSaveFailed": "Failed to save grading",
"previousStudent": "Previous Student",
"nextStudent": "Next Student",
"prev": "Prev",
"next": "Next",
"gradesAutoSaveNote": "Grades are saved automatically when you click Submit. Students will see their grades and feedback immediately after you submit."
},
"review": {
"title": "Review",
"yourAnswer": "Your Answer",
"correctAnswer": "Correct Answer",
"teacherFeedback": "Teacher Feedback",
"score": "Score",
"maxScore": "Max Score"
},
"status": {
"draft": "Draft",
"published": "Published",
"archived": "Archived",
"started": "Started",
"submitted": "Submitted",
"graded": "Graded",
"not_started": "Not Started",
"in_progress": "In Progress"
},
"error": {
"notFound": "Assignment not found",
"submissionNotFound": "Submission not found",
"unauthorized": "Unauthorized",
"submissionLocked": "Submission is locked",
"pastDue": "Past due",
"pastLateDue": "Past late due",
"noActiveStudents": "No active students in this class",
"classNotFound": "Class not found",
"examNotFound": "Exam not found",
"examSubjectNotSet": "Exam subject not set",
"notAssignedToClass": "Not assigned to this class",
"notAssignedToSubject": "Not assigned to this subject",
"notAssigned": "Not assigned",
"notAvailableYet": "Not available yet",
"noAttemptsLeft": "No attempts left",
"assignmentNotFound": "Assignment not found",
"assignmentNotAvailable": "Assignment not available"
}
},
"proctoring": {
"mode": {
"title": "Exam Mode",
"description": "Select exam mode and configure options. Proctored mode enables anti-cheat monitoring.",
"homework": "Homework Mode",
"timed": "Timed Mode",
"proctored": "Proctored Mode",
"homeworkDescription": "Students can answer at any time, no time limit",
"timedDescription": "Timed answering, auto-submit on timeout",
"proctoredDescription": "Timed + anti-cheat + forced fullscreen"
},
"config": {
"duration": "Duration (minutes)",
"durationTimedDescription": "Auto-submit after timeout when student starts",
"durationProctoredDescription": "Required in proctored mode",
"shuffleQuestions": "Shuffle Questions",
"shuffleQuestionsDescription": "Each student sees questions in random order",
"antiCheat": "Enable Anti-cheat Monitoring",
"antiCheatDescription": "Monitor tab switch, copy, right-click, devtools, etc.",
"allowLateStart": "Allow Late Start",
"allowLateStartDescription": "Allow students to enter within a grace period after exam starts",
"lateStartGrace": "Late Start Grace (minutes)",
"lateStartGraceDescription": "No new students allowed after this time"
},
"dashboard": {
"title": "Proctoring Dashboard",
"summary": "Summary",
"students": "Students",
"recentEvents": "Recent Events",
"noEvents": "No events",
"eventCount": "Event Count",
"abnormalCount": "Abnormal Count"
},
"events": {
"tab_switch": "Tab Switch",
"window_blur": "Window Blur",
"copy_attempt": "Copy Attempt",
"paste_attempt": "Paste Attempt",
"right_click": "Right Click",
"devtools_open": "DevTools Open",
"fullscreen_exit": "Fullscreen Exit",
"idle_timeout": "Idle Timeout"
}
},
"common": {
"loading": "Loading...",
"save": "Save",
"cancel": "Cancel",
"confirm": "Confirm",
"back": "Back",
"edit": "Edit",
"delete": "Delete",
"create": "Create",
"search": "Search",
"filter": "Filter",
"noResults": "No results",
"error": "Error",
"success": "Success",
"failed": "Failed",
"retry": "Retry",
"page": "Page",
"of": "of",
"selected": "selected",
"rows": "row(s)",
"view": "View",
"continue": "Continue",
"other": "Other",
"completed": "Completed"
}
}

View File

@@ -0,0 +1,352 @@
{
"exam": {
"list": {
"title": "考试列表",
"create": "创建考试",
"empty": "暂无考试",
"emptyFiltered": "没有匹配筛选条件的考试",
"emptyDescription": "创建第一份考试,开始布置与批改。",
"emptyFilteredDescription": "尝试清除筛选条件或调整关键词。",
"clearFilters": "清除筛选",
"showing": "显示",
"examsUnit": "份考试",
"searchPlaceholder": "搜索考试..."
},
"form": {
"createTitle": "创建考试",
"createDescription": "为班级配置一份新考试。",
"buildTitle": "组卷",
"buildDescription": "为考试组装题目。",
"title": "考试标题",
"subject": "科目",
"grade": "年级",
"difficulty": "难度",
"totalScore": "总分",
"durationMin": "考试时长(分钟)",
"scheduledAt": "计划时间",
"questions": "题目",
"missingSubjectOrGrade": "缺少科目或年级配置",
"previewBeforeCreate": "请先预览并确认后再创建",
"createSuccess": "考试草稿已创建",
"redirecting": "正在跳转到组卷页...",
"createFailed": "创建考试失败",
"loadFormFailed": "加载表单数据失败",
"loadSubjectsFailed": "加载科目失败",
"loadGradesFailed": "加载年级失败"
},
"status": {
"draft": "草稿",
"published": "已发布",
"archived": "已归档"
},
"difficulty": {
"1": "简单",
"2": "偏易",
"3": "中等",
"4": "偏难",
"5": "困难"
},
"actions": {
"preview": "预览考试",
"copyId": "复制 ID",
"edit": "编辑",
"build": "组卷",
"duplicate": "复制",
"publish": "发布",
"moveToDraft": "移至草稿",
"archive": "归档",
"delete": "删除",
"deleteConfirmTitle": "确定要删除吗?",
"deleteConfirmDescription": "此操作不可撤销。将永久删除考试\"{{title}}\"及所有关联数据。",
"cancel": "取消",
"deleteSuccess": "考试已删除",
"deleteFailed": "删除考试失败",
"publishSuccess": "考试已发布",
"archiveSuccess": "考试已归档",
"draftSuccess": "考试已移至草稿",
"duplicateSuccess": "考试已复制",
"duplicateFailed": "复制考试失败",
"updateFailed": "更新考试失败",
"previewFailed": "加载考试预览失败",
"idCopied": "考试 ID 已复制",
"openMenu": "打开菜单",
"selectRow": "选择行",
"selectAll": "全选",
"noQuestions": "此考试暂无题目。",
"loadingPreview": "正在加载预览..."
},
"columns": {
"examInfo": "考试信息",
"status": "状态",
"stats": "统计",
"difficulty": "难度",
"date": "日期",
"scheduled": "已计划",
"created": "创建于",
"questions": "题",
"points": "分"
},
"filters": {
"status": "状态",
"anyStatus": "任意状态",
"difficulty": "难度",
"anyDifficulty": "任意难度"
},
"error": {
"notFound": "考试不存在",
"loadFailed": "加载考试失败"
}
},
"homework": {
"list": {
"title": "作业列表",
"description": "管理作业,查看提交率与批改进度。",
"create": "创建作业",
"empty": "暂无作业",
"emptyFiltered": "该班级还没有作业。",
"emptyDescription": "您还没有创建任何作业。",
"clearFilters": "清除筛选",
"filterByClass": "按班级筛选:{{className}}",
"columns": {
"title": "标题",
"status": "状态",
"dueAt": "截止时间",
"submissionRate": "提交率",
"averageScore": "平均分",
"overdue": "逾期",
"sourceExam": "来源考试",
"createdAt": "创建时间"
},
"pagination": {
"itemLabel": "个作业"
}
},
"form": {
"createTitle": "创建作业",
"quickMode": "快速作业",
"quickModeDescription": "直接输入标题和描述,无需建题",
"examMode": "考试派生作业",
"examModeDescription": "从已有考试派生作业",
"class": "班级",
"selectClass": "选择班级",
"sourceExam": "来源考试",
"selectExam": "选择考试",
"assignmentTitle": "作业标题",
"titlePlaceholderQuick": "例如:背诵第三课课文",
"titlePlaceholderExam": "默认使用考试标题",
"description": "描述(可选)",
"descriptionPlaceholderQuick": "输入作业要求、题目内容或说明...",
"availableAt": "开放时间(可选)",
"dueAt": "截止时间(可选)",
"allowLate": "允许迟交",
"lateDueAt": "迟交截止时间(可选)",
"maxAttempts": "最大尝试次数",
"submit": "创建作业",
"submitting": "创建中...",
"creating": "正在创建作业...",
"selectExamRequired": "请选择考试",
"titleRequired": "请输入标题",
"selectClassRequired": "请选择班级",
"createSuccess": "作业已创建",
"createFailed": "创建失败"
},
"take": {
"questions": "题目",
"question": "第 {{index}} 题",
"points": "分",
"startAssignment": "开始作答",
"submitAssignment": "提交作业",
"submitAll": "全部提交",
"saveAnswer": "保存答案",
"saved": "已保存",
"saveFailed": "保存失败",
"starting": "正在开始...",
"submitting": "正在提交...",
"started": "已开始",
"submitted": "已提交",
"notStarted": "未开始",
"readyToStart": "准备好开始了吗?",
"readyDescription": "点击上方\"开始作答\"按钮。点击\"保存答案\"将保存您的答案。",
"startNow": "立即开始",
"back": "返回",
"confirmSubmit": "确认提交",
"confirmSubmitDescription": "所有题目已作答。提交后答案不可修改,确定要提交吗?",
"unansweredWarning": "您有 {{count}} 道题未作答。提交后答案不可修改,确定要提交吗?",
"cancel": "取消",
"confirmSubmitAction": "确认提交",
"submitSuccess": "已提交",
"submitFailed": "提交失败",
"startSuccess": "已开始",
"startFailed": "开始失败",
"assignmentInfo": "作业信息",
"status": "状态",
"dueDate": "截止时间",
"overdue": "已逾期",
"hoursLeft": "还剩 {{hours}} 小时",
"lessThanOneHour": "不足 1 小时",
"attempts": "尝试次数",
"attemptsUsed": "已用 {{used}} / {{max}}",
"attemptsRemaining": "· 剩余 {{remaining}} 次",
"description": "描述",
"noDescription": "无描述。",
"progress": "进度",
"jumpToQuestion": "跳转到第 {{index}} 题",
"yourAnswer": "你的答案",
"answerPlaceholder": "在此输入答案...",
"true": "正确",
"false": "错误",
"unsupportedType": "不支持的题型",
"teacherFeedback": "教师反馈",
"noFeedback": "无具体反馈。",
"makeSureAnswered": "请确保已作答所有题目。"
},
"grade": {
"title": "批改",
"submissions": "提交记录",
"student": "学生",
"status": "状态",
"submitted": "提交时间",
"score": "分数",
"action": "操作",
"back": "返回",
"openAssignment": "打开作业",
"late": "迟交",
"targets": "应交",
"submittedCount": "已交",
"gradedCount": "已改",
"exam": "考试",
"gradingSummary": "批改摘要",
"totalScore": "总分",
"correct": "正确",
"incorrect": "错误",
"partial": "部分正确",
"questionStatus": "题目状态",
"studentAnswer": "学生答案",
"referenceAnswer": "参考答案",
"noReferenceAnswer": "无参考答案。",
"noQuestionText": "无题目文本",
"autoGraded": "自动判分",
"correctButton": "正确",
"incorrectButton": "错误",
"scoreLabel": "分数",
"addFeedback": "添加反馈",
"hideFeedback": "隐藏反馈",
"feedbackPlaceholder": "为 {{name}} 添加反馈...",
"submitGrades": "提交成绩",
"saving": "保存中...",
"gradesSaved": "批改已保存",
"gradesSaveFailed": "保存批改失败",
"previousStudent": "上一名学生",
"nextStudent": "下一名学生",
"prev": "上一页",
"next": "下一页",
"gradesAutoSaveNote": "点击提交后成绩将自动保存。学生将在您提交后立即看到成绩和反馈。"
},
"review": {
"title": "复习",
"yourAnswer": "你的答案",
"correctAnswer": "正确答案",
"teacherFeedback": "教师反馈",
"score": "得分",
"maxScore": "满分"
},
"status": {
"draft": "草稿",
"published": "已发布",
"archived": "已归档",
"started": "进行中",
"submitted": "已提交",
"graded": "已批改",
"not_started": "未开始",
"in_progress": "进行中"
},
"error": {
"notFound": "作业不存在",
"submissionNotFound": "提交记录不存在",
"unauthorized": "无权限",
"submissionLocked": "提交已锁定",
"pastDue": "已过截止时间",
"pastLateDue": "已过迟交截止时间",
"noActiveStudents": "该班级没有活跃学生",
"classNotFound": "班级不存在",
"examNotFound": "考试不存在",
"examSubjectNotSet": "考试未设置科目",
"notAssignedToClass": "未分配到该班级",
"notAssignedToSubject": "未分配到该科目",
"notAssigned": "未分配该作业",
"notAvailableYet": "作业尚未开放",
"noAttemptsLeft": "尝试次数已用完",
"assignmentNotFound": "作业不存在",
"assignmentNotAvailable": "作业不可用"
}
},
"proctoring": {
"mode": {
"title": "考试模式",
"description": "选择考试模式并配置相关选项。监考模式会启用防作弊监控。",
"homework": "作业模式",
"timed": "限时模式",
"proctored": "监考模式",
"homeworkDescription": "学生可在任意时间作答,无时间限制",
"timedDescription": "限时作答,到时自动提交",
"proctoredDescription": "限时作答 + 防作弊监控 + 强制全屏"
},
"config": {
"duration": "考试时长(分钟)",
"durationTimedDescription": "学生开始作答后,到时自动提交",
"durationProctoredDescription": "监考模式下必须设置考试时长",
"shuffleQuestions": "题目乱序",
"shuffleQuestionsDescription": "每位学生看到的题目顺序随机",
"antiCheat": "启用防作弊监控",
"antiCheatDescription": "监听切屏、复制、右键、开发者工具等异常行为",
"allowLateStart": "允许迟开始",
"allowLateStartDescription": "允许学生在考试开始后一段时间内进入",
"lateStartGrace": "迟到宽限时间(分钟)",
"lateStartGraceDescription": "超过此时间后不允许新学生进入"
},
"dashboard": {
"title": "监考面板",
"summary": "摘要",
"students": "学生",
"recentEvents": "最近事件",
"noEvents": "暂无事件",
"eventCount": "事件数",
"abnormalCount": "异常数"
},
"events": {
"tab_switch": "切换标签页",
"window_blur": "窗口失焦",
"copy_attempt": "复制尝试",
"paste_attempt": "粘贴尝试",
"right_click": "右键点击",
"devtools_open": "开发者工具",
"fullscreen_exit": "退出全屏",
"idle_timeout": "空闲超时"
}
},
"common": {
"loading": "加载中...",
"save": "保存",
"cancel": "取消",
"confirm": "确认",
"back": "返回",
"edit": "编辑",
"delete": "删除",
"create": "创建",
"search": "搜索",
"filter": "筛选",
"noResults": "无结果",
"error": "错误",
"success": "成功",
"failed": "失败",
"retry": "重试",
"page": "页",
"of": "共",
"selected": "已选",
"rows": "行",
"view": "查看",
"continue": "继续",
"other": "其他",
"completed": "已完成"
}
}