From 40f770213bbaedcc761212afda997196ebce2b6c Mon Sep 17 00:00:00 2001 From: Reynaldo Reyes Date: Tue, 7 Jun 2016 22:47:21 -0400 Subject: [PATCH] Update reports view using chart.js --- app/app.js | 1 + .../report/course_assist.controller.js | 51 +++++++++++++++++-- app/partials/report/course_assist.html | 4 ++ .../report/section_assist.controller.js | 4 +- 4 files changed, 53 insertions(+), 7 deletions(-) diff --git a/app/app.js b/app/app.js index 0dcb7f9..4953375 100644 --- a/app/app.js +++ b/app/app.js @@ -8,6 +8,7 @@ 'app.reports', 'app.section', 'app.student', + 'chart.js', 'ngResource', 'ui.router' ]) diff --git a/app/partials/report/course_assist.controller.js b/app/partials/report/course_assist.controller.js index 009d3d6..a47c8f0 100644 --- a/app/partials/report/course_assist.controller.js +++ b/app/partials/report/course_assist.controller.js @@ -11,12 +11,29 @@ var vm = this; var user = authentication.currentUser(); var professorid = user._id; + vm.asistance = 0; vm.course = null; + vm.currentDay = 0; + vm.data = []; + vm.labels = []; vm.lectures = 0; + vm.negative = 0; vm.percentage = 0; vm.positive = 0; vm.professor = null; - vm.negative = 0; + vm.series = []; + vm.semidata = []; + + $scope.labels = ["January", "February", "March", "April", "May", "June", "July"]; + $scope.series = ['Series A', 'Series B','Series C', 'Series D','Series E', 'Series F']; + $scope.data = [ + [65, 59, 80, 81, 56, 55, 40], + [28, 48, 40, 19, 86, 27, 90], + [10, 59, 11, 71, 78, 44, 34], + [17, 28, 5, 19, 75, 75, 54], + [72, 14, 10, 61, 65, 36, 8], + [24, 3, 5, 19, 9, 5, 7] + ]; professors.get({ id: professorid }, function (successResult){ @@ -31,18 +48,42 @@ angular.forEach (vm.course.sections, function (value){ - angular.forEach (value.students, + vm.semester = value.semester; + angular.forEach (value.students[0].assistanceTotal, function (valued){ - vm.lectures = valued.assistance; + if(valued.day){ + vm.currentDay++; + vm.labels.push('Día ' + vm.currentDay); + }; + }); + vm.currentDay = 0; + vm.lectures = value.students[0].assistance; + angular.forEach (value.students, + function (valued){ angular.forEach (valued.assistanceTotal, - function (valueda){ + function (valueda){ if (valueda.assistance) { vm.positive++; + } else { vm.negative++; } - }); + }); }); + var st = value.students.length; + var ast = value.students[0].assistanceTotal.length; + for (var i = 0; i <= ast - 1; i++) { + for (var j = 0; j <= st - 1; j++) { + if (typeof value.students[j].assistanceTotal[i] != 'undefined'){ + if (value.students[j].assistanceTotal[i].assistance) vm.asistance++; + }; + }; + vm.semidata.push(vm.asistance); + vm.asistance = 0; + }; + vm.data.push(vm.semidata); + vm.semidata = []; + vm.series.push(vm.semester); }); vm.total = vm.positive + vm.negative; vm.percentage = (vm.positive/vm.total)*100; diff --git a/app/partials/report/course_assist.html b/app/partials/report/course_assist.html index 5f94d49..b16fb3b 100644 --- a/app/partials/report/course_assist.html +++ b/app/partials/report/course_assist.html @@ -13,4 +13,8 @@ ng-click = "vm.back()"> Regresar + + + \ No newline at end of file diff --git a/app/partials/report/section_assist.controller.js b/app/partials/report/section_assist.controller.js index deb50f7..18a5a7e 100644 --- a/app/partials/report/section_assist.controller.js +++ b/app/partials/report/section_assist.controller.js @@ -33,10 +33,10 @@ vm.section = value; } }); - + vm.lectures = vm.section.students[0].assistance; angular.forEach (vm.section.students, function (value){ - vm.lectures = value.assistance; + vm.subTotal = 0; angular.forEach (value.assistanceTotal, function (valued){