Files
teach_sys_Demo/check_homework_structure.cjs

84 lines
2.9 KiB
JavaScript
Raw Permalink Normal View History

const fs = require('fs');
const path = require('path');
// 读取日历课程
const calendarPath = path.join(__dirname, 'src/data/calendarCourses.json');
const calendarData = JSON.parse(fs.readFileSync(calendarPath, 'utf-8'));
// 读取作业海报映射
const posterMappingPath = path.join(__dirname, 'homework_poster_mapping.json');
const posterMapping = JSON.parse(fs.readFileSync(posterMappingPath, 'utf-8'));
// 从日历中提取课程,并匹配作业海报
const compoundCourses = [];
const verticalCourses = [];
calendarData.forEach(day => {
// 复合技能阶段课程
if (day['复合技能阶段'] && day['复合技能阶段'].trim()) {
const courseName = day['复合技能阶段'].trim();
if (!compoundCourses.some(c => c.name === courseName)) {
compoundCourses.push({
id: compoundCourses.length + 1,
name: courseName,
level: 'completed',
imageUrl: posterMapping[courseName] || null,
unit: day['❌查询单元名称'] || ''
});
}
}
// 垂直方向课程
if (day['垂直方向阶段(方向二:商业活动策划)'] && day['垂直方向阶段(方向二:商业活动策划)'].trim()) {
const courseName = day['垂直方向阶段(方向二:商业活动策划)'].trim();
if (!verticalCourses.some(c => c.name === courseName)) {
verticalCourses.push({
id: verticalCourses.length + 1,
name: courseName,
level: 'completed',
imageUrl: posterMapping[courseName] || null,
unit: day['❌查询单元名称'] || ''
});
}
}
});
console.log('===== 从日历提取的课程数据 =====\n');
console.log('【复合技能阶段】');
console.log(`总课程数: ${compoundCourses.length}`);
console.log(`有海报的: ${compoundCourses.filter(c => c.imageUrl).length}`);
console.log(`无海报的: ${compoundCourses.filter(c => !c.imageUrl).length}`);
console.log('\n【垂直方向阶段】');
console.log(`总课程数: ${verticalCourses.length}`);
console.log(`有海报的: ${verticalCourses.filter(c => c.imageUrl).length}`);
console.log(`无海报的: ${verticalCourses.filter(c => !c.imageUrl).length}`);
console.log('\n【无海报的课程列表】');
const noImageCourses = [
...compoundCourses.filter(c => !c.imageUrl),
...verticalCourses.filter(c => !c.imageUrl)
];
noImageCourses.forEach(course => {
console.log(` - ${course.name}`);
});
// 保存处理后的数据
const outputData = {
compound: compoundCourses,
vertical: verticalCourses,
summary: {
compoundTotal: compoundCourses.length,
compoundWithImage: compoundCourses.filter(c => c.imageUrl).length,
verticalTotal: verticalCourses.length,
verticalWithImage: verticalCourses.filter(c => c.imageUrl).length
}
};
const outputPath = path.join(__dirname, 'homework_courses_with_images.json');
fs.writeFileSync(outputPath, JSON.stringify(outputData, null, 2), 'utf-8');
console.log(`\n处理后的数据已保存到: ${outputPath}`);