start refactoring next challenge logic

This commit is contained in:
Quincy Larson
2015-09-08 21:45:53 -07:00
parent 1e82165ed2
commit f0a4924671
4 changed files with 7 additions and 11 deletions

View File

@ -457,7 +457,7 @@ function showCompletion() {
}, },
function(res) { function(res) {
if (res) { if (res) {
window.location = '/challenges/next-challenge'; window.location = '/challenges/next-challenge?id=' + challenge_Id;
} }
} }
); );

View File

@ -141,7 +141,7 @@ $(document).ready(function() {
}).success( }).success(
function(res) { function(res) {
if (res) { if (res) {
window.location.href = '/challenges/next-challenge'; window.location.href = '/challenges/next-challenge?id=' + challenge_Id;
} }
}).fail( }).fail(
function() { function() {
@ -164,7 +164,7 @@ $(document).ready(function() {
} }
}).success( }).success(
function() { function() {
window.location.href = '/challenges/next-challenge'; window.location.href = '/challenges/next-challenge?id=' + challenge_Id;
}).fail( }).fail(
function() { function() {
window.location.href = '/challenges'; window.location.href = '/challenges';
@ -187,13 +187,13 @@ $(document).ready(function() {
verified: false verified: false
} }
}).success(function() { }).success(function() {
window.location.href = '/challenges/next-challenge'; window.location.href = '/challenges/next-challenge?id=' + challenge_Id;
}).fail(function() { }).fail(function() {
window.location.replace(window.location.href); window.location.replace(window.location.href);
}); });
break; break;
case challengeTypes.BONFIRE: case challengeTypes.BONFIRE:
window.location.href = '/challenges/next-challenge'; window.location.href = '/challenges/next-challenge?id=' + challenge_Id;
default: default:
break; break;
} }

View File

@ -142,9 +142,7 @@ module.exports = function(app) {
function returnNextChallenge(req, res, next) { function returnNextChallenge(req, res, next) {
let nextChallengeName = firstChallenge; let nextChallengeName = firstChallenge;
const challengeId = req.user.currentChallenge ? const challengeId = req.query.id;
req.user.currentChallenge.challengeId :
'bd7123c8c441eddfaeb5bdef';
// find challenge // find challenge
return challenge$ return challenge$
@ -199,9 +197,6 @@ module.exports = function(app) {
nextChallengeName = nextChallenge.dashedName; nextChallengeName = nextChallenge.dashedName;
return nextChallengeName; return nextChallengeName;
}) })
.flatMap(() => {
return saveUser(req.user);
})
.subscribe( .subscribe(
function() {}, function() {},
next, next,

View File

@ -47,3 +47,4 @@
h3 This will restore your code editor to its original state. h3 This will restore your code editor to its original state.
a.btn.btn-lg.btn-info.btn-block#reset-button(href='#', data-dismiss='modal', aria-hidden='true') Clear my code a.btn.btn-lg.btn-info.btn-block#reset-button(href='#', data-dismiss='modal', aria-hidden='true') Clear my code
a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Cancel a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Cancel
script.