2507회 채점기준표
This commit is contained in:
@@ -4,6 +4,8 @@ const _ = require('lodash');
|
||||
|
||||
const findSimilarString = require('./findSimilarString');
|
||||
|
||||
module.exports = getGpdpScore;
|
||||
|
||||
function parseColorToHex(colorString) {
|
||||
// 정규식을 사용하여 B, G, R, A 값 추출
|
||||
const regex = /B:\s*(\d+),\s*G:\s*(\d+),\s*R:\s*(\d+),\s*A:\s*(\d+)/;
|
||||
@@ -26,8 +28,6 @@ function parseColorToHex(colorString) {
|
||||
return `${rHex}${gHex}${bHex}`;
|
||||
}
|
||||
|
||||
module.exports = getGpdpScore;
|
||||
|
||||
/**
|
||||
* /Document/Layers/Layer/Shapes/Shape/draw_type 속성값
|
||||
* > Interior: 내부 채우기 / Outline: 외곽선
|
||||
@@ -134,7 +134,7 @@ function getGpdpScore(gpdpData, scoringJson, index) {
|
||||
|
||||
// 채점기준표 문항별 분류
|
||||
for (const key in scoringData) {
|
||||
console.log(`[❔]문제번호 : [${index}-${key}]`)
|
||||
console.log(`❔❔ 문제번호 : [${index}-${key}]`)
|
||||
|
||||
let ele = scoringData[key].ele;
|
||||
let ele2 = scoringData[key].ele2;
|
||||
@@ -174,7 +174,7 @@ function getGpdpScore(gpdpData, scoringJson, index) {
|
||||
}
|
||||
|
||||
if (type === "none") {
|
||||
console.log("❌ 채점하지 않음");
|
||||
console.log("⚠️ 채점하지 않음");
|
||||
scoringResult[key] = "확인필요";
|
||||
continue;
|
||||
}
|
||||
@@ -379,48 +379,58 @@ function getGpdpScore(gpdpData, scoringJson, index) {
|
||||
let normalizedAnswer = null;
|
||||
let isMatched = false;
|
||||
|
||||
const isGradient = type.includes("gradient");
|
||||
const isSingleColor =
|
||||
type.includes("shape") || type.includes("text") || type.includes("clipping");
|
||||
|
||||
// 정답 색상 정규화
|
||||
if (isGradient) {
|
||||
normalizedAnswer = {
|
||||
startColor: rightAnswer.startColor.toLowerCase(),
|
||||
endColor: rightAnswer.endColor.toLowerCase(),
|
||||
};
|
||||
} else if (isSingleColor) {
|
||||
normalizedAnswer = rightAnswer.toLowerCase?.();
|
||||
}
|
||||
|
||||
// 각 항목 비교
|
||||
for (const item of items) {
|
||||
if (type.includes('gradient')) {
|
||||
// 그라데이션 컬러의 채점
|
||||
if (isGradient) {
|
||||
// 시작점과 끝점의 컬러를 구할 xpath구문
|
||||
const startColorXpath = scoringData[key].startColor;
|
||||
const endColorXpath = scoringData[key].endColor;
|
||||
|
||||
const startColorRGB = xpath.select1(startColorXpath, item).value;
|
||||
const endColorRGB = xpath.select1(endColorXpath, item).value;
|
||||
// 해당 xpath를 이용 RGB값 추출
|
||||
const startColorRGB = xpath.select1(startColorXpath, item)?.value;
|
||||
const endColorRGB = xpath.select1(endColorXpath, item)?.value;
|
||||
|
||||
const startColor = parseColorToHex(startColorRGB);
|
||||
const endColor = parseColorToHex(endColorRGB);
|
||||
// RGB to HEX
|
||||
const userStartColor = parseColorToHex(startColorRGB);
|
||||
const userEndColor = parseColorToHex(endColorRGB);
|
||||
|
||||
userAnswer = {
|
||||
startColor: startColor,
|
||||
endColor: endColor,
|
||||
}
|
||||
startColor: userStartColor,
|
||||
endColor: userEndColor,
|
||||
};
|
||||
|
||||
// JSON파일에서 대문자로 입력된 경우 소문자로 변환
|
||||
normalizedAnswer = {
|
||||
startColor: rightAnswer.startColor.toLowerCase(),
|
||||
endColor: rightAnswer.endColor.toLowerCase(),
|
||||
}
|
||||
|
||||
// 하나라도 일치하면 정답
|
||||
if (JSON.stringify(userAnswer) == JSON.stringify(normalizedAnswer)) {
|
||||
if (JSON.stringify(userAnswer) === JSON.stringify(normalizedAnswer)) {
|
||||
isMatched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// else {
|
||||
else if (type.includes('shape') || type.includes('text') || type.includes('clipping')) {
|
||||
if (isSingleColor) {
|
||||
const color = parseColorToHex(item.value);
|
||||
userAnswer = color;
|
||||
normalizedAnswer = rightAnswer.toLowerCase?.();
|
||||
|
||||
// 하나라도 일치하면 정답
|
||||
if (userAnswer === normalizedAnswer) {
|
||||
isMatched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
totalScore += compareAndScore(userAnswer, normalizedAnswer, point, key, scoringResult);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user