Files
MASA/app/partials/report/student_assist.controller.js

53 lines
1.9 KiB
JavaScript
Raw Normal View History

2016-04-11 00:05:59 -04:30
(function(){
'use strict';
angular
.module('app.reports')
.controller('StudentAssistCtrl', StudentAssistCtrl)
StudentAssistCtrl.$inject =
2016-05-20 23:00:34 -04:00
['$scope', '$state', 'professors', '$modal', 'selectedCourse', 'selectedSection', 'selectedStudent', 'authentication'];
function StudentAssistCtrl($scope, $state, professors, $modal, selectedCourse, selectedSection, selectedStudent, authentication) {
2016-04-11 00:05:59 -04:30
var vm = this;
2016-05-20 23:00:34 -04:00
var user = authentication.currentUser();
var professorid = user._id;
2016-04-11 00:05:59 -04:30
vm.section = [];
vm.lectures = 0;
vm.percentage = 0;
vm.positive = 0;
vm.professor = null;
vm.negative = 0;
professors.get({ id: professorid },
function (successResult){
vm.professor = successResult;
angular.forEach (vm.professor.courses[selectedCourse.index].sections[selectedSection.index].students,
function (value, key){
if (value._id == selectedStudent._id ) {
selectedStudent.index = key;
vm.assistances = value.assistanceTotal;
vm.student = value;
vm.lectures = value.assistance;
}
});
angular.forEach (vm.assistances,
function (value){
if (value.assistance) {
vm.positive++;
} else {
vm.negative++;
}
});
vm.total = vm.positive + vm.negative;
2016-04-12 23:21:59 -04:30
vm.percentage = (vm.positive/vm.total)*100;
2016-04-11 00:05:59 -04:30
},
function (){
console.log("Error al obtener los datos.");
});
vm.back = function (index) {
$state.go('studentReport');
};
};
})();