Skip to content

Commit

Permalink
feat: max total score in scoreboard
Browse files Browse the repository at this point in the history
  • Loading branch information
BoYanZh committed Nov 1, 2024
1 parent 2bc0a0a commit 939c101
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions joint_teapot/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ def joj3_all(
submitter,
os.path.join(repo_path, scoreboard_file_name),
exercise_name,
max_total_score,
)
tea.pot.git.add_commit(
repo_name,
Expand Down
13 changes: 9 additions & 4 deletions joint_teapot/utils/joj3.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@


def generate_scoreboard(
score_file_path: str, submitter: str, scoreboard_file_path: str, exercise_name: str
score_file_path: str,
submitter: str,
scoreboard_file_path: str,
exercise_name: str,
max_total_score: int = -1,
) -> None:
if not scoreboard_file_path.endswith(".csv"):
logger.error(
Expand Down Expand Up @@ -69,6 +73,8 @@ def generate_scoreboard(
for stage in stages:
for result in stage["results"]:
exercise_total_score += result["score"]
if max_total_score >= 0:
exercise_total_score = min(exercise_total_score, max_total_score)
submitter_row[columns.index(exercise_name)] = str(exercise_total_score)

total = 0
Expand All @@ -82,9 +88,8 @@ def generate_scoreboard(
submitter_row[columns.index("total")] = str(total)

now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
submitter_row[
columns.index("last_edit")
] = now # FIXME: Delete this in formal version
# FIXME: Delete this in formal version
submitter_row[columns.index("last_edit")] = now

# Sort data by total, from low to high
data.sort(key=lambda x: int(x[columns.index("total")]))
Expand Down

0 comments on commit 939c101

Please sign in to comment.