곰픽 문제1 채점 수정완료
This commit is contained in:
@@ -503,15 +503,16 @@
|
|||||||
"value": {
|
"value": {
|
||||||
"name": "세피아",
|
"name": "세피아",
|
||||||
"option": {
|
"option": {
|
||||||
"U":"75",
|
"U": "75",
|
||||||
"V":"150"
|
"V": "150"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"point": 5,
|
"point": 5,
|
||||||
"desc": "Flower 레이어의 효과 체크"
|
"desc": "Flower 레이어의 효과 체크"
|
||||||
},
|
},
|
||||||
"5": {
|
"5": {
|
||||||
"ele": "none",
|
"type": "none",
|
||||||
|
"ele": "",
|
||||||
"point": 6,
|
"point": 6,
|
||||||
"desc": "올가미 도구/이미지 문항은 채점 불가"
|
"desc": "올가미 도구/이미지 문항은 채점 불가"
|
||||||
},
|
},
|
||||||
@@ -523,14 +524,14 @@
|
|||||||
"desc": "세피아 효과가 있는지 여부 체크"
|
"desc": "세피아 효과가 있는지 여부 체크"
|
||||||
},
|
},
|
||||||
"7": {
|
"7": {
|
||||||
"type": "exact",
|
"type": "exists",
|
||||||
"ele": "//Layer/Shapes/Shape/shape_type/@value",
|
"ele": "//Layer/Shapes/Shape/shape_type/@value",
|
||||||
"value": "ELLIPSE",
|
"value": "ELLIPSE",
|
||||||
"point": 3,
|
"point": 3,
|
||||||
"desc": "레이어 쉐이프 타입이 타원인지 체크"
|
"desc": "레이어 쉐이프 타입이 타원인지 체크"
|
||||||
},
|
},
|
||||||
"8": {
|
"8": {
|
||||||
"type": "size",
|
"type": "shape.size",
|
||||||
"ele": "//Layer//op_points",
|
"ele": "//Layer//op_points",
|
||||||
"value": {
|
"value": {
|
||||||
"width": 120,
|
"width": 120,
|
||||||
@@ -540,21 +541,20 @@
|
|||||||
"desc": "레이어 쉐이프 X, Y 좌표를 가지고 너비, 높이 계산하여 정답 채점"
|
"desc": "레이어 쉐이프 X, Y 좌표를 가지고 너비, 높이 계산하여 정답 채점"
|
||||||
},
|
},
|
||||||
"9": {
|
"9": {
|
||||||
"type": "color",
|
"type": "shape.color",
|
||||||
"ele": "//Layer//Shape[contains(draw_type/@value, 'Interior')]/secondary_color/@value",
|
"ele": "//Layer//Shape[contains(draw_type/@value, 'Interior')]/secondary_color/@value",
|
||||||
"value": "7097bb",
|
"value": "7097BB",
|
||||||
"point": 6,
|
"point": 6,
|
||||||
"desc": "색상 코드 비교 시 소문자로 입력할 것"
|
"desc": ""
|
||||||
},
|
},
|
||||||
"10": {
|
"10": {
|
||||||
"type": "multiValue",
|
"type": "layer.blend.opacity",
|
||||||
"ele": "//Layer/BlendOp/@value | //Layer/Opacity/@value",
|
"ele": "//Layer",
|
||||||
"value": [
|
"value": {
|
||||||
"반사",
|
"BlendOp": "반사",
|
||||||
"80"
|
"Opacity": "80"
|
||||||
],
|
},
|
||||||
"point": 6,
|
"point": 6
|
||||||
"desc": "혼합모드(색 회피율, 불투명도 : 80)"
|
|
||||||
},
|
},
|
||||||
"11": {
|
"11": {
|
||||||
"ele": "none",
|
"ele": "none",
|
||||||
|
|||||||
139
gpdpScoring.js
139
gpdpScoring.js
@@ -278,9 +278,69 @@ function getGpdpScore(gpdpData, scoringJson, index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// [1-6] 세피아
|
// [1-6][1-7]
|
||||||
else if (type === "sepia.Exists") {
|
else if (type === "exists") {
|
||||||
|
const existsValues = xpath.select(ele, gpdpXmlDoc);
|
||||||
|
|
||||||
|
for (const v of existsValues) {
|
||||||
|
if (v.value === rightAnswer) {
|
||||||
|
userAnswer = v.value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
totalScore = compareAndScore(userAnswer, rightAnswer, point, key, scoringResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
else if (type === "shape.size") {
|
||||||
|
const items = xpath.select(ele, gpdpXmlDoc);
|
||||||
|
|
||||||
|
// 각 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);
|
||||||
|
|
||||||
|
const width = Math.round(Math.abs(x2 - x1));
|
||||||
|
const height = Math.round(Math.abs(y2 - y1));
|
||||||
|
|
||||||
|
userAnswer = {
|
||||||
|
width: width,
|
||||||
|
height: height,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
totalScore = compareAndScore(userAnswer, rightAnswer, point, key, scoringResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
// [1-8]
|
||||||
|
else if (type === "shape.color") {
|
||||||
|
const items = xpath.select(ele, gpdpXmlDoc);
|
||||||
|
|
||||||
|
for (const item of items) {
|
||||||
|
const color = parseColorToHex(item.value);
|
||||||
|
userAnswer = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
const normalizedRA = rightAnswer.toLowerCase?.();
|
||||||
|
totalScore = compareAndScore(userAnswer, normalizedRA, point, key, scoringResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (type === 'layer.blend.opacity') {
|
||||||
|
const layers = xpath.select(ele, gpdpXmlDoc);
|
||||||
|
|
||||||
|
for (const layer of layers) {
|
||||||
|
const blendop = xpath.select1('BlendOp/@value', layer).value;
|
||||||
|
const opacity = xpath.select1('Opacity/@value', layer).value;
|
||||||
|
|
||||||
|
userAnswer = {
|
||||||
|
BlendOp: blendop,
|
||||||
|
Opacity: opacity,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
totalScore = compareAndScore(userAnswer, rightAnswer, point, key, scoringResult);
|
||||||
}
|
}
|
||||||
else if (type == "boolean") {
|
else if (type == "boolean") {
|
||||||
const items = xpath.select(ele, gpdpXmlDoc);
|
const items = xpath.select(ele, gpdpXmlDoc);
|
||||||
@@ -354,28 +414,6 @@ function getGpdpScore(gpdpData, scoringJson, index) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == "exists") {
|
|
||||||
const result = xpath.select(ele, gpdpXmlDoc);
|
|
||||||
const isMatch = result.some(v => {
|
|
||||||
|
|
||||||
// 문자열 앞뒤 공백 제거
|
|
||||||
v.value = typeof v.value === 'string' ? v.value.trim() : v.value
|
|
||||||
rightAnswer = typeof rightAnswer === 'string' ? rightAnswer.trim() : rightAnswer
|
|
||||||
|
|
||||||
if (v.value === rightAnswer) {
|
|
||||||
totalScore += point;
|
|
||||||
scoringResult[key] = point;
|
|
||||||
console.log(`✅ 정답 일치 > [작성답안]:${v.value} [정답]:${rightAnswer}`);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!isMatch) {
|
|
||||||
scoringResult[key] = 0;
|
|
||||||
console.log(`❌ 정답 없음 > [정답]:${rightAnswer}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (type == "exact") {
|
else if (type == "exact") {
|
||||||
let result = xpath.select(ele, gpdpXmlDoc);
|
let result = xpath.select(ele, gpdpXmlDoc);
|
||||||
@@ -393,27 +431,6 @@ function getGpdpScore(gpdpData, scoringJson, index) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (type === "color") {
|
|
||||||
const items = xpath.select(ele, gpdpXmlDoc);
|
|
||||||
let matched = false;
|
|
||||||
|
|
||||||
for (const item of items) {
|
|
||||||
const color = parseColorToHex(item.value);
|
|
||||||
// console.log("🚀 ~ getGpdpScore ~ color:", color);
|
|
||||||
// console.log("🚀 ~ getGpdpScore ~ rightColor:", rightAnswer);
|
|
||||||
if (color === rightAnswer) {
|
|
||||||
totalScore += point;
|
|
||||||
scoringResult[key] = point;
|
|
||||||
matched = true;
|
|
||||||
console.log(`✅ 정답 일치 > [작성답안]:${color} [정답]:${rightAnswer}`);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!matched) {
|
|
||||||
scoringResult[key] = 0;
|
|
||||||
console.log(`❌ 정답 없음 > [정답]:${rightAnswer}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (type == "multi") {
|
else if (type == "multi") {
|
||||||
try {
|
try {
|
||||||
@@ -460,33 +477,6 @@ function getGpdpScore(gpdpData, scoringJson, index) {
|
|||||||
scoringResult[key] = 0;
|
scoringResult[key] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == "size") {
|
|
||||||
const items = xpath.select(ele, gpdpXmlDoc);
|
|
||||||
let matched = false;
|
|
||||||
|
|
||||||
// 각 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);
|
|
||||||
|
|
||||||
const width = Math.round(Math.abs(x2 - x1));
|
|
||||||
const height = Math.round(Math.abs(y2 - y1));
|
|
||||||
|
|
||||||
if (width === rightAnswer["width"] && height === rightAnswer["height"]) {
|
|
||||||
totalScore += point;
|
|
||||||
scoringResult[key] = point;
|
|
||||||
matched = true;
|
|
||||||
console.log("✅ 정답 일치:", rightAnswer);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!matched) {
|
|
||||||
scoringResult[key] = 0;
|
|
||||||
console.log("❌ 정답 없음:", rightAnswer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (type == "gradient") {
|
else if (type == "gradient") {
|
||||||
const items = xpath.select(ele, gpdpXmlDoc);
|
const items = xpath.select(ele, gpdpXmlDoc);
|
||||||
const startColorXpath = scoringData[key].startColor;
|
const startColorXpath = scoringData[key].startColor;
|
||||||
@@ -553,11 +543,6 @@ function getGpdpScore(gpdpData, scoringJson, index) {
|
|||||||
const result2 = null;
|
const result2 = null;
|
||||||
let isCheck = false;
|
let isCheck = false;
|
||||||
|
|
||||||
if (ele === 'none') {
|
|
||||||
scoringResult[key] = "확인필요";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result.length == 0) {
|
if (result.length == 0) {
|
||||||
isCheck = true;
|
isCheck = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user