2505회 수정사항 [2-3]문항 다단

This commit is contained in:
2025-06-09 18:01:35 +09:00
parent 5af870efe4
commit 23204b5398
4 changed files with 73 additions and 6 deletions

View File

@@ -770,7 +770,74 @@ class XMLScorer:
break
self.evaluate_answer(scoring, user_answer, right_answer, points, method="equal")
# 다단 확인 [2-3]문항
elif (category or "") == "TwoColumn":
has_section2 = root.xpath('//SECTION[2]')
if not has_section2:
# //P//COLDEF/@Count 속성이 시작하는 P태그 부터
# @Count 속성이 변한 P태그 이전인덱스 까지가 페이지 단수가 적용되어있는 구간
# 모든 <P> 요소 가져오기
p_elements = root.xpath('//P')
# 구간 결과를 저장할 리스트
sections = []
current_count = None
start_index = None
for i, p in enumerate(p_elements):
xml_index = i + 1 # XML 기준 1-based index
coldef = p.xpath('.//COLDEF')
if coldef:
# 다단 수(2단)
column_count = coldef[0].get('Count')
# 첫 번째 Count 발견 시 시작점 설정
if current_count is None:
current_count = column_count
start_index = i
# Count 값이 변경되었을 때 이전 구간을 저장
elif column_count != current_count:
sections.append((start_index, i - 1, current_count))
# 새 구간 시작
current_count = column_count
start_index = i
# 마지막 구간 저장
if current_count is not None and start_index is not None:
sections.append((start_index, len(p_elements) - 1, current_count))
# 결과 출력
for start, end, count in sections:
xml_start = start + 1 # XML 기준 1-based index
xml_end = end + 1
print(f"📄 {count}단 구간: P[{xml_start}] ~ P[{xml_end}]")
# PageBreak='true' 속성을 가진 P태그 인덱스
pagebreak_index = None
for i, p in enumerate(p_elements):
xml_index = i + 1
if p.get("PageBreak") == "true":
pagebreak_index = xml_index
break
print(f"📜PageBreak 인덱스 : P[{pagebreak_index}]", )
# 다단 2단 구간이 PageBreak='true'이후에도 속하는지 확인
# 다단 2단 속성이 2페이지 이후에도 속하는지 확인
for start, end, count in sections:
xml_start = start + 1
xml_end = end + 1
if count == '2' and xml_start <= pagebreak_index :
print("ㅇㅇ")
break
# 한자
elif (category or "") == "Hanja":
# 점수 계산
@@ -1135,8 +1202,8 @@ def main():
# 채점하고자 하는 유형은 주석 해제
exam_types = [
# 'A',
'B',
'A',
# 'B',
# 'C',
# 'D',
]