psdExport.js 예외처리
This commit is contained in:
75
psdExport.js
75
psdExport.js
@@ -6,8 +6,7 @@ const path = require('path');
|
||||
const xpath = require('xpath');
|
||||
const { DOMParser } = require('xmldom');
|
||||
|
||||
|
||||
const sampleDir = './output/C/DIC';
|
||||
const sampleDir = './output/B/DIC';
|
||||
const students = fs.readdirSync(sampleDir);
|
||||
|
||||
// 기준표 파일 읽기
|
||||
@@ -323,50 +322,54 @@ function getScore(psdData, scoring, index) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
const result = jsonPath.query(psdTree, ele);
|
||||
console.log(`ele: ${ele}, value: ${value} result: ${result}`);
|
||||
if (result.length == 0) {
|
||||
gradingResult[key] = 0;
|
||||
continue;
|
||||
}
|
||||
if (type == "boolean") {
|
||||
try {
|
||||
const result = jsonPath.query(psdTree, ele);
|
||||
console.log(`ele: ${ele}, value: ${value} result: ${result}`);
|
||||
if (result.length == 0) {
|
||||
gradingResult[key] = 0;
|
||||
continue;
|
||||
}
|
||||
if (type == "boolean") {
|
||||
// console.log(`result ${result.length}`);
|
||||
|
||||
gradingResult[key] = result.length > 0 ? point : 0;
|
||||
}
|
||||
// value가 color code인 경우 R,G,B를 16진수로 변환하여 비교하고 같다면 점수 부여
|
||||
// value: "ffa200"
|
||||
// result: [255,162,0,255]
|
||||
// 255,162,0,255 -> ffa200
|
||||
else if (type == "color") {
|
||||
// console.log(`result ${result}`); // result 255,162,0,255
|
||||
const temp = result[0].slice(0, 3).join(','); // 255,162,0
|
||||
color = temp.split(',').map(v => parseInt(v).toString(16)).join(''); // ffa20
|
||||
// ffa20 -> ffa200
|
||||
if (color.length == 5) {
|
||||
color = color + '0';
|
||||
gradingResult[key] = result.length > 0 ? point : 0;
|
||||
}
|
||||
// value가 color code인 경우 R,G,B를 16진수로 변환하여 비교하고 같다면 점수 부여
|
||||
// value: "ffa200"
|
||||
// result: [255,162,0,255]
|
||||
// 255,162,0,255 -> ffa200
|
||||
else if (type == "color") {
|
||||
// console.log(`result ${result}`); // result 255,162,0,255
|
||||
const temp = result[0].slice(0, 3).join(','); // 255,162,0
|
||||
color = temp.split(',').map(v => parseInt(v).toString(16)).join(''); // ffa20
|
||||
// ffa20 -> ffa200
|
||||
if (color.length == 5) {
|
||||
color = color + '0';
|
||||
}
|
||||
|
||||
// console.log(`color: ${color}`);
|
||||
gradingResult[key] = result.length > 0 && value === color ? point : 0;
|
||||
}
|
||||
gradingResult[key] = result.length > 0 && value === color ? point : 0;
|
||||
}
|
||||
|
||||
|
||||
// type이 font인 경우 font의 이름만 추출하여 비교
|
||||
// value: "Arial"
|
||||
// result: ["Arial-BoldItalicMT"]
|
||||
else if (type == "font") {
|
||||
// type이 font인 경우 font의 이름만 추출하여 비교
|
||||
// value: "Arial"
|
||||
// result: ["Arial-BoldItalicMT"]
|
||||
else if (type == "font") {
|
||||
// console.log(`result ${result}`);
|
||||
const font = result[0].split('-')[0];
|
||||
const font = result[0].split('-')[0];
|
||||
// console.log(`font: ${font}`);
|
||||
gradingResult[key] = result.length > 0 && value === font ? point : 0;
|
||||
}
|
||||
gradingResult[key] = result.length > 0 && value === font ? point : 0;
|
||||
}
|
||||
|
||||
else if (result[0] === value) {
|
||||
gradingResult[key] = point;
|
||||
totalScore += point;
|
||||
} else {
|
||||
else if (result[0] === value) {
|
||||
gradingResult[key] = point;
|
||||
totalScore += point;
|
||||
} else {
|
||||
gradingResult[key] = 0;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error processing JSONPath query for ele: ${ele}`, error);
|
||||
gradingResult[key] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user