Fixes ui bugs

parent cc5392c7
......@@ -87,16 +87,6 @@
<span *ngIf="!connectionService.websocketAvailable">{{'region.header.connection_status.websocket_status.not_connected' | translate}}</span>
</p>
</li>
<li>
<fa-icon [class.text-danger]="!indexedDbAvailable"
[class.text-success]="indexedDbAvailable"
[icon]="indexedDbAvailable ? 'check' : 'times'"></fa-icon>
<p class="ml-2 mb-0 d-inline">
<span>IndexedDb: </span>
<span *ngIf="indexedDbAvailable">{{'region.header.connection_status.indexedDb_status.writable' | translate}}</span>
<span *ngIf="!indexedDbAvailable">{{'region.header.connection_status.indexedDb_status.non_writable' | translate}}</span>
</p>
</li>
<li>
<fa-icon [class.text-danger]="connectionService.rtt > 300 || !connectionService.serverAvailable"
[class.text-success]="connectionService.rtt <= 300 && connectionService.serverAvailable"
......
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
import { Component, ElementRef, Inject, Input, OnDestroy, OnInit, PLATFORM_ID, SecurityContext, TemplateRef, ViewChild } from '@angular/core';
import { DomSanitizer, SafeStyle } from '@angular/platform-browser';
import { isPlatformBrowser } from '@angular/common';
import { Component, ElementRef, Inject, Input, OnDestroy, OnInit, PLATFORM_ID, TemplateRef, ViewChild } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { Router } from '@angular/router';
import { SwUpdate } from '@angular/service-worker';
import { NgbModal, NgbPopover } from '@ng-bootstrap/ng-bootstrap';
......@@ -45,17 +45,12 @@ export class HeaderComponent implements OnInit, OnDestroy {
this._inHomeRoute = value;
}
get indexedDbAvailable(): boolean {
return this._indexedDbAvailable;
}
private _storage: StorageEstimate;
get storage(): StorageEstimate {
return this._storage;
}
private readonly _indexedDbAvailable: boolean = this.indexedDbSupported();
@ViewChild('connectionIndicatorPopover', { static: true }) private connectionIndicatorPopover: NgbPopover;
@ViewChild('connectionIndicator', { static: true }) private connectionIndicator: ElementRef<SVGElement>;
......@@ -77,9 +72,10 @@ export class HeaderComponent implements OnInit, OnDestroy {
public generateConnectionQualityColor(): void {
const cssClass = this.connectionService.lowSpeed || //
this.connectionService.mediumSpeed || //
!this.indexedDbAvailable ? 'fill-danger' : //
(!this.connectionService.serverAvailable || !this.connectionService.websocketAvailable) ? 'fill-grey' : //
this.connectionService.mediumSpeed ? 'fill-danger' : //
(
!this.connectionService.serverAvailable || !this.connectionService.websocketAvailable
) ? 'fill-grey' : //
'fill-success';
this.connectionIndicator.nativeElement.classList.remove(...['fill-danger', 'fill-grey', 'fill-success']);
......@@ -141,7 +137,6 @@ export class HeaderComponent implements OnInit, OnDestroy {
dimension3: this.connectionService.rtt,
dimension4: this.connectionService.serverAvailable,
dimension5: this.connectionService.websocketAvailable,
dimension6: this.indexedDbAvailable,
},
});
......@@ -174,19 +169,4 @@ export class HeaderComponent implements OnInit, OnDestroy {
public round(number: number): number {
return Math.round(number);
}
private sanitizeStyle(value: string): SafeStyle {
if (isPlatformServer(this.platformId)) {
return value;
}
value = value.replace(/\s/g, '');
return this.sanitizer.sanitize(SecurityContext.STYLE, `${value}`);
}
private indexedDbSupported(): boolean {
return (isPlatformBrowser(this.platformId) && //
'indexedDB' in window //
);
}
}
......@@ -21,6 +21,10 @@ export class FreeTextAnswerEntity extends AbstractAnswerEntity {
}
public isCorrectInput(ref: string): boolean {
if (!ref) {
return false;
}
let refValue = this.answerText;
let result = false;
if (!this.configCaseSensitive) {
......
......@@ -245,10 +245,6 @@ export class LeaderboardComponent implements OnInit, OnDestroy, IHasTriggeredNav
this.router.navigate(['/quiz', 'flow', 'results']);
};
if (this.quizService.isOwner && this._isGlobalRanking) {
footerElements.push(this.footerBarService.footerElemExport);
}
this.footerBarService.replaceFooterElements(footerElements);
}
}
......@@ -32,18 +32,22 @@ export const quizFlowRoutes: Routes = [
path: 'results',
component: QuizResultsComponent,
data: {},
canDeactivate: [ShowUnloadWarningGuard],
}, {
path: 'results/:questionIndex',
component: QuestionDetailsComponent,
data: {},
canDeactivate: [ShowUnloadWarningGuard],
}, {
path: 'leaderboard',
component: LeaderboardComponent,
data: {},
canDeactivate: [ShowUnloadWarningGuard],
}, {
path: 'leaderboard/:questionIndex',
component: LeaderboardComponent,
data: {},
canDeactivate: [ShowUnloadWarningGuard],
}, {
path: 'voting',
component: VotingComponent,
......
......@@ -79,11 +79,14 @@
[questionText]="questionText"></app-voting-question>
<div *ngIf="showLeaderBoardButton(selectedQuestionIndex) || showQuestionButton(selectedQuestionIndex)"
class="btn-group w-100">
class="d-flex">
<button *ngIf="showLeaderBoardButton(selectedQuestionIndex)"
(click)="hasTriggeredNavigation = true"
[routerLink]="['/quiz', 'flow', 'leaderboard', visibleQuestions.length > 1 ? selectedQuestionIndex : 'all']"
class="btn btn-light w-100 cursor-pointer"
[class.mr-1]="showQuestionButton(selectedQuestionIndex)"
[class.w-100]="!showQuestionButton(selectedQuestionIndex)"
[class.w-50]="showQuestionButton(selectedQuestionIndex)"
class="btn btn-light"
type="button">
<fa-icon [icon]="'trophy'"
class="mr-2"></fa-icon>
......@@ -92,7 +95,10 @@
<button *ngIf="showQuestionButton(selectedQuestionIndex)"
(click)="hasTriggeredNavigation = true"
[routerLink]="['/quiz', 'flow', 'results', selectedQuestionIndex]"
class="btn btn-light w-100 cursor-pointer"
[class.ml-1]="showLeaderBoardButton(selectedQuestionIndex)"
[class.w-100]="!showLeaderBoardButton(selectedQuestionIndex)"
[class.w-50]="showLeaderBoardButton(selectedQuestionIndex)"
class="btn btn-light"
type="button">
<fa-icon [icon]="'question'"
class="mr-2"></fa-icon>
......
......@@ -398,12 +398,7 @@ export class QuizResultsComponent implements OnInit, OnDestroy, IHasTriggeredNav
this.footerBarService.footerElemBack,
];
if (this.quizService.quiz.currentQuestionIndex === this.quizService.quiz.questionList.length - 1) {
if (this.quizService.quiz.questionList.every(
question => [QuestionType.ABCDSingleChoiceQuestion, QuestionType.SurveyQuestion].includes(question.TYPE))) {
footerElems.push(this.footerBarService.footerElemExport);
} else {
footerElems.push(this.footerBarService.footerElemLeaderboard);
}
footerElems.push(this.footerBarService.footerElemExport);
} else {
if (environment.readingConfirmationEnabled) {
footerElems.splice(2, 0, this.footerBarService.footerElemReadingConfirmation);
......@@ -421,17 +416,6 @@ export class QuizResultsComponent implements OnInit, OnDestroy, IHasTriggeredNav
};
} else {
footerElems = [];
if (this.quizService.quiz.currentQuestionIndex === this.quizService.quiz.questionList.length - 1 && this.quizService.quiz.questionList.some(
question => [
QuestionType.FreeTextQuestion,
QuestionType.MultipleChoiceQuestion,
QuestionType.RangedQuestion,
QuestionType.SingleChoiceQuestion,
QuestionType.TrueFalseSingleChoiceQuestion,
QuestionType.YesNoSingleChoiceQuestion,
].includes(question.TYPE))) {
footerElems.push(this.footerBarService.footerElemLeaderboard);
}
}
this.footerBarService.replaceFooterElements(footerElems);
}
......
......@@ -156,12 +156,12 @@ export class VotingComponent implements OnInit, OnDestroy, IHasTriggeredNavigati
public initData(): void {
switch (this._currentQuestion.TYPE) {
case QuestionType.RangedQuestion:
this._selectedAnswers = null;
break;
case QuestionType.FreeTextQuestion:
this._selectedAnswers = '';
break;
case QuestionType.RangedQuestion:
this._selectedAnswers = -1;
break;
default:
this._selectedAnswers = [];
}
......@@ -268,7 +268,6 @@ export class VotingComponent implements OnInit, OnDestroy, IHasTriggeredNavigati
this.router.navigate(['/']);
}
}), this.messageQueue.subscribe(MessageProtocol.Stop, payload => {
this._selectedAnswers = [];
this.hasTriggeredNavigation = true;
this.sendResponses('results');
}),
......
......@@ -10,7 +10,7 @@ export class ShowUnloadWarningGuard<T extends IHasTriggeredNavigation> implement
constructor(private translate: TranslateService) {}
public canDeactivate(component): boolean {
public canDeactivate(component: T): boolean {
if (component && component.hasTriggeredNavigation) {
return true;
}
......
......@@ -21,7 +21,13 @@ body {
}
.thumbnail {
max-width: 100%;
@include media-breakpoint-down(sm) {
max-width: 100%;
}
@include media-breakpoint-up(md) {
max-width: 30vw;
}
max-height: 400px;
height: auto;
width: auto;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment