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

75 lines
2.9 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 =
2016-05-20 23:00:34 -04:00
['$scope', '$state', 'professors', '$modal', 'selectedCourse', 'selectedSection', 'selectedStudent', 'authentication'];
function SectionAssistCtrl($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.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;
}
});
2016-06-07 22:47:21 -04:00
vm.lectures = vm.section.students[0].assistance;
2016-04-11 00:05:59 -04:30
angular.forEach (vm.section.students,
function (value){
2016-06-07 22:47:21 -04:00
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;
});
2016-04-27 20:34:27 -04:30
if(((vm.positive/vm.subTotal)*100)>75){
vm.studentsPassed.push(value);
}else{
vm.students.push(value);
vm.flag = true;
2016-04-27 20:34:27 -04:30
}
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');
};
};
})();