Unificados datos a nivel de estudiante en lugar de a nivel de tab

parent 0235e981
......@@ -52,7 +52,22 @@ dashboardApp.config(function($translateProvider) {
//$translateProvider.determinePreferredLanguage();
});
/* Routes with ui-routes */
/*
* ui-routes is used to implement a PAC pattern so views and related controllers are
* hierarchically arranged.
*
* LoginCtrl
* - login.hmtl
* LoginSettingPasswodrCtrl
* - login_setting_password.html
* LoginAdminCtrl
* - login_admin.html
* SignInCtrl
* - signing.html
* SupervisorCtrl
* - supervisor.html
*/
dashboardApp.config(function($stateProvider, $urlRouterProvider) {
......@@ -105,6 +120,7 @@ dashboardApp.config(function($stateProvider, $urlRouterProvider) {
templateUrl: 'modules/student/views/student.html',
parent: 'supervisor',
controller: 'StudentCtrl',
data: {studentData1: "tomate"},
abstract: true,
})
.state('student_collections', {
......
......@@ -2,42 +2,3 @@
/* Controllers */
/*
Pictogram follows a Hierarchical MVC pattern (the old PAC pattern)
We have a main controller (see main.js) and then others that are associated to
different headers (by means of AngularJS directives)
Here we are just defining those directives
*/
var dashboardControllers = angular.module('dashboardControllers', ['dashboardConfig']);
// Header Supervisor
dashboardControllers.directive('headerSupervisor', function(){
return{
restrict: 'E',
templateUrl: 'modules/supervisor/views/header.html'
};
});
// Header Student
dashboardControllers.directive('headerStudent', function(){
return{
restrict: 'E',
templateUrl: 'modules/student/views/header.html'
};
});
// Header Admin
dashboardControllers.directive('headerAdmin', function(){
return{
restrict: 'E',
templateUrl: 'modules/admin/views/header.html'
};
});
// Translation footer
dashboardControllers.directive('footerTranslate', function(){
return{
restrict: 'E',
templateUrl: 'modules/translate/views/footer_translate.html'
};
});
\ No newline at end of file
......@@ -15,6 +15,11 @@ String.prototype.hashCode = function() {
//------------------
// Main Controller
//------------------
// Creamos el módulo dashboardControllers, de donde colgarán todos los controladores
var dashboardControllers = angular.module('dashboardControllers', ['dashboardConfig']);
// Creamos el controlador principal
dashboardControllers.controller('MainCtrl', function MainCtrl($scope, $window, $location, $translate) {
// Always use objects if we want to modify this scope in the childs
......
'use strict';
var dashboardDirectives = angular.module('dashboardDirectives', []);
var dashboardDirectives = angular.module('dashboardDirectives', ['dashboardConfig']);
/*-------------------------------------------------------------------------------
Pictogram follows a Hierarchical MVC pattern (the old PAC pattern)
We have a main controller (see main.js) and then others that are associated to
different headers (by means of AngularJS directives)
Here we are just defining those directives
*/
// Header Supervisor
dashboardDirectives.directive('headerSupervisor', function(){
return{
restrict: 'E',
templateUrl: 'modules/supervisor/views/header.html'
};
});
// Header Student
dashboardDirectives.directive('headerStudent', function(){
return{
restrict: 'E',
templateUrl: 'modules/student/views/header.html'
};
});
// Header Admin
dashboardDirectives.directive('headerAdmin', function(){
return{
restrict: 'E',
templateUrl: 'modules/admin/views/header.html'
};
});
// Translation footer
dashboardDirectives.directive('footerTranslate', function(){
return{
restrict: 'E',
templateUrl: 'modules/translate/views/footer_translate.html'
};
});
/*-------------------------------------------------------------------------------
*
* Mouse event related directives
*
*/
dashboardDirectives.directive('draggable', function() {
return function(scope, element) {
// this gives us the native JS object
......
......@@ -3,60 +3,11 @@
//-----------------------
// Student Collections Controller
//-----------------------
dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollectionsCtrl($scope, $rootScope, $stateParams, $http, config, $window, $filter, $modal, lodash) {
dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollectionsCtrl($scope, $rootScope, $stateParams, $state, $http, config, $window, $filter, $modal, lodash) {
// For tab navigation (here too, if the user refresh the page...)
// For tab navigation (here too, if the user refresh the page...)
$scope.nav.tab = 'collections';
// List of all student pictos
$scope.studentPictos = [];
// List of categories pictos
$scope.pictosCategory = [];
// List of pictos from a catgory
$scope.pictosFromCategory = [];
// The view of pictos: All | Categories
$scope.pictos = {
category: null,
idCat: null
};
// Initialization of PCB (the tablet view) and PCB-Categories
var rows = 5, cols = 10;
$scope.pcb = new Array(); $scope.pcb_cat = new Array();
// Set te empty elements
for (var i=0;i<rows;i++) {
$scope.pcb[i]=new Array(); $scope.pcb_cat[i]=new Array();
for (var j=0;j<cols; j++) {
// Default value
$scope.pcb[i][j]={'picto': {'uri': '/app/img/empty.gif'}, 'attributes': {'coord_x': i, 'coord_y': j}};
$scope.pcb_cat[i][j]={'picto': {'uri': '/app/img/empty.gif'}, 'attributes': {'coord_x': i, 'coord_y': j}};
}
}
$http
.get(config.backend+'/stu/'+ $scope.studentUser.id +'/pictos')
.success(function(data, status, headers, config) {
// Add to list
$scope.studentPictos = data;
//console.log(JSON.stringify($scope.studentPictos));
console.log("Student pictos listed");
// Filtered only the categories pictos
$scope.pictosCategory = $filter('filter')($scope.studentPictos, {attributes: { id_cat: null }});
console.log("Pictos Categories: " + JSON.stringify($scope.pictosCategory));
// Build the pcb_cat with the coords of the pictos
for(var i=0; i < $scope.pictosCategory.length; i++) {
var pic = $scope.pictosCategory[i];
$scope.pcb_cat[pic.attributes.coord_x][pic.attributes.coord_y] = pic;
console.log("Pic " + pic.id + ": " + pic.attributes.color );
}
//console.log(JSON.stringify($scope.pcb_cat));
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
// Reload student pictos (back from addpicto)
$scope.reload_pictos = function(){
$http
......
......@@ -8,49 +8,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
// For tab navigation (here too, if the user refresh the page...)
$scope.nav.tab = 'instructions';
// If it is the first time in a student section, it is not
// charged the student info in the user object at parent scope
if(!$scope.studentUser.id){
$scope.studentUser.id = $stateParams.idStudent;
}
//
// Array with methods available in meta_methods
//
$scope.methods_available = [];
// Query to meta_methods to fill the select fill with precharged methods
// and supervisor template methods
$http
.get(config.backend+'/metamethods/' + $scope.user.id)
.success(function(data, status, headers, config) {
// Add to list
$scope.methods_available = data;
console.log("Meta Methods charged:");
console.log(JSON.stringify($scope.methods_available));
// Option to add new methods
$scope.methods_available.push({ id: 0, name: "Nuevo método" });
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
//
// Array with student methods (with instructions)
//
$scope.methods = [];
// Query to obtain an array of student methods
$http
.get(config.backend+'/stu/'+ $scope.studentUser.id +'/methods')
.success(function(data, status, headers, config) {
// Add to list
$scope.methods = data;
console.log(JSON.stringify($scope.methods));
console.log("Methods recovered");
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
//
// Get last method/instruction for this student
......@@ -75,7 +33,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$http
.post(config.backend+'/method/new', {
'id_stu': $scope.studentUser.id,
'id_stu': $scope.studentData.id,
'name': "Nuevo método (cambiar nombre)"
})
.success(function(data, status, headers, config) {
......@@ -93,7 +51,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
$http
.post(config.backend+'/method', {
'id_mmethod': $scope.method_selected.id,
'id_stu': $scope.studentUser.id
'id_stu': $scope.studentData.id
})
.success(function(data, status, headers, config) {
console.log('Created Method and Instructions');
......@@ -102,7 +60,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
console.log($scope.method_selected.id + " " + $scope.studentUser.id);
console.log($scope.method_selected.id + " " + $scope.studentData.id);
});
}
};
......
......@@ -10,8 +10,8 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
// It it is the first time in a student section, there is not
// charged the student info in the user object at parent scope
if(!$scope.studentUser.id){
$scope.studentUser.id = $stateParams.idStudent;
if(!$scope.studentData.id){
$scope.studentData.id = $stateParams.idStudent;
}
// Date vars
......@@ -36,7 +36,7 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
// Get all the working sessions of the student
$http
.get(config.backend+'/stu/'+ $scope.studentUser.id +'/ws')
.get(config.backend+'/stu/'+ $scope.studentData.id +'/ws')
.success(function(data, status, headers, config) {
$scope.ws = data;
// Call function to build the charts and statistics
......@@ -221,7 +221,7 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
//
// Initializing array of methods
$scope.methods = [];
$scope.reportsMethods = [];
// Statistics vars
$scope.instructions_total = 0;
......@@ -230,7 +230,7 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
// Get all the tries of the student
$http
.get(config.backend+'/stu/'+ $scope.studentUser.id +'/tries')
.get(config.backend+'/stu/'+ $scope.studentData.id +'/tries')
.success(function(data, status, headers, config) {
// Call function to build the charts and statistics
// Loop methods
......@@ -321,9 +321,9 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
}
// End of looping methods
$scope.methods = data;
$scope.selectedMethod = $scope.methods[0]; // The default method is the first of the array
$scope.selectedIns = $scope.methods[0].instructions[0]; // And the first instruction
$scope.reportsMethods = data;
$scope.selectedMethod = $scope.reportsMethods[0]; // The default method is the first of the array
$scope.selectedIns = $scope.reportsMethods[0].instructions[0]; // And the first instruction
// Charts of selectedMethod
$scope.instructions_charts();
......
......@@ -4,68 +4,12 @@
// Student Session Controller
//-----------------------
dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtrl($rootScope, $scope, $stateParams, $http, config, $window) {
console.log("dashboardControllers reload:"+$scope.$id);
console.log("dashboardControllers reload:"+$scope.$id);
// For tab navigation (here too, if the user refresh the page...)
$scope.nav.tab = 'session';
// It it is the first time in a student section, there is not
// charged the student info in the user object at parent scope
if(!$scope.studentUser.id){
$scope.studentUser.id = $stateParams.idStudent;
}
// Actual WS
if(!$rootScope.ws){
$rootScope.ws = {};
}
if(!$rootScope.actual_try){
$rootScope.actual_try = {};
}
////////////////////////////////////////////////////////////////////////////
// Devices /////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
/*
// For mark in list the actual device (Received from PCB via websocket)
$scope.active_device = null;
// 1) Leer los dispositivos del alumno y mostrar en listado
// Array with student's devices
$scope.devices = [];
// Query to obtain an array of student devices
$http
.get(config.backend+'/stu/'+ $scope.studentUser.id +'/devices')
.success(function(data, status, headers, config) {
// Add to list
$scope.devices = data;
console.log(JSON.stringify($scope.devices));
console.log("Devices recovered");
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
*/
////////////////////////////////////////////////////////////////////////////
// Methods and Instructions ////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// 2) Leer los métodos del alumno con sus instrucciones
// Array with student methods (with instructions)
$scope.methods = [];
// Query to obtain an array of student methods
$http
.get(config.backend+'/stu/'+ $scope.studentUser.id +'/methods')
.success(function(data, status, headers, config) {
// Add to list
$scope.methods = data;
console.log(JSON.stringify($scope.methods));
console.log("Methods recovered");
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
// 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){
......@@ -84,33 +28,6 @@ console.log("dashboardControllers reload:"+$scope.$id);
// Tries ///////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Read the last working session to show the last tries when session tab is opened
$rootScope.wsessions = [];
// Query to obtain an array of only one working session (the last) with its tries/actions
$http
.get(config.backend+'/stu/'+ $scope.studentUser.id +'/lasttries')
.success(function(data, status, headers, config) {
// Add to list
$rootScope.wsessions = data;
console.log(JSON.stringify($rootScope.wsessions));
console.log("Tries of last working session recovered");
$scope.currentPage = 1;
$scope.numPerPage = 5;
$scope.totalPages = Math.ceil($rootScope.wsessions.length / $scope.numPerPage);
$scope.ws_recover = $rootScope.wsessions[0]!=null && $rootScope.wsessions[0].end==null;
console.log("tries: " + $rootScope.wsessions.length);
console.log("numPerPage: " + $scope.numPerPage);
console.log("pages: " + $scope.totalPages);
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
// Initially, show the last try
$scope.showLastTry = true;
// When clicking over an instruction in the select control
// load its working sessions with its associated tries and with its actions
$scope.load_tries = function (instruction){
......@@ -138,8 +55,7 @@ console.log("dashboardControllers reload:"+$scope.$id);
});
}
};
};
// Tries pagination - previous tries
$scope.before = function(){
......@@ -274,21 +190,22 @@ console.log("dashboardControllers reload:"+$scope.$id);
});
};
//
//
// update the description of a given working session
//
$scope.update_ws = function (ws){
console.log("WS description - updating: " + ws.id+":"+ws.description);
$http
.put(config.backend+'/workingsession/' + ws.id, { "description" : ws.description })
.then(function(data, status, headers, config) {
console.log("WS description - updated: " + ws.description);
console.log("WS description - updating: " + ws.id+":"+ws.description);
$http
.put(config.backend+'/workingsession/' + ws.id, { "description" : ws.description })
.then(function(data, status, headers, config) {
console.log("WS description - updated: " + ws.description);
})
,function(data, status, headers, config) {
console.log("Error from API: " + data.error);
};
}
})
,function(data, status, headers, config) {
console.log("Error from API: " + data.error);
};
}
//
// Finish a working session updating its end time
//
......@@ -399,8 +316,6 @@ console.log("dashboardControllers reload:"+$scope.$id);
////////////////////////////////////////////////////////////////////////////
// Timer Control - Show the time counter in view ///////////////////////////
////////////////////////////////////////////////////////////////////////////
$scope.paused = false;
$scope.startTimer = function (){
$scope.$broadcast('timer-start');
......
......@@ -19,14 +19,14 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
// Get the file extension
var extension = file.name.split('.').pop();
var filename = $scope.studentUser.id + file.name;
var filename = $scope.studentData.id + file.name;
console.log("Archivo: " + filename);
$upload.upload({
url: '/stu/upload', //upload.php script, node.js route, or servlet url
method: 'POST', // or 'PUT',
// Fields to sent in the body of the request
fields: {'filename': filename, 'extension': extension, 'folder': 'students', 'id': $scope.studentUser.id},
fields: {'filename': filename, 'extension': extension, 'folder': 'students', 'id': $scope.studentData.id},
// or ['1.jpg', '2.jpg', ...] // to modify the name of the file(s)
file: file, // or list of files ($files) for html5 only
}).progress(function(evt) {
......@@ -35,7 +35,7 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
// file is uploaded successfully
console.log(JSON.stringify(data.file));
// Assign the new image with new name
$scope.studentUser.pic = "/upload/students/" + data.file.name;
$scope.studentData.pic = "/upload/students/" + data.file.name;
//$scope.picture = user.id + "." + extension + "?t=" + new Date().getTime();
});
}else{
......@@ -73,20 +73,20 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
}
$http
.put(config.backend+'/stu/'+$scope.studentUser.id, $scope.formUser)
.put(config.backend+'/stu/'+$scope.studentData.id, $scope.formUser)
.success(function(data, status, headers, config) {
$scope.showmessagestudent = true;
$scope.alertstudent = "alert-success";
$scope.messagestudent = "student_updated";
// studentUser with new values
$scope.studentUser.surname = data.surname;
$scope.studentUser.birthdate = data.birthdate;
$scope.studentUser.country = data.country;
$scope.studentUser.pic = data.pic;
$scope.studentUser.gender = data.gender;
$scope.studentUser.lang = data.lang;
$scope.studentUser.notes = data.notes;
// studentData with new values
$scope.studentData.surname = data.surname;
$scope.studentData.birthdate = data.birthdate;
$scope.studentData.country = data.country;
$scope.studentData.pic = data.pic;
$scope.studentData.gender = data.gender;
$scope.studentData.lang = data.lang;
$scope.studentData.notes = data.notes;
console.log("Student updated");
})
......@@ -99,38 +99,6 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
});
};
// *******************************************************
// Therapists
// List of student's therapists
$scope.studentSupervisors = [];
$http
.get(config.backend+'/stu/'+ $scope.studentUser.id +'/therapists')
.success(function(data, status, headers, config) {
// Add to list
$scope.studentSupervisors = data;
console.log(JSON.stringify($scope.studentSupervisors));
console.log("Supervisors listed");
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
// List of student's tutors (parents)
$scope.studentTutors = [];
$http
.get(config.backend+'/stu/'+ $scope.studentUser.id +'/tutors')
.success(function(data, status, headers, config) {
// Add to list
$scope.studentTutors = data;
console.log(JSON.stringify($scope.studentTutors));
console.log("Tutors listed");
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
// Search supervisor by email
$scope.search_sup = function(){
// Find tutor by email
......@@ -164,12 +132,12 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
// Add supervisor (father or mother)
$scope.add_sup = function(){
var stusup = {
student: $scope.studentUser.id,
student: $scope.studentData.id,
supervisor: $scope.supToAdd.id
}
$http
.get(config.backend+'/stu/'+ $scope.studentUser.id + '/sup/' + $scope.supToAdd.id)
.get(config.backend+'/stu/'+ $scope.studentData.id + '/sup/' + $scope.supToAdd.id)
.success(function(data, status, headers, config) {
// Assign the info of supervisor to add
stusup.supervisor = $scope.supToAdd;
......@@ -198,7 +166,7 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
var deleteSup = $window.confirm('Are you absolutely sure you want to delete?');
if(deleteSup){
$http
.delete(config.backend+'/stu/'+ $scope.studentUser.id + '/sup/' + id_sup)
.delete(config.backend+'/stu/'+ $scope.studentData.id + '/sup/' + id_sup)
.success(function(data, status, headers, config) {
// Eliminar de la vista: Se recorre el array de objetos json para buscarlo
......@@ -251,12 +219,12 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
// Add tutor
$scope.add_tutor = function(){
var stusup = {
student: $scope.studentUser.id,
student: $scope.studentData.id,
supervisor: $scope.tutorToAdd.id
}
$http
.get(config.backend+'/stu/'+ $scope.studentUser.id + '/sup/' + $scope.tutorToAdd.id)
.get(config.backend+'/stu/'+ $scope.studentData.id + '/sup/' + $scope.tutorToAdd.id)
.success(function(data, status, headers, config) {
// Assign the info of supervisor to add
stusup.supervisor = $scope.tutorToAdd;
......@@ -284,7 +252,7 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
var deleteTutor = $window.confirm('Are you absolutely sure you want to delete?');
if(deleteTutor){
$http
.delete(config.backend+'/stu/'+ $scope.studentUser.id + '/sup/' + id_sup)
.delete(config.backend+'/stu/'+ $scope.studentData.id + '/sup/' + id_sup)
.success(function(data, status, headers, config) {
// Eliminar de la vista: Se recorre el array de objetos json para buscarlo
......@@ -304,30 +272,12 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
}
};
// *******************************************************
// Devices
// List of student's devices
$scope.studentDevices = [];
$http
.get(config.backend+'/stu/'+ $scope.studentUser.id +'/devices')
.success(function(data, status, headers, config) {
// Add to list
$scope.studentDevices = data;
console.log("Devices listed: ");
console.log(JSON.stringify($scope.studentDevices));
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
$scope.delete_device = function (id_dev){
var deleteDevice = $window.confirm('Are you absolutely sure you want to delete?');
if(deleteDevice){
$http
.delete(config.backend+'/stu/'+ $scope.studentUser.id +'/dev/' + id_dev)
.delete(config.backend+'/stu/'+ $scope.studentData.id +'/dev/' + id_dev)
.success(function(data, status, headers, config) {
// Eliminar de la vista: Se recorre el array de objetos json para buscarlo
......@@ -349,7 +299,7 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
$scope.associate_dev = function(){
var stu_dev = {
"id_stu": $scope.studentUser.id,
"id_stu": $scope.studentData.id,
"id_dev_firm": $scope.device_id_firmware
}
......@@ -379,7 +329,7 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
// *******************************************************
// Devices Setup
// $scope.studentUser.attributes
// $scope.studentData.attributes
// Update options attributes
//
$scope.update_attributes = function(){
......@@ -388,14 +338,14 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl($s
$scope.messageattributes = "attributes_updating";
$http
.put(config.backend+'/stu/'+$scope.studentUser.id, { 'attributes':JSON.stringify($scope.studentUser.attributes)})
.put(config.backend+'/stu/'+$scope.studentData.id, { 'attributes':JSON.stringify($scope.studentData.attributes)})
.success(function(data, status, headers, config) {
$scope.showmessageattributes = true;
$scope.alertattributes = "alert-success";
$scope.messageattributes = "attributes_updated";
// studentUser with new values
$scope.studentUser.attributes = data.attributes;
// studentData with new values
$scope.studentData.attributes = data.attributes;
console.log("Attributes updated");
})
......
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