@@ -21,8 +21,6 @@ import {
21
21
import ChallengeDescription from '../../components/Challenge-Description' ;
22
22
import Hotkeys from '../../components/Hotkeys' ;
23
23
import ChallengeTitle from '../../components/challenge-title' ;
24
- import CompletionModal from '../../components/completion-modal' ;
25
- import HelpModal from '../../components/help-modal' ;
26
24
import Output from '../../components/output' ;
27
25
import TestSuite from '../../components/test-suite' ;
28
26
import {
@@ -33,12 +31,12 @@ import {
33
31
initConsole ,
34
32
initTests ,
35
33
isChallengeCompletedSelector ,
34
+ testsRunningSelector ,
36
35
updateChallengeMeta ,
37
- updateSolutionFormValues
36
+ updateSolutionFormValues ,
37
+ submitChallenge
38
38
} from '../../redux' ;
39
- import { getGuideUrl } from '../../utils' ;
40
39
import SolutionForm from '../solution-form' ;
41
- import ProjectToolPanel from '../tool-panel' ;
42
40
43
41
import '../../components/test-frame.css' ;
44
42
@@ -48,16 +46,19 @@ const mapStateToProps = createSelector(
48
46
challengeTestsSelector ,
49
47
isChallengeCompletedSelector ,
50
48
isSignedInSelector ,
49
+ testsRunningSelector ,
51
50
(
52
51
output : string [ ] ,
53
52
tests : Test [ ] ,
54
53
isChallengeCompleted : boolean ,
55
- isSignedIn : boolean
54
+ isSignedIn : boolean ,
55
+ testsRunningSelector : boolean
56
56
) => ( {
57
57
tests,
58
58
output,
59
59
isChallengeCompleted,
60
- isSignedIn
60
+ isSignedIn,
61
+ testsRunningSelector
61
62
} )
62
63
) ;
63
64
@@ -67,7 +68,8 @@ const mapDispatchToActions = {
67
68
initConsole,
68
69
initTests,
69
70
updateChallengeMeta,
70
- updateSolutionFormValues
71
+ updateSolutionFormValues,
72
+ submitChallenge
71
73
} ;
72
74
73
75
// Types
@@ -86,8 +88,10 @@ interface BackEndProps {
86
88
pageContext : {
87
89
challengeMeta : ChallengeMeta ;
88
90
} ;
91
+ submitChallenge : ( ) => void ;
89
92
t : TFunction ;
90
93
tests : Test [ ] ;
94
+ testsRunning : boolean ;
91
95
title : string ;
92
96
updateChallengeMeta : ( arg0 : ChallengeMeta ) => void ;
93
97
updateSolutionFormValues : ( ) => void ;
@@ -175,24 +179,28 @@ class BackEnd extends Component<BackEndProps> {
175
179
}
176
180
177
181
handleSubmit ( ) : void {
178
- this . props . executeChallenge ( {
179
- showCompletionModal : false
180
- } ) ;
182
+ const { tests, submitChallenge } = this . props ;
183
+ const isChallengeComplete = tests . every ( test => test . pass && ! test . err ) ;
184
+
185
+ if ( isChallengeComplete ) {
186
+ submitChallenge ( ) ;
187
+ } else {
188
+ this . props . executeChallenge ( {
189
+ showCompletionModal : false
190
+ } ) ;
191
+ }
181
192
}
182
193
183
194
render ( ) {
184
195
const {
185
196
data : {
186
197
challengeNode : {
187
198
challenge : {
188
- fields : { blockName } ,
189
199
challengeType,
190
- forumTopicId,
191
200
title,
192
201
description,
193
202
instructions,
194
203
translationPending,
195
- certification,
196
204
superBlock,
197
205
block
198
206
}
@@ -205,9 +213,15 @@ class BackEnd extends Component<BackEndProps> {
205
213
} ,
206
214
t,
207
215
tests,
216
+ testsRunning,
208
217
updateSolutionFormValues
209
218
} = this . props ;
210
219
220
+ const isChallengeComplete = tests . every ( test => test . pass && ! test . err ) ;
221
+ const submitBtnLabel : string = ! isChallengeComplete
222
+ ? `${ t ( 'buttons.run-test' ) } ${ testsRunning ? ' ...' : '' } `
223
+ : t ( 'buttons.submit-and-go' ) ;
224
+
211
225
const blockNameTitle = `${ t (
212
226
`intro:${ superBlock } .blocks.${ block } .title`
213
227
) } - ${ title } `;
@@ -243,9 +257,7 @@ class BackEnd extends Component<BackEndProps> {
243
257
// eslint-disable-next-line @typescript-eslint/unbound-method
244
258
onSubmit = { this . handleSubmit }
245
259
updateSolutionForm = { updateSolutionFormValues }
246
- />
247
- < ProjectToolPanel
248
- guideUrl = { getGuideUrl ( { forumTopicId, title } ) }
260
+ buttonLabel = { submitBtnLabel }
249
261
/>
250
262
< br />
251
263
< Output
@@ -260,13 +272,6 @@ class BackEnd extends Component<BackEndProps> {
260
272
< TestSuite tests = { tests } />
261
273
< Spacer />
262
274
</ Col >
263
- < CompletionModal
264
- block = { block }
265
- blockName = { blockName }
266
- certification = { certification }
267
- superBlock = { superBlock }
268
- />
269
- < HelpModal challengeTitle = { title } challengeBlock = { blockName } />
270
275
</ Row >
271
276
</ Grid >
272
277
</ LearnLayout >
0 commit comments