Files
teach_sys_Demo/compare_calendar_with_json.cjs

57 lines
2.6 KiB
JavaScript
Raw Normal View History

const fs = require('fs');
const path = require('path');
// 读取日历课程列表
const calendarListPath = path.join(__dirname, 'calendar_courses_list.json');
const calendarCourses = JSON.parse(fs.readFileSync(calendarListPath, 'utf-8'));
// 读取作业海报JSON
const posterPath = path.join(__dirname, '网页未导入数据/文旅产业/文旅_作业海报.json');
const posterData = JSON.parse(fs.readFileSync(posterPath, 'utf-8'));
const posterNames = posterData.map(d => d['课程名称']);
console.log('===== 日历课程 vs 作业海报数据对比 =====\n');
// 复合技能课程对比
console.log('【复合技能阶段】');
console.log(`日历中的课程数: ${calendarCourses.compound.length}`);
const compoundMatched = calendarCourses.compound.filter(name => posterNames.includes(name));
const compoundNotMatched = calendarCourses.compound.filter(name => !posterNames.includes(name));
console.log(`在作业海报中找到的: ${compoundMatched.length}`);
console.log(`未找到海报的: ${compoundNotMatched.length}`);
if (compoundNotMatched.length > 0) {
console.log('\n未找到海报的复合技能课程:');
compoundNotMatched.forEach(name => console.log(` - ${name}`));
}
// 垂直方向课程对比
console.log('\n\n【垂直方向阶段】');
console.log(`日历中的课程数: ${calendarCourses.vertical.length}`);
const verticalMatched = calendarCourses.vertical.filter(name => posterNames.includes(name));
const verticalNotMatched = calendarCourses.vertical.filter(name => !posterNames.includes(name));
console.log(`在作业海报中找到的: ${verticalMatched.length}`);
console.log(`未找到海报的: ${verticalNotMatched.length}`);
if (verticalNotMatched.length > 0) {
console.log('\n未找到海报的垂直方向课程:');
verticalNotMatched.forEach(name => console.log(` - ${name}`));
}
// 总计
console.log('\n\n===== 总计 =====');
console.log(`日历总课程数: ${calendarCourses.all.length}`);
console.log(`可匹配海报的: ${compoundMatched.length + verticalMatched.length}`);
console.log(`无海报的: ${compoundNotMatched.length + verticalNotMatched.length}`);
// 作业海报中未被使用的
const allCalendarCourses = [...calendarCourses.compound, ...calendarCourses.vertical];
const unusedPosters = posterNames.filter(name => !allCalendarCourses.includes(name));
const uniqueUnused = [...new Set(unusedPosters)];
console.log(`\n作业海报中有但日历未使用的: ${uniqueUnused.length}`);
if (uniqueUnused.length < 50) {
console.log('\n未被日历使用的海报课程:');
uniqueUnused.forEach(name => console.log(` - ${name}`));
}