filtering of TSV data

parent dae25ad5
......@@ -48,8 +48,6 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
var tsvData = "";
const SEPARATOR = '\t';
// --------------------------------------------------------------------------
//
// OBTENCIÓN DE LOS DATOS
......@@ -60,21 +58,41 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
.get(config.backend+'/stu/'+ $scope.studentData.id +'/tries')
.success(function(data) {
$scope.fulldata = data;
tsvData = "method" + SEPARATOR + "instruction" + SEPARATOR + "instruction_begin" + SEPARATOR + "instruction_end" + SEPARATOR + "session_begin" + SEPARATOR + "session_end" + SEPARATOR + "try_begin" + SEPARATOR + "try_end" + SEPARATOR + "action" + SEPARATOR + "action_timestamp" + SEPARATOR + "action_expression\n";
for(var i =0; i<data.methods.length; i++){
$scope.elems.push({id:data.methods[i].id, class:"method-opt", name: data.methods[i].name});
for(var j=0; j<data.methods[i].instructions.length; j++){
if (data.methods[i].instructions[j].working_sessions) {
$scope.elems.push({id:data.methods[i].instructions[j].id,
class:"instruction-opt", name: "- - "+data.methods[i].instructions[j].name, id_method: data.methods[i].id});
for(var k=0; k<data.methods[i].instructions[j].working_sessions.length; k++)
for(var l=0; l<data.methods[i].instructions[j].working_sessions[k].tries.length; l++)
for(var m=0; m<data.methods[i].instructions[j].working_sessions[k].tries[l].actions.length; m++) {
}
}
}
$scope.filter();
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
/**
* Generates TSV data
*/
$scope.genTSV = function() {
tsvData = "method" + SEPARATOR + "instruction" + SEPARATOR + "instruction_begin" + SEPARATOR + "instruction_end" + SEPARATOR + "session_begin" + SEPARATOR + "session_end" + SEPARATOR + "try_begin" + SEPARATOR + "try_end" + SEPARATOR + "action" + SEPARATOR + "action_timestamp" + SEPARATOR + "action_expression\n";
data = $scope.fulldata;
for (var i =0; i<data.methods.length; i++) {
for (var j=0; j<data.methods[i].instructions.length; j++) {
if (data.methods[i].instructions[j].working_sessions) {
for (var k=0; k<data.methods[i].instructions[j].working_sessions.length; k++) {
for (var l=0; l<data.methods[i].instructions[j].working_sessions[k].tries.length; l++) {
for (var m=0; m<data.methods[i].instructions[j].working_sessions[k].tries[l].actions.length; m++) {
if (new Date(data.methods[i].instructions[j].begin).getTime() > $scope.reportDateSince.getTime() &&
new Date(data.methods[i].instructions[j].begin).getTime() < $scope.reportDateTo.getTime() &&
data.methods[i].id == $scope.selected_method.id) {
var expression = "";
if (data.methods[i].instructions[j].working_sessions[k].tries[l].actions[m].description &&
data.methods[i].instructions[j].working_sessions[k].tries[l].actions[m].description.attributes &&
data.methods[i].instructions[j].working_sessions[k].tries[l].actions[m].description.attributes.expression)
expression = data.methods[i].instructions[j].working_sessions[k].tries[l].actions[m].description.attributes.expression;
expression = data.methods[i].instructions[j].working_sessions[k].tries[l].actions[m].description.attributes.expression;
tsvData +=
data.methods[i].name + SEPARATOR +
data.methods[i].instructions[j].name + SEPARATOR +
......@@ -87,17 +105,16 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
data.methods[i].instructions[j].working_sessions[k].tries[l].actions[m].type + SEPARATOR +
data.methods[i].instructions[j].working_sessions[k].tries[l].actions[m].timestamp + SEPARATOR + expression + '\n';
}
}
}
}
}
}
$scope.filter();
})
.error(function(data, status, headers, config) {
console.log("Error from API: " + data.error);
});
}
};
/**
* Download data in CSV format
* Download data in TSV format
*/
$scope.download = function() {
var data = new Blob([tsvData], { type: 'text/plain;charset=utf-8' });
......@@ -137,7 +154,8 @@ dashboardControllers.controller('StudentReportsCtrl', function StudentReportsCtr
$scope.printName=JSON.parse($scope.selected_method).name;
$scope.statistics(JSON.parse($scope.selected_method));
}
// regeneramos TSV
$scope.genTSV();
};
//Statistics generation
......
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