Skip to content
Snippets Groups Projects
Commit 02b802ce authored by josborg's avatar josborg
Browse files

Tu costentacion en stats

parent 66cc07ab
No related branches found
No related tags found
No related merge requests found
......@@ -29,20 +29,17 @@
<div class="row mt-2">
<div class="col-sm">
<h1>Tus respuestas</h1>
<div *ngIf="encuesta.status.toString() == 'FINALIZADA'; else elseBlock">
<div *ngFor="let solucion of aciertosPorEncuesta; let i = index">
<div class="shadow-lg p-3 mb-1 bg-white rounded">
<p>{{solucion.name}} - {{solucion.diff / 1000}} segundos</p>
</div>
</div>
</div>
<ng-template #elseBlock>
<div *ngFor="let solucion of soluciones; let i = index">
<div *ngFor="let solucion of miSolucion; let i = index">
<div class="shadow-lg p-3 mb-1 bg-white rounded">
<p>{{solucion.name}} - {{solucion.diff / 1000}} segundos</p>
<div class="col">Pregunta: {{solucion.pregunta}}</div>
<div class="col">Respuesta: {{solucion.opcion}}</div>
<div class="col">Correcta: {{solucion.correct}}</div>
</div>
</div>
</ng-template>
</div>
</div>
</div>
......@@ -24,6 +24,7 @@ export class EstadisticasComponent implements OnInit {
id: Number = 0;
miSolucion: Array<any> = [];
soluciones: Solucion[] = [];
preguntas: Pregunta[] = [];
encuesta: Encuesta = <Encuesta>{};
......@@ -31,6 +32,7 @@ export class EstadisticasComponent implements OnInit {
aciertosPorEncuesta: Array<any> = [];
ranking: any;
userId:string = "";
map = new Map();
......@@ -53,7 +55,10 @@ export class EstadisticasComponent implements OnInit {
}
ngOnInit(): void {
var aux = localStorage.getItem('userId')
if(aux != null){
this.userId = aux;
}
}
initMap(){
......@@ -81,9 +86,21 @@ export class EstadisticasComponent implements OnInit {
}
}
this.miSolucion = []
this.soluciones.sort((a, b) => <number>a.diff - <number>b.diff);
this.soluciones.forEach(element => {
console.log("kkkk"+element.id +" - "+ element.diff);
this.soluciones.forEach(solucion => {
if(solucion.userId == this.userId){
solucion.respuestas.forEach(respuesta => {
var pregunta = this.encuesta.preguntas.find(p=>p.id == respuesta.idPregunta)
var opcion;
if(pregunta != undefined){
opcion = pregunta.opciones.find(o=>o.id == respuesta.idOpcion)
this.miSolucion.push({pregunta: pregunta.name, opcion: opcion?.name, correct: opcion?.correct})
}
});
}
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment