51 lines
1.9 KiB
Python
51 lines
1.9 KiB
Python
import json
|
|
|
|
def load_json(file_path):
|
|
with open(file_path, 'r', encoding='utf-8') as file:
|
|
return json.load(file)
|
|
|
|
def compare_params(params1, params2):
|
|
if len(params1) != len(params2):
|
|
return False
|
|
for p1, p2 in zip(params1, params2):
|
|
if p1 != p2:
|
|
return False
|
|
return True
|
|
|
|
def calculate_points(project_data, scoring_data):
|
|
total_points = 0
|
|
for key, criteria in scoring_data.items():
|
|
ele = criteria['ele']
|
|
arg = criteria['arg']
|
|
value = criteria['value']
|
|
|
|
|
|
if ele == "scenes":
|
|
for scene in project_data['scenes']:
|
|
if scene.get(arg) == value:
|
|
points = criteria['points']
|
|
total_points += points
|
|
break
|
|
elif ele == "objects":
|
|
for obj in project_data['objects']:
|
|
if obj.get(arg) == value:
|
|
if 'script' in criteria:
|
|
for script_criteria in criteria['script']:
|
|
for script in json.loads(obj['script']):
|
|
if script['type'] == script_criteria['type']:
|
|
if 'params' in script_criteria:
|
|
if compare_params(script['params'], script_criteria['params']):
|
|
total_points += script_criteria['points']
|
|
else:
|
|
total_points += script_criteria['points']
|
|
return total_points
|
|
|
|
def main():
|
|
project_data = load_json(r'D:\project\Entry\Entry-Scoring\sample\제2506회 코딩활용능력 2급 A형 정답\temp\project.json')
|
|
scoring_data = load_json('scoring.json')
|
|
|
|
total_points = calculate_points(project_data, scoring_data)
|
|
print(f"Total Points: {total_points}")
|
|
|
|
if __name__ == "__main__":
|
|
main() |