Corrected tutorial bugs
This commit is contained in:
parent
5f40dea529
commit
fb56153b4d
|
@ -2,7 +2,6 @@ module.exports.index = function(req, res) {
|
||||||
res.setHeader('Content-Type', 'text/html');
|
res.setHeader('Content-Type', 'text/html');
|
||||||
|
|
||||||
res.render('index.jade', res.locals, function(err, result) {
|
res.render('index.jade', res.locals, function(err, result) {
|
||||||
console.log(err);
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -581,7 +581,6 @@ DBReq.ExpCreator.prototype.execute = function() {
|
||||||
"LIMIT 1;",
|
"LIMIT 1;",
|
||||||
[self.user_id],
|
[self.user_id],
|
||||||
function(err, result) {
|
function(err, result) {
|
||||||
console.log(result.rows);
|
|
||||||
if (result.rows.length > 0) {
|
if (result.rows.length > 0) {
|
||||||
// Set the result
|
// Set the result
|
||||||
self.finalResult.coin_combination_id = result.rows[0].id;
|
self.finalResult.coin_combination_id = result.rows[0].id;
|
||||||
|
@ -904,6 +903,7 @@ DBReq.ExpGetter.prototype.finish = function() {
|
||||||
DBReq.TutorialCreator = function(id, finishAction) {
|
DBReq.TutorialCreator = function(id, finishAction) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.finishAction = finishAction;
|
this.finishAction = finishAction;
|
||||||
|
this.finalResult = {};
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
pg.connect(pgc.url, function(err, client, release) {
|
pg.connect(pgc.url, function(err, client, release) {
|
||||||
|
@ -924,11 +924,10 @@ DBReq.TutorialCreator.prototype.execute = function() {
|
||||||
"LIMIT 8;",
|
"LIMIT 8;",
|
||||||
[],
|
[],
|
||||||
function(err, result) {
|
function(err, result) {
|
||||||
self.coins = [];
|
self.finalResult.coins = [];
|
||||||
for (var i = 0; i < 8; i++) {
|
for (var i = 0; i < 8; i++) {
|
||||||
self.coins.push(result.rows[i].id);
|
self.finalResult.coins.push(result.rows[i].id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create CoinCombination
|
// Create CoinCombination
|
||||||
self.client.query(
|
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" +
|
"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;",
|
"RETURNING id;",
|
||||||
[self.id, result.rows[0].id],
|
[self.id, result.rows[0].id],
|
||||||
function(err, result) {
|
function(err, result) {
|
||||||
console.log(err);
|
self.finalResult.expId = result.rows[0].id;
|
||||||
self.finalResult = result.rows[0].id;
|
|
||||||
self.finish();
|
self.finish();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -969,7 +967,7 @@ DBReq.TutorialCreator.prototype.finish = function() {
|
||||||
this.release = null;
|
this.release = null;
|
||||||
this.client = null;
|
this.client = null;
|
||||||
|
|
||||||
this.finishAction(this.finalResult);
|
this.finishAction(this.finalResult.expId, this.finalResult.coins);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -173,8 +173,9 @@ module.exports.tutorial = function(req, res) {
|
||||||
req.session.user_id = id;
|
req.session.user_id = id;
|
||||||
|
|
||||||
// 1 is the ID of peach scene
|
// 1 is the ID of peach scene
|
||||||
db.createTutorial(id, function(id) {
|
db.createTutorial(id, function(id, coins) {
|
||||||
req.session.exp_id = id;
|
req.session.exp_id = id;
|
||||||
|
res.locals.coins = coins;
|
||||||
req.session.save();
|
req.session.save();
|
||||||
|
|
||||||
res.setHeader('Content-Type', 'text/html');
|
res.setHeader('Content-Type', 'text/html');
|
||||||
|
|
|
@ -7,7 +7,7 @@ block title
|
||||||
title #{title} - Prototype - Tutorial
|
title #{title} - Prototype - Tutorial
|
||||||
|
|
||||||
block configjs
|
block configjs
|
||||||
script Recommendation = L3D.ArrowRecommendation;
|
script Recommendation = L3D.ArrowRecommendation; coinsId = [#{coins}];
|
||||||
script(src="/static/js/tutorial.min.js")
|
script(src="/static/js/tutorial.min.js")
|
||||||
|
|
||||||
block lastbutton
|
block lastbutton
|
||||||
|
|
|
@ -20,7 +20,6 @@ block extrajs
|
||||||
$('#form').submit(function(e) {
|
$('#form').submit(function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var val = filterInt(document.getElementById('num').value);
|
var val = filterInt(document.getElementById('num').value);
|
||||||
console.log(val);
|
|
||||||
window.location.href = "/stream/" + val;
|
window.location.href = "/stream/" + val;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,6 @@ module.exports.index = function(req, res) {
|
||||||
res.setHeader('Content-Type', 'text/html');
|
res.setHeader('Content-Type', 'text/html');
|
||||||
|
|
||||||
res.render('index.jade', res.locals, function(err, result) {
|
res.render('index.jade', res.locals, function(err, result) {
|
||||||
console.log(err);
|
|
||||||
res.send(result);
|
res.send(result);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -255,9 +255,7 @@ L3D.generateCoins = function(totalCoins, coin_ids) {
|
||||||
|
|
||||||
var bound = (coin_ids instanceof Array && coin_ids.length === 0) ? totalCoins.length : 8;
|
var bound = (coin_ids instanceof Array && coin_ids.length === 0) ? totalCoins.length : 8;
|
||||||
|
|
||||||
console.log(totalCoins);
|
|
||||||
for (i = 0; i < bound; i++) {
|
for (i = 0; i < bound; i++) {
|
||||||
console.log(i + '/' + totalCoins.length);
|
|
||||||
coins.push(totalCoins[i].coin);
|
coins.push(totalCoins[i].coin);
|
||||||
totalCoins[i].coin.id = totalCoins[i].id;
|
totalCoins[i].coin.id = totalCoins[i].id;
|
||||||
indices.push(totalCoins[i].id);
|
indices.push(totalCoins[i].id);
|
||||||
|
|
Loading…
Reference in New Issue