Submit show completion

This commit is contained in:
Berkeley Martinez
2015-11-21 19:48:24 -08:00
parent 7593dc4e1b
commit fe659b20f4
5 changed files with 31 additions and 15 deletions

View File

@@ -25,15 +25,25 @@ $(document).ready(function() {
}
);
common.submitBtn$
Observable.merge(
common.editorExecute$,
common.submitBtn$
)
.flatMap(() => {
common.appendToOutputDisplay('\n// testing challenge...');
return common.executeChallenge$();
})
.map(({ tests, ...rest }) => {
const solved = tests.every(test => !test.err);
return { ...rest, tests, solved };
})
.subscribe(
({ output, original, tests }) => {
({ solved, output, tests }) => {
common.updateOutputDisplay(output);
common.codeStorage.updateStorage(challengeName, original);
common.displayTestResults(tests);
if (solved) {
common.showCompletion();
}
}
);
@@ -58,9 +68,9 @@ $(document).ready(function() {
) {
common.executeChallenge$()
.subscribe(
({ original }) => {
// common.updateOutputDisplay('' + output);
({ original, tests }) => {
common.codeStorage.updateStorage(challengeName, original);
common.displayTestResults(tests);
},
({ err }) => {
if (err.stack) {