곰픽 채점 수정버전 진행중 [1-6]

This commit is contained in:
2025-06-20 17:47:47 +09:00
parent 425e9876fe
commit 6f5d1c20f7
10 changed files with 1695 additions and 69 deletions

View File

@@ -13,9 +13,9 @@ const { userInfo } = require('os');
const { get } = require('http');
const todayDate = getToday();
const examRound = '2505';
const dic_or_dpi = 'DIC'
// const dic_or_dpi = 'DPI'
const examRound = '2504';
// const dic_or_dpi = 'DIC'
const dic_or_dpi = 'DPI'
const examTypes = [
// 'A',
'B',
@@ -24,8 +24,8 @@ const examTypes = [
];
// testMode가 true일 경우 TEST 폴더에 있는 답안 파일을 읽어옴
// const testMode = false;
const testMode = true;
const testMode = false;
// const testMode = true;
const outputExcelFiles = [];
@@ -188,15 +188,24 @@ function getGmepScore(gmepData, scoringJson, index) {
}
else if (Array.isArray(right) && Array.isArray(user)) {
if (right.length === user.length) {
if (type === 'number[]' || (type === 'auto' && typeof right[0] === 'number')) {
if
(type === 'number[]' ||
(type === 'auto' && typeof right[0] === 'number')) {
isEqual = right.every((val, idx) => Math.abs(val - user[idx]) <= tolerance);
} else if (type === 'string[]' || (type === 'auto' && typeof right[0] === 'string')) {
}
else if
(type === 'string[]' ||
(type === 'auto' && typeof right[0] === 'string')) {
isEqual = right.every((val, idx) => val === user[idx]);
}
}
} else if (type === 'object' || (type === 'auto' && typeof right === 'object' && typeof user === 'object')) {
}
else if
(type === 'object' ||
(type === 'auto' && typeof right === 'object' && typeof user === 'object')) {
isEqual = JSON.stringify(user) === JSON.stringify(right);
} else {
}
else {
isEqual = user == right; // primitive 비교
}
@@ -210,6 +219,7 @@ function getGmepScore(gmepData, scoringJson, index) {
}
scoringResult[key] = score;
// totalScore += score;
return score;
}
@@ -246,6 +256,8 @@ function getGmepScore(gmepData, scoringJson, index) {
// 채점기준표 문항별 분류
for (const key in scoringData) {
// XML <CRClip> 요소의 index값을 구함
function getCRClipIndex(mediaName) {
// CRClipArr/CRClip 요소의 Path속성 리스트를 구함
// 모션 클립 이미지도 고려해 처리
@@ -371,9 +383,6 @@ function getGmepScore(gmepData, scoringJson, index) {
}
let ele = scoringData[key].ele;
let ele2 = scoringData[key].ele2;
let ele3 = scoringData[key].ele3;
let existEle = scoringData[key].existEle;
const rightAnswer = scoringData[key].value;
const point = scoringData[key].point;
const type = scoringData[key].type ? scoringData[key].type : '';
@@ -389,23 +398,7 @@ function getGmepScore(gmepData, scoringJson, index) {
console.log(`example number: ${key}`)
// xpath 전처리
const trackClipNode = getTrackClipNode(gmepXmlDoc, type, videoStartTime, openingStartTime);
const subtitleIndex = trackClipNode ? parseInt(trackClipNode.getAttribute('ClipIndex'), 10) + 1 : null;
const textClipIndex = getTextClipIndex(gmepXmlDoc, search);
const subtitleOrder = type.includes('opening') ? 1 : type.includes('video') ? 2 : null;
const startTime = type === 'video' ? videoStartTime : type === 'opening' ? openingStartTime : null;
let xpathList = [ele, ele2, ele3, existEle];
xpathList = xpathList.map(e => e ? e
.replace(/{subtitleIndex}/g, subtitleIndex)
.replace(/{subtitleOrder}/g, subtitleOrder)
.replace(/{startTime}/g, startTime)
.replace(/{textClipIndex}/g, textClipIndex)
.replace(/{image}/g, image)
: e
);
[ele, ele2, ele3, existEle] = xpathList;
// search 값이 undefined 아니면 ele의 {search}부분을 search로 치환
/**
@@ -420,9 +413,10 @@ function getGmepScore(gmepData, scoringJson, index) {
if (result !== null) {
result = result.replace(/"/g, "'");
search = result;
[ele, ele2, ele3, existEle] = [ele, ele2, ele3, existEle].map(e => e?.replace(/{search}/g, search));
} else {
[ele, ele2, ele3] = [ele, ele2, ele3].map(e => e?.includes('{search}') ? null : e);
ele = ele?.replace(/{search}/g, search);
}
else {
ele = ele?.includes('{search}') ? null : ele;
}
}
@@ -432,11 +426,7 @@ function getGmepScore(gmepData, scoringJson, index) {
continue;
}
if (type == "boolean") {
scoringResult[key] = result.length > 0 ? point : 0;
}
else if (type == "oneAnswer") {
if (type == "oneAnswer") {
const result = xpath.select1(ele, gmepXmlDoc);
// userAnswer = {};
@@ -668,7 +658,7 @@ function getGmepScore(gmepData, scoringJson, index) {
const fadeoutEffect = xpath.select1(xpathQuery, gmepXmlDoc);
if (!fadeoutEffect) {
userAnswer = null;
}
}
else {
const attributes = fadeoutEffect.attributes;
const id = attributes.getNamedItem('ID').value;
@@ -697,6 +687,12 @@ function getGmepScore(gmepData, scoringJson, index) {
const indexByStartTime = getCilpIndexByStartTime(time);
// 1, 2, 3순으로 자막을 찾음
// 권수혁 김재은 27, 28, 29 문제 오답 0점 채점 안되는 부분 처리
// 06.18(목) 시작
const index = indexByText ?? indexByOrder ?? indexByStartTime;
if (index != null) {
// 자막 시작시간 [2-10] [2-28]
@@ -780,6 +776,7 @@ function getGmepScore(gmepData, scoringJson, index) {
}
else {
userAnswer = null;
totalScore += compareAndScore(userAnswer, rightAnswer, point, key, scoringResult);
}
}