Fixes bugs which prevented the start of quizzes if no server password is set

parent 8deb77cd
Pipeline #17955 passed with stages
in 9 minutes and 5 seconds
......@@ -84,9 +84,9 @@
<button *ngIf="!canEditQuiz && !isAddingDemoQuiz && !isAddingABCDQuiz"
id="addSession"
class="btn btn-success btn-block pointer"
[class.disabled]="!serverPassword.length"
[class.disabled]="passwordRequired && !serverPassword.length"
(click)="handleClick('addSession') && setAsCurrentQuiz(['/quiz', 'manager', 'overview'])"
[disabled]="!serverPassword.length">
[disabled]="passwordRequired && !serverPassword.length">
<span class="mr-1">{{'component.hashtag_management.create_session' | translate}}</span>
<i class="fas fa-edit"></i>
</button>
......@@ -100,18 +100,18 @@
<button *ngIf="isAddingDemoQuiz"
id="runDemoQuizSession"
class="btn btn-success btn-block pointer"
[class.disabled]="!serverPassword.length"
[class.disabled]="passwordRequired && !serverPassword.length"
(click)="handleClick('add-demo-quiz') && setActiveQuestionGroup() && setAsCurrentQuiz(['/quiz', 'flow'])"
[disabled]="!serverPassword.length">
[disabled]="passwordRequired && !serverPassword.length">
<span class="mr-1">{{'component.hashtag_management.create_demo_session' | translate}}</span>
<i class="fas fa-paper-plane"></i>
</button>
<button *ngIf="isAddingABCDQuiz"
id="runABCDQuizSession"
class="btn btn-success btn-block pointer"
[class.disabled]="!serverPassword.length"
[class.disabled]="passwordRequired && !serverPassword.length"
(click)="handleClick('add-abcd-quiz') && setActiveQuestionGroup() && setAsCurrentQuiz(['/quiz', 'flow'])"
[disabled]="!serverPassword.length">
[disabled]="passwordRequired && !serverPassword.length">
<span class="mr-1">{{'component.hashtag_management.create_abcd_session' | translate}}</span>
<i class="fas fa-paper-plane"></i>
</button>
......
......@@ -374,7 +374,7 @@ export class HomeComponent implements OnInit, OnDestroy {
const questionGroupInstance = questionGroupReflection[currentQuiz.TYPE](currentQuiz);
this.canAddQuiz = false;
this.canEditQuiz = true;
this.canStartQuiz = questionGroupInstance.isValid();
this.canStartQuiz = !this.settingsService.serverSettings.createQuizPasswordRequired && questionGroupInstance.isValid();
this.passwordRequired = this.canStartQuiz && this.settingsService.serverSettings.createQuizPasswordRequired;
}
......@@ -382,6 +382,7 @@ export class HomeComponent implements OnInit, OnDestroy {
this.isAddingDemoQuiz = true;
this.canAddQuiz = false;
this.canEditQuiz = false;
this.canStartQuiz = !this.settingsService.serverSettings.createQuizPasswordRequired;
this.passwordRequired = this.settingsService.serverSettings.createQuizPasswordRequired;
}
......@@ -389,6 +390,7 @@ export class HomeComponent implements OnInit, OnDestroy {
this.isAddingABCDQuiz = true;
this.canAddQuiz = false;
this.canEditQuiz = false;
this.canStartQuiz = !this.settingsService.serverSettings.createQuizPasswordRequired;
this.passwordRequired = this.settingsService.serverSettings.createQuizPasswordRequired;
}
......@@ -400,11 +402,13 @@ export class HomeComponent implements OnInit, OnDestroy {
this.canAddQuiz = false;
this.canJoinQuiz = false;
this.passwordRequired = false;
this.canStartQuiz = false;
break;
case 'QUIZ:AVAILABLE':
this.canAddQuiz = false;
this.canJoinQuiz = true;
this.passwordRequired = false;
this.canStartQuiz = false;
this._provideNickSelection = value.payload.provideNickSelection;
this.casService.casLoginRequired = value.payload.authorizeViaCas;
if (this.casService.casLoginRequired) {
......@@ -415,6 +419,7 @@ export class HomeComponent implements OnInit, OnDestroy {
this.canAddQuiz = true;
this.canJoinQuiz = false;
this.passwordRequired = this.settingsService.serverSettings.createQuizPasswordRequired;
this.canStartQuiz = !this.settingsService.serverSettings.createQuizPasswordRequired;
break;
default:
console.log(value);
......
......@@ -13,18 +13,9 @@ export class SettingsService {
return this._serverSettings;
}
constructor(@Inject(PLATFORM_ID) private platformId: Object,
private connectionService: ConnectionService,
private storageService: StorageService,
) {
constructor(@Inject(PLATFORM_ID) private platformId: Object, private connectionService: ConnectionService, private storageService: StorageService) {
if (isPlatformBrowser(this.platformId)) {
this.storageService.read(DB_TABLE.CONFIG, STORAGE_KEY.SERVER_SETTINGS).subscribe(val => {
if (val) {
this._serverSettings = val;
} else {
this.initServerSettings();
}
});
this.initServerSettings();
}
}
......
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