곰픽 size를 구하는 부분 변경

This commit is contained in:
2025-04-11 17:29:41 +09:00
parent 1afe0cadda
commit 60154db66f
7 changed files with 58 additions and 31 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -491,8 +491,7 @@
},
"8": {
"type": "size",
"posX": "//Layer//op_points[Item]/Item[last()]/X/@value - //Layer//op_points[Item]/Item[1]/X/@value",
"posY": "//Layer//op_points[Item]/Item[last()]/Y/@value - //Layer//op_points[Item]/Item[1]/Y/@value",
"ele": "//Layer//op_points",
"value": {
"width": 130,
"height": 80
@@ -545,7 +544,9 @@
"desc": "배경색 문항은 채점 불가"
},
"3": {
"ele": "//Layer[contains(Name/@value, 'Layer 2')][MaskOpType/@value='Layering']",
"type": "isExist",
"ele": "//Layer/MaskOpType/@value",
"value": "Layering",
"point": 6
},
"4": {
@@ -554,14 +555,14 @@
"desc": "가로방향 흐릿하게 문항은 채점 불가"
},
"5": {
"ele": "//Layer[contains(Name/@value, 'Layer 3')]//shape_type/@value",
"answer": "ROUNDED_RECTANGLE",
"type": "isExist",
"ele": "//Layer//shape_type/@value",
"value": "ROUNDED_RECTANGLE",
"point": 3
},
"6": {
"type": "size",
"posX": "//Layer[contains(Name/@value, 'Layer 3')]//op_points[Item]/Item[last()]/X/@value - //Layer[contains(Name/@value, 'Layer 3')]//op_points[Item]/Item[1]/X/@value",
"posY": "//Layer[contains(Name/@value, 'Layer 3')]//op_points[Item]/Item[last()]/Y/@value - //Layer[contains(Name/@value, 'Layer 3')]//op_points[Item]/Item[1]/Y/@value",
"ele": "//Layer//op_points",
"value": {
"width": 370,
"height": 60
@@ -571,6 +572,7 @@
},
"7": {
"type": "gradient",
"ele": "//Layer/Shapes/shape/*[starts-with(name(), 'gradiant')]",
"startColor": "//Layer[contains(Name/@value, 'Layer 3')]//gradient_start_color/@value",
"endColor": "//Layer[contains(Name/@value, 'Layer 3')]//gradient_end_color/@value",
"value": {
@@ -635,8 +637,7 @@
},
"17": {
"type": "size",
"posX": "//Layer[contains(Name/@value, 'Layer 5')]//op_points[Item]/Item[last()]/X/@value - //Layer[contains(Name/@value, 'Layer 5')]//op_points[Item]/Item[1]/X/@value",
"posY": "//Layer[contains(Name/@value, 'Layer 5')]//op_points[Item]/Item[last()]/Y/@value - //Layer[contains(Name/@value, 'Layer 5')]//op_points[Item]/Item[1]/Y/@value",
"ele": "//Layer//op_points",
"value": {
"width": 150,
"height": 150

View File

@@ -144,6 +144,7 @@ function getGpdpScore(gpdpData, scoringJson, index) {
const items = xpath.select(ele, gpdpXmlDoc);
let matched = false;
// 각 Item 요소별 이름과 속성값을 구하고 정답과 비교
for (const item of items) {
const name = xpath.select1('Name/@value', item)?.value;
@@ -294,37 +295,62 @@ function getGpdpScore(gpdpData, scoringJson, index) {
}
}
else if (type == "size") {
let posX = scoringData[key].posX;
let posY = scoringData[key].posY;
const items = xpath.select(ele, gpdpXmlDoc);
let matched = false;
let answerWidth = rightAnswer["width"];
let answerHeight = rightAnswer["height"];
// 각 Item 요소별 x,y 좌표 시작점과 끝점의 거리를 계산해 정답과 비교
for (const item of items) {
const x1 = Number(xpath.select1('Item[1]/X/@value', item)?.value);
const x2 = Number(xpath.select1('Item[last()]/X/@value', item)?.value);
const y1 = Number(xpath.select1('Item[1]/Y/@value', item)?.value);
const y2 = Number(xpath.select1('Item[last()]/Y/@value', item)?.value);
let width = xpath.select(posX, gpdpXmlDoc);
let height = xpath.select(posY, gpdpXmlDoc);
width = Math.round(width);
height = Math.round(height);
const width = Math.round(Math.abs(x2 - x1));
const height = Math.round(Math.abs(y2 - y1));
console.log(`width:${answerWidth},${width}, height: ${answerHeight},${height}`);
if (answerWidth === width && answerHeight === height) {
if ( width === rightAnswer["width"] && height === rightAnswer["height"]) {
totalScore += point;
scoringResult[key] = point;
console.log("same size");
matched = true;
console.log("✅ 정답 일치:", rightAnswer);
break;
}
else {
}
if (!matched) {
scoringResult[key] = 0;
console.log("different size");
console.log("❌ 정답 없음:", rightAnswer);
}
// let posX = scoringData[key].posX;
// let posY = scoringData[key].posY;
// let answerWidth = rightAnswer["width"];
// let answerHeight = rightAnswer["height"];
// let width = xpath.select(posX, gpdpXmlDoc);
// let height = xpath.select(posY, gpdpXmlDoc);
// width = Math.round(width);
// height = Math.round(height);
// console.log(`width:${answerWidth},${width}, height: ${answerHeight},${height}`);
// if (answerWidth === width && answerHeight === height) {
// totalScore += point;
// scoringResult[key] = point;
// console.log("same size");
// }
// else {
// scoringResult[key] = 0;
// console.log("different size");
// }
}
else if (type == "gradient") {
let startColor = scoringData[key].startColor;
let endColor = scoringData[key].endColor;
let getStartColorXpath = scoringData[key].startColor;
let getEndColorXpath = scoringData[key].endColor;
let answerStartColor = rightAnswer["startColor"];
let answerEndColor = rightAnswer["endColor"];
let start = xpath.select(startColor, gpdpXmlDoc);
let end = xpath.select(endColor, gpdpXmlDoc);
let startColor = xpath.select1(getStartColorXpath, gpdpXmlDoc)?.value;
let endColor = xpath.select1(getEndColorXpath, gpdpXmlDoc)?.value;
// console.log(start[0].value, end[0].value);
if (start.length == 0 || end.length == 0) {

View File

@@ -13,8 +13,8 @@ const todayDate = getToday();
const examRound = '0000';
const examTypes = [
// 'A',
'B',
'A',
// 'B',
// 'C',
// 'D'
];

View File

@@ -1 +1 @@
[{"kind":2,"language":"xpath","value":"//Layer[Name[@value='Tracking']]/Effects/Item/Name/@value"}]
[{"kind":2,"language":"xpath","value":"//Layer[Name[@value='Tracking']]/Effects/Item/Name/@value"},{"kind":2,"language":"xpath","value":"//Layer//op_points"}]