0508 요청사항 수정 (gmep파일이 아닌경우 0점처리 + gmep파일이 없는 경우 더미 0점값 채우는 과정 추가)

This commit is contained in:
2025-05-08 18:11:21 +09:00
parent 5ee5330e13
commit 56e38caa0f
8 changed files with 80 additions and 16 deletions

View File

@@ -12,8 +12,8 @@ const getToday = require('./getToday.js');
const todayDate = getToday();
const examRound = '2504';
// const dic_or_dpi = 'DIC'
const dic_or_dpi = 'DPI'
const dic_or_dpi = 'DIC'
// const dic_or_dpi = 'DPI'
const examTypes = [
// 'A',
'B',
@@ -63,13 +63,14 @@ examTypes.forEach(type => {
// 교육용 프로젝프로 생성시 gmdp확장자로 생성됨
// 두 경우 모두 처리
const gmepFile = fs.readdirSync(studentDir).filter(
file => file.toLowerCase().endsWith('.gmep')
|| file.toLowerCase().endsWith('.gmdp')
file => file.toLowerCase().endsWith('.gmep')
// || file.toLowerCase().endsWith('.gmdp')
);
// 곰픽 파일 gpdp 파일 이거나 xml 파일
const gpdpFiles = fs.readdirSync(studentDir).filter(
file => file.toLowerCase().endsWith('.xml')
|| (file === null && (name + '.xml'))
);
// 학생 이름을 key로 하는 객체 생성
@@ -101,17 +102,30 @@ examTypes.forEach(type => {
scoringResult[index + 1] = getGpdpScore(xmlDocument, scoringJson, index + 4);
});
gmepFile.forEach((gmep, index) => {
const gmepPath = path.join('./', studentDir, gmep);
console.log(`Reading ${gmepPath}...`);
if (gmepFile.length === 0) {
// 곰믹스 채점 항목 갯수
const gmepItemCount = Object.keys(scoringJson[2]).length - 2;
// console.log("🚀 ~ gmepItemCount:", gmepItemCount)
const xmlString = fs.readFileSync(gmepPath, 'utf8');
// XML 문자열을 파싱하여 XML 문서 객체로 변환
const xmlDocument = new DOMParser().parseFromString(xmlString, 'application/xml');
// console.log('xmlDocument:', xmlDocument);
scoringResult[3] = {};
for (let i = 1; i <= gmepItemCount; i++) {
scoringResult[3][i] = 0;
}
scoringResult[3]['총점'] = 0;
}
else {
gmepFile.forEach((gmep, index) => {
const gmepPath = path.join('./', studentDir, gmep);
console.log(`Reading ${gmepPath}...`);
scoringResult[3] = getGmepScore(xmlDocument, scoringJson, 2);
});
const xmlString = fs.readFileSync(gmepPath, 'utf8');
// XML 문자열을 파싱하여 XML 문서 객체로 변환
const xmlDocument = new DOMParser().parseFromString(xmlString, 'application/xml');
// console.log('xmlDocument:', xmlDocument);
scoringResult[3] = getGmepScore(xmlDocument, scoringJson, 2);
});
}
scoringResultList.push(scoringResult);
});
@@ -144,8 +158,8 @@ examTypes.forEach(type => {
});
console.log('채점 결과');
outputExcelFiles.forEach( (outputFile, index) => {
console.log(`[${index+1}] : ${outputFile}`);
outputExcelFiles.forEach((outputFile, index) => {
console.log(`[${index + 1}] : ${outputFile}`);
});