issue #595 fixed

parent 63b19fa7
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
signingConfigs { /*signingConfigs {
config { config {
keyAlias 'Pictogram' keyAlias 'Pictogram'
keyPassword 'danoia' keyPassword 'danoia'
storeFile file('C:/Users/Fernando/pictogramkeys.jks') storeFile file('C:/Users/Fernando/pictogramkeys.jks')
storePassword 'danoia' storePassword 'danoia'
} }
} }*/
compileSdkVersion 24 compileSdkVersion 24
buildToolsVersion "23.0.2" buildToolsVersion "23.0.2"
defaultConfig { defaultConfig {
...@@ -17,7 +18,7 @@ android { ...@@ -17,7 +18,7 @@ android {
targetSdkVersion 22 targetSdkVersion 22
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
signingConfig signingConfigs.config // signingConfig signingConfigs.config
} }
productFlavors { productFlavors {
CIFlavor { CIFlavor {
......
...@@ -669,6 +669,7 @@ public class PictogramActivity extends Activity implements iVocabularyListener, ...@@ -669,6 +669,7 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
@Override @Override
public void onClick(View arg0) { public void onClick(View arg0) {
LinkedList<Picto> lp = tapeAdapter.getAll(); LinkedList<Picto> lp = tapeAdapter.getAll();
// This triggers the "Show" websocket action
PCBcontext.getActionLog().log(new PictosAction(lp)); PCBcontext.getActionLog().log(new PictosAction(lp));
tapeAdapter.ttsAllNew(tts); tapeAdapter.ttsAllNew(tts);
} }
......
...@@ -125,11 +125,9 @@ ...@@ -125,11 +125,9 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/24.1.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/21.0.3/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/24.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.0.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/24.1.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-vector-drawable/24.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads-lite/9.2.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads-lite/9.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads/9.2.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads/9.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-auth-base/9.2.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-auth-base/9.2.1/jars" />
...@@ -161,32 +159,32 @@ ...@@ -161,32 +159,32 @@
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="wearable-2.0.0-alpha2" level="project" /> <orderEntry type="library" exported="" name="wearable-2.0.0-alpha2" level="project" />
<orderEntry type="library" exported="" name="okhttp-ws-2.3.0" level="project" /> <orderEntry type="library" exported="" name="okhttp-ws-2.3.0" level="project" />
<orderEntry type="library" exported="" name="support-v4-24.1.1" level="project" />
<orderEntry type="library" exported="" name="play-services-base-9.2.1" level="project" /> <orderEntry type="library" exported="" name="play-services-base-9.2.1" level="project" />
<orderEntry type="library" exported="" name="socket.io-client-0.5.0" level="project" /> <orderEntry type="library" exported="" name="socket.io-client-0.5.0" level="project" />
<orderEntry type="library" exported="" name="okhttp-2.3.0" level="project" /> <orderEntry type="library" exported="" name="okhttp-2.3.0" level="project" />
<orderEntry type="library" exported="" name="androidasync-2.1.9" level="project" /> <orderEntry type="library" exported="" name="androidasync-2.1.9" level="project" />
<orderEntry type="library" exported="" name="play-services-clearcut-9.2.1" level="project" /> <orderEntry type="library" exported="" name="play-services-clearcut-9.2.1" level="project" />
<orderEntry type="library" exported="" name="animated-vector-drawable-24.1.1" level="project" />
<orderEntry type="library" exported="" name="play-services-wearable-9.2.1" level="project" /> <orderEntry type="library" exported="" name="play-services-wearable-9.2.1" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" /> <orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
<orderEntry type="library" exported="" name="okio-1.3.0" level="project" /> <orderEntry type="library" exported="" name="okio-1.3.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
<orderEntry type="library" exported="" name="play-services-gcm-9.2.1" level="project" /> <orderEntry type="library" exported="" name="play-services-gcm-9.2.1" level="project" />
<orderEntry type="library" exported="" name="play-services-auth-base-9.2.1" level="project" /> <orderEntry type="library" exported="" name="play-services-auth-base-9.2.1" level="project" />
<orderEntry type="library" exported="" name="play-services-gass-9.2.1" level="project" /> <orderEntry type="library" exported="" name="play-services-gass-9.2.1" level="project" />
<orderEntry type="library" exported="" name="gson-2.3" level="project" /> <orderEntry type="library" exported="" name="gson-2.3" level="project" />
<orderEntry type="library" exported="" name="play-services-iid-9.2.1" level="project" /> <orderEntry type="library" exported="" name="play-services-iid-9.2.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-24.1.1" level="project" />
<orderEntry type="library" exported="" name="play-services-basement-9.2.1" level="project" /> <orderEntry type="library" exported="" name="play-services-basement-9.2.1" level="project" />
<orderEntry type="library" exported="" name="play-services-tasks-9.2.1" level="project" /> <orderEntry type="library" exported="" name="play-services-tasks-9.2.1" level="project" />
<orderEntry type="library" exported="" name="engine.io-client-0.5.0" level="project" /> <orderEntry type="library" exported="" name="engine.io-client-0.5.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-24.1.1" level="project" /> <orderEntry type="library" exported="" name="appcompat-v7-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-24.1.1" level="project" />
<orderEntry type="library" exported="" name="play-services-auth-9.2.1" level="project" /> <orderEntry type="library" exported="" name="play-services-auth-9.2.1" level="project" />
<orderEntry type="library" exported="" name="play-services-ads-9.2.1" level="project" /> <orderEntry type="library" exported="" name="play-services-ads-9.2.1" level="project" />
<orderEntry type="library" exported="" name="ion-2.1.9" level="project" /> <orderEntry type="library" exported="" name="ion-2.1.9" level="project" />
<orderEntry type="library" exported="" name="play-services-ads-lite-9.2.1" level="project" /> <orderEntry type="library" exported="" name="play-services-ads-lite-9.2.1" level="project" />
<orderEntry type="module" module-name="commonlibrary" exported="" /> <orderEntry type="module" module-name="commonlibrary" exported="" />
<orderEntry type="library" exported="" name="support-v4-23.0.0" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.0.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="json-20090211" level="project" /> <orderEntry type="library" exported="" scope="TEST" name="json-20090211" level="project" />
......
...@@ -50,7 +50,7 @@ FOREIGN KEY (id_ws) REFERENCES working_session(id) ON DELETE CASCADE ...@@ -50,7 +50,7 @@ FOREIGN KEY (id_ws) REFERENCES working_session(id) ON DELETE CASCADE
) ENGINE=InnoDB;; ) ENGINE=InnoDB;;
-- --
-- --
-- it keeps record of open try when a new try is inserted -- it keeps record of open try when a new try is inserted
-- --
DROP TRIGGER IF EXISTS TRG_NEW_TRY; DROP TRIGGER IF EXISTS TRG_NEW_TRY;
...@@ -58,23 +58,26 @@ CREATE TRIGGER TRG_NEW_TRY ...@@ -58,23 +58,26 @@ CREATE TRIGGER TRG_NEW_TRY
AFTER INSERT ON try AFTER INSERT ON try
FOR EACH ROW FOR EACH ROW
thisTrigger: BEGIN thisTrigger: BEGIN
DECLARE idstu INT;
DECLARE idsup INT; DECLARE idstu INT;
DECLARE idsup INT;
IF ((@TRIGGER_CHECKS = FALSE) IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_INSERT_CHECKS = FALSE)) OR (@TRIGGER_AFTER_INSERT_CHECKS = FALSE))
AND (USER() = 'root@localhost') AND (USER() = 'root@localhost')
THEN THEN
LEAVE thisTrigger; LEAVE thisTrigger;
END IF; END IF;
SELECT DISTINCT M.id_stu,W.id_sup INTO idstu, idsup
FROM SELECT DISTINCT M.id_stu,W.id_sup INTO idstu, idsup
instruction I, FROM
method M, instruction I,
method M,
working_session W working_session W
WHERE WHERE
NEW.id_ws=W.id AND NEW.id_ws=W.id AND
W.id_ins=I.id AND W.id_ins=I.id AND
I.id_met=M.id; I.id_met=M.id;
INSERT INTO stu_opentry(id_stu,id_sup,id_ws,id_opentry, total_tries,begin) INSERT INTO stu_opentry(id_stu,id_sup,id_ws,id_opentry, total_tries,begin)
VALUES ( VALUES (
...@@ -83,7 +86,7 @@ thisTrigger: BEGIN ...@@ -83,7 +86,7 @@ thisTrigger: BEGIN
NEW.id_ws, NEW.id_ws,
NEW.id, NEW.id,
0, 0,
NOW() NOW(3)
) )
ON DUPLICATE KEY UPDATE id_stu=idstu, id_sup=idsup, id_ws=NEW.id_ws, id_opentry=NEW.id; ON DUPLICATE KEY UPDATE id_stu=idstu, id_sup=idsup, id_ws=NEW.id_ws, id_opentry=NEW.id;
END;; END;;
...@@ -148,12 +151,12 @@ thisTrigger: BEGIN ...@@ -148,12 +151,12 @@ thisTrigger: BEGIN
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;;
-- Integrity rule 3: every event is required to have the id try whenver a try happens -- Integrity rule 3: every event is required to have the id try whenever a try happens
-- when: state COM, event a4 -- when: state COM, event a4
-- Additional rule: resume event does not belog to any try -- Additional rule: resume event does not belog to any try
-- --
...@@ -171,14 +174,15 @@ thisTrigger: BEGIN ...@@ -171,14 +174,15 @@ thisTrigger: BEGIN
THEN THEN
LEAVE thisTrigger; LEAVE thisTrigger;
END IF; END IF;
SET idstu=NEW.id_stu;
SELECT id_opentry INTO idtry SELECT id_opentry INTO idtry
FROM FROM
stu_opentry stu_opentry
WHERE WHERE
id_stu = idstu; id_stu = NEW.id_stu;
IF (idtry IS NOT NULL) THEN
SET NEW.id_try=idtry; IF (idtry IS NOT NULL) THEN
SET NEW.id_try = idtry;
END IF; END IF;
IF (NEW.type = 'resumesession') IF (NEW.type = 'resumesession')
...@@ -209,39 +213,43 @@ thisTrigger: BEGIN ...@@ -209,39 +213,43 @@ thisTrigger: BEGIN
LEAVE thisTrigger; LEAVE thisTrigger;
END IF; END IF;
-- get opentry
SELECT id_ws, id_opentry INTO idws, idopentry
FROM
stu_opentry
WHERE
id_stu = NEW.id_stu;
-- a new action updates try's end field
IF (NEW.id_try IS NOT NULL) THEN
UPDATE `try`
SET
end = NEW.timestamp
WHERE
id = idopentry;
END IF;
-- Show and resumesession actions creates new tries
CASE NEW.type CASE NEW.type
WHEN 'Show' THEN WHEN 'Show' THEN
SELECT id_ws, id_opentry INTO idws, idopentry
FROM
stu_opentry
WHERE
id_stu = NEW.id_stu;
IF (idopentry IS NOT NULL and NEW.id_sup IS NULL) THEN
UPDATE `try`
SET end=NOW()
WHERE id=idopentry;
INSERT INTO try(`id_ws`)
VALUES (idws);
INSERT INTO try(`id_ws`)
VALUES (idws);
WHEN 'pausesession' THEN
IF (idopentry IS NOT NULL) THEN
UPDATE try
SET
result = 'DISCARDED'
WHERE
id = idopentry;
END IF; END IF;
WHEN 'pausesession' THEN
SELECT id_ws, id_opentry INTO idws, idopentry WHEN 'resumesession' THEN
FROM
stu_opentry INSERT INTO try(`id_ws`)
WHERE VALUES (idws);
id_stu = NEW.id_stu;
IF (idopentry IS NOT NULL) THEN
UPDATE try set end=NOW(), result='DISCARDED' where id=idopentry;
END IF;
WHEN 'resumesession' THEN
SELECT id_ws INTO idws
FROM
stu_opentry
WHERE
id_stu = NEW.id_stu;
INSERT INTO try(`id_ws`)
VALUES (idws);
ELSE BEGIN END; ELSE BEGIN END;
END CASE; END CASE;
...@@ -263,8 +271,18 @@ thisTrigger: BEGIN ...@@ -263,8 +271,18 @@ thisTrigger: BEGIN
LEAVE thisTrigger; LEAVE thisTrigger;
END IF; END IF;
IF ((new.end IS NOT NULL) AND (new.current IS NOT NULL)) THEN IF ((new.end IS NOT NULL) AND (new.current IS NOT NULL)) THEN
SET new.current=NULL; SET new.current=NULL;
-- Remove opentry record
DELETE FROM stu_opentry
WHERE id_ws = new.id;
-- Remove tries with no actions
DELETE FROM `try`
WHERE
end = NULL AND
id_ws = new.id
END IF; END IF;
END;; END;;
...@@ -278,6 +296,7 @@ FOR EACH ROW ...@@ -278,6 +296,7 @@ FOR EACH ROW
thisTrigger: BEGIN thisTrigger: BEGIN
DECLARE idws INT; DECLARE idws INT;
DECLARE ws_end DATE; DECLARE ws_end DATE;
DECLARE ws_old_end DATE;
IF ((@TRIGGER_CHECKS = FALSE) IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_UPDATE_CHECKS = FALSE)) OR (@TRIGGER_AFTER_UPDATE_CHECKS = FALSE))
...@@ -285,16 +304,37 @@ thisTrigger: BEGIN ...@@ -285,16 +304,37 @@ thisTrigger: BEGIN
THEN THEN
LEAVE thisTrigger; LEAVE thisTrigger;
END IF; END IF;
SELECT id_ws, end INTO idws, ws_end
FROM -- Get open try for that session
stu_opentry SELECT end INTO ws_end
WHERE FROM
id_ws = NEW.id_ws; stu_opentry
IF ( (old.result IS NULL) and (new.result IS NOT NULL) and (new.end>ws_end)) THEN WHERE
UPDATE stu_opentry id_ws = NEW.id_ws;
SET end=new.end, total_tries=total_tries+1
WHERE id_ws=idws; -- Update open try end timestamp and total_tries
END IF; IF ( (old.result IS NULL) and (new.result IS NOT NULL) and (new.end>ws_end)) THEN
UPDATE stu_opentry
SET
end = new.end,
total_tries = total_tries + 1
WHERE
id_ws = NEW.id_ws;
END IF;
-- Update working session end timestamp
SELECT end INTO ws_old_end
FROM
working_session
WHERE
id = NEW.id_ws;
IF (ws_old_end < NEW.end) THEN
UPDATE working_session
SET end = NEW.end
WHERE id = NEW.id_ws;
END IF;
END;; END;;
......
...@@ -120,6 +120,9 @@ module.exports = { ...@@ -120,6 +120,9 @@ module.exports = {
}); });
}, },
/**
* Returns the working sessions related to that instruction
*/
ws: function(req, res) { ws: function(req, res) {
if (!req.params.id_ins) { if (!req.params.id_ins) {
return res.json(500, {error: "No instruction defined"}); return res.json(500, {error: "No instruction defined"});
......
...@@ -6,21 +6,37 @@ module.exports = { ...@@ -6,21 +6,37 @@ module.exports = {
create: function(req, res) { create: function(req, res) {
var params = req.allParams(); var params = req.allParams();
if (!params.ws) return res.json(500, {error: "No workingSession defined"}); if (!params.ws) return res.badRequest("No workingSession defined");
if (!params.begin) return res.json(500, {error: "No begin defined"}); if (!params.begin) return res.badRequest("No begin defined");
Try.create({ Try.create({
"workingSession":params.ws, "workingSession":params.ws,
"begin": params.begin "begin": params.begin
}).exec(function(err, tr){ }).exec(function(err, tr){
if(err || !tr){ if(err || !tr){
sails.log.debug("Creating new Try: " + err); sails.log.debug("Creating new Try: " + err);
return res.json(500, {error: 'Try not created: '+err}); return res.serverError('Try not created');
} }
return res.json({ return res.ok({"id": tr.id});
"id": tr.id
});
}); });
} },
/**
* Update a try
*/
update: function(req, res) {
var params = req.allParams();
if (!params.id) return res.badRequest("No try defined");
Try.update(params.id, params)
.then(function (t) {
return res.ok(t);
})
.catch(function (err) {
if (err)
return res.serverError(err);
});
}
}; };
...@@ -19,24 +19,26 @@ module.exports = { ...@@ -19,24 +19,26 @@ module.exports = {
if (!req.params.id_ws) if (!req.params.id_ws)
res.badRequest("No working session defined"); res.badRequest("No working session defined");
var ws_end = req.params.end ? req.params.end : new Date().toISOString();
WorkingSession.update({id: req.params.id_ws}, {end: ws_end})
.then(function(t) {
res.ok({end: ws_end});
})
.fail(function(err) {
console.log("could not update " + req.params.id_ws);
throw err;
});
/*
StuOpenTry.findOne( { id_ws : req.params.id_ws } ) StuOpenTry.findOne( { id_ws : req.params.id_ws } )
.then(function(t) { .then(function(t) {
var ws_end = req.params.end ? req.params.end : new Date().toISOString(); if (t && t.openTry) { // WS recovery
if (t && t.openTry) /*WS recovery*/ {
ws_end = t.end ? t.end.toISOString() : t.begin.toISOString(); ws_end = t.end ? t.end.toISOString() : t.begin.toISOString();
} }
WorkingSession.update({id: req.params.id_ws}, {end: ws_end})
.then(function(t) {
res.ok({end: ws_end});
})
.fail(function(err) {
console.log("could not update " + req.params.id_ws);
throw err;
});
}) })
.fail(function(err) { .fail(function(err) {
res.serverError('Error closing working session: ' + err); res.serverError('Error closing working session: ' + err);
}); });
*/
}, },
/** /**
...@@ -109,7 +111,8 @@ module.exports = { ...@@ -109,7 +111,8 @@ module.exports = {
return action; return action;
}); });
return [action, ws]; return [action, ws];
}).spread(function(action, ws) { })
.spread(function(action, ws) {
StuOpenTry.findOne({id_stu : params.id_stu }) StuOpenTry.findOne({id_stu : params.id_stu })
.then(function(opentry) { .then(function(opentry) {
if (!opentry) if (!opentry)
......
...@@ -12,7 +12,7 @@ module.exports = { ...@@ -12,7 +12,7 @@ module.exports = {
autoPK : false, autoPK : false,
autoCreatedAt : false, autoCreatedAt : false,
autoUpdatedAt : false, autoUpdatedAt : false,
attributes: { attributes: {
id: { id: {
type: "integer", type: "integer",
...@@ -44,7 +44,7 @@ module.exports = { ...@@ -44,7 +44,7 @@ module.exports = {
end: { end: {
type: "datetime" type: "datetime"
}, },
// Relación con WorkingSession. [1 Instruction to N WorkingSession] // Relación con WorkingSession. [1 Instruction to N WorkingSession]
workingSessions: { workingSessions: {
collection: "WorkingSession", collection: "WorkingSession",
via: "instruction" via: "instruction"
...@@ -54,21 +54,21 @@ module.exports = { ...@@ -54,21 +54,21 @@ module.exports = {
// //
// Returns all the tries of the student // Returns all the tries of the student
// //
ws: function(id_ins, callback) { ws: function(id_ins, callback) {
var l_ws = []; var l_ws = [];
WorkingSession.find({ instruction: id_ins }).exec(function(err, workingsessions) { WorkingSession.find({ instruction: id_ins }).exec(function(err, workingsessions) {
if (err || !workingsessions || workingsessions.length == 0){ if (err || !workingsessions || workingsessions.length == 0){
console.log("LOG: No working sessions on instruction " + id_ins+": "+err+"."); console.log("LOG: No working sessions on instruction " + id_ins+": "+err+".");
return callback(err, []); return callback(err, []);
} }
// eachSeries // eachSeries
async.eachSeries( async.eachSeries(
// 1st array of items // 1st array of items
workingsessions, workingsessions,
// 2nd function to operate over one item // 2nd function to operate over one item
function(ws, next) { function(ws, next) {
// Original: Devolver el objeto con la sesión / enayos / acciones // Original: Devolver el objeto con la sesión / enayos / acciones
...@@ -78,10 +78,13 @@ module.exports = { ...@@ -78,10 +78,13 @@ module.exports = {
workingSession: ws.id, // With the actual working session id workingSession: ws.id, // With the actual working session id
// or : [ // or : [
// { result: null }, // This is necessary here because it's not enough with the following query to recover null results // { result: null }, // This is necessary here because it's not enough with the following query to recover null results
// { result: { '!' : ['BROKEN', 'DISCARDED'] }} // And without this results // { result: { '!' : ['BROKEN', 'DISCARDED'] }} // And without this results
// ] // ]
}).populate('actions').exec(function(err, tries) { })
if (!err && tries && tries.length > 0) .sort("end DESC")
.populate('actions')
.then(function(tries) {
if (tries && tries.length > 0)
l_ws.push({ l_ws.push({
"id": ws.id, "id": ws.id,
"student": ws.student, "student": ws.student,
...@@ -109,4 +112,4 @@ module.exports = { ...@@ -109,4 +112,4 @@ module.exports = {
}); });
} }
}; };
\ No newline at end of file
...@@ -278,7 +278,7 @@ ...@@ -278,7 +278,7 @@
"totals": "Totals", "totals": "Totals",
"to_add": "To add", "to_add": "To add",
"tpl_day": "{{ day | date:'yyyy-MM-dd' }}", "tpl_day": "{{ day | date:'yyyy-MM-dd' }}",
"tpl_hours_frame": "from {{ begin | date:'HH:mm' }} to {{ end | date:'HH:mm' }}", "tpl_hours_frame": "from {{ begin | date:'HH:mm:ss' }} to {{ end | date:'HH:mm:ss' }}",
"tries": "Tries", "tries": "Tries",
"tries_length": "Tries length", "tries_length": "Tries length",
"tries_mean_length": "Tries mean length", "tries_mean_length": "Tries mean length",
......
...@@ -279,7 +279,7 @@ ...@@ -279,7 +279,7 @@
"totals": "Totales", "totals": "Totales",
"to_add": "Para añadir", "to_add": "Para añadir",
"tpl_day": "{{ day | date:'dd-MM-yyyy' }}", "tpl_day": "{{ day | date:'dd-MM-yyyy' }}",
"tpl_hours_frame": "de {{ begin | date:'HH:mm' }} a {{ end | date:'HH:mm' }}", "tpl_hours_frame": "de {{ begin | date:'HH:mm:ss' }} a {{ end | date:'HH:mm:ss' }}",
"tries": "Ensayos", "tries": "Ensayos",
"tries_length": "Duración ensayos", "tries_length": "Duración ensayos",
"tries_mean_length": "Duración media ensayos", "tries_mean_length": "Duración media ensayos",
......
...@@ -125,20 +125,18 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -125,20 +125,18 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$http $http
.put(config.backend+'/try/' + t.id, update_data) .put(config.backend+'/try/' + t.id, update_data)
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
}) })
.error(function(data, status, headers, config) { .error(function(data, status, headers, config) {
}); });
}; };
$scope.update_current_try = function(){ $scope.update_current_try = function(){
$http $http // actualizamos try actual
.put(config.backend+'/try/' + $scope.actual_try.id, { result: $scope.actual_try.result, end: new Date() }) .put(config.backend+'/try/' + $scope.actual_try.id, { result: $scope.actual_try.result, end: new Date().toISOString() })
.then( .then(
function(data, status, headers, config2) { function(data, status, headers, config2) {
$http $http // creamos un nuevo try
.post(config.backend+'/try/', {ws: $scope.ws, student: $scope.studentData.id, supervisor: $scope.user.id, begin:new Date() }) .post(config.backend+'/try/', {ws: $scope.ws, student: $scope.studentData.id, supervisor: $scope.user.id, begin:new Date().toISOString() })
.then( .then(
function(data, status, headers, config) { function(data, status, headers, config) {
$scope.load_tries($scope.selectedIns); $scope.load_tries($scope.selectedIns);
...@@ -170,7 +168,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -170,7 +168,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
.post(config.backend+ '/ws/'+$scope.wsessions[0].id+'/close') .post(config.backend+ '/ws/'+$scope.wsessions[0].id+'/close')
.then( .then(
function(data, status, headers, config) { function(data, status, headers, config) {
$scope.wsessions[0].end=data.data.end; $scope.wsessions[0].end = data.data.end;
$scope.ws_recover=false; $scope.ws_recover=false;
} }
,function(data, status, headers, config) { ,function(data, status, headers, config) {
...@@ -238,13 +236,13 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -238,13 +236,13 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$scope.sessionRunning = false; $scope.sessionRunning = false;
if ($scope.wsessions.length>0) if ($scope.wsessions.length>0)
$scope.wsessions[$scope.wsessions.length-1].tries.pop(); $scope.wsessions[$scope.wsessions.length-1].tries.pop();
$scope.ws.end = new Date().toISOString(); $scope.ws.end = new Date();
$http $http
.post( .post(
config.backend+'/ws/' + $scope.ws.id + '/close', config.backend+'/ws/' + $scope.ws.id + '/close',
{ {
"end": $scope.ws.end, "end": $scope.ws.end.toISOString(),
"id_stu": $scope.studentData.id "id_stu": $scope.studentData.id
} }
) )
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
</timer> </timer>
</div> </div>
<div class="try"> <div class="try">
<div class="pull-left" ng-repeat="a in actual_try.actions track by $index"> <div class="pull-left" ng-repeat="a in actual_try.actions track by $index">
<div ng-if="a.action != 'initsession'" class="picto" popover="{{ a.attributes.stu_picto.expression.text | translate }}" popover-trigger="mouseenter"> <div ng-if="a.action != 'initsession'" class="picto" popover="{{ a.attributes.stu_picto.expression.text | translate }}" popover-trigger="mouseenter">
<img ng-src="{{ a.attributes.stu_picto.picto.uri }}" style="{{a.attributes.id_sup!=null ? 'border:2px dotted red': ''}}"/> <img ng-src="{{ a.attributes.stu_picto.picto.uri }}" style="{{a.attributes.id_sup!=null ? 'border:2px dotted red': ''}}"/>
<div class="action-type"> <div class="action-type">
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
<ul class="dropdown-menu dropdown-menu-right" role="menu" style="z-index:10"> <ul class="dropdown-menu dropdown-menu-right" role="menu" style="z-index:10">
<li> <li>
<a class="pointer" role="menuitem" tabindex="0" ng-click="actual_try.result = null; update_current_try();send_show_action() "> <a class="pointer" role="menuitem" tabindex="0" ng-click="actual_try.result = null; update_current_try();send_show_action() ">
<span class="glyphicon glyphicon-question-sign color_blue" aria-hidden="true"></span>{{'state_not_evaluated' | translate }}> <span class="glyphicon glyphicon-question-sign color_blue" aria-hidden="true"></span>{{'state_not_evaluated' | translate }}>
</a> </a>
</li> </li>
<li> <li>
...@@ -136,9 +136,10 @@ ...@@ -136,9 +136,10 @@
{{ 'tries' | translate }} {{ 'tries' | translate }}
<span class="badge">{{ s.tries.length }}</span> <span class="badge">{{ s.tries.length }}</span>
</button> </button>
<span ng-show="!showLastTry" class="list-group-item-heading color_green">{{$index+1}}&nbsp;&nbsp;&nbsp;</span>
<!-- span ng-show="!showLastTry" class="list-group-item-heading color_green">{{$index+1}}&nbsp;&nbsp;&nbsp;</span -->
<p style="text-align: left ; margin-bottom: 5px" class="list-group-item-text color_green"> <p style="text-align: left ; margin-bottom: 5px" class="list-group-item-text color_green">
<b>{{ 'tpl_day' | translate:{'day':s.begin} }}</b> <span translate>session</span> <b>{{ 'tpl_day' | translate:{'day':s.begin} }}</b>
{{ 'tpl_hours_frame' | translate:{'begin':s.begin, 'end':s.end} }} {{ 'tpl_hours_frame' | translate:{'begin':s.begin, 'end':s.end} }}
</p> </p>
<textarea type="editable title" rows="2" id="ins_desc_ws" placeholder=" {{ 'session_notes' | translate }}" ng-model="s.description" <textarea type="editable title" rows="2" id="ins_desc_ws" placeholder=" {{ 'session_notes' | translate }}" ng-model="s.description"
...@@ -183,13 +184,13 @@ ...@@ -183,13 +184,13 @@
'color_red': t.result == 'FAIL' || t.result == 'DISCARDED', 'color_red': t.result == 'FAIL' || t.result == 'DISCARDED',
'color_black': t.result == 'BROKEN', 'color_black': t.result == 'BROKEN',
'color_orange': t.result == 'MODEL' 'color_orange': t.result == 'MODEL'
}" aria-hidden="true" title="{{ }" aria-hidden="true" title="{{
(t.result == null ? 'state_not_evaluated' : (t.result == null ? 'state_not_evaluated' :
t.result == 'SUCCESS' ? 'state_correct' : t.result == 'SUCCESS' ? 'state_correct' :
t.result == 'SUPERVISED SUCCESS' ? 'state_supervised' : t.result == 'SUPERVISED SUCCESS' ? 'state_supervised' :
t.result == 'SPONTANEOUS SUCCESS' ? 'state_spontaneous' : t.result == 'SPONTANEOUS SUCCESS' ? 'state_spontaneous' :
t.result == 'FAIL' ? 'state_fail' : t.result == 'FAIL' ? 'state_fail' :
t.result == 'DISCARDED' ? 'state_discarded' : t.result == 'DISCARDED' ? 'state_discarded' :
t.result == 'MODEL' ? 'state_demostration' : t.result == 'MODEL' ? 'state_demostration' :
'state_broken') | translate }}"> 'state_broken') | translate }}">
</span> </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