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

View File

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

View File

@@ -13,8 +13,8 @@ const todayDate = getToday();
const examRound = '0000'; const examRound = '0000';
const examTypes = [ const examTypes = [
// 'A', 'A',
'B', // 'B',
// 'C', // 'C',
// 'D' // '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"}]