@@ -307,7 +307,12 @@ class ScoreTypeGroup(ScoreTypeAlone):
307307 <tr class="partiallycorrect">
308308 {% endif %}
309309 <td class="idx">{{ loop.index }}</td>
310- <td class="outcome">{{ _(tc["outcome"]) }}</td>
310+ <td class="outcome">
311+ {{ _(tc["outcome"]) }}
312+ {% if "is_rel_score" in tc and tc["is_rel_score"] and tc["outcome_float"] > 0 %}
313+ {{ " ({:.2f}% of best)".format(tc["outcome_float"] * 100) }}
314+ {% endif %}
315+ </td>
311316 <td class="details">
312317 {{ tc["text"]|format_status_text }}
313318 {% if tc["help"] is not none %}
@@ -451,10 +456,35 @@ def compute_score(self, submission_result):
451456
452457 tc_first_lowest_idx = None
453458 tc_first_lowest_score = None
459+ tc_scores : list [float ] = []
460+
454461 for tc_idx in target :
455462 tc_score = float (evaluations [tc_idx ].outcome )
463+
464+ # Implement relative scoring
465+ if submission_result .dataset .relative_scoring :
466+ is_official = submission_result .submission .official
467+ tc = submission_result .dataset .testcases [tc_idx ]
468+ safegt = lambda a ,b : b is None or a > b
469+ # hackity hack hack :)
470+ # this will be committed to the DB by the ScoringService who called compute_score
471+ if safegt (tc_score , tc .best_unofficial_score ):
472+ tc .best_unofficial_score = tc_score
473+ invalidate_dataset = True
474+ if is_official and safegt (tc_score , tc .best_official_score ):
475+ tc .best_official_score = tc_score
476+ invalidate_dataset = True
477+ scaler = tc .best_official_score if is_official else tc .best_unofficial_score
478+ scaler = scaler or 1.0
479+ tc_score /= scaler
480+
481+ tc_scores .append (tc_score )
456482 tc_outcome = self .get_public_outcome (
457483 tc_score , parameter )
484+ if submission_result .dataset .relative_scoring and tc_score > 0 :
485+ # hack: for relative scoring "partially correct" isnt really meaningful,
486+ # so force it to be green
487+ tc_outcome = self .get_public_outcome (1.0 , parameter )
458488
459489 time_limit_was_exceeded = False
460490 if evaluations [tc_idx ].text == [EVALUATION_MESSAGES .get ("timeout" ).message ]:
@@ -482,6 +512,8 @@ def compute_score(self, submission_result):
482512 testcases .append ({
483513 "idx" : tc_idx ,
484514 "outcome" : tc_outcome ,
515+ "outcome_float" : tc_score ,
516+ "is_rel_score" : submission_result .dataset .relative_scoring ,
485517 "text" : evaluations [tc_idx ].text ,
486518 "help" : helptext ,
487519 "time" : evaluations [tc_idx ].execution_time ,
@@ -500,29 +532,6 @@ def compute_score(self, submission_result):
500532 else :
501533 public_testcases .append ({"idx" : tc_idx })
502534
503- # Implement relative scoring
504- if submission_result .dataset .relative_scoring :
505- is_official = submission_result .submission .official
506- tc_scores = []
507- for tc_idx in target :
508- tc_outcome = float (evaluations [tc_idx ].outcome )
509- tc = submission_result .dataset .testcases [tc_idx ]
510- safegt = lambda a ,b : b is None or a > b
511- # hackity hack hack :)
512- # this will be committed to the DB by the ScoringService who called compute_score
513- if safegt (tc_outcome , tc .best_unofficial_score ):
514- logger .info (f"new best on tc={ tc_idx } outcome={ tc_outcome } old={ tc .best_unofficial_score } " )
515- tc .best_unofficial_score = tc_outcome
516- invalidate_dataset = True
517- if is_official and safegt (tc_outcome , tc .best_official_score ):
518- tc .best_official_score = tc_outcome
519- invalidate_dataset = True
520- scaler = tc .best_official_score if is_official else tc .best_unofficial_score
521- scaler = scaler or 1.0
522- tc_scores .append (tc_outcome / scaler )
523- else :
524- tc_scores = [float (evaluations [tc_idx ].outcome ) for tc_idx in target ]
525-
526535 st_score_fraction = self .reduce (
527536 tc_scores ,
528537 parameter )
0 commit comments