From 367b04c25d741e4fdc9d6e55daee7ff09afe3f21 Mon Sep 17 00:00:00 2001 From: Ashar Fuadi Date: Thu, 12 Oct 2023 22:35:51 +0700 Subject: [PATCH] Revamp verdict: expand verdict code and make general info compact --- .../GradingVerdictTag/GradingVerdictTag.jsx | 39 +++++++++ .../GradingVerdictTag/GradingVerdictTag.scss | 12 +++ .../Programming/SubmissionDetails.jsx | 82 +++++-------------- .../Programming/SubmissionDetails.scss | 7 +- .../Programming/SubmissionsTable.scss | 32 -------- .../src/components/VerdictTag/VerdictTag.jsx | 6 +- .../src/modules/api/gabriel/verdict.js | 16 ++-- .../ContestSubmissionsTable.jsx | 30 ++++--- .../ContestSubmissionPage.jsx | 1 - .../ChapterProblemSubmissionsTable.jsx | 26 +++--- .../ProblemSubmissionsTable.jsx | 26 +++--- .../ProblemSubmissionPage.jsx | 1 - .../SubmissionsTable/SubmissionsTable.jsx | 28 +++---- .../single/SubmissionPage/SubmissionPage.jsx | 1 - judgels-client/src/styles/index.scss | 5 ++ 15 files changed, 146 insertions(+), 166 deletions(-) create mode 100644 judgels-client/src/components/GradingVerdictTag/GradingVerdictTag.jsx create mode 100644 judgels-client/src/components/GradingVerdictTag/GradingVerdictTag.scss diff --git a/judgels-client/src/components/GradingVerdictTag/GradingVerdictTag.jsx b/judgels-client/src/components/GradingVerdictTag/GradingVerdictTag.jsx new file mode 100644 index 000000000..893030414 --- /dev/null +++ b/judgels-client/src/components/GradingVerdictTag/GradingVerdictTag.jsx @@ -0,0 +1,39 @@ +import { Tag } from '@blueprintjs/core'; +import classNames from 'classnames'; + +import { VerdictTag } from '../VerdictTag/VerdictTag'; +import { VerdictCode } from '../../modules/api/gabriel/verdict'; + +import './GradingVerdictTag.scss'; + +export function GradingVerdictTag({ grading, wide }) { + console.log({ grading }); + + const verdict = grading.verdict; + + const getScore = () => { + if (verdict.code === VerdictCode.PND || verdict.code === VerdictCode.CE || verdict.code === VerdictCode.ERR) { + return null; + } else if (verdict.code === VerdictCode.AC) { + return grading.score !== 100 ? grading.score : null; + } else { + return grading.score !== 0 ? grading.score : null; + } + }; + + const renderScore = () => { + const score = getScore(); + if (score === null) { + return null; + } + + return {score}; + }; + + return ( +
+ {verdict && } + {renderScore()} +
+ ); +} diff --git a/judgels-client/src/components/GradingVerdictTag/GradingVerdictTag.scss b/judgels-client/src/components/GradingVerdictTag/GradingVerdictTag.scss new file mode 100644 index 000000000..f68bb0275 --- /dev/null +++ b/judgels-client/src/components/GradingVerdictTag/GradingVerdictTag.scss @@ -0,0 +1,12 @@ +.grading-verdict-tag { + display: inline-flex; + gap: 10px; + + .grading-verdict-tag__score { + margin-left: auto; + } + + &--wide { + width: 100%; + } +} diff --git a/judgels-client/src/components/SubmissionDetails/Programming/SubmissionDetails.jsx b/judgels-client/src/components/SubmissionDetails/Programming/SubmissionDetails.jsx index 305e468d0..656cf1161 100644 --- a/judgels-client/src/components/SubmissionDetails/Programming/SubmissionDetails.jsx +++ b/judgels-client/src/components/SubmissionDetails/Programming/SubmissionDetails.jsx @@ -7,6 +7,7 @@ import { FormattedDate } from '../../FormattedDate/FormattedDate'; import { UserRef } from '../../UserRef/UserRef'; import { ContentCard } from '../../ContentCard/ContentCard'; import { VerdictTag } from '../../VerdictTag/VerdictTag'; +import { GradingVerdictTag } from '../../GradingVerdictTag/GradingVerdictTag'; import { constructProblemName } from '../../../modules/api/sandalphon/problem'; import { getGradingLanguageName, @@ -26,7 +27,6 @@ export function SubmissionDetails({ problemName, problemAlias, problemUrl, - containerTitle, containerName, onDownload, }) { @@ -60,66 +60,26 @@ export function SubmissionDetails({ }; const renderGeneralInfo = () => { + const separator = <> ● ; + const grading = latestGrading; return ( - <> -

General Info

- - - - - Info - Value - - - - - Author - - - - - {problemName && ( - - Problem - - {!!problemUrl ? ( - {constructProblemName(problemName, problemAlias)} - ) : ( - constructProblemName(problemName, problemAlias) - )} - - - )} - {containerName && ( - - {containerTitle} - {containerName} - - )} - - Language - {getGradingLanguageName(gradingLanguage)} - - - Verdict - {grading && } - - - Score - {grading && grading.score} - - - Time - - - - - - - - +
+ {grading && } {separator} + {(containerName || problemName) && ( + <> + {' '} + {separator} {containerName && <>{containerName} / } + {problemName && !!problemUrl ? ( + {constructProblemName(problemName, problemAlias)} + ) : ( + constructProblemName(problemName, problemAlias) + )} + + )}{' '} + {separator} {getGradingLanguageName(gradingLanguage)} {separator} +
); }; @@ -131,7 +91,7 @@ export function SubmissionDetails({ const results = latestGrading.details.subtaskResults.map(({ verdict, score }, idx) => ( {idx + 1} - + {score} @@ -166,7 +126,7 @@ export function SubmissionDetails({ const results = details.testDataResults[0].testCaseResults.map((result, idx) => ( {idx + 1} - + {renderExecutionTime(result)} @@ -212,7 +172,7 @@ export function SubmissionDetails({ const results = group.testCaseResults.map((result, idx2) => ( {idx2 + 1} - + {renderExecutionTime(result)} diff --git a/judgels-client/src/components/SubmissionDetails/Programming/SubmissionDetails.scss b/judgels-client/src/components/SubmissionDetails/Programming/SubmissionDetails.scss index b464de2c4..7cfdd7d4e 100644 --- a/judgels-client/src/components/SubmissionDetails/Programming/SubmissionDetails.scss +++ b/judgels-client/src/components/SubmissionDetails/Programming/SubmissionDetails.scss @@ -25,8 +25,7 @@ } .col-verdict { - width: 100px; - text-align: center; + width: 160px; } .col-tc-info { @@ -42,6 +41,10 @@ text-align: center; } + .general-info { + margin-bottom: 25px; + } + .test-group__id { float: left; } diff --git a/judgels-client/src/components/SubmissionsTable/Programming/SubmissionsTable.scss b/judgels-client/src/components/SubmissionsTable/Programming/SubmissionsTable.scss index 0e3aaf414..7ca9d0195 100644 --- a/judgels-client/src/components/SubmissionsTable/Programming/SubmissionsTable.scss +++ b/judgels-client/src/components/SubmissionsTable/Programming/SubmissionsTable.scss @@ -1,38 +1,6 @@ @import '../../../styles/table'; .submissions-table { - .col-regrade { - width: 7px; - } - - .col-id { - width: 106px; - } - - .col-prob { - width: 80px; - } - - .col-lang { - width: 90px; - } - - .col-verdict { - width: 60px; - } - - .col-pts { - width: 60px; - } - - .col-actions { - width: 50px; - } - - .cell-centered { - text-align: center; - } - .action { cursor: pointer; } diff --git a/judgels-client/src/components/VerdictTag/VerdictTag.jsx b/judgels-client/src/components/VerdictTag/VerdictTag.jsx index 012026f99..ce5404280 100644 --- a/judgels-client/src/components/VerdictTag/VerdictTag.jsx +++ b/judgels-client/src/components/VerdictTag/VerdictTag.jsx @@ -1,13 +1,11 @@ import { Tag } from '@blueprintjs/core'; -import { Time } from '@blueprintjs/icons'; -import { getVerdictDisplayCode, getVerdictIntent, VerdictCode } from '../../modules/api/gabriel/verdict'; +import { getVerdictDisplayName, getVerdictIntent } from '../../modules/api/gabriel/verdict'; export const VerdictTag = ({ verdictCode }) => { - const tag = verdictCode === VerdictCode.PND ?