diff --git a/FrontEnd/src/app/tests/test-details/question-view/gaps/gaps.component.html b/FrontEnd/src/app/tests/test-details/question-view/gaps/gaps.component.html index 33859a1..e0566a3 100644 --- a/FrontEnd/src/app/tests/test-details/question-view/gaps/gaps.component.html +++ b/FrontEnd/src/app/tests/test-details/question-view/gaps/gaps.component.html @@ -1,6 +1,6 @@
- {{question.question}} ({{question.points}}pkt.) + {{question.question}} ({{question.points}}pkt.) Czas: {{ timeLeft }}
{{item.content}} diff --git a/FrontEnd/src/app/tests/test-details/question-view/gaps/gaps.component.ts b/FrontEnd/src/app/tests/test-details/question-view/gaps/gaps.component.ts index c4d30ed..521da7f 100644 --- a/FrontEnd/src/app/tests/test-details/question-view/gaps/gaps.component.ts +++ b/FrontEnd/src/app/tests/test-details/question-view/gaps/gaps.component.ts @@ -1,8 +1,9 @@ -import { Component, OnInit, Input, Output, EventEmitter, OnDestroy } from '@angular/core'; +import { Component, OnInit, Input, Output, EventEmitter, OnDestroy, ViewChild } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { TestsService } from '../../../tests.service'; import * as $ from 'jquery'; import { ISubscription } from 'rxjs/Subscription'; +import { NgForm } from '@angular/forms'; @Component({ selector: 'app-gaps', @@ -15,6 +16,9 @@ export class GapsComponent implements OnInit, OnDestroy { @Output() emitNextQuestionRequest = new EventEmitter(); private id; private verifyAnswerSubscription: ISubscription; + interval: any; + public timeLeft = 0; + @ViewChild('f') public form: NgForm; constructor(private route: ActivatedRoute, private testsService: TestsService) { } @@ -34,10 +38,24 @@ export class GapsComponent implements OnInit, OnDestroy { }); } + startTimer() { + this.interval = setInterval(() => { + if (this.timeLeft > 0) { + this.timeLeft--; + } else { + this.nextQuestion(this.form); + } + }, 1000); + } + ngOnInit() { + if (this.timeLeft > 0) { + this.startTimer(); + } } ngOnDestroy() { + clearInterval(this.interval); if (this.verifyAnswerSubscription) { this.verifyAnswerSubscription.unsubscribe(); } diff --git a/FrontEnd/src/app/tests/test-details/question-view/multiple-choice/multiple-choice.component.html b/FrontEnd/src/app/tests/test-details/question-view/multiple-choice/multiple-choice.component.html index 94e6208..c008de0 100644 --- a/FrontEnd/src/app/tests/test-details/question-view/multiple-choice/multiple-choice.component.html +++ b/FrontEnd/src/app/tests/test-details/question-view/multiple-choice/multiple-choice.component.html @@ -1,6 +1,6 @@
- {{question.question}} ({{question.points}}pkt.) + {{question.question}} ({{question.points}}pkt.) Czas: {{ timeLeft }}
{{item.content}} diff --git a/FrontEnd/src/app/tests/test-details/question-view/multiple-choice/multiple-choice.component.ts b/FrontEnd/src/app/tests/test-details/question-view/multiple-choice/multiple-choice.component.ts index 010f882..9c89d3b 100644 --- a/FrontEnd/src/app/tests/test-details/question-view/multiple-choice/multiple-choice.component.ts +++ b/FrontEnd/src/app/tests/test-details/question-view/multiple-choice/multiple-choice.component.ts @@ -1,8 +1,9 @@ -import { Component, OnInit, Input, Output, EventEmitter, OnDestroy } from '@angular/core'; +import { Component, OnInit, Input, Output, EventEmitter, OnDestroy, ViewChild } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { TestsService } from '../../../tests.service'; import * as $ from 'jquery'; import { ISubscription } from 'rxjs/Subscription'; +import { NgForm } from '@angular/forms'; @Component({ selector: 'app-multiple-choice', @@ -15,6 +16,9 @@ export class MultipleChoiceComponent implements OnInit, OnDestroy{ @Output() emitNextQuestionRequest = new EventEmitter(); private id; private verifyAnswerSubscription: ISubscription; + interval: any; + public timeLeft = 0; + @ViewChild('f') public form: NgForm; constructor(private route: ActivatedRoute, private testsService: TestsService) { } @@ -31,10 +35,24 @@ export class MultipleChoiceComponent implements OnInit, OnDestroy{ }); } + startTimer() { + this.interval = setInterval(() => { + if (this.timeLeft > 0) { + this.timeLeft--; + } else { + this.nextQuestion(this.form); + } + }, 1000); + } + ngOnInit() { + if (this.timeLeft > 0) { + this.startTimer(); + } } ngOnDestroy() { + clearInterval(this.interval); if (this.verifyAnswerSubscription) { this.verifyAnswerSubscription.unsubscribe(); } diff --git a/FrontEnd/src/app/tests/test-details/question-view/pairs/pairs.component.html b/FrontEnd/src/app/tests/test-details/question-view/pairs/pairs.component.html index befa258..ad35815 100644 --- a/FrontEnd/src/app/tests/test-details/question-view/pairs/pairs.component.html +++ b/FrontEnd/src/app/tests/test-details/question-view/pairs/pairs.component.html @@ -1,5 +1,5 @@
- {{question.question}} ({{question.points}}pkt.) + {{question.question}} ({{question.points}}pkt.) Czas: {{ timeLeft }}

Dostępne lewe strony:

diff --git a/FrontEnd/src/app/tests/test-details/question-view/pairs/pairs.component.ts b/FrontEnd/src/app/tests/test-details/question-view/pairs/pairs.component.ts index 26b08c6..166f93f 100644 --- a/FrontEnd/src/app/tests/test-details/question-view/pairs/pairs.component.ts +++ b/FrontEnd/src/app/tests/test-details/question-view/pairs/pairs.component.ts @@ -19,6 +19,8 @@ export class PairsComponent implements OnInit, OnChanges, OnDestroy { rightSides = []; leftSidesToSend = []; selectedLeftSide = { indexOfLeftSide: Number, leftSideText: String, from: '' }; + interval: any; + public timeLeft = 0; constructor(private route: ActivatedRoute, private testsService: TestsService) { } @@ -41,6 +43,16 @@ export class PairsComponent implements OnInit, OnChanges, OnDestroy { }); } + startTimer() { + this.interval = setInterval(() => { + if (this.timeLeft > 0) { + this.timeLeft--; + } else { + this.nextQuestion(); + } + }, 1000); + } + leftSideClick(item, i) { if (item !== '' && item !== undefined) { if (this.selectedLeftSide.from === 'leftSides') { @@ -81,6 +93,9 @@ export class PairsComponent implements OnInit, OnChanges, OnDestroy { ngOnInit() { this.prepareLists(); + if (this.timeLeft > 0) { + this.startTimer(); + } } ngOnChanges() { @@ -88,6 +103,7 @@ export class PairsComponent implements OnInit, OnChanges, OnDestroy { } ngOnDestroy() { + clearInterval(this.interval); if (this.verifyAnswerSubscription) { this.verifyAnswerSubscription.unsubscribe(); } diff --git a/FrontEnd/src/app/tests/test-details/question-view/puzzle/puzzle.component.html b/FrontEnd/src/app/tests/test-details/question-view/puzzle/puzzle.component.html index 2627220..1c243c6 100644 --- a/FrontEnd/src/app/tests/test-details/question-view/puzzle/puzzle.component.html +++ b/FrontEnd/src/app/tests/test-details/question-view/puzzle/puzzle.component.html @@ -1,5 +1,5 @@
- {{question.question}} ({{question.points}}pkt.) + {{question.question}} ({{question.points}}pkt.) Czas: {{ timeLeft }}

Dostępne elementy rozsypanki:

diff --git a/FrontEnd/src/app/tests/test-details/question-view/puzzle/puzzle.component.ts b/FrontEnd/src/app/tests/test-details/question-view/puzzle/puzzle.component.ts index 03a34c8..612e049 100644 --- a/FrontEnd/src/app/tests/test-details/question-view/puzzle/puzzle.component.ts +++ b/FrontEnd/src/app/tests/test-details/question-view/puzzle/puzzle.component.ts @@ -18,6 +18,8 @@ export class PuzzleComponent implements OnInit, OnChanges, OnDestroy { puzzles = []; puzzlesToSend = []; private selectedPuzzle = { indexOfPuzzle: Number, puzzleText: String, from: '' }; + interval: any; + public timeLeft = 0; constructor(private route: ActivatedRoute, private testsService: TestsService) { } @@ -30,6 +32,16 @@ export class PuzzleComponent implements OnInit, OnChanges, OnDestroy { }); } + startTimer() { + this.interval = setInterval(() => { + if (this.timeLeft > 0) { + this.timeLeft--; + } else { + this.nextQuestion(); + } + }, 1000); + } + puzzleClick(item, i) { if (item !== '' && item !== undefined) { if (this.selectedPuzzle.from === 'puzzles') { @@ -68,6 +80,9 @@ export class PuzzleComponent implements OnInit, OnChanges, OnDestroy { ngOnInit() { this.prepareLists(); + if (this.timeLeft > 0) { + this.startTimer(); + } } ngOnChanges() { @@ -75,6 +90,7 @@ export class PuzzleComponent implements OnInit, OnChanges, OnDestroy { } ngOnDestroy() { + clearInterval(this.interval); if (this.verifyAnswerSubscription) { this.verifyAnswerSubscription.unsubscribe(); } diff --git a/FrontEnd/src/app/tests/test-details/question-view/single-choice/single-choice.component.html b/FrontEnd/src/app/tests/test-details/question-view/single-choice/single-choice.component.html index afd2409..426dbc1 100644 --- a/FrontEnd/src/app/tests/test-details/question-view/single-choice/single-choice.component.html +++ b/FrontEnd/src/app/tests/test-details/question-view/single-choice/single-choice.component.html @@ -1,6 +1,6 @@
- {{question.question}} ({{question.points}}pkt.) + {{question.question}} ({{question.points}}pkt.) Czas: {{ timeLeft }}
{{item.content}} diff --git a/FrontEnd/src/app/tests/test-details/question-view/single-choice/single-choice.component.ts b/FrontEnd/src/app/tests/test-details/question-view/single-choice/single-choice.component.ts index e4b52cc..779281c 100644 --- a/FrontEnd/src/app/tests/test-details/question-view/single-choice/single-choice.component.ts +++ b/FrontEnd/src/app/tests/test-details/question-view/single-choice/single-choice.component.ts @@ -1,8 +1,9 @@ -import { Component, OnInit, Input, Output, EventEmitter, OnDestroy } from '@angular/core'; +import { Component, OnInit, Input, Output, EventEmitter, OnDestroy, ViewChild } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { TestsService } from '../../../tests.service'; import * as $ from 'jquery'; import { ISubscription } from 'rxjs/Subscription'; +import { NgForm } from '@angular/forms'; @Component({ selector: 'app-single-choice', @@ -16,6 +17,9 @@ export class SingleChoiceComponent implements OnInit, OnDestroy { @Output() emitNextQuestionRequest = new EventEmitter(); private id; private verifyAnswerSubscription: ISubscription; + interval: any; + public timeLeft = 0; + @ViewChild('f') public form: NgForm; constructor(private route: ActivatedRoute, private testsService: TestsService) { } @@ -32,10 +36,24 @@ export class SingleChoiceComponent implements OnInit, OnDestroy { }); } + startTimer() { + this.interval = setInterval(() => { + if (this.timeLeft > 0) { + this.timeLeft--; + } else { + this.nextQuestion(this.form); + } + }, 1000); + } + ngOnInit() { + if (this.timeLeft > 0) { + this.startTimer(); + } } ngOnDestroy() { + clearInterval(this.interval); if (this.verifyAnswerSubscription) { this.verifyAnswerSubscription.unsubscribe(); } diff --git a/FrontEnd/src/app/tests/test-details/question-view/true-false/true-false.component.html b/FrontEnd/src/app/tests/test-details/question-view/true-false/true-false.component.html index 5783abe..3424e83 100644 --- a/FrontEnd/src/app/tests/test-details/question-view/true-false/true-false.component.html +++ b/FrontEnd/src/app/tests/test-details/question-view/true-false/true-false.component.html @@ -1,5 +1,5 @@
- {{question.question}} ({{question.points}}pkt.) + {{question.question}} ({{question.points}}pkt.) Czas: {{ timeLeft }}