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

58 lines
2.1 KiB
JavaScript
Raw Normal View History

2016-04-11 00:05:59 -04:30
(function(){
'use strict';
angular
.module('app.reports')
.controller('CourseAssistCtrl', CourseAssistCtrl)
CourseAssistCtrl.$inject =
2016-05-20 23:00:34 -04:00
['$scope', '$state', 'professors', '$modal', 'selectedCourse', 'authentication'];
function CourseAssistCtrl($scope, $state, professors, $modal, selectedCourse, 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.course = null;
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,
function (value, key){
if (value._id == selectedCourse._id ) {
selectedCourse.index = key;
vm.course = value;
}
});
angular.forEach (vm.course.sections,
function (value){
angular.forEach (value.students,
function (valued){
vm.lectures = valued.assistance;
2016-04-11 00:05:59 -04:30
angular.forEach (valued.assistanceTotal,
function (valueda){
if (valueda.assistance) {
vm.positive++;
} else {
vm.negative++;
}
});
});
});
2016-04-11 00:05:59 -04:30
vm.total = vm.positive + vm.negative;
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('courseReport');
};
};
})();