fixed some bugs

parent 7511ebdf
...@@ -843,6 +843,22 @@ module.exports = { ...@@ -843,6 +843,22 @@ module.exports = {
}); });
}, },
//
// Returns the last instruction for the student
//
last_instruction: function(req, res) {
if (!req.params.id_stu)
return res.json(400, {err: 'id_stu parameter is missing'});
VStuLastInstruction.find({id_stu: req.params.id_stu}).exec(function(err, found) {
if (err)
return res.json(500, err);
if (!found)
return res.json({});
return res.json(found);
});
},
// //
// Test raw sql on models // Test raw sql on models
sqlquery: function(req, res) { sqlquery: function(req, res) {
......
...@@ -71,11 +71,13 @@ module.exports = { ...@@ -71,11 +71,13 @@ module.exports = {
// //
categories: function(id_sup, id_cat, callback) { categories: function(id_sup, id_cat, callback) {
Supervisor.findOne(id_sup).exec(function(err, sup) { Supervisor.findOne(id_sup).exec(function(err, sup) {
if (err) if (err) {
console.log("Error retrieving categories for supervisor " + id_sup + ": " + err);
return callback(err, {}); return callback(err, {});
}
// 0 for the main categories --> null in DB // 0 for the main categories --> null in DB
if(id_cat == 0) id_cat = null; // if(id_cat == 0) id_cat = null;
PictoCat.find({id_supercat: id_cat}).populate('exps', {lang: sup.lang}).exec(function(err, pictoCats) { PictoCat.find({id_supercat: id_cat}).populate('exps', {lang: sup.lang}).exec(function(err, pictoCats) {
if (err || !pictoCats || pictoCats.length == 0) if (err || !pictoCats || pictoCats.length == 0)
...@@ -91,9 +93,11 @@ module.exports = { ...@@ -91,9 +93,11 @@ module.exports = {
// //
fromcategory: function(id_sup, id_cat, callback) { fromcategory: function(id_sup, id_cat, callback) {
Supervisor.findOne(id_sup).exec(function(err, sup) { Supervisor.findOne(id_sup).exec(function(err, sup) {
if (err) if (err) {
console.log("Error retrieving categories for supervisor " + id_sup + ": " + err);
return callback(err, {}); return callback(err, {});
}
Picto.find({category: id_cat}).populate('expressions', {lang: sup.lang}).exec(function(err, pictos) { Picto.find({category: id_cat}).populate('expressions', {lang: sup.lang}).exec(function(err, pictos) {
if (err || !pictos || pictos.length == 0) if (err || !pictos || pictos.length == 0)
return callback(err, {}); return callback(err, {});
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
"child": "Child", "child": "Child",
"click": "Click", "click": "Click",
"click_login": "Click to login", "click_login": "Click to login",
"close": "Close",
"collections": "Collections", "collections": "Collections",
"confirmation": "Are you sure?", "confirmation": "Are you sure?",
"contact_person": "Contact person", "contact_person": "Contact person",
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
"child": "Niño", "child": "Niño",
"click": "Clic", "click": "Clic",
"click_login": "Clic para iniciar sesión", "click_login": "Clic para iniciar sesión",
"close": "Cerrar",
"collections": "Colecciones", "collections": "Colecciones",
"confirmation": "¿Estás seguro?", "confirmation": "¿Estás seguro?",
"contact_person": "Persona de contacto", "contact_person": "Persona de contacto",
......
...@@ -22,7 +22,7 @@ angular.module('dashboardServices', []) ...@@ -22,7 +22,7 @@ angular.module('dashboardServices', [])
responseError: function (rejection) { responseError: function (rejection) {
if (rejection.status === 401) { if (rejection.status === 401) {
// handle the case where the user is not authenticated // handle the case where the user is not authenticated
console.log("eerrrorrrrr 401"); console.log("error 401");
// send "logout" to children controllers so main.js controller can catch it and logout // send "logout" to children controllers so main.js controller can catch it and logout
$rootScope.$broadcast('logout', null); $rootScope.$broadcast('logout', null);
......
<div class="container" ng-controller="AdminCtrl"> <!-- AdminCtrl controls here, see app.js -->
<div class="container">
<!-- Admin header --> <!-- Admin header -->
<header-admin></header-admin> <header-admin></header-admin>
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
<img src="img/logo_pictogram.png" alt="Pictogram" title="Pictogram" /> <img src="img/logo_pictogram.png" alt="Pictogram" title="Pictogram" />
</p> </p>
<!-- Formulario --> <!-- Formulario -->
<form name="loginForm" ng-controller="LoginCtrl" ng-submit="login()" novalidate> <!-- LoginCtrl controls here, see app.js -->
<form name="loginForm" ng-submit="login()" novalidate>
<!-- Alert and success messages --> <!-- Alert and success messages -->
<div ng-show="{{ 'showmessage' }}" class="alert" ng-class="alert" translate translate-value-name="{{name}}">{{message}}</div> <div ng-show="{{ 'showmessage' }}" class="alert" ng-class="alert" translate translate-value-name="{{name}}">{{message}}</div>
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
<img src="img/logo_pictogram.png" alt="Pictogram" title="Pictogram" /> <img src="img/logo_pictogram.png" alt="Pictogram" title="Pictogram" />
</p> </p>
<!-- Formulario --> <!-- Formulario -->
<form name="loginForm" ng-controller="LoginAdminCtrl" ng-submit="login()" novalidate> <!-- LoginAdminCtrl controls here, see app.js -->
<form name="loginForm" ng-submit="login()" novalidate>
<!-- Alert and success messages --> <!-- Alert and success messages -->
<div ng-show="{{ 'showmessage' }}" class="alert" ng-class="alert" translate translate-value-name="{{name}}">{{message}}</div> <div ng-show="{{ 'showmessage' }}" class="alert" ng-class="alert" translate translate-value-name="{{name}}">{{message}}</div>
......
<div class="row" ng-controller="LoginSettingPasswordCtrl"> <!-- LoggingSettingPasswordCtrl controls here, see app.js -->
<div class="row">
<!-- Rejilla 3 elementos de igual ancho --> <!-- Rejilla 3 elementos de igual ancho -->
<div class="col-md-4">&nbsp;</div> <div class="col-md-4">&nbsp;</div>
......
<!-- SigningCtrl controls here, see app.js -->
<div class="container"> <div class="container">
<div class="row"> <div class="row">
...@@ -16,7 +17,7 @@ ...@@ -16,7 +17,7 @@
<!-- Logo Pictogram --> <!-- Logo Pictogram -->
<!-- Formulario --> <!-- Formulario -->
<form name="signInForm" role="form" ng-controller="SignInCtrl" ng-submit="signin()"> <form name="signInForm" role="form" ng-submit="signin()">
<!-- Alert and success messages --> <!-- Alert and success messages -->
<div ng-show="{{ 'showmessage' }}" class="alert" ng-class="alert" translate translate-values="{name: formdata.name, surname: formdata.surname, email: formdata.email}">{{message}}</div> <div ng-show="{{ 'showmessage' }}" class="alert" ng-class="alert" translate translate-values="{name: formdata.name, surname: formdata.surname, email: formdata.email}">{{message}}</div>
......
...@@ -44,7 +44,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance ...@@ -44,7 +44,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
console.log("Error from API: " + data.error); console.log("Error from API: " + data.error);
}); });
//
// Load pictos from a category // Load pictos from a category
//
$scope.load_pictos = function (id_cat){ $scope.load_pictos = function (id_cat){
$http $http
.get(config.backend+'/sup/'+ $scope.sup.id +'/pic_fromcategory/' + id_cat) .get(config.backend+'/sup/'+ $scope.sup.id +'/pic_fromcategory/' + id_cat)
...@@ -52,15 +54,17 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance ...@@ -52,15 +54,17 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
// Add to list // Add to list
$scope.pictos = data; $scope.pictos = data;
//console.log(JSON.stringify($scope.pictos)); //console.log(JSON.stringify($scope.pictos));
console.log("Pictos listed"); console.log("Pictos listed" + data);
}) })
.error(function(data, status, headers, config) { .error(function(data, status, headers, config) {
console.log("Error from API: " + data.error); console.log("Error from API: " + data.error);
}); });
}; };
//
// Load pictos from owned by the actual supervisor // Load pictos from owned by the actual supervisor
// TEST --> change with real supervisor pictos // TEST --> change with real supervisor pictos
//
$scope.load_own_pictos = function (){ $scope.load_own_pictos = function (){
$http $http
.get(config.backend+'/sup/'+ $scope.sup.id +'/pictos') .get(config.backend+'/sup/'+ $scope.sup.id +'/pictos')
...@@ -75,7 +79,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance ...@@ -75,7 +79,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
}); });
}; };
//
// Load the folders of a category // Load the folders of a category
//
$scope.load_category = function (id_cat){ $scope.load_category = function (id_cat){
$http $http
.get(config.backend+'/sup/'+ $scope.sup.id +'/pic_categories/' + id_cat) .get(config.backend+'/sup/'+ $scope.sup.id +'/pic_categories/' + id_cat)
...@@ -89,7 +95,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance ...@@ -89,7 +95,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
}); });
}; };
//
// Request folders of a category from the panel (symbolstx) // Request folders of a category from the panel (symbolstx)
//
$scope.open_category = function (cat) { $scope.open_category = function (cat) {
// Add to breadcrumbs // Add to breadcrumbs
$scope.breadcrumbs.push({ $scope.breadcrumbs.push({
...@@ -102,7 +110,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance ...@@ -102,7 +110,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
$scope.load_pictos(cat.id); $scope.load_pictos(cat.id);
}; };
//
// Request folders of a category from the breadcrumbs (symbolstx) // Request folders of a category from the breadcrumbs (symbolstx)
//
$scope.open_category_from_bc = function (id_cat) { $scope.open_category_from_bc = function (id_cat) {
// Delete from breadcrumbs // Delete from breadcrumbs
...@@ -119,11 +129,16 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance ...@@ -119,11 +129,16 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
$scope.alert = { type: 'danger', msg: 'Category is full of pictos.', show: false }; $scope.alert = { type: 'danger', msg: 'Category is full of pictos.', show: false };
//
// Close alert message
//
$scope.closeAlert = function() { $scope.closeAlert = function() {
$scope.alert.show = false; $scope.alert.show = false;
}; };
//
// Upload to own supervisor collection when a picto is selected from file // Upload to own supervisor collection when a picto is selected from file
//
$scope.onPictoSelect = function($files) { $scope.onPictoSelect = function($files) {
//$files: an array of files selected, each file has name, size, and type. //$files: an array of files selected, each file has name, size, and type.
for (var i = 0; i < $files.length; i++) { for (var i = 0; i < $files.length; i++) {
...@@ -165,7 +180,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance ...@@ -165,7 +180,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
} }
}; };
//
// Add a picto to student when it is dropped into a category // Add a picto to student when it is dropped into a category
//
$scope.handleDropAddPicto = function(origin, destination) { $scope.handleDropAddPicto = function(origin, destination) {
// Add picto to stu_picto // Add picto to stu_picto
var v_dest = destination.split("_"); // 3 values: idcat_coordx_coordy var v_dest = destination.split("_"); // 3 values: idcat_coordx_coordy
...@@ -327,7 +344,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance ...@@ -327,7 +344,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
} }
}; };
//
// Delete picto added // Delete picto added
//
$scope.remove_picto = function (stuPicto, id_cat){ $scope.remove_picto = function (stuPicto, id_cat){
console.log("delete_studentPicto: " + JSON.stringify(stuPicto)); console.log("delete_studentPicto: " + JSON.stringify(stuPicto));
...@@ -369,7 +388,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance ...@@ -369,7 +388,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
}; };
//
// Delete own picto // Delete own picto
//
$scope.remove_own_picto = function (id_picto){ $scope.remove_own_picto = function (id_picto){
console.log("delete_picto:" + id_picto); console.log("delete_picto:" + id_picto);
var deletePicto = $window.confirm('Are you absolutely sure you want to delete?'); var deletePicto = $window.confirm('Are you absolutely sure you want to delete?');
...@@ -392,6 +413,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance ...@@ -392,6 +413,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
} }
}; };
//
//
//
$scope.close = function () { $scope.close = function () {
$modalInstance.close("Ejemplo de elemento devuelto"); $modalInstance.close("Ejemplo de elemento devuelto");
}; };
...@@ -403,7 +427,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance ...@@ -403,7 +427,9 @@ dashboardControllers.controller('AddPictoCtrl', function ($scope, $modalInstance
$modalInstance.dismiss('cancel'); $modalInstance.dismiss('cancel');
}; };
//
// Modal window to open picto expression // Modal window to open picto expression
//
$scope.open_exp = function (picto) { $scope.open_exp = function (picto) {
var modalInstance = $modal.open({ var modalInstance = $modal.open({
......
...@@ -237,7 +237,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec ...@@ -237,7 +237,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
animation: true, animation: true,
templateUrl: 'modules/student/views/addpicto.html', templateUrl: 'modules/student/views/addpicto.html',
controller: 'AddPictoCtrl', controller: 'AddPictoCtrl',
size: size, size: 'lg',
resolve: { // Passing data to the controller of the window resolve: { // Passing data to the controller of the window
stu_id: function(){ stu_id: function(){
return $scope.studentData.id; return $scope.studentData.id;
......
...@@ -115,6 +115,6 @@ ...@@ -115,6 +115,6 @@
</div> </div>
<!-- End modal-body --> <!-- End modal-body -->
<div class="modal-footer"> <div class="modal-footer">
<button class="btn btn-primary" ng-click="close()">Cerrar</button> <button class="btn btn-primary" ng-click="close()">{{ 'close' | translate }}</button>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<!-- Fin de columna vistas por categorías --> <!-- Fin de columna vistas por categorías -->
<div class="col-md-2 text-right"> <div class="col-md-2 text-right">
<a href="#" class="btn btn-success btn-sm" role="button" ng-click="open('lg')"> <a class="btn btn-success btn-sm" role="button" ng-click="open()">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> <span translate>add_picto<span> <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> <span translate>add_picto<span>
</a> </a>
</div> </div>
......
...@@ -16,20 +16,25 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl($scope, $s ...@@ -16,20 +16,25 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl($scope, $s
"lang": 'es-es', "lang": 'es-es',
"notes": '', "notes": '',
"pic": "/app/img/default.jpg", "pic": "/app/img/default.jpg",
"office": $scope.user.office "office": $scope.user.office || {name: ""}
}; };
// //
// Flags for showing buttons according to role // Flags for showing buttons according to role
// //
$scope.user = JSON.parse($window.sessionStorage.user); $scope.user = JSON.parse($window.sessionStorage.user);
if ($scope.user.office && $scope.user.office.admin === $scope.user.id) // The user is administrator of the office
$scope.user.isAdmin = true;
if ($scope.user.office.currentStudents >= $scope.user.office.maxStudents) if ($scope.user.office) {
$scope.num_licenses_left = 0; if ($scope.user.office.admin === $scope.user.id) // The user is administrator of the office
else $scope.user.isAdmin = true;
$scope.num_licenses_left = $scope.user.office.maxStudents - $scope.user.office.currentStudents;
if ($scope.user.office.currentStudents >= $scope.user.office.maxStudents)
$scope.num_licenses_left = 0;
else
$scope.num_licenses_left = $scope.user.office.maxStudents - $scope.user.office.currentStudents;
} else {
$scope.user.office = {name: ""}
}
// //
// Get list of supervisor's students // Get list of supervisor's students
...@@ -60,7 +65,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl($scope, $s ...@@ -60,7 +65,7 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl($scope, $s
"lang": 'es-es', "lang": 'es-es',
"notes": '', "notes": '',
"pic": "/app/img/default.jpg", "pic": "/app/img/default.jpg",
"office": $scope.user.office, "office": $scope.user.office || {name: ""},
"current_method": "no_method", "current_method": "no_method",
"current_instruction": "no_instruction" "current_instruction": "no_instruction"
}; };
......
<div ng-controller="SetupCtrl"> <!-- SetupCtrl controls here, see app.js -->
<div>
<div class="page-header"> <div class="page-header">
<h2 translate>setup</h2> <h2 translate>setup</h2>
</div> </div>
......
<toast></toast> <toast></toast>
<!-- StudentsCtrl controls here, see app.js -->
<div class="panel panel-default" ng-controller="StudentsCtrl"> <div class="panel panel-default">
<!-- Default panel contents --> <!-- Default panel contents -->
<div class="panel-heading"><h3 class="panel-title" translate>students</h3> <div class="panel-heading"><h3 class="panel-title" translate>students</h3>
<span ng-if="user.isAdmin">({{user.office.currentStudents}}/{{user.office.maxStudents}} - <span translate="licenses_left" translate-values="{number: num_licenses_left}"></span>)</span> <span ng-if="user.isAdmin">({{user.office.currentStudents}}/{{user.office.maxStudents}} - <span translate="licenses_left" translate-values="{number: num_licenses_left}"></span>)</span>
......
<div class="container" ng-controller="SupervisorCtrl"> <!-- SupervisorCtrl controls here, see app.js -->
<div class="container">
<header-supervisor></header-supervisor> <header-supervisor></header-supervisor>
......
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