From fb56153b4dba9b79c72f072fa8f088a104bd348b Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Wed, 5 Aug 2015 14:47:54 +0200 Subject: [PATCH] Corrected tutorial bugs --- controllers/feedback/index.js | 1 - controllers/prototype/dbrequests.js | 12 +++++------- controllers/prototype/index.js | 3 ++- controllers/prototype/views/tutorial.jade | 2 +- controllers/stream/views/index.jade | 1 - controllers/thankyou/index.js | 1 - js/l3d/src/scenes/initScene.js | 2 -- 7 files changed, 8 insertions(+), 14 deletions(-) diff --git a/controllers/feedback/index.js b/controllers/feedback/index.js index 422bb2e..a6a2159 100644 --- a/controllers/feedback/index.js +++ b/controllers/feedback/index.js @@ -2,7 +2,6 @@ module.exports.index = function(req, res) { res.setHeader('Content-Type', 'text/html'); res.render('index.jade', res.locals, function(err, result) { - console.log(err); res.send(result); }); }; diff --git a/controllers/prototype/dbrequests.js b/controllers/prototype/dbrequests.js index a94cead..7ae6ebd 100644 --- a/controllers/prototype/dbrequests.js +++ b/controllers/prototype/dbrequests.js @@ -581,7 +581,6 @@ DBReq.ExpCreator.prototype.execute = function() { "LIMIT 1;", [self.user_id], function(err, result) { - console.log(result.rows); if (result.rows.length > 0) { // Set the result self.finalResult.coin_combination_id = result.rows[0].id; @@ -904,6 +903,7 @@ DBReq.ExpGetter.prototype.finish = function() { DBReq.TutorialCreator = function(id, finishAction) { this.id = id; this.finishAction = finishAction; + this.finalResult = {}; var self = this; pg.connect(pgc.url, function(err, client, release) { @@ -924,11 +924,10 @@ DBReq.TutorialCreator.prototype.execute = function() { "LIMIT 8;", [], function(err, result) { - self.coins = []; + self.finalResult.coins = []; for (var i = 0; i < 8; i++) { - self.coins.push(result.rows[i].id); + self.finalResult.coins.push(result.rows[i].id); } - // Create CoinCombination self.client.query( "INSERT INTO CoinCombination(scene_id, coin_1, coin_2, coin_3, coin_4, coin_5, coin_6, coin_7, coin_8)\n" + @@ -953,8 +952,7 @@ DBReq.TutorialCreator.prototype.execute = function() { "RETURNING id;", [self.id, result.rows[0].id], function(err, result) { - console.log(err); - self.finalResult = result.rows[0].id; + self.finalResult.expId = result.rows[0].id; self.finish(); } ); @@ -969,7 +967,7 @@ DBReq.TutorialCreator.prototype.finish = function() { this.release = null; this.client = null; - this.finishAction(this.finalResult); + this.finishAction(this.finalResult.expId, this.finalResult.coins); } /** diff --git a/controllers/prototype/index.js b/controllers/prototype/index.js index d331567..43df7e0 100644 --- a/controllers/prototype/index.js +++ b/controllers/prototype/index.js @@ -173,8 +173,9 @@ module.exports.tutorial = function(req, res) { req.session.user_id = id; // 1 is the ID of peach scene - db.createTutorial(id, function(id) { + db.createTutorial(id, function(id, coins) { req.session.exp_id = id; + res.locals.coins = coins; req.session.save(); res.setHeader('Content-Type', 'text/html'); diff --git a/controllers/prototype/views/tutorial.jade b/controllers/prototype/views/tutorial.jade index e9ab140..359fb33 100644 --- a/controllers/prototype/views/tutorial.jade +++ b/controllers/prototype/views/tutorial.jade @@ -7,7 +7,7 @@ block title title #{title} - Prototype - Tutorial block configjs - script Recommendation = L3D.ArrowRecommendation; + script Recommendation = L3D.ArrowRecommendation; coinsId = [#{coins}]; script(src="/static/js/tutorial.min.js") block lastbutton diff --git a/controllers/stream/views/index.jade b/controllers/stream/views/index.jade index 4255619..c880ecb 100644 --- a/controllers/stream/views/index.jade +++ b/controllers/stream/views/index.jade @@ -20,7 +20,6 @@ block extrajs $('#form').submit(function(e) { e.preventDefault(); var val = filterInt(document.getElementById('num').value); - console.log(val); window.location.href = "/stream/" + val; }); }); diff --git a/controllers/thankyou/index.js b/controllers/thankyou/index.js index 422bb2e..a6a2159 100644 --- a/controllers/thankyou/index.js +++ b/controllers/thankyou/index.js @@ -2,7 +2,6 @@ module.exports.index = function(req, res) { res.setHeader('Content-Type', 'text/html'); res.render('index.jade', res.locals, function(err, result) { - console.log(err); res.send(result); }); }; diff --git a/js/l3d/src/scenes/initScene.js b/js/l3d/src/scenes/initScene.js index 2db4e83..3bef1c2 100644 --- a/js/l3d/src/scenes/initScene.js +++ b/js/l3d/src/scenes/initScene.js @@ -255,9 +255,7 @@ L3D.generateCoins = function(totalCoins, coin_ids) { var bound = (coin_ids instanceof Array && coin_ids.length === 0) ? totalCoins.length : 8; - console.log(totalCoins); for (i = 0; i < bound; i++) { - console.log(i + '/' + totalCoins.length); coins.push(totalCoins[i].coin); totalCoins[i].coin.id = totalCoins[i].id; indices.push(totalCoins[i].id);