Solving problems with sessions and timestamps

parent 77b7ae86
...@@ -43,7 +43,7 @@ public abstract class Action { ...@@ -43,7 +43,7 @@ public abstract class Action {
final String param_id_dev="id_dev"; final String param_id_dev="id_dev";
final String param_timestamp="timestamp"; final String param_timestamp="timestamp";
final Date currentTime = new Date(); final Date currentTime = new Date();
SimpleDateFormat datetime = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); SimpleDateFormat datetime = new SimpleDateFormat("yyyy-MM-ddTHH:mm:ss.SSSZ");
try { try {
JSONObject jsonObject = new JSONObject() JSONObject jsonObject = new JSONObject()
.put(param_id_stu, PCBcontext.getPcbdb().getCurrentUser().get_id_stu()) .put(param_id_stu, PCBcontext.getPcbdb().getCurrentUser().get_id_stu())
......
...@@ -196,7 +196,7 @@ END ...@@ -196,7 +196,7 @@ END
CREATE TRIGGER trg_insert_users_detail CREATE TRIGGER trg_insert_users_detail
INSTEAD OF INSERT ON users_detail INSTEAD OF INSERT ON users_detail
FOR EACH ROW FOR EACH ROW
WHEN NEW.pwd_stu NOT IS NULL WHEN NEW.pwd_stu IS NOT NULL
BEGIN BEGIN
INSERT OR REPLACE INTO student VALUES (NEW.id_stu, NEW.nickname_stu, NEW.pwd_stu, NEW.name_stu, NEW.surname_stu, NEW.url_img_stu, NEW.gender_stu, NEW.lang_stu, NEW.attributes_stu); INSERT OR REPLACE INTO student VALUES (NEW.id_stu, NEW.nickname_stu, NEW.pwd_stu, NEW.name_stu, NEW.surname_stu, NEW.url_img_stu, NEW.gender_stu, NEW.lang_stu, NEW.attributes_stu);
INSERT OR REPLACE INTO supervisor VALUES (NEW.id_sup, NEW.email_sup, NEW.pwd_sup, NEW.name_sup, NEW.surname_sup, NEW.url_img_sup, NEW.gender_sup, NEW.lang_sup, NEW.tts_engine_sup); INSERT OR REPLACE INTO supervisor VALUES (NEW.id_sup, NEW.email_sup, NEW.pwd_sup, NEW.name_sup, NEW.surname_sup, NEW.url_img_sup, NEW.gender_sup, NEW.lang_sup, NEW.tts_engine_sup);
......
...@@ -27,11 +27,11 @@ SET time_zone = "+00:00"; ...@@ -27,11 +27,11 @@ SET time_zone = "+00:00";
CREATE TABLE IF NOT EXISTS `action` ( CREATE TABLE IF NOT EXISTS `action` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`type` varchar(20) COLLATE utf8_unicode_ci NOT NULL CHECK (type IN ('Add','Select','Delete','Show','Unshow','Pause','tryinit','tryend','initsession','endsession','pausesession','resumesession')), `type` varchar(20) COLLATE utf8_unicode_ci NOT NULL CHECK (type IN ('Add','Select','Delete','Show','Unshow','Pause','tryinit','tryend','initsession','endsession','pausesession','resumesession')),
`timestamp` timestamp DEFAULT CURRENT_TIMESTAMP, `timestamp` timestamp(3) DEFAULT CURRENT_TIMESTAMP,
`id_sup` int(11) DEFAULT NULL, `id_sup` int(11) DEFAULT NULL,
`id_stu` int(11) NOT NULL, `id_stu` int(11) NOT NULL,
`id_try` int(11) DEFAULT NULL, `id_try` int(11) DEFAULT NULL,
`description` varchar(1024) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'serialization of properties of the picto at the time of the action', `description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'serialization of properties of the picto at the time of the action',
`gps_lat` float DEFAULT NULL, `gps_lat` float DEFAULT NULL,
`gps_lon` float DEFAULT NULL, `gps_lon` float DEFAULT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
...@@ -42,7 +42,7 @@ CREATE TABLE IF NOT EXISTS `action` ( ...@@ -42,7 +42,7 @@ CREATE TABLE IF NOT EXISTS `action` (
KEY `fk_stu_act` (`id_stu`), KEY `fk_stu_act` (`id_stu`),
KEY `id_try` (`id_try`) KEY `id_try` (`id_try`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
COMMENT="This table registers and action performed by a user at a given time, all information of the action is in JSON format in the 'description' column and the operation performed is one of the possible for the 'type' column"; COMMENT="This table registers and action performed by a user at a given time, all information of the action is in JSON format in the 'description' column and the operation performed is one of the possible for the 'type' column. NOTE: timestamps must support fractional seconds, so MySQL versions >= 5.6.4 are required.";
-- -------------------------------------------------------- -- --------------------------------------------------------
...@@ -70,10 +70,10 @@ COMMENT="Stores the expressions available in several languages for a given categ ...@@ -70,10 +70,10 @@ COMMENT="Stores the expressions available in several languages for a given categ
CREATE TABLE IF NOT EXISTS `method` ( CREATE TABLE IF NOT EXISTS `method` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(40) COLLATE utf8_unicode_ci NOT NULL, `name` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`description` varchar(1024) COLLATE utf8_unicode_ci DEFAULT NULL, `description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
`id_stu` int(11) NOT NULL, `id_stu` int(11) NOT NULL,
`registration` date DEFAULT NULL, `registration` date DEFAULT NULL,
`notes` varchar(1024) COLLATE utf8_unicode_ci DEFAULT NULL, `notes` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `fk_stu_met` (`id_stu`) KEY `fk_stu_met` (`id_stu`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
...@@ -91,8 +91,8 @@ CREATE TABLE IF NOT EXISTS `instruction` ( ...@@ -91,8 +91,8 @@ CREATE TABLE IF NOT EXISTS `instruction` (
`name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`objective` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL, `objective` varchar(512) COLLATE utf8_unicode_ci DEFAULT NULL,
`status` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL CHECK (status IN ('started','finished')), `status` varchar(60) COLLATE utf8_unicode_ci DEFAULT NULL CHECK (status IN ('started','finished')),
`begin` timestamp NULL, `begin` timestamp(3) NULL,
`end` timestamp NULL, `end` timestamp(3) NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
COMMENT="An instruction is a 'phase' in a method for learning AAC"; COMMENT="An instruction is a 'phase' in a method for learning AAC";
...@@ -122,7 +122,7 @@ COMMENT="One in a set of instructions predefined or stored by users. They are re ...@@ -122,7 +122,7 @@ COMMENT="One in a set of instructions predefined or stored by users. They are re
CREATE TABLE IF NOT EXISTS `meta_method` ( CREATE TABLE IF NOT EXISTS `meta_method` (
`id` tinyint(4) NOT NULL AUTO_INCREMENT, `id` tinyint(4) NOT NULL AUTO_INCREMENT,
`name` varchar(40) COLLATE utf8_unicode_ci NOT NULL, `name` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`description` varchar(1024) COLLATE utf8_unicode_ci DEFAULT NULL, `description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
`id_sup` INT( 11 ) DEFAULT NULL, `id_sup` INT( 11 ) DEFAULT NULL,
UNIQUE(name,id_sup), UNIQUE(name,id_sup),
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
...@@ -195,7 +195,7 @@ CREATE TABLE IF NOT EXISTS `picto_acl` ( ...@@ -195,7 +195,7 @@ CREATE TABLE IF NOT EXISTS `picto_acl` (
`id_sup` int(11) NOT NULL DEFAULT '0', `id_sup` int(11) NOT NULL DEFAULT '0',
`id_pic` int(11) NOT NULL DEFAULT '0', `id_pic` int(11) NOT NULL DEFAULT '0',
`privilege` varchar(1) COLLATE utf8_unicode_ci NOT NULL, `privilege` varchar(1) COLLATE utf8_unicode_ci NOT NULL,
`timestamp` datetime, `timestamp` timestamp(3),
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `k_pic_aclp` (`id_pic`), KEY `k_pic_aclp` (`id_pic`),
KEY `k_sup_aclp` (`id_sup`) KEY `k_sup_aclp` (`id_sup`)
...@@ -264,7 +264,7 @@ COMMENT="Labels assigned to pictos by default or by supervisors"; ...@@ -264,7 +264,7 @@ COMMENT="Labels assigned to pictos by default or by supervisors";
CREATE TABLE IF NOT EXISTS `source` ( CREATE TABLE IF NOT EXISTS `source` (
`id` tinyint(4) NOT NULL AUTO_INCREMENT, `id` tinyint(4) NOT NULL AUTO_INCREMENT,
`name` varchar(40) COLLATE utf8_unicode_ci NOT NULL, `name` varchar(40) COLLATE utf8_unicode_ci NOT NULL,
`description` varchar(1024) COLLATE utf8_unicode_ci DEFAULT NULL, `description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2
COMMENT="Contains all possible sources of pictos"; COMMENT="Contains all possible sources of pictos";
...@@ -285,9 +285,9 @@ CREATE TABLE IF NOT EXISTS `student` ( ...@@ -285,9 +285,9 @@ CREATE TABLE IF NOT EXISTS `student` (
`gender` char(1) COLLATE utf8_unicode_ci NOT NULL, `gender` char(1) COLLATE utf8_unicode_ci NOT NULL,
`country` char(2) COLLATE utf8_unicode_ci NOT NULL, `country` char(2) COLLATE utf8_unicode_ci NOT NULL,
`pic` varchar(255) COLLATE utf8_unicode_ci DEFAULT 'defaultAvatar.jpg', `pic` varchar(255) COLLATE utf8_unicode_ci DEFAULT 'defaultAvatar.jpg',
`notes` varchar(1024) COLLATE utf8_unicode_ci DEFAULT NULL, `notes` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
`lang` varchar(5) COLLATE utf8_unicode_ci NOT NULL, `lang` varchar(5) COLLATE utf8_unicode_ci NOT NULL,
`attributes` varchar(1024) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Attributes describing student along with his/her configuration', `attributes` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Attributes describing student along with his/her configuration',
`id_off` int(11) DEFAULT NULL, `id_off` int(11) DEFAULT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `username` (`username`), UNIQUE KEY `username` (`username`),
...@@ -366,10 +366,10 @@ COMMENT="Supervisors information"; ...@@ -366,10 +366,10 @@ COMMENT="Supervisors information";
CREATE TABLE IF NOT EXISTS `try` ( CREATE TABLE IF NOT EXISTS `try` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`id_ws` int(11) NOT NULL, `id_ws` int(11) NOT NULL,
`begin` timestamp DEFAULT CURRENT_TIMESTAMP, `begin` timestamp(3) DEFAULT CURRENT_TIMESTAMP,
`end` timestamp NULL, `end` timestamp(3) NULL,
`result` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL, `result` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
`description` varchar(1024) COLLATE utf8_unicode_ci DEFAULT NULL, `description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `id_ws` (`id_ws`) KEY `id_ws` (`id_ws`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1
...@@ -388,10 +388,10 @@ CREATE TABLE IF NOT EXISTS `working_session` ( ...@@ -388,10 +388,10 @@ CREATE TABLE IF NOT EXISTS `working_session` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`id_sup` int(11) NOT NULL, `id_sup` int(11) NOT NULL,
`id_ins` int(11) NOT NULL, `id_ins` int(11) NOT NULL,
`begin` timestamp DEFAULT CURRENT_TIMESTAMP, `begin` timestamp(3) DEFAULT CURRENT_TIMESTAMP,
`end` timestamp NULL, `end` timestamp(3) NULL,
`current` boolean NULL DEFAULT 1, `current` boolean NULL DEFAULT 1,
`description` varchar(1024) COLLATE utf8_unicode_ci DEFAULT NULL, `description` varchar(4096) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `id_sup` (`id_sup`), KEY `id_sup` (`id_sup`),
KEY `id_ins` (`id_ins`), KEY `id_ins` (`id_ins`),
......
...@@ -142,9 +142,9 @@ thisTrigger: BEGIN ...@@ -142,9 +142,9 @@ thisTrigger: BEGIN
LEAVE thisTrigger; LEAVE thisTrigger;
END IF; END IF;
IF ((old.end IS NULL) and (new.end IS NOT NULL)) THEN IF ((old.end IS NULL) and (new.end IS NOT NULL)) THEN
CALL deleteOpenTry(new.id); CALL deleteOpenTry(new.id);
END IF; END IF;
END;; END;;
......
...@@ -42,7 +42,7 @@ module.exports = { ...@@ -42,7 +42,7 @@ module.exports = {
if (!params.type) return res.json(500, {error: "No type of action defined"}); if (!params.type) return res.json(500, {error: "No type of action defined"});
// Optional params // Optional params
var timestamp = null; if(params.timestamp) timestamp = params.timestamp; var timestamp = null; if(params.timestamp) timestamp = params.timestamp.toISOString();
var sup = null; if(params.supervisor) sup = params.supervisor; var sup = null; if(params.supervisor) sup = params.supervisor;
var _try = null; if(params._try) _try = params._try; var _try = null; if(params._try) _try = params._try;
var description = null; if(params.description) description = params.description; var description = null; if(params.description) description = params.description;
...@@ -59,18 +59,20 @@ module.exports = { ...@@ -59,18 +59,20 @@ module.exports = {
"description": description, "description": description,
"gpsLat": gpsLat, "gpsLat": gpsLat,
"gpsLon": gpsLon "gpsLon": gpsLon
}).exec(function(err, created){ })
if(err || !created) return res.json(500, { error: "Error saving an action "+ params.type +": " + err }); .then(function(created){
if(created) { if (!created)
StuOpenTry.findOne({id_stu : params.student}).exec(function(err, data){ throw new Error("Action.create returned NULL");
if(err || !data){
sails.log.error("Error finding try for student "+ params.student + ' when creating action '+ params.type); StuOpenTry.findOne({id_stu : params.student})
return res.json(500, {error: 'Action '+ params.type +' not created'}); .then(function(data){
} if(!data)
sails.log.debug("Try for student "+params.student+ ":"+JSON.stringify(data)); throw new Error("Error finding try for student "+ params.student + ' when creating action '+ params.type);
return res.json(200,{open_try: data.openTry }); return res.ok({open_try: data.openTry });
}) })
} })
.fail(function(err) {
res.serverError("Error saving an action "+ params.type +": " + err);
}); });
}, },
...@@ -100,7 +102,7 @@ module.exports = { ...@@ -100,7 +102,7 @@ module.exports = {
Action.create({ Action.create({
type: a.action, type: a.action,
timestamp: a.attributes.timestamp, timestamp: a.attributes.timestamp.toISOString(),
supervisor: sup, supervisor: sup,
student: params.student, student: params.student,
description: desc description: desc
......
...@@ -271,7 +271,8 @@ module.exports = { ...@@ -271,7 +271,8 @@ module.exports = {
* { * {
* id: pictoId, * id: pictoId,
* source: 1, * source: 1,
* owner: supervisorId * owner: supervisorId,
* uri: 'https://path/to/picto/in/the/web'
* } * }
*/ */
upload: function (req, res) { upload: function (req, res) {
......
...@@ -83,17 +83,17 @@ module.exports = { ...@@ -83,17 +83,17 @@ module.exports = {
res.serverError(); res.serverError();
}); });
} else { } else {
res.badRequest('Invalid user or password'); res.badRequest('Invalid password');
} }
} else { } else {
res.badRequest('Invalid user or password'); res.badRequest('Invalid user');
} }
}) })
.catch(function () { .catch(function () {
res.badRequest('Invalid user or password'); res.badRequest('Invalid user or password');
}); });
} else { } else {
res.badRequest('Invalid user or password'); res.badRequest('No email or or password');
} }
}, },
......
...@@ -30,7 +30,7 @@ module.exports = { ...@@ -30,7 +30,7 @@ module.exports = {
columnName: "id_ins", columnName: "id_ins",
required: true, required: true,
type: "integer", type: "integer",
model: "Instruction" model: "Instruction"
}, },
begin: { begin: {
type: "datetime", type: "datetime",
...@@ -40,21 +40,50 @@ module.exports = { ...@@ -40,21 +40,50 @@ module.exports = {
type: "datetime" type: "datetime"
}, },
current: { current: {
type: "integer", type: "integer",
}, },
description: { description: {
type: "string", type: "string",
size: 1024 size: 1024
}, },
// Relación con Try. [1 WorkingSession to N Try] // Relación con Try. [1 WorkingSession to N Try]
tries: { tries: {
collection: 'Try', collection: 'Try',
via: "workingSession" via: "workingSession"
} }
}, },
/**
* Checks a previous session is not opened for that supervisor. If so,
* session is closed (current is set to 0)
* @param {Object} attrs All session properties to be stored
* @param {Function} next Function to be executed when the check process
* has been completed (an error object will be passed
* to the function if necesary)
*/
beforeCreate: function (attrs, next) {
WorkingSession.find({id_sup: attrs.supervisor, current: 1})
.then(function(wss) {
if (wss) {
async.each(wss, function(ws, cb) {
ws.current = 0;
WorkingSession.update(ws.id, ws, function(err, update) {
if (err) throw new Error("Error when udpating open sessions");
cb();
});
});
}
next();
})
.fail(function(err) {
next(err);
})
},
// //
// Returns the number of working sessions per year (REPORTS) // Returns the number of working sessions per year (REPORTS)
// //
per_year: function(id_stu, year, callback) { per_year: function(id_stu, year, callback) {
var l = []; var l = [];
...@@ -65,18 +94,18 @@ module.exports = { ...@@ -65,18 +94,18 @@ module.exports = {
// eachSeries // eachSeries
async.eachSeries( async.eachSeries(
// 1st array of items // 1st array of items
months, months,
// 2nd function to operate over one item // 2nd function to operate over one item
function(month, next) { function(month, next) {
var month_1 = year +'-'+ month +'-01'; // 2015-1-01 var month_1 = year +'-'+ month +'-01'; // 2015-1-01
var month_2 = (month<12) ? (year +'-'+ (month+1) +'-01') : ((year+1) +'-01-01'); // 2015-2-01 ó 2016-01-01 var month_2 = (month<12) ? (year +'-'+ (month+1) +'-01') : ((year+1) +'-01-01'); // 2015-2-01 ó 2016-01-01
WorkingSession.count({ WorkingSession.count({
'id_stu' : id_stu, 'id_stu' : id_stu,
'begin' : { 'begin' : {
'>=' : month_1, '>=' : month_1,
'<' : month_2 '<' : month_2
} }
}).exec(function(err, ws) { }).exec(function(err, ws) {
if (err) if (err)
...@@ -84,7 +113,7 @@ module.exports = { ...@@ -84,7 +113,7 @@ module.exports = {
if(!ws) if(!ws)
console.log("No ws in this month"); console.log("No ws in this month");
if(ws) if(ws)
console.log(JSON.stringify(ws)); console.log(JSON.stringify(ws));
...@@ -99,7 +128,7 @@ module.exports = { ...@@ -99,7 +128,7 @@ module.exports = {
}, },
// 3rd final function when all is ready // 3rd final function when all is ready
function (err){ function (err){
console.log("It's the final functiooonnnnnnnn....."); console.log("It's the final functiooonnnnnnnn.....");
console.log(JSON.stringify(l)); console.log(JSON.stringify(l));
return callback(err, l); return callback(err, l);
...@@ -111,7 +140,7 @@ module.exports = { ...@@ -111,7 +140,7 @@ module.exports = {
// //
// Returns the number of working sessions per month (REPORTS) // Returns the number of working sessions per month (REPORTS)
// //
per_month: function(id_stu, month, callback) { per_month: function(id_stu, month, callback) {
var l = []; var l = [];
...@@ -122,18 +151,18 @@ module.exports = { ...@@ -122,18 +151,18 @@ module.exports = {
// eachSeries // eachSeries
async.eachSeries( async.eachSeries(
// 1st array of items // 1st array of items
months, months,
// 2nd function to operate over one item // 2nd function to operate over one item
function(month, next) { function(month, next) {
var month_1 = year + '-'+ month +'-01'; // 2015-1-01 var month_1 = year + '-'+ month +'-01'; // 2015-1-01
var month_2 = (month<12) ? (year +'-'+ (month+1) +'-01') : ((year+1) +'-01-01'); // 2015-2-01 ó 2016-01-01 var month_2 = (month<12) ? (year +'-'+ (month+1) +'-01') : ((year+1) +'-01-01'); // 2015-2-01 ó 2016-01-01
WorkingSession.count({ WorkingSession.count({
'id_stu' : id_stu, 'id_stu' : id_stu,
'begin' : { 'begin' : {
'>=' : month_1, '>=' : month_1,
'<' : month_2 '<' : month_2
} }
}).exec(function(err, ws) { }).exec(function(err, ws) {
if (err) if (err)
...@@ -141,7 +170,7 @@ module.exports = { ...@@ -141,7 +170,7 @@ module.exports = {
if(!ws) if(!ws)
console.log("No ws in this month"); console.log("No ws in this month");
if(ws) if(ws)
console.log(JSON.stringify(ws)); console.log(JSON.stringify(ws));
...@@ -154,7 +183,7 @@ module.exports = { ...@@ -154,7 +183,7 @@ module.exports = {
}, },
// 3rd final function when all is ready // 3rd final function when all is ready
function (err){ function (err){
console.log("It's the final functiooonnnnnnnn....."); console.log("It's the final functiooonnnnnnnn.....");
console.log(JSON.stringify(l)); console.log(JSON.stringify(l));
return callback(err, l); return callback(err, l);
......
...@@ -80,6 +80,7 @@ ...@@ -80,6 +80,7 @@
"enlarge": "Enlarge", "enlarge": "Enlarge",
"enormous": "Enormous", "enormous": "Enormous",
"error_adding_picto": "Error adding picto", "error_adding_picto": "Error adding picto",
"error_creating_session": "Error when creating session",
"error_deleting_picto": "Error deleting picto", "error_deleting_picto": "Error deleting picto",
"error_downloading_supervisors": "Error downloading supervisors", "error_downloading_supervisors": "Error downloading supervisors",
"error_downloading_offices": "Error downloading offices", "error_downloading_offices": "Error downloading offices",
......
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
"expand_navigation": "Desplegar navegación", "expand_navigation": "Desplegar navegación",
"expression": "Expresión:", "expression": "Expresión:",
"error_adding_picto": "Error al añadir el picto", "error_adding_picto": "Error al añadir el picto",
"error_creating_session": "Error al crear sesión",
"error_deleting_picto": "Error borrando el picto", "error_deleting_picto": "Error borrando el picto",
"error_downloading_supervisors": "Error al descargar los supervisores", "error_downloading_supervisors": "Error al descargar los supervisores",
"error_downloading_offices": "Error al descargar las oficinas", "error_downloading_offices": "Error al descargar las oficinas",
......
...@@ -3,7 +3,14 @@ ...@@ -3,7 +3,14 @@
//----------------------- //-----------------------
// Student Session Controller // Student Session Controller
//----------------------- //-----------------------
dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtrl($scope, $stateParams, $http, config, $window) { dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtrl(
$scope,
$stateParams,
$http,
config,
$window,
$translate,
ngToast) {
...@@ -206,7 +213,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -206,7 +213,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
.post(config.backend+'/ws', { .post(config.backend+'/ws', {
"id_sup": $scope.user.id, "id_sup": $scope.user.id,
"id_stu": $scope.studentData.id, "id_stu": $scope.studentData.id,
"id_ins": $scope.selectedIns "id_ins": $scope.selectedIns.id
}) })
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
...@@ -229,7 +236,9 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -229,7 +236,9 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$scope.studentData.current_instruction=$scope.selectedIns.name; $scope.studentData.current_instruction=$scope.selectedIns.name;
}) })
.error(function(data, status, headers, config) { .error(function(data, status, headers, config) {
$translate('error_creating_session').then(function (translation) {
ngToast.danger({ content: translation });
});
}); });
}; };
...@@ -237,12 +246,10 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -237,12 +246,10 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// update the description of a given working session // update the description of a given working session
// //
$scope.update_ws = function (ws){ $scope.update_ws = function (ws){
$http $http
.put(config.backend+'/ws/' + ws.id, { "description" : ws.description }) .put(config.backend+'/ws/' + ws.id, { "description" : ws.description })
.then(function(data, status, headers, config) { .then(function(data, status, headers, config) {
// TODO notify update?
}) })
,function(data, status, headers, config) { ,function(data, status, headers, config) {
...@@ -260,8 +267,8 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -260,8 +267,8 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$http $http
.put(config.backend+'/ws/' + $scope.ws.id, { "end": $scope.ws.end, .put(config.backend+'/ws/' + $scope.ws.id, { "end": $scope.ws.end,
"id_stu": $scope.studentData.id "id_stu": $scope.studentData.id
}) })
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
// Empty actual WS and actual try // Empty actual WS and actual try
...@@ -376,26 +383,22 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -376,26 +383,22 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// what data has updated, and refresh what needs to be refreshed. // what data has updated, and refresh what needs to be refreshed.
if($scope.ws){ if($scope.ws){
console.log(data.action);
switch(data.action){ switch(data.action){
case 'Add': case 'Add':
$scope.actual_try.actions.push(data); $scope.actual_try.actions.push(data);
break; break;
case 'Delete': case 'Delete':
$scope.actual_try.actions.push(data); $scope.actual_try.actions.push(data);
break; break;
case 'Select': case 'Select':
$scope.actual_try.actions.push(data); $scope.actual_try.actions.push(data);
break; break;
case 'Show': case 'Show':
$scope.load_tries($scope.selectedIns);
$scope.load_tries($scope.selectedIns);
// Empty actual try and push the first action of next try // Empty actual try and push the first action of next try
$scope.actual_try.actions = []; $scope.actual_try.actions = [];
$scope.actual_try.actions.push({ action: 'tryinit' }); $scope.actual_try.actions.push({ action: 'tryinit' });
break; break;
} }
} }
......
...@@ -44,10 +44,10 @@ ...@@ -44,10 +44,10 @@
<img ng-src="{{ a.attributes.picto.picto.uri }}" /> <img ng-src="{{ a.attributes.picto.picto.uri }}" />
<div class="action-type"> <div class="action-type">
<span ng-if="a.action == 'add'" class="glyphicon glyphicon-plus color_green" aria-hidden="true"></span> <span ng-if="a.action == 'add'" class="glyphicon glyphicon-plus color_green" aria-hidden="true"></span>
<span ng-if="a.action == 'select'" class="glyphicon glyphicon-hand-up color_blue" aria-hidden="true"></span> <span ng-if="a.action == 'Select'" class="glyphicon glyphicon-hand-up color_blue" aria-hidden="true"></span>
<span ng-if="a.action == 'delete'" class="glyphicon glyphicon-remove color_red" aria-hidden="true"></span> <span ng-if="a.action == 'Delete'" class="glyphicon glyphicon-remove color_red" aria-hidden="true"></span>
<span ng-if="a.action == 'show'" class="glyphicon glyphicon-eye-open color_blue" aria-hidden="true"></span> <span ng-if="a.action == 'Show'" class="glyphicon glyphicon-eye-open color_blue" aria-hidden="true"></span>
<span ng-if="a.action == 'unshow'" class="glyphicon glyphicon-edit color_blue" aria-hidden="true"></span> <span ng-if="a.action == 'Unshow'" class="glyphicon glyphicon-edit color_blue" aria-hidden="true"></span>
<span ng-if="a.action == 'tryinit'" class="glyphicon glyphicon-log-in" aria-hidden="true"></span> <span ng-if="a.action == 'tryinit'" class="glyphicon glyphicon-log-in" aria-hidden="true"></span>
<span ng-if="a.action == 'tryend'" class="glyphicon glyphicon-log-out" aria-hidden="true"></span> <span ng-if="a.action == 'tryend'" class="glyphicon glyphicon-log-out" aria-hidden="true"></span>
<span ng-if="a.action == 'pausesession'" class="glyphicon glyphicon-pause" aria-hidden="true"></span> <span ng-if="a.action == 'pausesession'" class="glyphicon glyphicon-pause" aria-hidden="true"></span>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment