Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9111b9b6
authored
Mar 03, 2017
by
Jose Antonio
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
working on reports
not finished
parent
2bfa5412
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
136 additions
and
21 deletions
sails/src/assets/app/i18n/en-gb.json
sails/src/assets/app/i18n/es-es.json
sails/src/assets/scripts/modules/student/controllers/reports.js
sails/src/assets/scripts/modules/student/views/reports.html
sails/src/assets/app/i18n/en-gb.json
View file @
9111b9b6
...
...
@@ -33,6 +33,8 @@
"attributes_updated"
:
"Changes saved"
,
"attributes_updating"
:
"Saving..."
,
"August"
:
"August"
,
"average_time_between_pictos"
:
"Average time between pictograms"
,
"average_time_per_try"
:
"Average time per try"
,
"background"
:
"Background"
,
"beep"
:
"Beep"
,
"birthdate"
:
"Birthdate"
,
...
...
@@ -120,6 +122,7 @@
"error_on_update"
:
"Error on update"
,
"error_loading_pictos"
:
"Error loading pictos information"
,
"error_general"
:
"An error has been produced"
,
"error_rate"
:
"Error rate"
,
"expand_navigation"
:
"Expand navigation"
,
"expand_navigation"
:
"Expand navigation"
,
"expression"
:
"Expression"
,
...
...
sails/src/assets/app/i18n/es-es.json
View file @
9111b9b6
...
...
@@ -33,6 +33,8 @@
"attributes_updated"
:
"Cambios guardados"
,
"attributes_updating"
:
"Guardando..."
,
"August"
:
"Agosto"
,
"average_time_between_pictos"
:
"Tiempo medio entre pictogramas"
,
"average_time_per_try"
:
"Tiempo medio por intento"
,
"background"
:
"Fondo"
,
"beep"
:
"Pitido"
,
"birthdate"
:
"Fecha de nacimiento"
,
...
...
@@ -123,6 +125,7 @@
"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_general"
:
"Se ha producido un error"
,
"error_rate"
:
"Tasa de error"
,
"February"
:
"Febrero"
,
"feedback_picto"
:
"Efecto de selección"
,
"filter"
:
"Filtrar"
,
...
...
sails/src/assets/scripts/modules/student/controllers/reports.js
View file @
9111b9b6
...
...
@@ -3,7 +3,13 @@
//-----------------------
// 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
$scope
.
year
=
today
.
getFullYear
();
$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)
$scope
.
years
=
[];
for
(
var
i
=
2013
;
i
<=
$scope
.
year
;
i
++
)
$scope
.
years
.
push
(
i
);
// Array of months transalated
$scope
.
months
=
[
"January"
,
"February"
,
"March"
,
"April"
,
"May"
,
"June"
,
"July"
,
"August"
,
"September"
,
"October"
,
"November"
,
"December"
];
$translate
(
$scope
.
months
).
then
(
function
(
translations
)
{
// Convert translation format [{"January":"Enero"}, ...] to a simple array ["January", ...]
var
trans
=
[];
for
(
var
i
=
0
;
i
<
$scope
.
months
.
length
;
i
++
)
trans
.
push
(
translations
[
$scope
.
months
[
i
]]);
// Assign translated months to array and the actual month
$scope
.
months
=
trans
;
$scope
.
month
=
$scope
.
months
[
$scope
.
month_number
];
});
//
$scope.years = [];
//
for(var i=2013; i<=$scope.year; i++) $scope.years.push(i);
//
//
Array of months transalated
//
$scope.months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
//
$translate($scope.months).then(function (translations) {
//
// Convert translation format [{"January":"Enero"}, ...] to a simple array ["January", ...]
//
var trans = [];
//
for(var i=0; i<$scope.months.length; i++) trans.push(translations[$scope.months[i]]);
//
// Assign translated months to array and the actual month
//
$scope.months = trans;
//
$scope.month = $scope.months[$scope.month_number];
//
});
// --------------------------------------------------------------------------
...
...
@@ -44,23 +58,70 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
// OBTENCIÓN DE LOS DATOS
//
//
Get all the tries of the student
//
Query to obtain an array of student methods
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentData
.
id
+
'/
trie
s'
)
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentData
.
id
+
'/
method
s'
)
.
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
;
// 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
)
{
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
$scope
.
statistics
=
function
(){
//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"
...
...
@@ -104,7 +165,7 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
for
(
var
i
=
0
;
i
<
data
.
methods
.
length
;
i
++
){
//***** INSTRUCTIONS LOOP
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
for
(
var
k
=
0
;
k
<
data
.
methods
[
i
].
instructions
[
j
].
working_sessions
.
length
;
k
++
){
//working_sessions GENERAL
...
...
@@ -209,6 +270,11 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
//CHART DATA TEST
//*** 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
.
series2
=
[
'Sesiones'
,
'Pictogramas'
,
'Horas'
];
$scope
.
dataChart2
=
[
...
...
sails/src/assets/scripts/modules/student/views/reports.html
View file @
9111b9b6
<!-- Reports tab-->
<div
class=
"panel panel-default student_tab_panel"
>
<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=
"col-lg-4 bg-light-gray"
>
<h1
class=
"text-center"
>
{{'global' | translate}}
</h1>
<h1
class=
"text-center"
>
<small>
{{'error_rate' | translate}}
</small>
</h1>
<hr>
<table
class=
"table table-bordered"
>
...
...
@@ -33,7 +76,7 @@
<hr>
</div>
<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>
...
...
@@ -61,7 +104,7 @@
<canvas
id=
"bar2"
class=
"chart chart-bar"
chart-data=
"dataChart2"
chart-labels=
"labels2"
chart-series=
"series2"
></canvas>
</div>
<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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment