Skip to content

Commit

Permalink
client: beautify subtask score alignment for decimal score (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
fushar authored Aug 25, 2024
1 parent 34a16f3 commit 0c9fd9d
Showing 1 changed file with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,31 @@ export function SubmissionDetails({
};

const renderScore = score => {
let formattedScore = score;

if (score.startsWith('*')) {
return '✓' + score.substring(1);
}
if (score.startsWith('X')) {
return '✕' + score.substring(1);
formattedScore = '✓' + score.substring(1);
} else if (score.startsWith('X')) {
formattedScore = '✕' + score.substring(1);
}
return score;
};

const renderSubtaskScore = score => {
if (Number.isInteger(score)) {
return <span className="subtask-score">{score}</span>;
}

const integer = Math.trunc(score);
const decimal = (score - integer).toString().replace('0.', '.');
return (
<>
<span className="subtask-score">{integer}</span>
<span className="subtask-score">{decimal}</span>
</>
);
};

const renderSubtaskResults = () => {
if (!hasSubtasks) {
return null;
Expand All @@ -115,7 +131,7 @@ export function SubmissionDetails({
<span className="subtask-verdict">
<VerdictTag verdictCode={subtaskResult.verdict.code} />
</span>
<span className="subtask-score">{subtaskResult.score}</span>
{renderSubtaskScore(subtaskResult.score)}
</h5>
</summary>

Expand Down

0 comments on commit 0c9fd9d

Please sign in to comment.