Skip to content

Commit

Permalink
quiz results and level
Browse files Browse the repository at this point in the history
  • Loading branch information
danitorrel committed Jan 22, 2022
1 parent ffdc6f2 commit d3d5e7a
Show file tree
Hide file tree
Showing 9 changed files with 190 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class FirstQuestionComponent implements OnInit {
audio.load();
audio.play();
}

user: any
result=[] as any
points1 = 0 as any
Expand All @@ -30,36 +30,36 @@ export class FirstQuestionComponent implements OnInit {
toggleSelection(chip: MatChip) {
chip.toggleSelected();
console.log(chip.value)
this.playAudio();
this.playAudio();


if(!this.result.includes(chip.value)){
this.result.push(chip.value)

this.result.push(chip.value)
}
else {
const exist = this.result.indexOf(chip.value)
if(exist){
this.result.splice(exist,1)
}
}
}

let resultLength =this.result.length
switch (resultLength) {
case 1||2 : {this.points1=1}
case 1||2 : {this.points1=1}
break;
case 3||4 : {this.points1=2}
case 3||4 : {this.points1=2}
break;
case 5||6 : {this.points1=3}
case 5||6 : {this.points1=3}
break;
case 7||8 : {this.points1=4}
case 7||8 : {this.points1=4}
break;
case 9||10 : {this.points1=5}
case 9||10 : {this.points1=5}
break;
}
this.settingStorage()
}

