From f0a49246710d43c7aba325217ac12c12635fd129 Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Tue, 8 Sep 2015 21:45:53 -0700 Subject: [PATCH] start refactoring next challenge logic --- client/commonFramework.js | 2 +- client/main.js | 8 ++++---- server/boot/challenge.js | 7 +------ server/views/partials/challenge-modals.jade | 1 + 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/client/commonFramework.js b/client/commonFramework.js index be5be4533c..0d2a4d9894 100644 --- a/client/commonFramework.js +++ b/client/commonFramework.js @@ -457,7 +457,7 @@ function showCompletion() { }, function(res) { if (res) { - window.location = '/challenges/next-challenge'; + window.location = '/challenges/next-challenge?id=' + challenge_Id; } } ); diff --git a/client/main.js b/client/main.js index bbd69857d0..fe46956142 100644 --- a/client/main.js +++ b/client/main.js @@ -141,7 +141,7 @@ $(document).ready(function() { }).success( function(res) { if (res) { - window.location.href = '/challenges/next-challenge'; + window.location.href = '/challenges/next-challenge?id=' + challenge_Id; } }).fail( function() { @@ -164,7 +164,7 @@ $(document).ready(function() { } }).success( function() { - window.location.href = '/challenges/next-challenge'; + window.location.href = '/challenges/next-challenge?id=' + challenge_Id; }).fail( function() { window.location.href = '/challenges'; @@ -187,13 +187,13 @@ $(document).ready(function() { verified: false } }).success(function() { - window.location.href = '/challenges/next-challenge'; + window.location.href = '/challenges/next-challenge?id=' + challenge_Id; }).fail(function() { window.location.replace(window.location.href); }); break; case challengeTypes.BONFIRE: - window.location.href = '/challenges/next-challenge'; + window.location.href = '/challenges/next-challenge?id=' + challenge_Id; default: break; } diff --git a/server/boot/challenge.js b/server/boot/challenge.js index 94412a226e..4c3c261d47 100644 --- a/server/boot/challenge.js +++ b/server/boot/challenge.js @@ -142,9 +142,7 @@ module.exports = function(app) { function returnNextChallenge(req, res, next) { let nextChallengeName = firstChallenge; - const challengeId = req.user.currentChallenge ? - req.user.currentChallenge.challengeId : - 'bd7123c8c441eddfaeb5bdef'; + const challengeId = req.query.id; // find challenge return challenge$ @@ -199,9 +197,6 @@ module.exports = function(app) { nextChallengeName = nextChallenge.dashedName; return nextChallengeName; }) - .flatMap(() => { - return saveUser(req.user); - }) .subscribe( function() {}, next, diff --git a/server/views/partials/challenge-modals.jade b/server/views/partials/challenge-modals.jade index cd0339cc08..24805a953b 100644 --- a/server/views/partials/challenge-modals.jade +++ b/server/views/partials/challenge-modals.jade @@ -47,3 +47,4 @@ 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-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Cancel +script.