Commit 9111b9b6 by Jose Antonio

working on reports

not finished
parent 2bfa5412
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
"attributes_updated": "Changes saved", "attributes_updated": "Changes saved",
"attributes_updating": "Saving...", "attributes_updating": "Saving...",
"August": "August", "August": "August",
"average_time_between_pictos": "Average time between pictograms",
"average_time_per_try": "Average time per try",
"background": "Background", "background": "Background",
"beep": "Beep", "beep": "Beep",
"birthdate": "Birthdate", "birthdate": "Birthdate",
...@@ -120,6 +122,7 @@ ...@@ -120,6 +122,7 @@
"error_on_update": "Error on update", "error_on_update": "Error on update",
"error_loading_pictos": "Error loading pictos information", "error_loading_pictos": "Error loading pictos information",
"error_general": "An error has been produced", "error_general": "An error has been produced",
"error_rate": "Error rate",
"expand_navigation": "Expand navigation", "expand_navigation": "Expand navigation",
"expand_navigation": "Expand navigation", "expand_navigation": "Expand navigation",
"expression": "Expression", "expression": "Expression",
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
"attributes_updated": "Cambios guardados", "attributes_updated": "Cambios guardados",
"attributes_updating": "Guardando...", "attributes_updating": "Guardando...",
"August": "Agosto", "August": "Agosto",
"average_time_between_pictos": "Tiempo medio entre pictogramas",
"average_time_per_try": "Tiempo medio por intento",
"background": "Fondo", "background": "Fondo",
"beep": "Pitido", "beep": "Pitido",
"birthdate": "Fecha de nacimiento", "birthdate": "Fecha de nacimiento",
...@@ -123,6 +125,7 @@ ...@@ -123,6 +125,7 @@
"error_on_upload": "Error al subir la imagen. Compruebe que el archivo no supera 1MB de tamaño.", "error_on_upload": "Error al subir la imagen. Compruebe que el archivo no supera 1MB de tamaño.",
"error_loading_pictos": "Error cargando información de los pictos", "error_loading_pictos": "Error cargando información de los pictos",
"error_general": "Se ha producido un error", "error_general": "Se ha producido un error",
"error_rate": "Tasa de error",
"February": "Febrero", "February": "Febrero",
"feedback_picto": "Efecto de selección", "feedback_picto": "Efecto de selección",
"filter": "Filtrar", "filter": "Filtrar",
......
...@@ -3,7 +3,13 @@ ...@@ -3,7 +3,13 @@
//----------------------- //-----------------------
// Student Reports Controller // Student Reports Controller
//----------------------- //-----------------------
dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtrl($scope, $stateParams, $http, config, $filter, $translate) { dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtrl(
$scope,
$stateParams,
$http,
config,
$filter,
$translate) {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
// //
...@@ -24,19 +30,27 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr ...@@ -24,19 +30,27 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
$scope.year = today.getFullYear(); $scope.year = today.getFullYear();
$scope.month_number = today.getMonth(); $scope.month_number = today.getMonth();
$scope.reportDateSince = new Date(86400000); //Zero time Fri Jan 02 1970 01:00:00 GMT+0100 (CET)
$scope.reportDateTo = today;
$scope.openedSince = false;
$scope.openedTo =false;
$scope.methods = [];
$scope.selected_method = {id: -1};
// Array of years from 2015 to now (for testing, from 2013) // Array of years from 2015 to now (for testing, from 2013)
$scope.years = []; // $scope.years = [];
for(var i=2013; i<=$scope.year; i++) $scope.years.push(i); // for(var i=2013; i<=$scope.year; i++) $scope.years.push(i);
// Array of months transalated // // Array of months transalated
$scope.months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; // $scope.months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
$translate($scope.months).then(function (translations) { // $translate($scope.months).then(function (translations) {
// Convert translation format [{"January":"Enero"}, ...] to a simple array ["January", ...] // // Convert translation format [{"January":"Enero"}, ...] to a simple array ["January", ...]
var trans = []; // var trans = [];
for(var i=0; i<$scope.months.length; i++) trans.push(translations[$scope.months[i]]); // for(var i=0; i<$scope.months.length; i++) trans.push(translations[$scope.months[i]]);
// Assign translated months to array and the actual month // // Assign translated months to array and the actual month
$scope.months = trans; // $scope.months = trans;
$scope.month = $scope.months[$scope.month_number]; // $scope.month = $scope.months[$scope.month_number];
}); // });
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
...@@ -44,23 +58,70 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr ...@@ -44,23 +58,70 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
// OBTENCIÓN DE LOS DATOS // OBTENCIÓN DE LOS DATOS
// //
// Get all the tries of the student // Query to obtain an array of student methods
$http $http
.get(config.backend+'/stu/'+ $scope.studentData.id +'/tries') .get(config.backend+'/stu/'+ $scope.studentData.id +'/methods')
.success(function(data, status, headers, config) { .success(function(data, status, headers, config) {
// Add to list
$scope.methods = data;
console.log(JSON.stringify($scope.methods));
console.log("Methods recovered");
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
//Get all the tries of the student
$http
.get(config.backend+'/stu/'+ $scope.studentData.id +'/tries')
.success(function(data) {
$scope.fulldata = data; $scope.fulldata = data;
// Call function to build the charts and statistics // Call function to build the charts and statistics
$scope.statistics(); for(var i=0;i<data.methods.length;i++){
var method={name:data.methods[i].name, id: data.methods[i].id};
$scope.methods.push(method);
}
//$scope.statistics("GLOBAL",$scope.reportDateSince, $scope.reportDateTo);
}) })
.error(function(data, status, headers, config) { .error(function(data, status, headers, config) {
console.log("Error from API: " + data.error); console.log("Error from API: " + data.error);
}); });
/**
* Opens the calendar for selecting student's birthdate.
* Prevents the propagation of the click event.
* @param {event} Click event
*/
$scope.openCalendar = function (event,id) {
event.stopPropagation();
if(id == 1)
$scope.openedSince = true;
else
$scope.openedTo = true;
};
// When clicking over a method in the select control
// load its data in the statistics fields
$scope.load_method_data = function (){
if ($scope.selected_method.id == -1)
return;
//Load method data
};
//Statistics generation //Statistics generation
$scope.statistics = function(){ $scope.statistics = function(){
//Full tries data list //Full tries data list
var data = $scope.fulldata; var data ={};
// if(method == "GLOBAL"){
// data = $scope.fulldata;
// }else{
// data = $scope.fulldata.methods[]
// }
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
"methods->instructions->working_sessions->tries" "methods->instructions->working_sessions->tries"
...@@ -104,7 +165,7 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr ...@@ -104,7 +165,7 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
for(var i=0;i<data.methods.length;i++){ for(var i=0;i<data.methods.length;i++){
//***** INSTRUCTIONS LOOP //***** INSTRUCTIONS LOOP
for(var j=0;j<data.methods[i].instructions.length;j++){ for(var j=0;j<data.methods[i].instructions.length;j++){
if(data.methods[i].instructions[i].begin > $scope.reportDateSince && data.methods[i].instructions[i].end < $scope.reportDateTo)
//***** WORKING_SESSIONS LOOP //***** WORKING_SESSIONS LOOP
for(var k=0;k<data.methods[i].instructions[j].working_sessions.length;k++){ for(var k=0;k<data.methods[i].instructions[j].working_sessions.length;k++){
//working_sessions GENERAL //working_sessions GENERAL
...@@ -209,6 +270,11 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr ...@@ -209,6 +270,11 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
//CHART DATA TEST //CHART DATA TEST
//*** Year Chart *** //*** Year Chart ***
$scope.labels1 = $scope.months;
$scope.series1 = ['Tasa de error'];
//$scope.dataChart1 = [error_rate];
$scope.dataChart1 = [1];
//*** Year Chart ***
$scope.labels2 = $scope.months; $scope.labels2 = $scope.months;
$scope.series2 = ['Sesiones','Pictogramas','Horas']; $scope.series2 = ['Sesiones','Pictogramas','Horas'];
$scope.dataChart2 = [ $scope.dataChart2 = [
......
<!-- Reports tab--> <!-- Reports tab-->
<div class="panel panel-default student_tab_panel"> <div class="panel panel-default student_tab_panel">
<div class="panel-body"> <div class="panel-body">
<div class="row">
<div class="col-md-4">
<h1>{{'methods' | translate}}</h1>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<p class="input-group">
<select class="form-control" name="method_select" id="method_select" ng-model="selected_method.id" ng-change="load_method_data()">
<option value="-1">{{'select_method' | translate}}</option>
<option ng-repeat="ma in methods track by $index"
ng-value="ma.id"
label="{{ ma.name }}">
{{ ma.name }}
</option>
</select>
</p>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<p class="input-group">
<input type="text" class="form-control" datepicker-popup=" {{ 'day_format' | translate }}" ng-model="reportDateSince" placeholder="{{ 'since' | translate }}" is-open="openedSince" close-text="{{'close' | translate}}" />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="openCalendar($event,1)"><i class="glyphicon glyphicon-calendar"></i></button>
</span>
</p>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<p class="input-group">
<input type="text" class="form-control" datepicker-popup=" {{ 'day_format' | translate }}" ng-model="reportDateTo" placeholder="{{ 'to' | translate }}" is-open="openedTo" close-text="{{'close' | translate}}" />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="openCalendar($event,2)"><i class="glyphicon glyphicon-calendar"></i></button>
</span>
</p>
</div>
</div>
</div>
<hr>
<div class="row"> <div class="row">
<div class="col-lg-4 bg-light-gray"> <div class="col-lg-4 bg-light-gray">
<h1 class="text-center">{{'global' | translate}}</h1> <h1 class="text-center"><small>{{'error_rate' | translate}}</small></h1>
<hr> <hr>
<table class="table table-bordered"> <table class="table table-bordered">
...@@ -33,7 +76,7 @@ ...@@ -33,7 +76,7 @@
<hr> <hr>
</div> </div>
<div class="col-lg-4"> <div class="col-lg-4">
<h1 class="text-center">{{'annual' | translate}} <small>{{ year }}</small></h1> <h1 class="text-center"><small>{{'average_time_per_try' | translate}}</small></h1>
<hr> <hr>
...@@ -61,7 +104,7 @@ ...@@ -61,7 +104,7 @@
<canvas id="bar2" class="chart chart-bar" chart-data="dataChart2" chart-labels="labels2" chart-series="series2"></canvas> <canvas id="bar2" class="chart chart-bar" chart-data="dataChart2" chart-labels="labels2" chart-series="series2"></canvas>
</div> </div>
<div class="col-lg-4 bg-light-gray"> <div class="col-lg-4 bg-light-gray">
<h1 class="text-center">{{'monthly' | translate}} <small>{{ month }}</small></h1> <h1 class="text-center"><small>{{'average_time_between_pictos' | translate}}</small></h1>
<hr> <hr>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment