Big commit

This commit is contained in:
Thomas FORGIONE 2015-07-29 11:04:38 +02:00
parent a914ed2a2d
commit c690accd4b
22 changed files with 238 additions and 12 deletions

View File

@ -0,0 +1,9 @@
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);
});
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/feedback': 'index',
};

View File

@ -0,0 +1,24 @@
extends ../../../views/base.jade
mixin question(id, qu)
label(for="#{id}") #{qu}
input.form-control(name="answer#{id}", type="text", placeholder="Answer")
block extrahead
link(rel="stylesheet", href="/static/css/feedback.css")
block content
form.form-signin(method="POST", action='/feedback-target')
h2 Please give us your feedback
+question(1, "Did you have trouble to find the coins without the recommendations ?")
+question(2, "Did the recommendations helped you to find the coins ?")
+question(3, "Did the recommendations helped you to browser the scene ?")
+question(4, "Do you think recommendations can be helpful ?")
+question(5, "Which recommendation style do you prefer and why ?")
//-label(for='input1') Did you have trouble to find the coins during the first step ?
//-input#input1.form-control(name="input1", type="text", placeholder='Id')
button.btn.btn-lg.btn-primary.btn-block(type='submit') Submit

View File

@ -506,10 +506,11 @@ DBReq.UserCreator.prototype.finish = function() {
* @memberof DBReq
* @constructor
*/
DBReq.ExpCreator = function(user_id, scene_id, finishAction) {
DBReq.ExpCreator = function(user_id, scene_id, template, finishAction) {
this.finishAction = finishAction;
this.user_id = user_id;
this.scene_id = scene_id;
this.template = template;
// Connect to db
var self = this;
@ -526,8 +527,8 @@ DBReq.ExpCreator = function(user_id, scene_id, finishAction) {
DBReq.ExpCreator.prototype.execute = function() {
var self = this;
this.client.query(
"INSERT INTO experiment(user_id, scene_id) VALUES($1,$2);",
[self.user_id, self.scene_id],
"INSERT INTO experiment(user_id, scene_id, template) VALUES($1,$2,$3);",
[self.user_id, self.scene_id, self.template],
function(err, result) {
self.client.query("SELECT MAX(id) AS id FROM experiment;", function(err, result) {
self.finalResult = result.rows[0].id;
@ -776,8 +777,8 @@ DBReq.createUser = function(callback) {
* @param scene_id {Number} id of the scene on which the experiment is
* @param callback {function} callback called on the new experiment id
*/
DBReq.createExp = function(id, scene_id, callback) {
new DBReq.ExpCreator(id, scene_id, callback);
DBReq.createExp = function(id, scene_id, template, callback) {
new DBReq.ExpCreator(id, scene_id, template, callback);
};
/**

View File

@ -32,6 +32,18 @@ function randomArray() {
return arr;
}
function randomReco() {
var recoStyles = [
'prototype_empty.jade',
'prototype_viewports.jade',
'prototype_arrows.jade'
];
return shuffle(recoStyles);
}
module.exports.index = function(req, res) {
res.setHeader('Content-Type', 'text/html');
@ -51,6 +63,15 @@ var generateSceneNumber = function(req, res) {
return req.session.scenes[req.session.currentSceneIndex];
};
var generateRecommendationStyle = function(req, res) {
if (req.session.recos === undefined) {
req.session.recos = randomReco();
}
return req.session.recos.shift();
}
var sceneToFunction = function(scene) {
switch (scene) {
case 2:
@ -65,14 +86,23 @@ var sceneToFunction = function(scene) {
};
var protoHelper = function(template) {
return function(req, res) {
template = generateRecommendationStyle(req, res);
if (template === undefined) {
res.redirect('/feedback');
return;
}
db.tryUser(req.session.user_id, function(id) {
// Get random scene number
var scene = generateSceneNumber(req, res);
res.locals.scene = sceneToFunction(scene);
req.session.user_id = id;
db.createExp(id, req.session.scenes[req.session.currentSceneIndex], function(id) {
db.createExp(id, req.session.scenes[req.session.currentSceneIndex], template, function(id) {
req.session.exp_id = id;
req.session.save();
res.setHeader('Content-Type','text/html');
@ -87,6 +117,7 @@ var protoHelper = function(template) {
module.exports.arrows = protoHelper('prototype_arrows.jade');
module.exports.viewports = protoHelper('prototype_viewports.jade');
module.exports.reverse = protoHelper('prototype_reverse.jade');
module.exports.empty = protoHelper('prototype_empty.jade');
module.exports.sponza = function(req, res) {
res.setHeader('Content-Type', 'text/html');
@ -143,7 +174,7 @@ module.exports.tutorial = function(req, res) {
req.session.user_id = id;
// 1 is the ID of peach scene
db.createExp(id, 1, function(id) {
db.createExp(id, 1, null, function(id) {
req.session.exp_id = id;
req.session.save();

View File

@ -2,6 +2,7 @@ module.exports = {
'/prototype': 'index',
'/prototype/arrows': 'arrows',
'/prototype/viewports': 'viewports',
'/prototype/empty': 'empty',
'/prototype/reverse': 'reverse',
'/prototype/replay': 'replay_index',
'/prototype/replay/:id': 'replay',

View File

@ -40,8 +40,10 @@ block content
input#lock(type="checkbox", style={'margin-right': '10px', 'margin-bottom': '10px'}, checked)
label(for="lock" style={'margin-right':'10px'}) Pointer lock
input#showarrows(type="checkbox", style={'margin-right': '10px', 'margin-bottom': '10px'}, checked)
label(for="showarrows" style={'margin-right':'10px'}) Show arrows
input#showarrows(type="checkbox", style={'margin-right': '10px', 'margin-bottom': '10px', 'display':'none'}, checked)
label(for="showarrows" style={'margin-right':'10px', 'display': 'none'}) Show arrows
block lastbutton
//-input#recommendation(type="checkbox", style={'margin-right': '10px', 'margin-bottom': '10px'})
//-label(for="recommendation" style={'margin-right':'10px'}) Fixed prev

View File

@ -5,6 +5,17 @@ block title
block configjs
script Recommendation = L3D.ArrowRecommendation;
script.
Coin.onLastCoin = function() {
$('#next').show();
$('#next').click(function() {
window.location = '/prototype/arrows';
});
};
block lastbutton
button#next.btn.btn-success.navbar-btn(style={'margin-right':'10px', 'margin-bottom':'10px', 'display':'none'})
span Go to the next step
//-block preciseDescription
p

View File

@ -0,0 +1,25 @@
extends ./prototype_interactive
block title
title #{title} - Prototype - Arrows
block configjs
script Recommendation = L3D.EmptyRecommendation;
script.
Coin.onLastCoin = function() {
$('#next').show();
$('#next').click(function() {
window.location = '/prototype/arrows';
});
};
block lastbutton
button#next.btn.btn-success.navbar-btn(style={'margin-right':'10px', 'margin-bottom':'10px', 'display':'none'})
span Go to the next step
//-block preciseDescription
p
| Recommended views are displayed with a
| transparent blue arrow. They disappear when you
| come closer to them, and shows the motion between
| your current position and the recommendation.

View File

@ -5,6 +5,17 @@ block title
block configjs
script Recommendation = L3D.ViewportRecommendation;
script.
Coin.onLastCoin = function() {
$('#next').show();
$('#next').click(function() {
window.location = '/prototype/arrows';
});
};
block lastbutton
button#next.btn.btn-success.navbar-btn(style={'margin-right':'10px', 'margin-bottom':'10px', 'display':'none'})
span Go to the next step
//-block preciseDescription
p

View File

@ -0,0 +1,9 @@
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);
});
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/thankyou': 'index',
};

View File

@ -0,0 +1,5 @@
extends ../../../views/base.jade
block content
h1 Thank you for everything !

View File

@ -29,6 +29,7 @@ L3D:
--js l3d/src/recommendations/ViewportRecommendation.js \
--js l3d/src/recommendations/ArrowRecommendation.js \
--js l3d/src/recommendations/ReverseRecommendation.js \
--js l3d/src/recommendations/EmptyRecommendation.js \
--js l3d/src/cameras/ReplayCamera.js \
--js l3d/src/cameras/Camera.js \
--js l3d/src/cameras/FixedCamera.js \

View File

@ -156,6 +156,9 @@ Coin.prototype.get = function() {
Coin.sounds[(Coin.total ++) - 1].play();
if (Coin.total === 9) {
if (typeof Coin.onLastCoin === 'function') {
Coin.onLastCoin();
}
// You got the last coin
var music = document.getElementById('music');
if (music !== null) {

View File

@ -111,7 +111,7 @@ var TutorialSteps = function(tutoCamera, scene, coins, onWindowResize, container
justclick:false
},
{
text: "Congratulations ! You've successfully finished the tutorial !",
text: "Congratulations ! You've successfully finished the tutorial ! <a href=\"/prototype/empty\">Click here</a> to start.",
justclick: false
}
];

View File

@ -0,0 +1,20 @@
L3D.EmptyRecommendation = function() {
L3D.BaseRecommendation.apply(this, arguments);
this.target = new THREE.Vector3();
};
L3D.EmptyRecommendation.prototype = Object.create(L3D.BaseRecommendation.prototype);
L3D.EmptyRecommendation.prototype.constructor = L3D.EmptyRecommendation;
L3D.EmptyRecommendation.prototype.raycast = function() {};
L3D.EmptyRecommendation.prototype.check = function() {};
L3D.EmptyRecommendation.prototype.initExtremity = function() {};
L3D.EmptyRecommendation.prototype.updateExtremity = function() {};
L3D.EmptyRecommendation.prototype.setSize = function() {};
L3D.EmptyRecommendation.prototype.update = function() {};
L3D.EmptyRecommendation.prototype.regenerateArrow = function() {};
L3D.EmptyRecommendation.prototype.look = function() {};
L3D.EmptyRecommendation.prototype.addToScene = function() {};

View File

@ -0,0 +1,25 @@
var mail = require('../../lib/mail.js');
var Log = require('../../lib/NodeLog.js');
module.exports.index = function(req, res) {
var text = '';
for (var i in req.body) {
text += i + ' : ' + req.body[i] + '\n'
}
mail.send({
from: req.session.user_id + " <" + req.session.user_id + "@toto.tata>",
to: "Thomas <thomas.forgione@gmail.com>",
subject: "By " + req.session.user_id,
text: text
}, function(err, message) {
if (err !== null) {
Log.mailerror(err);
}
});
res.redirect('/thankyou');
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/feedback-target': 'index'
};

View File

@ -30,7 +30,7 @@ module.exports.index = function(req, res) {
);
});
res.redirect('/');
res.redirect('/prototype/tutorial');
});
} else {

View File

@ -51,7 +51,8 @@ CREATE TABLE Scene(
CREATE TABLE Experiment(
id SERIAL PRIMARY KEY,
user_id SERIAL REFERENCES Users (id),
scene_id SERIAL REFERENCES Scene (id)
scene_id SERIAL REFERENCES Scene (id),
template VARCHAR(30)
);
CREATE TABLE Coin(

38
static/css/feedback.css Normal file
View File

@ -0,0 +1,38 @@
body {
padding-top: 40px;
padding-bottom: 40px;
background-color: #eee;
}
.form-signin {
padding: 15px;
margin: 0 auto;
}
.form-signin .form-signin-heading,
.form-signin .checkbox {
margin-bottom: 10px;
}
.form-signin .checkbox {
font-weight: normal;
}
.form-signin .form-control {
position: relative;
height: auto;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 10px;
font-size: 16px;
}
.form-signin .form-control:focus {
z-index: 2;
}
.form-signin input {
margin-bottom: 5px;
margin-top: 5px;
}
.form-signin label {
margin-right: 0px;
margin-left: 0px;
}