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, |                     submitter, | ||||||
|                     os.path.join(repo_path, scoreboard_file_name), |                     os.path.join(repo_path, scoreboard_file_name), | ||||||
|                     exercise_name, |                     exercise_name, | ||||||
|  |                     max_total_score, | ||||||
|                 ) |                 ) | ||||||
|                 tea.pot.git.add_commit( |                 tea.pot.git.add_commit( | ||||||
|                     repo_name, |                     repo_name, | ||||||
|  |  | ||||||
|  | @ -9,7 +9,11 @@ from joint_teapot.utils.logger import logger | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def generate_scoreboard( | 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: | ) -> None: | ||||||
|     if not scoreboard_file_path.endswith(".csv"): |     if not scoreboard_file_path.endswith(".csv"): | ||||||
|         logger.error( |         logger.error( | ||||||
|  | @ -69,6 +73,8 @@ def generate_scoreboard( | ||||||
|     for stage in stages: |     for stage in stages: | ||||||
|         for result in stage["results"]: |         for result in stage["results"]: | ||||||
|             exercise_total_score += result["score"] |             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) |     submitter_row[columns.index(exercise_name)] = str(exercise_total_score) | ||||||
| 
 | 
 | ||||||
|     total = 0 |     total = 0 | ||||||
|  | @ -82,9 +88,8 @@ def generate_scoreboard( | ||||||
|     submitter_row[columns.index("total")] = str(total) |     submitter_row[columns.index("total")] = str(total) | ||||||
| 
 | 
 | ||||||
|     now = datetime.now().strftime("%Y-%m-%d %H:%M:%S") |     now = datetime.now().strftime("%Y-%m-%d %H:%M:%S") | ||||||
|     submitter_row[ |     # FIXME: Delete this in formal version | ||||||
|         columns.index("last_edit") |     submitter_row[columns.index("last_edit")] = now | ||||||
|     ] = now  # FIXME: Delete this in formal version |  | ||||||
| 
 | 
 | ||||||
|     # Sort data by total, from low to high |     # Sort data by total, from low to high | ||||||
|     data.sort(key=lambda x: int(x[columns.index("total")])) |     data.sort(key=lambda x: int(x[columns.index("total")])) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user