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

73 lines
2.8 KiB
JavaScript
Raw Normal View History

2016-04-11 00:05:59 -04:30
(function(){
'use strict';
angular
.module('app.reports')
.controller('SectionAssistCtrl', SectionAssistCtrl)
SectionAssistCtrl.$inject =
['$scope', '$rootScope','$state', 'professors', '$modal', 'selectedCourse', 'selectedSection', 'selectedStudent'];
function SectionAssistCtrl($scope, $rootScope, $state, professors, $modal, selectedCourse, selectedSection, selectedStudent) {
var vm = this;
var professorid = $rootScope.professorId;
vm.section = [];
vm.lectures = 0;
vm.percentage = 0;
vm.positive = 0;
vm.professor = null;
vm.students = [];
vm.studentsPassed = [];
2016-04-11 00:05:59 -04:30
vm.negative = 0;
vm.flag = false;
vm.positiveTotal = 0;
vm.negativeTotal = 0;
2016-04-11 00:05:59 -04:30
professors.get({ id: professorid },
function (successResult){
vm.professor = successResult;
angular.forEach (vm.professor.courses[selectedCourse.index].sections,
function (value, key){
if (value._id == selectedSection._id ) {
selectedSection.index = key;
vm.section = value;
}
});
angular.forEach (vm.section.students,
function (value){
vm.lectures = value.assistance;
vm.subTotal = 0;
2016-04-11 00:05:59 -04:30
angular.forEach (value.assistanceTotal,
function (valued){
2016-04-11 00:05:59 -04:30
if (valued.assistance) {
vm.positive++;
} else {
vm.negative++;
}
vm.subTotal = vm.positive + vm.negative;
});
if(((vm.positive/vm.subTotal)*100)<75){
vm.students.push(value);
vm.flag = true;
}else{
vm.studentsPassed.push(value);
}
vm.positiveTotal = vm.positiveTotal + vm.positive;
vm.negativeTotal = vm.negativeTotal + vm.negative;
vm.positive = 0;
vm.negative = 0;
vm.subTotal = 0;
2016-04-11 00:05:59 -04:30
});
vm.total = vm.positiveTotal + vm.negativeTotal;
vm.percentage = (vm.positiveTotal/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('sectionReport');
};
};
})();