@@ -102,6 +102,31 @@ class SubmissionsComponent extends React.Component {
102
102
}
103
103
}
104
104
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
+
105
130
/**
106
131
* Check if it have flag for first try
107
132
* @param {Object } registrant registrant info
@@ -209,6 +234,10 @@ class SubmissionsComponent extends React.Component {
209
234
if ( isHaveFinalScore ) {
210
235
valueA = getFinalScore ( a ) ;
211
236
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 ) ;
212
241
} else {
213
242
valueA = ! _ . isEmpty ( a . review ) && a . review [ 0 ] . score ;
214
243
valueB = ! _ . isEmpty ( b . review ) && b . review [ 0 ] . score ;
@@ -904,11 +933,7 @@ class SubmissionsComponent extends React.Component {
904
933
< div styleName = "col-5" >
905
934
< div styleName = "mobile-header" > INITIAL SCORE</ div >
906
935
< 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 ) }
912
937
</ p >
913
938
</ div >
914
939
< div styleName = "col-6" >
0 commit comments