session controls ready

parent f77656fb
...@@ -83,7 +83,7 @@ module.exports = { ...@@ -83,7 +83,7 @@ module.exports = {
var ws_end = t.end ? t.end.toISOString() : t.begin.toISOString(); var ws_end = t.end ? t.end.toISOString() : t.begin.toISOString();
ws = WorkingSession.update({id: t.id_ws}, {end: ws_end}) ws = WorkingSession.update({id: t.id_ws}, {end: ws_end})
.then(function(ws) { .then(function(ws) {
return ws; return ws;
}); });
} }
return ws; return ws;
...@@ -128,8 +128,8 @@ module.exports = { ...@@ -128,8 +128,8 @@ module.exports = {
}); });
}); });
}) })
.fail(function(err) { .catch(function(err) {
res.serverError("Session not created: " + err); return res.serverError("Session not created: " + err);
}); });
}, },
......
...@@ -243,6 +243,7 @@ ...@@ -243,6 +243,7 @@
"password_new_type": "Type the new password", "password_new_type": "Type the new password",
"password_short": "Password must have {{minlength}} characters length at least", "password_short": "Password must have {{minlength}} characters length at least",
"password_type": "Password", "password_type": "Password",
"pause": "Pause",
"pause_session": "Pause session", "pause_session": "Pause session",
"personal_data": "Personal data", "personal_data": "Personal data",
"personal_data": "Personal data", "personal_data": "Personal data",
...@@ -268,12 +269,14 @@ ...@@ -268,12 +269,14 @@
"previous_actions": "Previous actions", "previous_actions": "Previous actions",
"previous_sessions": "Previous sessions", "previous_sessions": "Previous sessions",
"profile_picture": "Profile picture", "profile_picture": "Profile picture",
"record": "Record",
"read_picto": "Read picto", "read_picto": "Read picto",
"register": "Sign in", "register": "Sign in",
"reloading_pictos": "Reloading pictograms", "reloading_pictos": "Reloading pictograms",
"remember": "Remember me", "remember": "Remember me",
"reports": "Reports", "reports": "Reports",
"request_change_password": "Request change password", "request_change_password": "Request change password",
"resume": "Resume",
"room_changed": "A partner is offline. Session paused.", "room_changed": "A partner is offline. Session paused.",
"save": "Save", "save": "Save",
"save_as_template": "Save as template", "save_as_template": "Save as template",
...@@ -317,6 +320,7 @@ ...@@ -317,6 +320,7 @@
"state_not_evaluated": "Not evaluated", "state_not_evaluated": "Not evaluated",
"state_spontaneous": "Spontaneous", "state_spontaneous": "Spontaneous",
"state_supervised": "Supervised", "state_supervised": "Supervised",
"stop": "Stop",
"student_added": "Student added", "student_added": "Student added",
"student_already_exists": "A student with that username already exists, please try with another one", "student_already_exists": "A student with that username already exists, please try with another one",
"student_deleted": "Student deleted", "student_deleted": "Student deleted",
......
...@@ -243,6 +243,7 @@ ...@@ -243,6 +243,7 @@
"password_new_type": "Escriba la nueva contraseña", "password_new_type": "Escriba la nueva contraseña",
"password_type": "Escriba la contraseña", "password_type": "Escriba la contraseña",
"password_short": "La contraseña es muy corta, debe tener al menos una longitud de {{minlength}} caracteres", "password_short": "La contraseña es muy corta, debe tener al menos una longitud de {{minlength}} caracteres",
"pause": "Pausar",
"pause_session": "Pausar sesión", "pause_session": "Pausar sesión",
"personal_data": "Datos personales", "personal_data": "Datos personales",
"personal_data": "Datos personales", "personal_data": "Datos personales",
...@@ -269,12 +270,14 @@ ...@@ -269,12 +270,14 @@
"previous_sessions": "Sesiones anteriores", "previous_sessions": "Sesiones anteriores",
"profile_picture": "Foto del perfil", "profile_picture": "Foto del perfil",
"read_picto": "Leer picto", "read_picto": "Leer picto",
"record": "Grabar",
"register": "Regístrate", "register": "Regístrate",
"register_button": "Registrar", "register_button": "Registrar",
"reloading_pictos": "Recargando pictogramas", "reloading_pictos": "Recargando pictogramas",
"remember": "No cerrar sesión", "remember": "No cerrar sesión",
"reports": "Informes", "reports": "Informes",
"request_change_password": "Solicitar cambio de contraseña", "request_change_password": "Solicitar cambio de contraseña",
"resume": "Continuar",
"room_changed":"Un participante abandonó la sesión. Sesión en pausa.", "room_changed":"Un participante abandonó la sesión. Sesión en pausa.",
"save": "Guardar", "save": "Guardar",
"save_as_template": "Guardar como plantilla", "save_as_template": "Guardar como plantilla",
...@@ -318,6 +321,7 @@ ...@@ -318,6 +321,7 @@
"state_not_evaluated": "No evaluado", "state_not_evaluated": "No evaluado",
"state_spontaneous": "Espontáneo", "state_spontaneous": "Espontáneo",
"state_supervised": "Guiado", "state_supervised": "Guiado",
"stop": "Parar",
"student_added": "Estudiante añadido", "student_added": "Estudiante añadido",
"student_already_exists": "Ya existe un estudiante con ese nombre de usuario. Por favor, inténtelo de nuevo con algo diferente.", "student_already_exists": "Ya existe un estudiante con ese nombre de usuario. Por favor, inténtelo de nuevo con algo diferente.",
"student_deleted": "Estudiante eliminado", "student_deleted": "Estudiante eliminado",
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
</div> </div>
<div class="col-md-8"> <div class="col-md-8">
<div class="form-group"> <div class="form-group">
<select class="form-control" ng-model="formdata.country" required> <select class="form-control" ng-model="formdata.country" required ng-change="load_tries()">
<option value="00" selected disabled hidden>{{ 'country' | translate }}</option> <option value="00" selected disabled hidden>{{ 'country' | translate }}</option>
<option value="ES">España</option> <option value="ES">España</option>
<option value="US">United States</option> <option value="US">United States</option>
......
...@@ -25,30 +25,24 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -25,30 +25,24 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$scope.ws = $scope.ws || {}; $scope.ws = $scope.ws || {};
$scope.actual_try = $scope.actual_try || {}; $scope.actual_try = $scope.actual_try || {};
// pause flag
$scope.paused = false; $scope.paused = false;
// Read the last working session to show the last tries when session tab is opened // Read the last working session to show the last tries when session tab is opened
$scope.wsessions = []; $scope.wsessions = [];
//
// Array with student methods (with instructions) // Array with student methods (with instructions)
//
$scope.methods = []; $scope.methods = [];
// Visibility of the list of stored sessions // Visibility of the list of stored sessions
$scope.showSessions = false; $scope.showSessions = false;
// Query to obtain an array of student methods // Query to obtain an array of student methods
$http $http
.get(config.backend+'/stu/'+ $scope.studentData.id +'/methods') .get(config.backend+'/stu/'+ $scope.studentData.id +'/methods')
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
// Add to list
$scope.methods = data; $scope.methods = data;
}) })
.error(function(data, status, headers, config) { .error(function(data, status, headers, config) {
}); });
// Query to obtain an array of only one working session (the last) with its tries/actions // Query to obtain an array of only one working session (the last) with its tries/actions
...@@ -67,18 +61,8 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -67,18 +61,8 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// Initially, show the last try // Initially, show the last try
$scope.showLastTry = true; $scope.showLastTry = true;
// VER SI BORRAR --> SÓLO NECESARIO PARA DEJAR EN BLANCO LOS ENSAYOS CARGADOS
// Cargar instrucciones en select del método seleccionado arriba
$scope.load_instructions = function (method){
// Empty ws/tries/actions
$scope.wsessions=[];
// Update the number of pages
$scope.totalPages = 0;
// Empty selected instruction in select field
//$scope.selectedIns = {};
};
$scope.selectedIns = -1;
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// Tries /////////////////////////////////////////////////////////////////// // Tries ///////////////////////////////////////////////////////////////////
...@@ -86,23 +70,25 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -86,23 +70,25 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// When clicking over an instruction in the select control // When clicking over an instruction in the select control
// load its working sessions with its associated tries and with its actions // load its working sessions with its associated tries and with its actions
$scope.load_tries = function (instruction){ $scope.load_tries = function (){
if ($scope.selectedIns == -1)
return;
$scope.showLastTry = false; $scope.showLastTry = false;
// If to avoid the default select option "-- select one instruction --" // If to avoid the default select option "-- select one instruction --"
if(instruction){ $http
$http .get(config.backend+'/instruction/'+ $scope.selectedIns +'/ws')
.get(config.backend+'/instruction/'+ instruction.id +'/ws') .success(function(data, status, headers, config) {
.success(function(data, status, headers, config) { // Add to list
// Add to list $scope.wsessions = data;
$scope.wsessions = data; // Refresh navigation vars
// Refresh navigation vars $scope.currentPage = 1;
$scope.currentPage = 1; $scope.numPerPage = 5;
$scope.numPerPage = 5; $scope.totalPages = Math.ceil($scope.wsessions.length / $scope.numPerPage);
$scope.totalPages = Math.ceil($scope.wsessions.length / $scope.numPerPage); })
}) .error(function(data, status, headers, config) {});
.error(function(data, status, headers, config) {});
}
}; };
// Tries pagination - previous tries // Tries pagination - previous tries
...@@ -184,6 +170,12 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -184,6 +170,12 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// Create new working session // Create new working session
// //
$scope.new_ws = function (){ $scope.new_ws = function (){
if ($scope.sessionRunning)
return;
$scope.startTimer();
// Var for view // Var for view
$scope.sessionRunning = true; $scope.sessionRunning = true;
...@@ -222,20 +214,26 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -222,20 +214,26 @@ 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? // TODO notify update?
}) })
.error(function(data, status, headers, config) { .error(function(data, status, headers, config) {
}); });
}; };
// //
// Finish a working session updating its end time // Finish a working session updating its end time
// //
$scope.stop_ws = function () { $scope.stop_ws = function () {
if (!$scope.sessionRunning)
return;
$scope.stopTimer();
// For view // For view
$scope.sessionRunning = false; $scope.sessionRunning = false;
if ($scope.wsessions.length>0) if ($scope.wsessions.length>0)
...@@ -268,6 +266,12 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -268,6 +266,12 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// Pause the actual working session // Pause the actual working session
// //
$scope.pause_ws = function (){ $scope.pause_ws = function (){
if (!$scope.sessionRunning || $scope.paused)
return;
$scope.pauseTimer();
$http $http
.post(config.backend+'/action', { .post(config.backend+'/action', {
"type": "pausesession", "type": "pausesession",
...@@ -290,21 +294,27 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr ...@@ -290,21 +294,27 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// Resume the actual working session // Resume the actual working session
// //
$scope.resume_ws = function (){ $scope.resume_ws = function (){
$http
.post(config.backend+'/action', { if (!$scope.sessionRunning || !$scope.paused)
"type": "resumesession", return;
"student": $scope.studentData.id,
"supervisor": $scope.user.id, $scope.resumeTimer();
"timestamp": (new Date()).toISOString()
}) $http
.success(function(data, status, headers, config) { .post(config.backend+'/action', {
// Adding resume action to the list of actions "type": "resumesession",
$scope.actual_try.actions = []; "student": $scope.studentData.id,
$scope.actual_try.actions.push({ action: 'resumesession'} ); "supervisor": $scope.user.id,
$scope.actual_try.id=data.open_try; "timestamp": (new Date()).toISOString()
}) })
.error(function(data, status, headers, config) { .success(function(data, status, headers, config) {
}); // Adding resume action to the list of actions
$scope.actual_try.actions = [];
$scope.actual_try.actions.push({ action: 'resumesession'} );
$scope.actual_try.id=data.open_try;
})
.error(function(data, status, headers, config) {
});
}; };
......
...@@ -8,38 +8,64 @@ ...@@ -8,38 +8,64 @@
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<form role="form" action="#" ng-hide="ws_recover "> <form role="form" action="#" ng-hide="ws_recover ">
<select class="form-control" name="met_select" id="met_select" ng-model="selectedMethod" ng-options="m.name for m in methods" ng-change="load_instructions(selectedMethod)"> <select class="form-control" name="met_select" id="met_select" ng-model="selectedIns" ng-change="load_tries()">
<option value="" translate>select_a_method</option> <option value="-1" selected disabled hidden>{{ 'select_instruction' | translate }}</option>
</select> <optgroup ng-repeat="m in methods" label="{{ m.name }}">
<select ng-hide="!selectedMethod" class="form-control" name="instruction_select" id="instruction_select" ng-model="selectedIns" ng-options="ins.name for ins in selectedMethod.instructions" ng-change="load_tries(selectedIns)"> <option ng-repeat="ins in m.instructions" ng-value="ins.id">{{ins.name}}</option>
<option value="" translate>select_instruction</option> </optgroup>
</select> </select>
</form> </form>
</div> </div>
</div> <div class="col-md-6">
<div class="row" ng-hide="!selectedIns"> <div class="row session-controls form-horizontal" ng-show="selectedIns != -1">
<p class="session_controls"> <div class="col-md-4 form-group">
<div class="col-md-4"> <label class="control-label" translate> sessions </label>
<a ng-click="startTimer(); new_ws()" ng-disabled="!selectedIns " ng-hide="sessionRunning || studentData.num_peers<2" class="btn btn-success btn-sm" role="button" id="session_new" translate>new_session</a> <button ng-click="showSessions = !showSessions" class="btn btn-default" ng-disabled="wsessions.length == 0">
<a class="text_large" ng-click="pause_ws(); pauseTimer();" ng-hide="!sessionRunning || paused" id="session_pause" popover="{{ 'pause_session' | translate}}" popover-trigger="mouseenter"> <span class="badge" style="font-size: 10pt"> {{ wsessions.length }}</span>
<span class="glyphicon glyphicon-pause" aria-hidden="true" title="{{ 'pause_session' | translate }}"></span> <span class="glyphicon glyphicon-collapse-down" aria-hidden="true" ng-show="!showSessions"></span>
</a> <span class="glyphicon glyphicon-collapse-up" aria-hidden="true" ng-show="showSessions"></span>
<a class="text_large" ng-click="resume_ws(); resumeTimer();" ng-hide="!sessionRunning || !paused" id="session_continue" popover="{{ 'continue_session' | translate}}" popover-trigger="mouseenter"> </button>
<span class="glyphicon glyphicon-play" aria-hidden="true" title="{{ 'continue_session' | translate }}"></span> </div>
</a> <div class="col-md-8 form-group" ng-disabled="selectedIns == -1 || studentData.num_peers<2">
<a class="text_large" ng-click="stopTimer(); stop_ws()" ng-hide="!sessionRunning" id="session_stop" popover="{{ 'finish_session' | translate}}" popover-trigger="mouseenter"> <div class="btn-group pull-right"> <!-- controls for session recording-->
<span class="glyphicon glyphicon-stop color_black" aria-hidden="true" title="{{ 'finish_session' | translate }}"></span> <button type="button"
</a> class="btn btn-default btn-sm"
</div> ng-class="{ disabled: sessionRunning }"
<div class="col-md-2" style="text-align: right"> popover="{{ 'new_session' | translate }}"
<button ng-click="showSessions = !showSessions" class="btn btn-success btn-sm" style="font-size: 10pt"> popover-trigger="mouseenter"
<i class="fa fa-caret-down" aria-hidden="true" ng-show="!showSessions"></i> ng-click="new_ws()"
<i class="fa fa-caret-up" aria-hidden="true" ng-show="showSessions"></i> id="session_new">
<span translate> sessions </span> <span class="glyphicon glyphicon-record color_red"
<span class="badge" style="font-size: 10pt"> {{wsessions.length }}</span> ng-class="{ blink: sessionRunning }"></span> {{ 'record' | translate }}
</button> </button>
<button type="button"
class="btn btn-default btn-sm"
ng-class="{ disabled: !sessionRunning || !paused }"
popover="{{ 'continue_session' | translate }}"
popover-trigger="mouseenter"
ng-click="resume_ws();">
<span class="glyphicon glyphicon-play"></span> {{ 'resume' | translate }}
</button>
<button type="button"
class="btn btn-default btn-sm"
ng-class="{ disabled: !sessionRunning || paused }"
popover="{{ 'pause_session' | translate }}"
popover-trigger="mouseenter"
ng-click="pause_ws();">
<span class="glyphicon glyphicon-pause"></span> {{ 'pause' | translate }}
</button>
<button type="button"
class="btn btn-default btn-sm"
ng-class="{ disabled: !sessionRunning }"
popover="{{ 'finish_session' | translate }}"
popover-trigger="mouseenter"
ng-click="stop_ws();">
<span class="glyphicon glyphicon-stop"></span> {{ 'stop' | translate }}
</button>
</div> <!-- / controls for session recording-->
</div>
</div> </div>
</p> </div>
</div> </div>
<div id="tries"> <div id="tries">
<div id="actual_try" ng-model="actual_try" ng-show="tryRunning"> <div id="actual_try" ng-model="actual_try" ng-show="tryRunning">
......
...@@ -972,6 +972,17 @@ input[type=range]:focus::-ms-fill-upper { ...@@ -972,6 +972,17 @@ input[type=range]:focus::-ms-fill-upper {
} }
/* /*
Blink class
*/
.blink {
animation: blinker 1s linear infinite;
}
@keyframes blinker {
50% { opacity: 0.0; }
}
/*
ng-file-upload and ngImgCrop ng-file-upload and ngImgCrop
*/ */
.cropArea { .cropArea {
......
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