浏览代码

Quiz UI softcoding completed

master
kj1352 5 年前
父节点
当前提交
03306aef06
共有 3 个文件被更改,包括 54 次插入21 次删除
  1. +10
    -4
      src/app/tabs/courses/quiz/quiz.component.html
  2. +33
    -14
      src/app/tabs/courses/quiz/quiz.component.scss
  3. +11
    -3
      src/app/tabs/courses/quiz/quiz.component.ts

+ 10
- 4
src/app/tabs/courses/quiz/quiz.component.html 查看文件

@@ -1,4 +1,4 @@
<div class="page">
<div class="page" *ngIf="questionList.length > 0">
<header class="nav-header"> <header class="nav-header">
<button class="close-button" (click)="back()"> <button class="close-button" (click)="back()">
<svg-icon [applyClass]="true" class="icon" src="assets/custom-icons/close.svg"></svg-icon> <svg-icon [applyClass]="true" class="icon" src="assets/custom-icons/close.svg"></svg-icon>
@@ -12,7 +12,7 @@
<section class="question-status"> <section class="question-status">
<div class="container"> <div class="container">
<div class="question-number correct" *ngFor="let question of questionList; let i = index" <div class="question-number correct" *ngFor="let question of questionList; let i = index"
[ngClass]="{'current': selectedQuestionId && selectedQuestionId === question.id,
[ngClass]="{'current': selectedQuestion && selectedQuestion.id === question.id,
'correct' : question.userAnswer === question.correctAnswer, 'correct' : question.userAnswer === question.correctAnswer,
'wrong' : question.userAnswer !== 0 && question.userAnswer !== question.correctAnswer}"> 'wrong' : question.userAnswer !== 0 && question.userAnswer !== question.correctAnswer}">
<span> <span>
@@ -48,7 +48,7 @@
[ngClass]="{'correct' : question.userAnswer === question.correctAnswer && question.userAnswer === option.id, [ngClass]="{'correct' : question.userAnswer === question.correctAnswer && question.userAnswer === option.id,
'wrong': question.userAnswer !== 0 && question.userAnswer !== question.correctAnswer && question.userAnswer === option.id, 'wrong': question.userAnswer !== 0 && question.userAnswer !== question.correctAnswer && question.userAnswer === option.id,
'show-correct': question.userAnswer !== 0 && question.userAnswer !== question.correctAnswer && question.correctAnswer === option.id }" 'show-correct': question.userAnswer !== 0 && question.userAnswer !== question.correctAnswer && question.correctAnswer === option.id }"
(click)="question.userAnswer = option.id;">
(click)="question.userAnswer = option.id">
<label> {{ j + 1 }}. {{ option.text }} </label> <label> {{ j + 1 }}. {{ option.text }} </label>
<div class="icon-holder"> <div class="icon-holder">
<svg-icon [applyClass]="true" class="icon wrong-icon" src="assets/custom-icons/close-circle.svg"></svg-icon> <svg-icon [applyClass]="true" class="icon wrong-icon" src="assets/custom-icons/close-circle.svg"></svg-icon>
@@ -59,6 +59,12 @@
</ngx-siema-slide> </ngx-siema-slide>
</ngx-siema> </ngx-siema>


<button class="next-button" (click)="next()"> Next </button>
<div class="action-buttons">
<button class="prev-button" *ngIf="selectedQuestion.id !== questionList[0].id" (click)="prev()"> Previous </button>
<button class="next-button" (click)="next()">
<span *ngIf="selectedQuestion.userAnswer !== 0"> Next </span>
<span *ngIf="selectedQuestion.userAnswer === 0"> Skip </span>
</button>
</div>


</div> </div>

+ 33
- 14
src/app/tabs/courses/quiz/quiz.component.scss 查看文件

@@ -2,6 +2,7 @@
background-color: var(--black); background-color: var(--black);
height: 100vh; height: 100vh;
overflow: auto; overflow: auto;
padding-bottom: 60px;
} }


.nav-header { .nav-header {
@@ -311,18 +312,36 @@ ngx-siema-slide {
} }
} }


.next-button {
width: 100px;
height: 50px;
border-radius: 30px;
background-color: var(--teal-green);
color: white;
font-size: 14px;
border: 0px;
display: block;
position: sticky;
position: -webkit-sticky;
bottom: 20px;
margin: 10px auto 40px;
box-shadow: 0px 0px 10px var(--teal-green);
.action-buttons {
display: flex;
width: 100%;
position: fixed;
align-items: stretch;
bottom: 0;
z-index: 1;
background-color: var(--ash-black);
padding: 10px;
border-top-left-radius: 7px;
border-top-right-radius: 7px;
overflow: hidden;

button {
width: 48%;
display: block;
border-radius: 7px;
border: 0px;
height: 40px;
background-color: transparent;

&.next-button {
background-color: var(--teal);
color: white;
margin-left: auto;
}

&.prev-button {
border: 2px solid var(--teal);
color: var(--teal);
}
}
} }

+ 11
- 3
src/app/tabs/courses/quiz/quiz.component.ts 查看文件

@@ -25,7 +25,7 @@ export class QuizComponent implements OnInit {
}, },
}; };


selectedQuestionId: number;
selectedQuestion: any;


questionList = [{ questionList = [{
id: 1, id: 1,
@@ -101,19 +101,27 @@ export class QuizComponent implements OnInit {
}] }]
}]; }];



constructor( constructor(
private location: Location, private location: Location,
private ngxSiemaService: NgxSiemaService private ngxSiemaService: NgxSiemaService
) { } ) { }


ngOnInit(): void { ngOnInit(): void {
this.selectedQuestionId = this.questionList[0].id;
this.selectedQuestion = this.questionList[0];
} }


next() { next() {
this.ngxSiemaService.next(1); this.ngxSiemaService.next(1);
this.ngxSiemaService.currentSlide().subscribe((index) => { this.ngxSiemaService.currentSlide().subscribe((index) => {
this.selectedQuestionId = this.questionList[index.currentSlide].id;
this.selectedQuestion = this.questionList[index.currentSlide];
}).unsubscribe();
}

prev() {
this.ngxSiemaService.prev(1);
this.ngxSiemaService.currentSlide().subscribe((index) => {
this.selectedQuestion = this.questionList[index.currentSlide];
}).unsubscribe(); }).unsubscribe();
} }