forked from JOJ/Joint-Teapot
		
	feat: max total score in scoreboard
This commit is contained in:
		
							parent
							
								
									2bc0a0a18d
								
							
						
					
					
						commit
						939c101eeb
					
				|  | @ -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, | ||||
|  |  | |||
|  | @ -9,7 +9,11 @@ from joint_teapot.utils.logger import logger | |||
| 
 | ||||
| 
 | ||||
| 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( | ||||
|  | @ -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 | ||||
|  | @ -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")])) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user