시작하기 클릭이 여러개 있는 경우 배열에 추가하고 정렬하도록 수정(2506 CAS 2급 채점 완료)

This commit is contained in:
2025-07-10 13:08:58 +09:00
parent 0fd9c9e8c0
commit 23946baccf
18 changed files with 22419 additions and 24 deletions

44
main.py
View File

@@ -7,8 +7,8 @@ import unicodedata # 상단에 import 추가
import re # 상단에 추가
# 파일 경로 설정
project_json_path = 'output/2503 CAT 3급 A형'
scoring_json_path = './2503 CAT 3급 A형.json'
project_json_path = './output/2506_CAS_2_A/'
scoring_json_path = './correct/2506_CAS_2_A.json'
# JSON 파일 읽기
def read_json(file_path):
@@ -49,10 +49,10 @@ def swap_script(origin):
return origin
# 스크립트 블록 분류를 위한 임시 저장소
run_button_block = None
run_button_blocks = []
key_press_blocks = []
clone_start_block = None
message_cast_block = None
message_cast_block = []
other_blocks = []
# 각 블록을 타입별로 분류
@@ -62,23 +62,23 @@ def swap_script(origin):
block_type = block[0].get("type")
# 기존 로직: run_button과 scene_start 처리
if (block_type == "when_run_button_click" or block_type == "when_scene_start") and i > 0:
print(f"swap script run button or scene start")
swap = origin[0]
origin[0] = origin[i]
origin[i] = swap
# # 기존 로직: run_button과 scene_start 처리
# if (block_type == "when_run_button_click" or block_type == "when_scene_start") and i > 0:
# print(f"swap script run button or scene start")
# swap = origin[0]
# origin[0] = origin[i]
# origin[i] = swap
# 기존 로직: clone_start와 message_cast 처리
elif (block_type == "when_clone_start" or block_type == "when_message_cast") and i > 0:
print(f"swap script clone start or msg cast")
swap = origin[1]
origin[1] = origin[i]
origin[i] = swap
# # 기존 로직: clone_start와 message_cast 처리
# elif (block_type == "when_clone_start" or block_type == "when_message_cast") and i > 0:
# print(f"swap script clone start or msg cast")
# swap = origin[1]
# origin[1] = origin[i]
# origin[i] = swap
# 새로운 로직: 키 이벤트 처리
if block_type == "when_run_button_click":
run_button_block = block
run_button_blocks.append(block)
elif block_type == "when_some_key_pressed":
# params[1]에서 키 값 확인 (49, 50, 51) 아스키코드 값이므로 필요하면 추가 가능
key_value = block[0].get("params")[1]
@@ -87,7 +87,7 @@ def swap_script(origin):
elif block_type == "when_clone_start":
clone_start_block = block
elif block_type == "when_message_cast":
message_cast_block = block
message_cast_block.append(block)
else:
other_blocks.append(block)
@@ -95,8 +95,8 @@ def swap_script(origin):
result = []
# 1. when_run_button_click 블록을 첫 번째로 추가
if run_button_block:
result.append(run_button_block)
if run_button_blocks:
result.extend(run_button_blocks)
# 2. when_some_key_pressed 블록들을 키 값 순서대로 정렬하여 추가
key_press_blocks.sort(key=lambda x: int(x[0]) if x[0] else 0)
@@ -106,7 +106,7 @@ def swap_script(origin):
if clone_start_block:
result.append(clone_start_block)
if message_cast_block:
result.append(message_cast_block)
result.extend(message_cast_block)
# 4. 나머지 블록 추가
result.extend(other_blocks)
@@ -259,7 +259,7 @@ def main():
try:
# 디렉토리 패스 내에 학생 이름만 뽑아서 엑셀 컬럼 명으로 추가
# output/cas-000040-이지원/temp/project.json
student_id = normalize_path(full_path.split('/')[2])
student_id = normalize_path(full_path.split('/')[3])
project_data = read_json(full_path)
points = process_project(project_data, scoring_data)
points.insert(0, student_id)