Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions api/judging/judging_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def submit_judge_score(judge_id: str, team_id: str, event_id: str,
required_fields = ['scopeImpact', 'scopeComplexity',
'documentationCode', 'documentationEase',
'polishWorkRemaining', 'polishCanUseToday',
'securityData', 'securityRole']
'securityData', 'securityRole'] # We don't include accessibility here as it's optional and a special category prize

for field in required_fields:
if field not in scores_data:
Expand Down Expand Up @@ -492,10 +492,14 @@ def format_team_for_judge(team: Dict, score_lookup: Dict = None, nonprofit_id: s
if github_links and len(github_links) > 0:
github_url = github_links[0].get('link', '')

# Get score info for this team
score_key = f"{team_id}_round1"
score_obj = score_lookup.get(score_key) if score_key in score_lookup else None

return {
"id": team_id,
"name": team.get('name', ''),
"problem_statement": {
"problem_statement": {
"nonprofit": nonprofit_name,
"nonprofit_id": nonprofit_id
},
Expand All @@ -505,9 +509,12 @@ def format_team_for_judge(team: Dict, score_lookup: Dict = None, nonprofit_id: s
"slack_channel": team.get('slack_channel', ''),
"video_url": team.get('video_url', ''),
"demo_time": None, # Will be overridden for round2
"judged": f"{team_id}_round1" in score_lookup,
"score": (score_lookup.get(f"{team_id}_round1").total_score
if f"{team_id}_round1" in score_lookup else None)
"judged": score_obj is not None,
"score": score_obj.total_score if score_obj else None,
"specialCategoryScores":
{
"accessibility": score_obj.accessibility if score_obj else None
}
}


Expand Down
4 changes: 4 additions & 0 deletions api/teams/teams_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ def edit_team(json):
"devpost_link": "devpost_link",
}

# If this is the first time setting devpost_link, set devpost_link_submitted date
if "devpost_link" in json and "devpost_link" not in team_data:
update_data["devpost_link_submitted"] = datetime.now().isoformat()

for db_field, json_field in field_mappings.items():
if json_field in json:
update_data[db_field] = json[json_field]
Expand Down
20 changes: 14 additions & 6 deletions model/judge_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(self):
self.polish_can_use_today = None # 1-5 points
self.security_data = None # 1-5 points
self.security_role = None # 1-5 points
self.accessibility = None # 1-5 points
self.total_score = None # Calculated from individual scores
self.feedback = '' # Optional feedback from judge
self.is_draft = False
Expand All @@ -39,14 +40,15 @@ def deserialize(cls, d):
score.polish_can_use_today = d.get('polish_can_use_today')
score.security_data = d.get('security_data')
score.security_role = d.get('security_role')
score.accessibility = d.get('accessibility')
score.total_score = d.get('total_score')
score.is_draft = d.get('is_draft', False)
score.feedback = d.get('feedback', '')
score.submitted_at = d.get('submitted_at')
score.created_at = d.get('created_at')
score.updated_at = d.get('updated_at')
return score

def serialize(self):
d = {}
props = dir(self)
Expand All @@ -58,7 +60,8 @@ def serialize(self):
return d

def calculate_total_score(self):
"""Calculate total score from individual criteria scores"""
"""Calculate total score from individual criteria scores.
Note: accessibility is excluded as it's a special category prize."""
scores = [
self.scope_impact,
self.scope_complexity,
Expand All @@ -68,12 +71,13 @@ def calculate_total_score(self):
self.polish_can_use_today,
self.security_data,
self.security_role
# accessibility is intentionally excluded from total score
]
# Only calculate if all scores are present

# Only calculate if all required scores are present
if all(score is not None for score in scores):
self.total_score = sum(scores)

return self.total_score

def to_api_format(self):
Expand All @@ -87,6 +91,7 @@ def to_api_format(self):
"polishCanUseToday": self.polish_can_use_today,
"securityData": self.security_data,
"securityRole": self.security_role,
"accessibility": self.accessibility,
"total": self.total_score
}

Expand All @@ -102,8 +107,11 @@ def from_api_format(cls, api_scores):
score.polish_can_use_today = api_scores.get('polishCanUseToday')
score.security_data = api_scores.get('securityData')
score.security_role = api_scores.get('securityRole')
score.accessibility = api_scores.get('accessibility')
score.total_score = api_scores.get('total')
return score

def __str__(self):
return f"JudgeScore(id={self.id}, judge_id={self.judge_id}, team_id={self.team_id}, event_id={self.event_id}, round={self.round}, total={self.total_score})"
return (f"JudgeScore(id={self.id}, judge_id={self.judge_id}, "
f"team_id={self.team_id}, event_id={self.event_id}, "
f"round={self.round}, total={self.total_score})")