v2 - 문제2 36문항

This commit is contained in:
2025-05-14 18:01:36 +09:00
parent 8c93c6d446
commit 872d5f6da6
5 changed files with 301 additions and 12 deletions

View File

@@ -343,7 +343,9 @@ class XMLScorer:
# Boolean 타입 정답인 경우
elif "Boolean" in (category or ""):
items = root.xpath(xpath)
user_answer = True if items else False
items2 = root.xpath(xpath2) if xpath2 else False
user_answer = bool( items or items2 )
self.evaluate_answer(scoring, user_answer, right_answer, points)
@@ -387,6 +389,12 @@ class XMLScorer:
font_id = root.xpath(f"//CHARSHAPE[@Id='{charshape_id[0]}']/FONTID/@Hangul")
font_name = root.xpath(f"//FONTFACE[@Lang='Hangul']/FONT[@Id='{font_id[0]}']/@Name")
user_answer = font_name[0]
# 폰트 "견고딕"과 "중고딕"은
# 한글프로그램 내부적으로 "한양견고딕", "한양중고딕"으로 저장되므로
# 수험자 답변에서 "한양"을 제거
if right_answer in ["견고딕", "중고딕"]:
user_answer = user_answer.replace("한양", "")
self.evaluate_answer(scoring, user_answer, right_answer, points, method="equal")
@@ -483,6 +491,31 @@ class XMLScorer:
self.evaluate_answer(scoring, user_answer, right_answer, points, method="equal")
elif "Hanja" in (category or ""):
word_list = criterion.get('word', [])
# 점수 계산
score = 0
max_score = points
# 부분점수 (최대점수에서 한자 갯수만큼 나눈 몫)
score_per_pair = max_score // len(word_list)
# 한자가 5개 고정일 경우
# score_per_pair = 2
for kor, chn in word_list:
# XPath 구문 구성 및 실행
exec_xpath = xpath.replace('{kor}', kor).replace('{chn}', chn)
matched = root.xpath(exec_xpath)
if matched:
score += score_per_pair
# 최대 점수 초과 방지
user_answer = min(score, max_score)
self.evaluate_answer(scoring, user_answer, right_answer, points, method="partial_score")
onePersonResult['score_results'].append(scoring)
print(f'scoring: {scoring}')