Skip to content

Commit 09b38a4

Browse files
authored
Merge pull request #74 from topcoder-platform/TCA-425_update-backend-project-layout
TCA-425 - Update backend projects to advance to next lesson without c…
2 parents 934011d + d22a7f2 commit 09b38a4

File tree

2 files changed

+32
-26
lines changed

2 files changed

+32
-26
lines changed

client/src/templates/Challenges/projects/backend/Show.tsx

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import {
2121
import ChallengeDescription from '../../components/Challenge-Description';
2222
import Hotkeys from '../../components/Hotkeys';
2323
import ChallengeTitle from '../../components/challenge-title';
24-
import CompletionModal from '../../components/completion-modal';
25-
import HelpModal from '../../components/help-modal';
2624
import Output from '../../components/output';
2725
import TestSuite from '../../components/test-suite';
2826
import {
@@ -33,12 +31,12 @@ import {
3331
initConsole,
3432
initTests,
3533
isChallengeCompletedSelector,
34+
testsRunningSelector,
3635
updateChallengeMeta,
37-
updateSolutionFormValues
36+
updateSolutionFormValues,
37+
submitChallenge
3838
} from '../../redux';
39-
import { getGuideUrl } from '../../utils';
4039
import SolutionForm from '../solution-form';
41-
import ProjectToolPanel from '../tool-panel';
4240

4341
import '../../components/test-frame.css';
4442

@@ -48,16 +46,19 @@ const mapStateToProps = createSelector(
4846
challengeTestsSelector,
4947
isChallengeCompletedSelector,
5048
isSignedInSelector,
49+
testsRunningSelector,
5150
(
5251
output: string[],
5352
tests: Test[],
5453
isChallengeCompleted: boolean,
55-
isSignedIn: boolean
54+
isSignedIn: boolean,
55+
testsRunningSelector: boolean
5656
) => ({
5757
tests,
5858
output,
5959
isChallengeCompleted,
60-
isSignedIn
60+
isSignedIn,
61+
testsRunningSelector
6162
})
6263
);
6364

@@ -67,7 +68,8 @@ const mapDispatchToActions = {
6768
initConsole,
6869
initTests,
6970
updateChallengeMeta,
70-
updateSolutionFormValues
71+
updateSolutionFormValues,
72+
submitChallenge
7173
};
7274

7375
// Types
@@ -86,8 +88,10 @@ interface BackEndProps {
8688
pageContext: {
8789
challengeMeta: ChallengeMeta;
8890
};
91+
submitChallenge: () => void;
8992
t: TFunction;
9093
tests: Test[];
94+
testsRunning: boolean;
9195
title: string;
9296
updateChallengeMeta: (arg0: ChallengeMeta) => void;
9397
updateSolutionFormValues: () => void;
@@ -175,24 +179,28 @@ class BackEnd extends Component<BackEndProps> {
175179
}
176180

177181
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+
}
181192
}
182193

183194
render() {
184195
const {
185196
data: {
186197
challengeNode: {
187198
challenge: {
188-
fields: { blockName },
189199
challengeType,
190-
forumTopicId,
191200
title,
192201
description,
193202
instructions,
194203
translationPending,
195-
certification,
196204
superBlock,
197205
block
198206
}
@@ -205,9 +213,15 @@ class BackEnd extends Component<BackEndProps> {
205213
},
206214
t,
207215
tests,
216+
testsRunning,
208217
updateSolutionFormValues
209218
} = this.props;
210219

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+
211225
const blockNameTitle = `${t(
212226
`intro:${superBlock}.blocks.${block}.title`
213227
)} - ${title}`;
@@ -243,9 +257,7 @@ class BackEnd extends Component<BackEndProps> {
243257
// eslint-disable-next-line @typescript-eslint/unbound-method
244258
onSubmit={this.handleSubmit}
245259
updateSolutionForm={updateSolutionFormValues}
246-
/>
247-
<ProjectToolPanel
248-
guideUrl={getGuideUrl({ forumTopicId, title })}
260+
buttonLabel={submitBtnLabel}
249261
/>
250262
<br />
251263
<Output
@@ -260,13 +272,6 @@ class BackEnd extends Component<BackEndProps> {
260272
<TestSuite tests={tests} />
261273
<Spacer />
262274
</Col>
263-
<CompletionModal
264-
block={block}
265-
blockName={blockName}
266-
certification={certification}
267-
superBlock={superBlock}
268-
/>
269-
<HelpModal challengeTitle={title} challengeBlock={blockName} />
270275
</Row>
271276
</Grid>
272277
</LearnLayout>

client/src/templates/Challenges/projects/solution-form.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface SubmitProps {
1616
}
1717

1818
interface FormProps extends WithTranslation {
19+
buttonLabel?: string;
1920
challengeType: number;
2021
description?: string;
2122
onSubmit: (arg0: SubmitProps) => void;
@@ -46,7 +47,7 @@ export class SolutionForm extends Component<FormProps> {
4647
};
4748

4849
render(): JSX.Element {
49-
const { challengeType, description, t } = this.props;
50+
const { buttonLabel, challengeType, description, t } = this.props;
5051

5152
// back end challenges and front end projects use a single form field
5253
const solutionField = [
@@ -57,7 +58,7 @@ export class SolutionForm extends Component<FormProps> {
5758
{ name: 'githubLink', label: t('learn.github-link') }
5859
];
5960

60-
const buttonCopy = t('learn.submit-and-go');
61+
const buttonCopy: string = buttonLabel ?? t('learn.submit-and-go');
6162

6263
const options = {
6364
types: {

0 commit comments

Comments
 (0)