Skip to content

Commit 70eb081

Browse files
authored
Merge pull request #6992 from topcoder-platform/develop
HOTFIX - better handle score display (PS-295)
2 parents 957d0f5 + 0c347e9 commit 70eb081

File tree

3 files changed

+30
-39
lines changed

3 files changed

+30
-39
lines changed

src/shared/components/challenge-detail/Specification/SideBar/index.jsx

-29
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@ import styles from './styles.scss';
1818
export default function SideBar({
1919
challengesUrl,
2020
legacyId,
21-
documents,
2221
eventDetail,
2322
// shareable,
2423
forumLink,
2524
discuss,
26-
hasRegistered,
2725
reviewType,
2826
isDesign,
2927
terms,
@@ -116,29 +114,6 @@ export default function SideBar({
116114
return (
117115
<div styleName="challenge-spec-sidebar">
118116
<div styleName="challenge-sidebar-inner">
119-
{
120-
hasRegistered && documents && documents.length > 0 && (
121-
<div>
122-
<h3>
123-
DOWNLOADS:
124-
</h3>
125-
<ul>
126-
{
127-
documents.map((doc) => {
128-
const url = `${config.URL.COMMUNITY}/tc?module=DownloadDocument&docid=${doc.documentId}`;
129-
return (
130-
<li key={url}>
131-
<a href={url}>
132-
{doc.documentName}
133-
</a>
134-
</li>
135-
);
136-
})
137-
}
138-
</ul>
139-
</div>
140-
)
141-
}
142117
<div>
143118
<h2>
144119
Learn
@@ -518,8 +493,6 @@ export default function SideBar({
518493
SideBar.defaultProps = {
519494
eventDetail: null,
520495
discuss: [],
521-
documents: undefined,
522-
hasRegistered: false,
523496
reviewType: 'COMMUNITY',
524497
isDesign: false,
525498
terms: [],
@@ -541,11 +514,9 @@ SideBar.propTypes = {
541514
eventName: PT.string.isRequired,
542515
description: PT.string.isRequired,
543516
}),
544-
documents: PT.arrayOf(PT.shape()),
545517
// shareable: PT.bool.isRequired,
546518
forumLink: PT.string.isRequired,
547519
discuss: PT.arrayOf(PT.shape()),
548-
hasRegistered: PT.bool,
549520
reviewType: PT.string,
550521
isDesign: PT.bool,
551522
terms: PT.arrayOf(PT.shape()),

src/shared/components/challenge-detail/Specification/index.jsx

-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export default function ChallengeDetailsView(props) {
2828
const {
2929
communitiesList,
3030
terms,
31-
hasRegistered,
3231
challenge,
3332
challengesUrl,
3433
savingChallenge,
@@ -44,7 +43,6 @@ export default function ChallengeDetailsView(props) {
4443
descriptionFormat,
4544
legacy,
4645
legacyId,
47-
documents,
4846
userDetails,
4947
metadata,
5048
events,
@@ -365,8 +363,6 @@ export default function ChallengeDetailsView(props) {
365363
legacyId={legacyId}
366364
forumLink={forumLink}
367365
discuss={discuss}
368-
documents={documents}
369-
hasRegistered={hasRegistered}
370366
isDesign={track.toLowerCase() === 'design'}
371367
isDevelop={track.toLowerCase() === 'development'}
372368
eventDetail={_.isEmpty(events) ? null : events[0]}
@@ -406,7 +402,6 @@ ChallengeDetailsView.defaultProps = {
406402

407403
ChallengeDetailsView.propTypes = {
408404
terms: PT.arrayOf(PT.shape()),
409-
hasRegistered: PT.bool.isRequired,
410405
challenge: PT.shape({
411406
description: PT.string,
412407
descriptionFormat: PT.string,

src/shared/components/challenge-detail/Submissions/index.jsx

+30-5
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,31 @@ class SubmissionsComponent extends React.Component {
102102
}
103103
}
104104

105+
/**
106+
* Returns the value of the "Initial Score" shown on the submissions tab
107+
* We have to check a couple things because sometimes we're running code challenges that
108+
* likely should be marathon matches (PS-295)
109+
*
110+
* Marathon matches place the initial score in submission.score
111+
*
112+
* Code challenges place the initial score in submission.review[x].score
113+
*
114+
* We need to check both places
115+
* @param {Object} submission The submission to return the score for
116+
*/
117+
getInitialScore(submission) {
118+
let score = 'N/A';
119+
if (!_.isEmpty(submission.review)
120+
&& !_.isEmpty(submission.review[0])
121+
&& submission.review[0].score
122+
&& this.challenge.status === 'Completed') {
123+
score = Number(submission.review[0].score).toFixed(2);
124+
} else if (!_.isEmpty(submission.score)) {
125+
score = Number(submission.score).toFixed(2);
126+
}
127+
return score;
128+
}
129+
105130
/**
106131
* Check if it have flag for first try
107132
* @param {Object} registrant registrant info
@@ -209,6 +234,10 @@ class SubmissionsComponent extends React.Component {
209234
if (isHaveFinalScore) {
210235
valueA = getFinalScore(a);
211236
valueB = getFinalScore(b);
237+
} else if (valueA.score || valueB.score) {
238+
// Handle MM formatted scores in a code challenge (PS-295)
239+
valueA = Number(valueA.score);
240+
valueB = Number(valueB.score);
212241
} else {
213242
valueA = !_.isEmpty(a.review) && a.review[0].score;
214243
valueB = !_.isEmpty(b.review) && b.review[0].score;
@@ -904,11 +933,7 @@ class SubmissionsComponent extends React.Component {
904933
<div styleName="col-5">
905934
<div styleName="mobile-header">INITIAL SCORE</div>
906935
<p>
907-
{
908-
(!_.isEmpty(s.review) && !_.isEmpty(s.review[0]) && s.review[0].score && challenge.status === 'Completed')
909-
? Number(s.review[0].score).toFixed(2)
910-
: 'N/A'
911-
}
936+
{this.getInitialScore(s)}
912937
</p>
913938
</div>
914939
<div styleName="col-6">

0 commit comments

Comments
 (0)