Skip to content

Commit 0322ba5

Browse files
committed
flip flop quiz changes
1 parent 686af6e commit 0322ba5

18 files changed

+261
-35
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ ng generate class models/Quiz
99
# Run Application
1010
```
1111
ng serve
12+
localhost:4200/
1213
```

src/app/app.component.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
h4{
2+
margin-top: 10px;
3+
}

src/app/app.component.html

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
<!--The content below is only a placeholder and can be replaced.-->
2-
<h4 class="text-center">Flip Flop Quiz</h4>
3-
<p class="text-center">Click on the card</p>
4-
<app-quizhome></app-quizhome>
2+
<div class="container">
3+
<div class="row">
4+
<div class="col-lg-9 col-md-8 col-sm-7">
5+
<h4>Flip Flop Quiz</h4>
6+
<p>Click on the card</p>
7+
</div>
8+
<div class="col-lg-3 col-md-4 col-sm-5">
9+
<app-quizresult [isResultSubmitted]="isResultSubmitted"></app-quizresult>
10+
</div>
11+
</div>
12+
<app-quizhome (isSubmitted)="checkIsSubmitted($event)"></app-quizhome>
13+
</div>

src/app/app.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,12 @@ import { Component } from '@angular/core';
77
})
88
export class AppComponent {
99
title = 'flipflop';
10+
public isResultSubmitted = false;
11+
12+
checkIsSubmitted(evt) {
13+
console.log('evt => ', evt);
14+
if (evt === 'true') {
15+
this.isResultSubmitted = true;
16+
}
17+
}
1018
}

src/app/app.module.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { BrowserModule } from '@angular/platform-browser';
22
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
33
import { HttpClientModule } from '@angular/common/http';
44
import { CommonModule } from '@angular/common';
5+
import { ReactiveFormsModule } from '@angular/forms';
56

67
import { AppComponent } from './app.component';
78
import { QuizhomeComponent } from './quizhome/quizhome.component';
@@ -10,18 +11,21 @@ import { QuizexpandComponent } from './quizexpand/quizexpand.component';
1011
import { ApiService } from './services/api.service';
1112

1213
import { QuizcontainerDirective } from './quizhome/quizhome.component';
14+
import { QuizresultComponent } from './quizresult/quizresult.component';
1315

1416
@NgModule({
1517
declarations: [
1618
AppComponent,
1719
QuizhomeComponent,
1820
QuizcontainerDirective,
19-
QuizexpandComponent
21+
QuizexpandComponent,
22+
QuizresultComponent
2023
],
2124
imports: [
2225
BrowserModule,
2326
CommonModule,
24-
HttpClientModule
27+
HttpClientModule,
28+
ReactiveFormsModule
2529
],
2630
schemas: [
2731
CUSTOM_ELEMENTS_SCHEMA

src/app/models/quiz.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
import { ArrayType } from '@angular/compiler';
21

3-
export class Quiz {
2+
export class QuizModel {
3+
public questions: Questions[];
4+
}
5+
6+
export class Questions {
47
question: string;
5-
answers: ArrayType;
8+
answers: Array<any>;
69
correctIndex: number;
710
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<h6>{{serialno+1}}. {{data.question}}</h6>
22
<ul>
33
<li *ngFor="let ans of data.answers; let i = index;">
4-
<input type="radio" name="answer{{serialno}}" value="{{ans}}" (click)="chooseAns(serialno, i)"> {{ans}}
4+
<input type="radio" name="answer{{serialno}}" value="{{ans}}" [checked]="i===alreadychoosedans" (click)="chooseAns(serialno, i)"> {{ans}}
55
</li>
66
</ul>

src/app/quizexpand/quizexpand.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
88
export class QuizexpandComponent implements OnInit {
99
@Input() data: any;
1010
@Input() serialno: number;
11+
@Input() alreadychoosedans: number;
1112
@Output() chooseVal = new EventEmitter();
1213

1314
constructor() { }

src/app/quizhome/quizhome.component.css

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
display: flex;
66
flex-wrap: wrap;
77
}
8+
.flip-card-wrapper {
9+
margin-top: 20px;
10+
margin-bottom: 20px;
11+
}
812
.flip-card {
913
position: relative;
1014
min-height: 200px;
11-
height: 96%;
12-
margin: 20px 0;
15+
height: 100%;
1316
transition: transform 0.6s;
1417
transform-style: preserve-3d;
1518
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
<div class="container">
21
<div class="row">
3-
<div class="col-12 col-sm-6 col-md-4 col-lg-3 quiz{{i}}" *ngFor="let quiz of quizLists; let i = index;">
2+
<div class="col-12 col-sm-6 col-md-4 col-lg-3 flip-card-wrapper quiz{{i}}" *ngFor="let quiz of quizLists; let i = index;">
43
<div class="flip-card">
54
<div class="flip-card-front" (click)="expandSection(i)">
65
<div class="num">{{i+1}}</div>
@@ -11,4 +10,7 @@
1110
</div>
1211
</div>
1312
</div>
14-
</div>
13+
<div class="form-group text-right">
14+
<button type="button" class="btn btn-success" (click)="submitQuiz()">Submit Quiz</button>
15+
</div>
16+

0 commit comments

Comments
 (0)