issue #595 fixed

parent 63b19fa7
apply plugin: 'com.android.application'
android {
signingConfigs {
/*signingConfigs {
config {
keyAlias 'Pictogram'
keyPassword 'danoia'
storeFile file('C:/Users/Fernando/pictogramkeys.jks')
storePassword 'danoia'
}
}
}*/
compileSdkVersion 24
buildToolsVersion "23.0.2"
defaultConfig {
......@@ -17,7 +18,7 @@ android {
targetSdkVersion 22
versionCode 1
versionName "1.0"
signingConfig signingConfigs.config
// signingConfig signingConfigs.config
}
productFlavors {
CIFlavor {
......
......@@ -669,6 +669,7 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
@Override
public void onClick(View arg0) {
LinkedList<Picto> lp = tapeAdapter.getAll();
// This triggers the "Show" websocket action
PCBcontext.getActionLog().log(new PictosAction(lp));
tapeAdapter.ttsAllNew(tts);
}
......
......@@ -125,11 +125,9 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<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/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/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-vector-drawable/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.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-auth-base/9.2.1/jars" />
......@@ -161,32 +159,32 @@
<orderEntry type="sourceFolder" forTests="false" />
<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="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="socket.io-client-0.5.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="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="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="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-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="gson-2.3" 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-tasks-9.2.1" 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="support-vector-drawable-24.1.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-21.0.3" 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="ion-2.1.9" 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="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="junit-4.12" 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
) ENGINE=InnoDB;;
--
--
--
-- it keeps record of open try when a new try is inserted
--
DROP TRIGGER IF EXISTS TRG_NEW_TRY;
......@@ -58,23 +58,26 @@ CREATE TRIGGER TRG_NEW_TRY
AFTER INSERT ON try
FOR EACH ROW
thisTrigger: BEGIN
DECLARE idstu INT;
DECLARE idsup INT;
DECLARE idstu INT;
DECLARE idsup INT;
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_INSERT_CHECKS = FALSE))
AND (USER() = 'root@localhost')
THEN
LEAVE thisTrigger;
END IF;
SELECT DISTINCT M.id_stu,W.id_sup INTO idstu, idsup
FROM
instruction I,
method M,
SELECT DISTINCT M.id_stu,W.id_sup INTO idstu, idsup
FROM
instruction I,
method M,
working_session W
WHERE
WHERE
NEW.id_ws=W.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)
VALUES (
......@@ -83,7 +86,7 @@ thisTrigger: BEGIN
NEW.id_ws,
NEW.id,
0,
NOW()
NOW(3)
)
ON DUPLICATE KEY UPDATE id_stu=idstu, id_sup=idsup, id_ws=NEW.id_ws, id_opentry=NEW.id;
END;;
......@@ -148,12 +151,12 @@ thisTrigger: BEGIN
END IF;
IF ((old.end IS NULL) and (new.end IS NOT NULL)) THEN
CALL deleteOpenTry(new.id);
CALL deleteOpenTry(new.id);
END IF;
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
-- Additional rule: resume event does not belog to any try
--
......@@ -171,14 +174,15 @@ thisTrigger: BEGIN
THEN
LEAVE thisTrigger;
END IF;
SET idstu=NEW.id_stu;
SELECT id_opentry INTO idtry
FROM
stu_opentry
WHERE
id_stu = idstu;
IF (idtry IS NOT NULL) THEN
SET NEW.id_try=idtry;
id_stu = NEW.id_stu;
IF (idtry IS NOT NULL) THEN
SET NEW.id_try = idtry;
END IF;
IF (NEW.type = 'resumesession')
......@@ -209,39 +213,43 @@ thisTrigger: BEGIN
LEAVE thisTrigger;
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
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;
WHEN 'pausesession' THEN
SELECT id_ws, id_opentry INTO idws, idopentry
FROM
stu_opentry
WHERE
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);
WHEN 'resumesession' THEN
INSERT INTO try(`id_ws`)
VALUES (idws);
ELSE BEGIN END;
END CASE;
......@@ -263,8 +271,18 @@ thisTrigger: BEGIN
LEAVE thisTrigger;
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;
-- 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;;
......@@ -278,6 +296,7 @@ FOR EACH ROW
thisTrigger: BEGIN
DECLARE idws INT;
DECLARE ws_end DATE;
DECLARE ws_old_end DATE;
IF ((@TRIGGER_CHECKS = FALSE)
OR (@TRIGGER_AFTER_UPDATE_CHECKS = FALSE))
......@@ -285,16 +304,37 @@ thisTrigger: BEGIN
THEN
LEAVE thisTrigger;
END IF;
SELECT id_ws, end INTO idws, ws_end
FROM
stu_opentry
WHERE
id_ws = NEW.id_ws;
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=idws;
END IF;
-- Get open try for that session
SELECT end INTO ws_end
FROM
stu_opentry
WHERE
id_ws = NEW.id_ws;
-- Update open try end timestamp and total_tries
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;;
......
......@@ -120,6 +120,9 @@ module.exports = {
});
},
/**
* Returns the working sessions related to that instruction
*/
ws: function(req, res) {
if (!req.params.id_ins) {
return res.json(500, {error: "No instruction defined"});
......
......@@ -6,21 +6,37 @@ module.exports = {
create: function(req, res) {
var params = req.allParams();
if (!params.ws) return res.json(500, {error: "No workingSession defined"});
if (!params.begin) return res.json(500, {error: "No begin defined"});
if (!params.ws) return res.badRequest("No workingSession defined");
if (!params.begin) return res.badRequest("No begin defined");
Try.create({
"workingSession":params.ws,
"begin": params.begin
"begin": params.begin
}).exec(function(err, tr){
if(err || !tr){
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({
"id": tr.id
});
return res.ok({"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 = {
if (!req.params.id_ws)
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 } )
.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();
}
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) {
res.serverError('Error closing working session: ' + err);
});
*/
},
/**
......@@ -109,7 +111,8 @@ module.exports = {
return action;
});
return [action, ws];
}).spread(function(action, ws) {
})
.spread(function(action, ws) {
StuOpenTry.findOne({id_stu : params.id_stu })
.then(function(opentry) {
if (!opentry)
......
......@@ -12,7 +12,7 @@ module.exports = {
autoPK : false,
autoCreatedAt : false,
autoUpdatedAt : false,
attributes: {
id: {
type: "integer",
......@@ -44,7 +44,7 @@ module.exports = {
end: {
type: "datetime"
},
// Relación con WorkingSession. [1 Instruction to N WorkingSession]
// Relación con WorkingSession. [1 Instruction to N WorkingSession]
workingSessions: {
collection: "WorkingSession",
via: "instruction"
......@@ -54,21 +54,21 @@ module.exports = {
//
// Returns all the tries of the student
//
//
ws: function(id_ins, callback) {
var l_ws = [];
WorkingSession.find({ instruction: id_ins }).exec(function(err, workingsessions) {
if (err || !workingsessions || workingsessions.length == 0){
console.log("LOG: No working sessions on instruction " + id_ins+": "+err+".");
return callback(err, []);
}
// eachSeries
async.eachSeries(
// 1st array of items
workingsessions,
workingsessions,
// 2nd function to operate over one item
function(ws, next) {
// Original: Devolver el objeto con la sesión / enayos / acciones
......@@ -78,10 +78,13 @@ module.exports = {
workingSession: ws.id, // With the actual working session id
// or : [
// { 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({
"id": ws.id,
"student": ws.student,
......@@ -109,4 +112,4 @@ module.exports = {
});
}
};
\ No newline at end of file
};
......@@ -278,7 +278,7 @@
"totals": "Totals",
"to_add": "To add",
"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_length": "Tries length",
"tries_mean_length": "Tries mean length",
......
......@@ -279,7 +279,7 @@
"totals": "Totales",
"to_add": "Para añadir",
"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_length": "Duración ensayos",
"tries_mean_length": "Duración media ensayos",
......
......@@ -125,20 +125,18 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$http
.put(config.backend+'/try/' + t.id, update_data)
.success(function(data, status, headers, config) {
})
.error(function(data, status, headers, config) {
});
};
$scope.update_current_try = function(){
$http
.put(config.backend+'/try/' + $scope.actual_try.id, { result: $scope.actual_try.result, end: new Date() })
$http // actualizamos try actual
.put(config.backend+'/try/' + $scope.actual_try.id, { result: $scope.actual_try.result, end: new Date().toISOString() })
.then(
function(data, status, headers, config2) {
$http
.post(config.backend+'/try/', {ws: $scope.ws, student: $scope.studentData.id, supervisor: $scope.user.id, begin:new Date() })
$http // creamos un nuevo try
.post(config.backend+'/try/', {ws: $scope.ws, student: $scope.studentData.id, supervisor: $scope.user.id, begin:new Date().toISOString() })
.then(
function(data, status, headers, config) {
$scope.load_tries($scope.selectedIns);
......@@ -170,7 +168,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
.post(config.backend+ '/ws/'+$scope.wsessions[0].id+'/close')
.then(
function(data, status, headers, config) {
$scope.wsessions[0].end=data.data.end;
$scope.wsessions[0].end = data.data.end;
$scope.ws_recover=false;
}
,function(data, status, headers, config) {
......@@ -238,13 +236,13 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$scope.sessionRunning = false;
if ($scope.wsessions.length>0)
$scope.wsessions[$scope.wsessions.length-1].tries.pop();
$scope.ws.end = new Date().toISOString();
$scope.ws.end = new Date();
$http
.post(
config.backend+'/ws/' + $scope.ws.id + '/close',
{
"end": $scope.ws.end,
"end": $scope.ws.end.toISOString(),
"id_stu": $scope.studentData.id
}
)
......
......@@ -44,7 +44,7 @@
</timer>
</div>
<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">
<img ng-src="{{ a.attributes.stu_picto.picto.uri }}" style="{{a.attributes.id_sup!=null ? 'border:2px dotted red': ''}}"/>
<div class="action-type">
......@@ -71,7 +71,7 @@
<ul class="dropdown-menu dropdown-menu-right" role="menu" style="z-index:10">
<li>
<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>
</li>
<li>
......@@ -136,9 +136,10 @@
{{ 'tries' | translate }}
<span class="badge">{{ s.tries.length }}</span>
</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">
<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} }}
</p>
<textarea type="editable title" rows="2" id="ins_desc_ws" placeholder=" {{ 'session_notes' | translate }}" ng-model="s.description"
......@@ -183,13 +184,13 @@
'color_red': t.result == 'FAIL' || t.result == 'DISCARDED',
'color_black': t.result == 'BROKEN',
'color_orange': t.result == 'MODEL'
}" aria-hidden="true" title="{{
}" aria-hidden="true" title="{{
(t.result == null ? 'state_not_evaluated' :
t.result == 'SUCCESS' ? 'state_correct' :
t.result == 'SUPERVISED SUCCESS' ? 'state_supervised' :
t.result == 'SPONTANEOUS SUCCESS' ? 'state_spontaneous' :
t.result == 'FAIL' ? 'state_fail' :
t.result == 'DISCARDED' ? 'state_discarded' :
t.result == 'SUCCESS' ? 'state_correct' :
t.result == 'SUPERVISED SUCCESS' ? 'state_supervised' :
t.result == 'SPONTANEOUS SUCCESS' ? 'state_spontaneous' :
t.result == 'FAIL' ? 'state_fail' :
t.result == 'DISCARDED' ? 'state_discarded' :
t.result == 'MODEL' ? 'state_demostration' :
'state_broken') | translate }}">
</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