Skip to content

Commit

Permalink
Merge pull request #6992 from topcoder-platform/develop
Browse files Browse the repository at this point in the history
HOTFIX - better handle score display (PS-295)
  • Loading branch information
jmgasper authored Jul 8, 2024
2 parents 957d0f5 + 0c347e9 commit 70eb081
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ import styles from './styles.scss';
export default function SideBar({
challengesUrl,
legacyId,
documents,
eventDetail,
// shareable,
forumLink,
discuss,
hasRegistered,
reviewType,
isDesign,
terms,
Expand Down Expand Up @@ -116,29 +114,6 @@ export default function SideBar({
return (
<div styleName="challenge-spec-sidebar">
<div styleName="challenge-sidebar-inner">
{
hasRegistered && documents && documents.length > 0 && (
<div>
<h3>
DOWNLOADS:
</h3>
<ul>
{
documents.map((doc) => {
const url = `${config.URL.COMMUNITY}/tc?module=DownloadDocument&docid=${doc.documentId}`;
return (
<li key={url}>
<a href={url}>
{doc.documentName}
</a>
</li>
);
})
}
</ul>
</div>
)
}
<div>
<h2>
Learn
Expand Down Expand Up @@ -518,8 +493,6 @@ export default function SideBar({
SideBar.defaultProps = {
eventDetail: null,
discuss: [],
documents: undefined,
hasRegistered: false,
reviewType: 'COMMUNITY',
isDesign: false,
terms: [],
Expand All @@ -541,11 +514,9 @@ SideBar.propTypes = {
eventName: PT.string.isRequired,
description: PT.string.isRequired,
}),
documents: PT.arrayOf(PT.shape()),
// shareable: PT.bool.isRequired,
forumLink: PT.string.isRequired,
discuss: PT.arrayOf(PT.shape()),
hasRegistered: PT.bool,
reviewType: PT.string,
isDesign: PT.bool,
terms: PT.arrayOf(PT.shape()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default function ChallengeDetailsView(props) {
const {
communitiesList,
terms,
hasRegistered,
challenge,
challengesUrl,
savingChallenge,
Expand All @@ -44,7 +43,6 @@ export default function ChallengeDetailsView(props) {
descriptionFormat,
legacy,
legacyId,
documents,
userDetails,
metadata,
events,
Expand Down Expand Up @@ -365,8 +363,6 @@ export default function ChallengeDetailsView(props) {
legacyId={legacyId}
forumLink={forumLink}
discuss={discuss}
documents={documents}
hasRegistered={hasRegistered}
isDesign={track.toLowerCase() === 'design'}
isDevelop={track.toLowerCase() === 'development'}
eventDetail={_.isEmpty(events) ? null : events[0]}
Expand Down Expand Up @@ -406,7 +402,6 @@ ChallengeDetailsView.defaultProps = {

ChallengeDetailsView.propTypes = {
terms: PT.arrayOf(PT.shape()),
hasRegistered: PT.bool.isRequired,
challenge: PT.shape({
description: PT.string,
descriptionFormat: PT.string,
Expand Down
35 changes: 30 additions & 5 deletions src/shared/components/challenge-detail/Submissions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,31 @@ class SubmissionsComponent extends React.Component {
}
}

/**
* Returns the value of the "Initial Score" shown on the submissions tab
* We have to check a couple things because sometimes we're running code challenges that
* likely should be marathon matches (PS-295)
*
* Marathon matches place the initial score in submission.score
*
* Code challenges place the initial score in submission.review[x].score
*
* We need to check both places
* @param {Object} submission The submission to return the score for
*/
getInitialScore(submission) {
let score = 'N/A';
if (!_.isEmpty(submission.review)
&& !_.isEmpty(submission.review[0])
&& submission.review[0].score
&& this.challenge.status === 'Completed') {
score = Number(submission.review[0].score).toFixed(2);
} else if (!_.isEmpty(submission.score)) {
score = Number(submission.score).toFixed(2);
}
return score;
}

/**
* Check if it have flag for first try
* @param {Object} registrant registrant info
Expand Down Expand Up @@ -209,6 +234,10 @@ class SubmissionsComponent extends React.Component {
if (isHaveFinalScore) {
valueA = getFinalScore(a);
valueB = getFinalScore(b);
} else if (valueA.score || valueB.score) {
// Handle MM formatted scores in a code challenge (PS-295)
valueA = Number(valueA.score);
valueB = Number(valueB.score);
} else {
valueA = !_.isEmpty(a.review) && a.review[0].score;
valueB = !_.isEmpty(b.review) && b.review[0].score;
Expand Down Expand Up @@ -904,11 +933,7 @@ class SubmissionsComponent extends React.Component {
<div styleName="col-5">
<div styleName="mobile-header">INITIAL SCORE</div>
<p>
{
(!_.isEmpty(s.review) && !_.isEmpty(s.review[0]) && s.review[0].score && challenge.status === 'Completed')
? Number(s.review[0].score).toFixed(2)
: 'N/A'
}
{this.getInitialScore(s)}
</p>
</div>
<div styleName="col-6">
Expand Down

0 comments on commit 70eb081

Please sign in to comment.