Template
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
108 lines
2.5 KiB
TypeScript
108 lines
2.5 KiB
TypeScript
import type {
|
|
CourseCategory,
|
|
CourseFlowProgress,
|
|
CourseResource,
|
|
CourseResourceCategory,
|
|
} from "./CourseDemo.types";
|
|
|
|
export const courseResources: CourseResource[] = [
|
|
{
|
|
id: "policy-video",
|
|
title: "资助政策微课",
|
|
description: "了解国家助学政策和申请条件",
|
|
category: "policy",
|
|
icon: "🎬",
|
|
},
|
|
{
|
|
id: "policy-guide",
|
|
title: "申请流程图",
|
|
description: "按步骤核对材料与办理节点",
|
|
category: "policy",
|
|
icon: "🗺️",
|
|
},
|
|
{
|
|
id: "practice-case",
|
|
title: "诚信申请案例",
|
|
description: "判断案例中的规范与风险",
|
|
category: "practice",
|
|
icon: "🧩",
|
|
},
|
|
{
|
|
id: "practice-checklist",
|
|
title: "材料自查清单",
|
|
description: "动手检查课程中的模拟材料",
|
|
category: "practice",
|
|
icon: "✅",
|
|
},
|
|
{
|
|
id: "support-qa",
|
|
title: "常见问题答疑",
|
|
description: "查找填报和审核中的常见问题",
|
|
category: "support",
|
|
icon: "💬",
|
|
},
|
|
{
|
|
id: "support-contact",
|
|
title: "校园咨询渠道",
|
|
description: "联系辅导员与学生资助中心",
|
|
category: "support",
|
|
icon: "☎️",
|
|
},
|
|
];
|
|
|
|
export const courseCategories: CourseCategory[] = [
|
|
{
|
|
id: "policy",
|
|
title: "政策学习",
|
|
description: "帮助理解政策与办理流程",
|
|
icon: "📚",
|
|
},
|
|
{
|
|
id: "practice",
|
|
title: "互动实践",
|
|
description: "需要判断、检查或动手完成",
|
|
icon: "🧠",
|
|
},
|
|
{
|
|
id: "support",
|
|
title: "学习支持",
|
|
description: "遇到问题时可以随时查阅",
|
|
icon: "🤝",
|
|
},
|
|
];
|
|
|
|
export function createEmptyProgress(): CourseFlowProgress {
|
|
return {
|
|
placed: { policy: [], practice: [], support: [] },
|
|
completed: false,
|
|
updatedAt: new Date().toISOString(),
|
|
};
|
|
}
|
|
|
|
export function parseProgress(content: string): CourseFlowProgress | null {
|
|
try {
|
|
const value = JSON.parse(content) as Partial<CourseFlowProgress>;
|
|
if (!value.placed || typeof value.placed !== "object") return null;
|
|
const placed = Object.fromEntries(
|
|
courseCategories.map(({ id }) => [
|
|
id,
|
|
Array.isArray(value.placed?.[id])
|
|
? value.placed[id].filter((item): item is string =>
|
|
courseResources.some(
|
|
(resource) => resource.id === item && resource.category === id,
|
|
),
|
|
)
|
|
: [],
|
|
]),
|
|
) as Record<CourseResourceCategory, string[]>;
|
|
const placedCount = Object.values(placed).flat().length;
|
|
return {
|
|
placed,
|
|
completed: placedCount === courseResources.length,
|
|
updatedAt: value.updatedAt ?? new Date().toISOString(),
|
|
};
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|