fixed #584 and #478

parent 1120a249
......@@ -42,12 +42,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/LocalFlavorDebug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/LocalFlavorDebug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/LocalFlavorDebug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/LocalFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/LocalFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/LocalFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/LocalFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/LocalFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/LocalFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testLocalFlavorDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testLocalFlavorDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testLocalFlavorDebug/assets" type="java-test-resource" />
......@@ -56,6 +50,12 @@
<sourceFolder url="file://$MODULE_DIR$/src/testLocalFlavorDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testLocalFlavorDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testLocalFlavorDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/LocalFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/LocalFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/LocalFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/LocalFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/LocalFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/LocalFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/LocalFlavor/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/LocalFlavor/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/LocalFlavor/assets" type="java-resource" />
......
......@@ -42,12 +42,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavorDebug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavorDebug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavorDebug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/DefaultFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/DefaultFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavorDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavorDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavorDebug/assets" type="java-test-resource" />
......@@ -56,6 +50,12 @@
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavorDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavorDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavorDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/DefaultFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/DefaultFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/assets" type="java-resource" />
......@@ -64,14 +64,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/assets" type="java-test-resource" />
......@@ -80,6 +72,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
......
......@@ -149,69 +149,28 @@ module.exports = {
},
//
// create action
// adds a new student into the database
// Adds a new student into the database
//
create: function (req, res) {
var params = req.params.all();
Student.create(params)
.exec(function (err, created) {
if (err) {
console.log(err);
sails.log.debug(err);
return res.json(500, err);
}
if (created) {
sails.log.debug('Student ' + created.id + ' created: ' + JSON.stringify(created));
// Assign the initial collection of pictos to the student
PictoCore.find()
.exec(function (pictoCoreError, pictoCore) {
var i;
if (pictoCoreError || !pictoCore || pictoCore.length === 0) {
sails.log.debug('PictoCore: ' + pictoCoreError);
return;
}
sails.log.debug('PictoCore Length: ' + pictoCore.length);
sails.log.debug(pictoCore);
// Every picto from 'picto_core_cat' is going to be created
// in 'stu_picto'
for (i = 0; i < pictoCore.length; i++) {
sails.log.debug('Loop: ' + i);
sails.log.debug('Picto Category: ' + pictoCore[i].category);
sails.log.debug('User id: ' + created.id);
StuPicto.create({
student: created.id,
picto: pictoCore[i].picto,
attributes: {
id_cat: pictoCore[i].category,
coord_x: pictoCore[i].coord_x,
coord_y: pictoCore[i].coord_y,
status: 'invisible', // Default, the pictos don't appear to the user
color: pictoCore[i].color
}
})
.exec(function (stuPictoError, added) {
if (stuPictoError) sails.log.debug('StuPicto.create: ' +
stuPictoError);
if (added) {
sails.log.debug(
'Picto ' + added.picto +
' added to student ' + created.id +
' with attributes: ' + JSON.stringify(added.attributes));
}
});
}
});
return res.json({
student: created
});
}
});
.then(function(created) {
sails.log.debug('Student ' + created.id + ' created: ' + JSON.stringify(created));
return res.ok({ student: created });
})
.error(function(err) {
if (err.message.search("Maximum number of enrolments reached") > 0) {
// This is a MySQL error triggered by TRG_NEW_STUDENT_MAXENROLMENTS trigger
// (see triggers-enroments-integrity-constraints.sql)
// As the format is not that of a normal error, we just get message
sails.log.debug(err.message);
return res.serverError(err.message);
}
else {
sails.log.debug(err);
return res.serverError(err);
}
});
},
/**
......
......@@ -233,6 +233,53 @@ module.exports = {
},
/**
* Sets initial vocabulary of students to Picto Core
* @param {Object} attrs All student properties stored
* @param {Function} next Function to be executed when the check process
* has been completed (an error object will be passed
* to the function if necesary)
*/
afterCreate: function (attrs, next) {
// Assign the initial collection of pictos to the student
PictoCore.find()
.then(function(pictoCore) {
var i;
// Every picto from 'picto_core_cat' is going to be created
// in 'stu_picto'
for (var i = 0; i < pictoCore.length; i++) {
StuPicto.create({
student: created.id,
picto: pictoCore[i].picto,
attributes: {
id_cat: pictoCore[i].category,
coord_x: pictoCore[i].coord_x,
coord_y: pictoCore[i].coord_y,
status: 'invisible', // Default, the pictos don't appear to the user
color: pictoCore[i].color
}
})
.then(function (stuPictoError, added) {
if (added) {
sails.log.debug(
'Picto ' + added.picto +
' added to student ' + created.id +
' with attributes: ' + JSON.stringify(added.attributes));
}
})
.error(function(err) {
sails.log.debug('StuPicto.create: ' + err);
throw err;
});
}
next();
})
.error(function(err) {
next(err);
});
},
/**
* Checks the given properties before updating a new Student
* @param {Object} attrs All student properties to be stored
* @param {Function} next Function to be executed when the check process
......
......@@ -156,7 +156,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
}, function () {});
$translate('picto_removed').then(function (translation) {
ngToast.danger({ content: translation });
ngToast.success({ content: translation });
});
}).error(function () {});
......@@ -182,7 +182,7 @@ dashboardControllers.controller('StudentCollectionsCtrl', function StudentCollec
}, function () {});
$translate('picto_removed').then(function (translation) {
ngToast.danger({ content: translation });
ngToast.success({ content: translation });
});
}).error(function () {});
......
......@@ -83,7 +83,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
// Add empty array of instructions
data.instructions = [];
console.log('Created new empty Method:' + JSON.stringify(data));
$scope.methods.push(data);
$scope.methods.unshift(data);
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
......@@ -108,8 +108,6 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
}
};
// Delete template
$scope.delete_template = function(){
......@@ -177,7 +175,7 @@ dashboardControllers.controller('StudentInstructionsCtrl', function StudentInstr
});
}
,function(data, status, headers, config) { //error
,function(data, status, headers, config) { //error
console.log("Error from API: " + data.error+"("+data.status+")");
ngToast.success({
content: $translate.instant('method_name_duplicated', {method_name: method.name}),
......
......@@ -12,10 +12,9 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$translate,
ngToast) {
// For tab navigation (here too, if the user refresh the page...)
$scope.nav.tab = 'session';
// ----------------------------------------------------------------------
// SESSION
// Prepare session recording information
......@@ -59,13 +58,8 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$scope.numPerPage = 5;
$scope.totalPages = Math.ceil($scope.wsessions.length / $scope.numPerPage);
$scope.ws_recover = $scope.wsessions[0]!=null && $scope.wsessions[0].end==null;
})
.error(function(data, status, headers, config) {
.error(function(data, status, headers, config) {
});
// Initially, show the last try
......@@ -94,7 +88,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// If to avoid the default select option "-- select one instruction --"
if(instruction){
$http
$http
.get(config.backend+'/instruction/'+ instruction.id +'/ws')
.success(function(data, status, headers, config) {
// Add to list
......@@ -104,11 +98,8 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$scope.numPerPage = 5;
$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
......@@ -124,8 +115,8 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
//
// Evaluate a try (result update request)
//Modify the desc. of a try
$scope.update_try = function(t){
// Modify the desc. of a try
$scope.update_try = function(t) {
var update_data={};
if (t.description)
update_data.description = t.description;
......@@ -142,33 +133,28 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
};
$scope.update_current_try = function(){
$http
.put(config.backend+'/try/' + $scope.actual_try.id, { result: $scope.actual_try.result, end: new Date() })
.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() })
.then(
function(data, status, headers, config) {
$scope.load_tries($scope.selectedIns);
// Empty actual try and push the first action of next try
$scope.actual_try.actions = [];
$scope.actual_try.actions.push({ action: 'tryinit' });
$scope.actual_try.id = data.id;
}
,function(data, status, headers, config) {
}
)
,function(data, status, headers, config) {
}
}
);
function(data, status, headers, config2) {
$http
.post(config.backend+'/try/', {ws: $scope.ws, student: $scope.studentData.id, supervisor: $scope.user.id, begin:new Date() })
.then(
function(data, status, headers, config) {
$scope.load_tries($scope.selectedIns);
// Empty actual try and push the first action of next try
$scope.actual_try.actions = [];
$scope.actual_try.actions.push({ action: 'tryinit' });
$scope.actual_try.id = data.id;
},
function(data, status, headers, config) {}
)
,function(data, status, headers, config) {}
}
);
};
$scope.send_show_action = function(){
};
$scope.send_show_action = function(){};
////////////////////////////////////////////////////////////////////////////
......@@ -190,9 +176,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
,function(data, status, headers, config) {
}
);
}
};
//
// Create new working session
......@@ -228,11 +212,9 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$scope.studentData.current_instruction=$scope.selectedIns.name;
})
.error(function(data, status, headers, config) {
$translate('error_creating_session').then(function (translation) {
ngToast.danger({ content: translation });
});
ngToast.danger({ content: $translate.instant('error_creating_session') });
});
}
};
//
// update the description of a given working session
......@@ -243,10 +225,10 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
.then(function(data, status, headers, config) {
// TODO notify update?
})
,function(data, status, headers, config) {
.error(function(data, status, headers, config) {
};
}
});
};
//
// Finish a working session updating its end time
......@@ -315,7 +297,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
})
.success(function(data, status, headers, config) {
// Adding resume action to the list of actions
$scope.actual_try.actions = [];
$scope.actual_try.actions = [];
$scope.actual_try.actions.push({ action: 'resumesession'} );
$scope.actual_try.id=data.open_try;
})
......@@ -393,38 +375,39 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// Add new listener to the event
io.socket.on('action', function(data) {
// Socket.io does not live inside the angular lifecycle, and thus Angular
// doesn't know new data has come in. Inside the socket.io callback,
// as the last action, added $scope.apply() that lets angular know
// what data has updated, and refresh what needs to be refreshed.
//only events (i) from a student (and ii)when a try is opened are managed
if($scope.ws && $scope.actual_try.actions && $scope.paused == false){
switch(data.action){
case 'Add':
$scope.actual_try.actions.push(data);
break;
case 'Delete':
// Socket.io does not live inside the angular lifecycle, and thus Angular
// doesn't know new data has come in. Inside the socket.io callback,
// as the last action, added $scope.apply() that lets angular know
// what data has updated, and refresh what needs to be refreshed.
// only events (i) from a student (and ii)when a try is opened are managed
if($scope.ws && $scope.actual_try.actions && $scope.paused == false){
switch(data.action){
case 'Add':
$scope.actual_try.actions.push(data);
break;
case 'Delete':
$scope.actual_try.actions.push(data);
break;
case 'Select':
$scope.actual_try.actions.push(data);
break;
case 'Show':
// Empty actual try and push the first action of next try
if (!data.attributes.id_sup) {
$scope.load_tries($scope.selectedIns);
$scope.actual_try.actions = [];
$scope.actual_try.actions.push({ action: 'tryinit' });
}
else
$scope.actual_try.actions.push(data);
break;
case 'Select':
$scope.actual_try.actions.push(data);
break;
case 'Show':
// Empty actual try and push the first action of next try
if (!data.attributes.id_sup) {
$scope.load_tries($scope.selectedIns);
$scope.actual_try.actions = [];
$scope.actual_try.actions.push({ action: 'tryinit' });
}
else
$scope.actual_try.actions.push(data);
break;
}
break;
}
$scope.$apply();
}
$scope.$apply();
});
});
......@@ -31,11 +31,15 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
// Flags for showing buttons according to role
$scope.user = JSON.parse($window.sessionStorage.user);
// Identify if the user is office administrator
if ($scope.user.office) {
if ($scope.user.office.admin === $scope.user.id) {
$scope.user.isAdmin = true;
}
console.log("currentStudents: " + $scope.user.office.currentStudents);
console.log("maxStudents: " + $scope.user.office.maxStudents);
if ($scope.user.office.currentStudents >= $scope.user.office.maxStudents) {
$scope.num_licenses_left = 0;
} else {
......@@ -47,15 +51,15 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
$scope.user.office = { name: '' };
}
$scope.hidestudentadd = true;
// Get list of supervisor's students
$http.get(config.backend + '/sup/' + $scope.user.id + '/students')
.success(function (data) {
$scope.students = data;
})
.error(function () {
$translate('error_fetching_students').then(function (translation) {
ngToast.danger({ content: translation });
});
ngToast.danger({ content: $translate.instant('error_fetching_students') });
});
// Reset form Student
......@@ -81,15 +85,15 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
$scope.hidestudentadd = true;
};
// Add Student
/**
* Add Student
*/
$scope.add_student = function () {
var student = $scope.formdatastudent;
// Validate password match
if (student.password_confirm.length && student.password !== student.password_confirm) {
$translate('password_match').then(function (translation) {
ngToast.danger({ content: translation });
});
ngToast.danger({ content: $translate.instant('password_match') });
return;
}
......@@ -101,40 +105,42 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
$http.post(config.backend + '/stu', student)
.success(function (data) {
$translate('student_added').then(function (translation) {
ngToast.success({ content: translation });
});
ngToast.success({ content: $translate.instant('student_added') });
// default values
data.student.supervision = 0; // by default, only related to office administrator
data.student.current_method = 'no_method';
data.student.current_instruction = 'no_instruction';
data.supervision = 0; // by default, only related to office administrator
data.current_method = $translate.instant('no_method');
data.current_instruction = $translate.instant('no_instruction');
// Add to the list of students in view
$scope.students.push(data.student);
$scope.students.push(data);
// Delete the fields of the form to avoid data binding
// between the new element created and the form fields
$scope.resetForm();
// Show the add form to new adding
$scope.hidestudentadd = false;
$scope.hidestudentadd = true;
// Update counters
$scope.user.office.currentStudents += 1;
$scope.num_licenses_left -= 1;
})
.error(function (data) {
.error(function (err) {
var errorMessage = 'student_not_added';
if (data && data.raw && data.raw.sqlState && data.raw.sqlState === '20001') {
if (typeof err == "string" && err.search("Maximum number of enrolments reached") > 0)
errorMessage = 'max_licenses_reached';
} else if (data && data.status === 400) {
else if (err && err.status === 400)
errorMessage = 'invalid_fields';
}
$translate(errorMessage).then(function (translation) {
ngToast.danger({ content: translation });
});
ngToast.danger({ content: $translate.instant(errorMessage) });
});
};
// Delete Student
/**
* Delete Student
*/
$scope.delete_student = function (student) {
$translate('confirmation').then(t => {
if ($window.confirm(t))
......@@ -153,11 +159,13 @@ dashboardControllers.controller('StudentsCtrl', function StudentsCtrl(
IOService.post('/stu/unsubscribe', {
action: 'unsubscribe'
});
// Update counters
$scope.user.office.currentStudents -= 1;
$scope.num_licenses_left += 1;
})
.error(function () {
$translate('student_not_deleted').then(function (translation) {
ngToast.danger({ content: translation });
});
ngToast.danger({ content: $translate.instant('student_not_deleted') });
});
});
};
......
......@@ -26,7 +26,7 @@
<!-- Table -->
<table id="table_students" class="table table-hover">
<tr ng-repeat="student in students | filter:search_students | orderBy: 'name'">
<tr ng-repeat="student in students | filter:search_students | orderBy: ['surname', 'name']">
<td>
<div class="thumbnail img_profile_small">
<img ng-src="{{student.pic}}" alt="" title="" />
......@@ -36,7 +36,7 @@
<h4>{{student.name}} {{student.surname}}</h4>
</td>
<td>
<p> {{student.current_method | translate}} <br />{{student.current_instruction | translate}}</p>
<p> {{student.current_method}} <br />{{student.current_instruction}}</p>
</td>
<td> <!-- BUTTONS -->
......
......@@ -21,6 +21,8 @@ module.exports.pictogram = {
* @return {String} Public url of user's avatar
*/
getSupervisorAvatarUrl: function (filename) {
if (!filename)
filename = sails.config.pictogram.paths.deafultAvatarFileName;
return `/upload/supervisorAvatar/${filename}`;
},
......@@ -30,6 +32,8 @@ module.exports.pictogram = {
* @return {String} Public url of student's avatar
*/
getStudentAvatarUrl: function (filename) {
if (!filename)
filename = sails.config.pictogram.paths.deafultAvatarFileName;
return `/upload/studentAvatar/${filename}`;
},
......
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