Commit 5d10a0d9 by Jose Antonio

working on reports - filter by instruction or method

dates are disordered
parent a6439228
......@@ -40,7 +40,7 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
$scope.average_time_trie={dates:[],rate:[]}; // { dates:[2010-02....], rate:[33.3, ...] }
$scope.average_time_pictos={dates:[],rate:[]}; //{ dates:[2010-02....], rate:[33.3, ...] }
$scope.selected_method = {id: "-1"};
$scope.selected_method = "-1";
$scope.fulldata = {
"methods": [
{
......@@ -16078,9 +16078,318 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
]
};
for(var i=0;i<$scope.fulldata.methods.length; i++){
$scope.methods.push({"id":$scope.fulldata.methods[i].id, "name":$scope.fulldata.methods[i].name});
// for(var i=0;i<$scope.fulldata.methods.length; i++){
// $scope.methods.push({"id":$scope.fulldata.methods[i].id, "name":$scope.fulldata.methods[i].name});
// }
var methods=[
{
"instructions": [
{
"id": 1,
"name": "tomate paraleo",
"objective": null,
"status": "started",
"begin": null,
"end": "2017-01-07T10:16:00.000Z",
"method": 1
}
],
"student": 24,
"id": 1,
"name": "Test Method",
"description": null,
"registration": null,
"notes": null,
"last_ins": 1
},
{
"instructions": [
{
"id": 13,
"name": "Fase 1 - El Intercambio físico",
"objective": "En cuanto vea un objeto altamente preferido, el estudiante tomará la imagen del objeto, se acercará hacia el terapeuta y dejará la imagen (fotografía) en la mano del terapeuta.",
"status": "started",
"begin": "2016-10-20T11:01:24.540Z",
"end": "2017-01-07T10:33:06.000Z",
"method": 8
},
{
"id": 14,
"name": "Fase 2 - Desarrollando la espontaneidad",
"objective": "El estudiante irá a su tablero de comunicación, tomará una fotografía, irá a un adulto y la dejará en su mano.",
"status": "started",
"begin": "2016-10-21T10:14:55.760Z",
"end": "2017-02-16T08:59:46.000Z",
"method": 8
},
{
"id": 15,
"name": "Fase 3 - Discriminación de fotografías",
"objective": "El estudiante solicitará los objetos deseados yendo al tablero de comunicación, seleccionando la fotografía apropiada y volviendo de nuevo hasta el interlocutor a darle la fotografía.",
"status": "started",
"begin": "2016-10-21T10:15:05.430Z",
"end": "2017-01-16T11:20:06.000Z",
"method": 8
},
{
"id": 16,
"name": "Fase 4 - Estructura de la oración",
"objective": "El estudiante solicita artículos presentes y no presentes usando una frase de varias palabras yendo al libro.El estudiante toma una fotografía/símbolo de \"Yo quiero\" y la coloca en una línea de frase (tira de Velcro). Luego, el estudiante toma una imagen de lo que desea, la coloca en la línea de frase, quita toda la tira de Velcro, y la lleva a su interlocutor.",
"status": "started",
"begin": "2016-10-21T10:15:34.830Z",
"end": "2016-12-30T18:30:53.000Z",
"method": 8
},
{
"id": 17,
"name": "Fase 5 - Respondiendo a \"¿Qué quieres?\"",
"objective": "El estudiante puede de manera espontánea solicitar una variedad de objetos y puede responder a la pregunta, \"Que quieres?\"",
"status": "started",
"begin": "2016-10-21T10:15:39.410Z",
"end": "2016-10-21T10:15:49.540Z",
"method": 8
},
{
"id": 18,
"name": "Fase 6 - Respuesta y comentario espontáneo",
"objective": "El estudiante responde apropiadamente a \"Qué quieres?\", \"Qué ves?\", \"Qué tienes?\" y a otras preguntas similares cuando éstas son hechas de manera aleatoria.",
"status": "started",
"begin": "2016-10-21T10:15:55.320Z",
"end": "2016-10-24T08:51:44.340Z",
"method": 8
}
],
"student": 24,
"id": 8,
"name": "Comunicación Aumentativa y Adaptativa",
"description": null,
"registration": null,
"notes": null,
"last_ins": 14
},
{
"instructions": [
{
"id": 88,
"name": "Instrucción 1",
"objective": "Objetivo 1",
"status": "started",
"begin": "2017-01-08T11:32:03.000Z",
"end": "2017-01-08T11:32:03.000Z",
"method": 24
}
],
"student": 24,
"id": 24,
"name": "Método propio",
"description": null,
"registration": null,
"notes": null,
"last_ins": 88
},
{
"instructions": [
{
"id": 97,
"name": "Test Instruction",
"objective": null,
"status": null,
"begin": null,
"end": null,
"method": 27
}
],
"student": 24,
"id": 27,
"name": "Test Method",
"description": null,
"registration": null,
"notes": null,
"last_ins": null
},
{
"instructions": [
{
"id": 98,
"name": "Fase 1 - El Intercambio físico",
"objective": "En cuanto vea un objeto altamente preferido, el estudiante tomará la imagen del objeto, se acercará hacia el terapeuta y dejará la imagen (fotografía) en la mano del terapeuta.",
"status": null,
"begin": null,
"end": null,
"method": 28
},
{
"id": 99,
"name": "Fase 2 - Desarrollando la espontaneidad",
"objective": "El estudiante irá a su tablero de comunicación, tomará una fotografía, irá a un adulto y la dejará en su mano.",
"status": null,
"begin": null,
"end": null,
"method": 28
},
{
"id": 100,
"name": "Fase 3 - Discriminación de fotografías",
"objective": "El estudiante solicitará los objetos deseados yendo al tablero de comunicación, seleccionando la fotografía apropiada y volviendo de nuevo hasta el interlocutor a darle la fotografía.",
"status": null,
"begin": null,
"end": null,
"method": 28
},
{
"id": 101,
"name": "Fase 4 - Estructura de la oración",
"objective": "El estudiante solicita artículos presentes y no presentes usando una frase de varias palabras yendo al libro.El estudiante toma una fotografía/símbolo de \"Yo quiero\" y la coloca en una línea de frase (tira de Velcro). Luego, el estudiante toma una imagen de lo que desea, la coloca en la línea de frase, quita toda la tira de Velcro, y la lleva a su interlocutor.",
"status": null,
"begin": null,
"end": null,
"method": 28
},
{
"id": 102,
"name": "Fase 5 - Respondiendo a \"¿Qué quieres?\"",
"objective": "El estudiante puede de manera espontánea solicitar una variedad de objetos y puede responder a la pregunta, \"Que quieres?\"",
"status": null,
"begin": null,
"end": null,
"method": 28
},
{
"id": 103,
"name": "Fase 6 - Respuesta y comentario espontáneo",
"objective": "El estudiante responde apropiadamente a \"Qué quieres?\", \"Qué ves?\", \"Qué tienes?\" y a otras preguntas similares cuando éstas son hechas de manera aleatoria.",
"status": null,
"begin": null,
"end": null,
"method": 28
}
],
"student": 24,
"id": 28,
"name": "Plantilla de método nueva",
"description": null,
"registration": null,
"notes": null,
"last_ins": null
},
{
"instructions": [
{
"id": 104,
"name": "Fase 1 - El Intercambio físico",
"objective": "En cuanto vea un objeto altamente preferido, el estudiante tomará la imagen del objeto, se acercará hacia el terapeuta y dejará la imagen (fotografía) en la mano del terapeuta.",
"status": null,
"begin": null,
"end": null,
"method": 29
},
{
"id": 105,
"name": "Fase 2 - Desarrollando la espontaneidad",
"objective": "El estudiante irá a su tablero de comunicación, tomará una fotografía, irá a un adulto y la dejará en su mano.",
"status": null,
"begin": null,
"end": null,
"method": 29
},
{
"id": 106,
"name": "Fase 3 - Discriminación de fotografías",
"objective": "El estudiante solicitará los objetos deseados yendo al tablero de comunicación, seleccionando la fotografía apropiada y volviendo de nuevo hasta el interlocutor a darle la fotografía.",
"status": null,
"begin": null,
"end": null,
"method": 29
},
{
"id": 107,
"name": "Fase 4 - Estructura de la oración",
"objective": "El estudiante solicita artículos presentes y no presentes usando una frase de varias palabras yendo al libro.El estudiante toma una fotografía/símbolo de \"Yo quiero\" y la coloca en una línea de frase (tira de Velcro). Luego, el estudiante toma una imagen de lo que desea, la coloca en la línea de frase, quita toda la tira de Velcro, y la lleva a su interlocutor.",
"status": null,
"begin": null,
"end": null,
"method": 29
},
{
"id": 108,
"name": "Fase 5 - Respondiendo a \"¿Qué quieres?\"",
"objective": "El estudiante puede de manera espontánea solicitar una variedad de objetos y puede responder a la pregunta, \"Que quieres?\"",
"status": null,
"begin": null,
"end": null,
"method": 29
},
{
"id": 109,
"name": "Fase 6 - Respuesta y comentario espontáneo",
"objective": "El estudiante responde apropiadamente a \"Qué quieres?\", \"Qué ves?\", \"Qué tienes?\" y a otras preguntas similares cuando éstas son hechas de manera aleatoria.",
"status": null,
"begin": null,
"end": null,
"method": 29
}
],
"student": 24,
"id": 29,
"name": "Comunicación Aumentativa y Adaptativa",
"description": null,
"registration": null,
"notes": null,
"last_ins": null
},
{
"instructions": [
{
"id": 110,
"name": "Instrucción nueva 1",
"objective": "Nuevo objetivo",
"status": null,
"begin": null,
"end": null,
"method": 30
},
{
"id": 111,
"name": "Instrucción nueva 2",
"objective": "Nuevo objetivo",
"status": null,
"begin": null,
"end": null,
"method": 30
}
],
"student": 24,
"id": 30,
"name": "Método de Prueba",
"description": "",
"registration": null,
"notes": null,
"last_ins": null
},
{
"instructions": [],
"student": 24,
"id": 31,
"name": "New method(clic to edit)",
"description": null,
"registration": null,
"notes": null,
"last_ins": null
}
];
$scope.elems = [];
for(var i =0; i<methods.length; i++){
$scope.elems.push({id:methods[i].id, class:"method-opt", name: methods[i].name});
for(var j=0; j<methods[i].instructions.length; j++){
$scope.elems.push({id:methods[i].instructions[j].id,
class:"instruction-opt", name: "- - "+methods[i].instructions[j].name, id_method: methods[i].id});
}
}
// 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);
......@@ -16152,50 +16461,144 @@ for(var i=0;i<$scope.fulldata.methods.length; i++){
//Mostrar error
return;
}
$scope.statistics();
if($scope.selected_method == "-1"){
$scope.statistics({id: -1, class: "method-opt"});
}else{
$scope.statistics(JSON.parse($scope.selected_method));
}
};
//Statistics generation
$scope.statistics = function(){
$scope.statistics = function(selected_method){
//instructions and tries data list
//var instructions ={};
var methods=[];
var working_sessions=[];
$scope.statistic_methods=[];
$scope.tries_count = {"total":0, "success":0, "supervised_success":0,
"spontaneous_success":0, "fail":0, "discarded":0, "model":0,
"broken":0, "null":0
};
$scope.error_rate_dates = []; // [2010-02....]
$scope.error_rate_rate = []; // [33.3, ...]
if(selected_method.class === "method-opt"){
//check the selected method
if($scope.selected_method.id == "-1"){
methods=$scope.fulldata.methods;
if(selected_method.id == -1){
$scope.statistic_methods=$scope.fulldata.methods;
}else{
for(var i=0; i< $scope.fulldata.methods.length; i++){
if($scope.fulldata.methods[i].id == parseInt($scope.selected_method.id)){
methods.push($scope.fulldata.methods[i]);
if($scope.fulldata.methods[i].id == selected_method.id){
$scope.statistic_methods.push($scope.fulldata.methods[i]);
}
}
}
//There is a method selected
//Get the selected method/s instructions by date
for(var i=0; i<methods.length; i++){
for(var j=0; j < methods[i].instructions.length; j++){
var dates=[[]];
var error_rate = [[]];
for(var i=0; i < $scope.statistic_methods.length; i++){
for(var j=0; j < $scope.statistic_methods[i].instructions.length; j++){
console.log($scope.statistic_methods[i].instructions[j].end + " <" +$scope.reportDateTo);
if(new Date($scope.statistic_methods[i].instructions[j].begin).getTime() > $scope.reportDateSince.getTime()
&& new Date($scope.statistic_methods[i].instructions[j].begin).getTime() < $scope.reportDateTo.getTime()){
//llamar a la funcion estadisticas con esta instruccion
console.log("calcular instruccion");
var statistics = statistics_instruction(j, i);
// if(methods[i].instructions[j].begin > $scope.reportDateSince && methods[i].instructions[j].end < $scope.reportDateTo){
// data.push(instructions[i].instructions[j]);
// }
for( var k=0; k < methods[i].instructions[j].working_sessions.length; k++){
if(new Date(methods[i].instructions[j].working_sessions[k].begin).getTime() > $scope.reportDateSince.getTime()
&& new Date(methods[i].instructions[j].working_sessions[k].end).getTime() < $scope.reportDateTo.getTime()){
working_sessions.push(methods[i].instructions[j].working_sessions[k]);
error_rate[0].push(statistics[2]);
dates[0].push(moment($scope.statistic_methods[i].instructions[j].begin).format("YYYY-MM-DD"));
// $scope.error_rate_rate[0].push(statistics_instruction(j, i)[2].error_rate);
// $scope.error_rate_dates[0].push(moment($scope.statistic_methods[i].instructions[j].begin).format("YYYY-MM-DD"));
}
}
}
$scope.error_rate_dates = dates;
$scope.error_rate_rate = error_rate;
}else{
//check the selected method
for(var i=0; i< $scope.fulldata.methods.length; i++){
if($scope.fulldata.methods[i].id == selected_method.id_method){
$scope.statistic_methods.push($scope.fulldata.methods[i]);
}
$scope.tries_count = {"total":0, "success":0, "supervised_success":0,
"spontaneous_success":0, "fail":0, "discarded":0, "model":0,
"broken":0, "null":0
}
//There is an instruction selected
//Get the selected method/s instructions by date
for(var j=0; j < $scope.statistic_methods[0].instructions.length; j++){
if ($scope.statistic_methods[0].instructions[j].id == selected_method.id){
if(new Date($scope.statistic_methods[0].instructions[j].begin).getTime() > $scope.reportDateSince.getTime()
&& new Date($scope.statistic_methods[0].instructions[j].begin).getTime() < $scope.reportDateTo.getTime()){
var statistics = statistics_instruction(j, 0);
$scope.error_rate_rate.push(statistics[1]);
$scope.error_rate_dates.push(statistics[0]);
}
}
}
}
//CHART DATA
console.log("datos para el chart");
console.log($scope.error_rate_dates[0]);
console.log($scope.error_rate_rate[0]);
//*** Error rate chart***
$scope.labels1 = $scope.error_rate_dates[0];
$scope.series1 = ['Tasa de error'];
//$scope.dataChart1 = [error_rate];
$scope.dataChart1 = $scope.error_rate_rate;
$scope.optionsChart1 = {
scales: {
xAxes: [
{
type: 'time',
time: {
displayFormats: {
'millisecond': 'DD/MM',
'second': 'DD/MM',
'minute': 'DD/MM',
'hour': 'DD/MM',
'day': 'DD/MM',
'month': 'MM/YY',
'quarter': 'MM/YY',
'year': 'YYYY',
},
minUnit: 'day'
}
}
]
}
};
};
$scope.error_rate_dates = [[]]; // [2010-02....]
$scope.error_rate_rate = [[]]; // [33.3, ...]
/***
* Instruction selected
* method_pos is the position of the method in $scope.statistic_methods
* instruction_pos is the position of the instruction in $scope.statistic_methods
* return array[ [tries dates], [tries error rate], [instruction global statistic]]
*/
function statistics_instruction(instruction_pos, method_pos){
var working_sessions=[];
//Get the selected instruction's working sessions by date
for( var k=0; k < $scope.statistic_methods[method_pos].instructions[instruction_pos].working_sessions.length; k++){
//Iterate over instruction working session
if(new Date($scope.statistic_methods[method_pos].instructions[instruction_pos].working_sessions[k].begin).getTime() > $scope.reportDateSince.getTime()
&& new Date($scope.statistic_methods[method_pos].instructions[instruction_pos].working_sessions[k].begin).getTime() < $scope.reportDateTo.getTime()){
working_sessions.push($scope.statistic_methods[method_pos].instructions[instruction_pos].working_sessions[k]);
}
}
var instruction_statistic = [[],[], 0];
var instruction_error_rate = 0;
for(var i=0; i < working_sessions.length; i++){
var error_rate = 0; //error_rate for this working session
var success = 0;
......@@ -16233,90 +16636,16 @@ for(var i=0;i<$scope.fulldata.methods.length; i++){
}
$scope.tries_count["total"]+=working_sessions[i].tries.length;
error_rate = success / working_sessions[i].tries.length;
$scope.error_rate_dates[0].push(moment(working_sessions[i].begin).format("YYYY-MM-DD")); //https://github.com/moment/moment/issues/1407
$scope.error_rate_rate[0].push(Math.round(error_rate * 10000) / 100);
instruction_error_rate += error_rate;
// $scope.error_rate_dates[0].push(moment(working_sessions[i].begin).format("YYYY-MM-DD")); //https://github.com/moment/moment/issues/1407
// $scope.error_rate_rate[0].push(Math.round(error_rate * 10000) / 100);
//console.log(instruction_statistic);
instruction_statistic[0].push(moment(working_sessions[i].begin).format("YYYY-MM-DD")); //https://github.com/moment/moment/issues/1407
instruction_statistic[1].push(Math.round(error_rate * 10000) / 100);
}
/* -----------------------------------------------------------------------
"methods->instructions->working_sessions->tries"
- Para cada nodo de la estructura anterior pueden existir mas de una ocurrencia
- Se crean acumuladores para obtener los datos con el menor numero de iteraciones
- Las estadisticas se muestran como : GENERAL - ANUAL - MENSUAL, por lo que
los recorridos que se especifican a continuacion se pueden reutilizar para
cualquiera de los 3 casos, simplemente hay que cambiar la lista de datos que
se le pasa. Referencia: $scope.fulldata
----------------------------------------------------------------------- */
//TRANSLATE LANGUAGE
if ($translate.use() == 'es-es') $scope.user_language = 'es';
if ($translate.use() == 'en-gb') $scope.user_language = 'en';
//ws TIME
// $scope.ws_time = humanizeDuration(ws_time[0], { language: $scope.user_language, round: true });
// $scope.ws_time_year = humanizeDuration(ws_time[1], { language: $scope.user_language, round: true });
// $scope.ws_time_month = humanizeDuration(ws_time[2], { language: $scope.user_language, round: true });
//tries TIME
// $scope.tries_time = humanizeDuration(tries_time[0], { language: $scope.user_language, round: true });
// $scope.tries_time_year = humanizeDuration(tries_time[1], { language: $scope.user_language, round: true });
// $scope.tries_time_month = humanizeDuration(tries_time[2], { language: $scope.user_language, round: true });
//CHART DATA
//*** Error rate chart***
$scope.labels1 = $scope.error_rate_dates[0];
$scope.series1 = ['Tasa de error'];
//$scope.dataChart1 = [error_rate];
$scope.dataChart1 = $scope.error_rate_rate;
$scope.optionsChart1 = {
scales: {
xAxes: [
{
type: 'time',
time: {
displayFormats: {
'millisecond': 'DD/MM',
'second': 'DD/MM',
'minute': 'DD/MM',
'hour': 'DD/MM',
'day': 'DD/MM',
'month': 'MM/YY',
'quarter': 'MM/YY',
'year': 'YYYY',
},
minUnit: 'day'
}
}
]
instruction_statistic[2] = ((instruction_error_rate / working_sessions.length) * 10000) / 100;
console.log(instruction_statistic);
return instruction_statistic;
}
};
//*** Year Chart ***
// $scope.labels2 = $scope.months;
// $scope.series2 = ['Sesiones','Pictogramas','Horas'];
// $scope.dataChart2 = [
// ws_number_array_month,
// pictos_number_array_month,
// ws_time_array_month,
// ];
//*** Month Chart ***
// var daysMonth = [];
// for(var i=0;i<daysThisMonth.length;i++){
// daysMonth[i] = i+1;
// }
// $scope.labels3 = daysMonth;
// $scope.series3 = ['Sesiones','Pictogramas','Horas'];
// $scope.dataChart3 = [
// ws_number_array_dayThisMonth,
// pictos_number_array_dayThismonth
// ];
};
});
......@@ -11,13 +11,9 @@
<div class="col-md-3">
<div class="form-group">
<p class="input-group">
<select class="form-control" name="method_select" id="method_select" ng-model="selected_method.id">
<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 class="form-control" name="method_select" id="method_select" ng-model="selected_method">
<option value="-1" selected>{{'select_method' | translate}}</option>
<option ng-repeat="elem in elems track by $index" class="{{elem.class}}" value="{{elem}}">{{elem.name}}</option>
</select>
</p>
</div>
......
......@@ -1020,3 +1020,6 @@ form .progress {
width: 0;
height: 0;
}
.method-opt{
font-weight: 600;
}
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