settingStorage(){
const str = this.points1.toString()
sessionStorage.setItem("Score1", str)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,59 +1,45 @@
<div class="formulario">
<h1>
{{user}}, arrastra cada enunciado a la columna que consideres correcta
</h1>
<section class="names">
<section class="background" id='pig'>
<img src="../../../assets/Piggy bank_Outline.png" alt="Ahorrar" />
</section>
<section class="background" ><img src="../../../assets/Coins_Two Color.png" alt="Invertir" /></section>
</section>
<div cdkDropListGroup>
<div class="example-container">
<div
cdkDropList
#questionList="cdkDropList"
[cdkDropListConnectedTo]="[ahorrarList, invertirList]"
[cdkDropListData]="questions"
class="example-list"
[cdkDropListEnterPredicate]="noReturnPredicate"
(cdkDropListDropped)="drop($event)"
>
<div class="example-box" *ngFor="let item of questions">
<app-chip [content]="item" cdkDrag> </app-chip>
</div>
</div>
</div>
<h1>
{{user}}, arrastra cada enunciado a la columna que consideres correcta
</h1>
<section class="names">
<section class="background" id='pig'>
<p>ahorrar</p>
<img src="../../../assets/Piggy bank_Outline.png" alt="Ahorrar" />
</section>
<section class="background">
<p>Invertir</p>
<img src="../../../assets/Coins_Two Color.png" alt="Invertir" />
</section>
</section>
<div cdkDropListGroup>
<div class="example-container">
<div cdkDropList #questionList="cdkDropList" [cdkDropListConnectedTo]="[ahorrarList, invertirList]"
[cdkDropListData]="questions" class="example-list" [cdkDropListEnterPredicate]="noReturnPredicate"
(cdkDropListDropped)="drop($event)">
<div class="example-box" *ngFor="let item of questions">
<app-chip [content]="item" cdkDrag> </app-chip>
</div>
</div>
</div>

<div class="example-container">
<div
cdkDropList
#ahorrarList="cdkDropList"
[cdkDropListConnectedTo]="[invertirList]"
[cdkDropListData]="ahorrar"
class="example-list"
(cdkDropListDropped)="drop($event)"
>
<div class="example-box" *ngFor="let item of ahorrar">
<app-chip [content]="item" cdkDrag> </app-chip>
</div>
</div>
</div>
<div class="example-container">
<div cdkDropList #ahorrarList="cdkDropList" [cdkDropListConnectedTo]="[invertirList]" [cdkDropListData]="ahorrar"
class="example-list" (cdkDropListDropped)="drop($event)">
<div class="example-box" *ngFor="let item of ahorrar">
<app-chip [content]="item" cdkDrag> </app-chip>
</div>
</div>
</div>


<div class="example-container">

<div
cdkDropList
#invertirList="cdkDropList"
[cdkDropListConnectedTo]="[ahorrarList]"
[cdkDropListData]="invertir"
class="example-list"
(cdkDropListDropped)="drop($event)">
<div class="example-box" *ngFor="let item of invertir">
<app-chip [content]="item" cdkDrag>

</app-chip>
</div>
</div>
<div class="example-container">

<div cdkDropList #invertirList="cdkDropList" [cdkDropListConnectedTo]="[ahorrarList]" [cdkDropListData]="invertir"
class="example-list" (cdkDropListDropped)="drop($event)">
<div class="example-box" *ngFor="let item of invertir">
<app-chip [content]="item" cdkDrag>

</app-chip>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,48 +1,98 @@
import { CdkDragDrop, moveItemInArray, transferArrayItem } from '@angular/cdk/drag-drop';
import {
CdkDragDrop,
moveItemInArray,
transferArrayItem,
} from '@angular/cdk/drag-drop';
import { Component, Input, OnInit } from '@angular/core';

@Component({
selector: 'app-fourthquestion',
templateUrl: './fourthquestion.component.html',
styleUrls: ['./fourthquestion.component.scss']
styleUrls: ['./fourthquestion.component.scss'],
})
export class FourthquestionComponent implements OnInit {
@Input() userName: string='';
playAudio(){
const audio = new Audio();
audio.src = "../../../assets/draganddrop_sound.mp3";
audio.load();
export class FourthquestionComponent implements OnInit {
@Input() userName: string = '';
playAudio() {
const audio = new Audio();
audio.src = '../../../assets/draganddrop_sound.mp3';
audio.load();
audio.play();
}
user: any
ahorrar = ["Te ayuda a tener más confianza"];
}
user: any;

ahorrar = ['Te ayuda a tener más confianza'];

invertir = ["Te puedes diversificar"];
questions=["Me da rendimientos","Es la opción más liquida",
"Existen múltiples instrumentos financieros para esta estrategia","Me producirá mas dinero en el futuro", "Me protege contra la inflación"];
invertir = ['Te puedes diversificar'];
questions = [
'Me da rendimientos',
'Es la opción más liquida',
'Existen múltiples instrumentos financieros para esta estrategia',
'Me producirá mas dinero en el futuro',
'Me protege contra la inflación',
];

ngOnInit(){
this.user= sessionStorage.getItem('Nombre')
answersAhorrar = [
'Es la opción más liquida',
'Te ayuda a tener más confianza',
];
answersInvertir = [
'Existen múltiples instrumentos financieros para esta estrategia',
'Me da rendimientos',
'Me producirá mas dinero en el futuro',
'Me protege contra la inflación',
'Te puedes diversificar',
];

ngOnInit() {
this.user = sessionStorage.getItem('Nombre');
}

drop(event: CdkDragDrop <string[]>) {
this.playAudio();
drop(event: CdkDragDrop<string[]>) {
this.playAudio();
if (event.previousContainer === event.container) {
moveItemInArray(event.container.data, event.previousIndex, event.currentIndex);
moveItemInArray(
event.container.data,
event.previousIndex,
event.currentIndex
);
console.log;
} else {
transferArrayItem(
event.previousContainer.data,
event.container.data,
event.previousIndex,
event.currentIndex,
event.currentIndex
);
}
console.log(this.ahorrar.sort(), this.invertir.sort());
const selectAhorrar = this.ahorrar.sort();
const selectInvertir = this.invertir.sort();
let points = 0;
if (selectAhorrar.includes('Es la opción más liquida')) {
points++;
}
if (
selectInvertir.includes(
'Existen múltiples instrumentos financieros para esta estrategia'
)
) {
points++;
}
if (selectInvertir.includes('Me da rendimientos')) {
points++;
}
if (selectInvertir.includes('Me producirá mas dinero en el futuro')) {
points++;
}
if (selectInvertir.includes('Me protege contra la inflación')) {
points++;
}
console.log(points);
sessionStorage.setItem('Score4', points.toString());
console.log(sessionStorage.getItem('Score4'));
}

noReturnPredicate() {
return false;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class SecondquestionComponent implements OnInit {
return 0;
}
user: any

constructor() { }

ngOnInit(){
Expand All @@ -38,17 +38,19 @@ export class SecondquestionComponent implements OnInit {

sendResults(){
switch (this.value) {
case 0||10||20:{this.points = 1}
case 0 :{this.points=0}
break;
case 10||20:{this.points = 1}
break;
case 30||40:{this.points = 2}
case 30||40:{this.points = 2}
break;
case 50||60:{this.points = 3}
case 50||60:{this.points = 3}
break;
case 70||80:{this.points = 4}
case 70||80:{this.points = 4}
break;
case 90||100:{this.points = 5}
case 90||100:{this.points = 5}
break;

}
let str = this.points.toString()
sessionStorage.setItem("Score2", str)
Expand Down
18 changes: 9 additions & 9 deletions blackrock/src/app/pages/quiz/quiz.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@
<mat-step [stepControl]="firstFormGroup">
<app-first-question ></app-first-question>
<div>
<button mat-button matStepperNext><mat-icon class='iconBtn' aria-hidden='false' aria-label='arrow_circle_down'>arrow_circle_down
<button mat-button matStepperNext><mat-icon class='iconBtn' aria-hidden='false' aria-label='arrow_circle_down'>arrow_circle_down
</mat-icon></button>
</div>
</mat-step>
<mat-step [stepControl]="secondFormGroup">
<app-secondquestion ></app-secondquestion>
<div>
<button mat-button matStepperPrevious><mat-icon class='iconBtn' aria-hidden='false' aria-label='arrow_circle_up'>arrow_circle_up
<button mat-button matStepperPrevious><mat-icon class='iconBtn' aria-hidden='false' aria-label='arrow_circle_up'>arrow_circle_up
</mat-icon></button>
<button mat-button matStepperNext><mat-icon class='iconBtn' aria-hidden='false' aria-label='arrow_circle_down'>arrow_circle_down
<button mat-button matStepperNext><mat-icon class='iconBtn' aria-hidden='false' aria-label='arrow_circle_down'>arrow_circle_down
</mat-icon></button>
</div>
</mat-step>
<mat-step [stepControl]="thirdFormGroup">
<app-third-question></app-third-question>
<div>
<button mat-button matStepperPrevious><mat-icon class='iconBtn' aria-hidden='false' aria-label='arrow_circle_up'>arrow_circle_up
<button mat-button matStepperPrevious><mat-icon class='iconBtn' aria-hidden='false' aria-label='arrow_circle_up'>arrow_circle_up
</mat-icon></button>
<button mat-button matStepperNext><mat-icon class='iconBtn' aria-hidden='false' aria-label='arrow_circle_down'>arrow_circle_down
<button mat-button matStepperNext><mat-icon class='iconBtn' aria-hidden='false' aria-label='arrow_circle_down'>arrow_circle_down
</mat-icon></button>
</div>
</mat-step>
<mat-step [stepControl]="fourthFormGroup">
<app-fourthquestion ></app-fourthquestion>
<div>
<button mat-button matStepperPrevious><mat-icon class='iconBtn' aria-hidden='false' aria-label='arrow_circle_up'>arrow_circle_up
<button mat-button matStepperPrevious><mat-icon class='iconBtn' aria-hidden='false' aria-label='arrow_circle_up'>arrow_circle_up
</mat-icon></button>
<button mat-button matStepperNext><mat-icon class='iconBtn' aria-hidden='false' aria-label='arrow_circle_down'>arrow_circle_down
<button mat-button matStepperNext><mat-icon class='iconBtn' aria-hidden='false' aria-label='arrow_circle_down'>arrow_circle_down
</mat-icon></button>
</div>
</mat-step>
<mat-step [stepControl]="fifthFormGroup">
<app-fifth-question ></app-fifth-question>
<div>
<button mat-button matStepperPrevious><mat-icon class='iconBtn' aria-hidden='false' aria-label='arrow_circle_up' >arrow_circle_up
<button mat-button matStepperPrevious><mat-icon class='iconBtn' aria-hidden='false' aria-label='arrow_circle_up' >arrow_circle_up
</mat-icon></button>
<button mat-button routerLink="/results"> <mat-icon class='iconBtn' aria-hidden='false' aria-label='Arrow forward' >arrow_forward_ios
<button mat-button (click)="punctuation()"> <mat-icon class='iconBtn' aria-hidden='false' aria-label='Arrow forward' >arrow_forward_ios
</mat-icon> Ver mis resultados</button>
</div>
</mat-step>
Expand Down
Loading

0 comments on commit d3d5e7a

Please sign in to comment.