Skip to content

Commit 77b655b

Browse files
committedMar 31, 2020
Invert logic of tutorial mode configuration property
1 parent 62f0e8a commit 77b655b

8 files changed

+17
-17
lines changed
 

‎.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ config/*.yml
5252
!config/7ms.yml
5353
!config/mozilla.yml
5454
!config/unsafe.yml
55-
!config/beginner.yml
55+
!config/tutorial.yml

‎config.schema.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ challenges:
9999
type: boolean
100100
showHints:
101101
type: boolean
102-
isFullModeUnlocked:
102+
restrictToTutorialsFirst:
103103
type: boolean
104104
overwriteUrlForProductTamperingChallenge:
105105
type: string

‎config/beginner.yml

-2
This file was deleted.

‎config/default.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ application:
6767
challenges:
6868
showSolvedNotifications: true
6969
showHints: true
70-
isFullModeUnlocked: true
70+
restrictToTutorialsFirst: false
7171
overwriteUrlForProductTamperingChallenge: 'https://owasp.slack.com'
7272
xssBonusPayload: '<iframe width="100%" height="166" scrolling="no" frameborder="no" allow="autoplay" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/771984076&color=%23ff5500&auto_play=true&hide_related=false&show_comments=true&show_user=true&show_reposts=false&show_teaser=true"></iframe>'
7373
safetyOverride: false

‎config/tutorial.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
challenges:
2+
restrictToTutorialsFirst: true

‎frontend/src/app/Services/configuration.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ interface Config {
7575
challenges: {
7676
showSolvedNotifications: boolean
7777
showHints: boolean
78-
isFullModeUnlocked: boolean
78+
restrictToTutorialsFirst: boolean
7979
safetyOverride: boolean
8080
overwriteUrlForProductTamperingChallenge: string
8181
}

‎frontend/src/app/score-board/score-board.component.html

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<mat-card>
1515
<div class="star-container" fxLayout="row wrap">
1616
<mat-button-toggle *ngFor="let difficulty of availableDifficulties" (change)="toggleDifficulty(difficulty)"
17-
[checked]="displayedDifficulties.includes(difficulty)" [disabled]="!fullModeUnlocked && !allTutorialsCompleted">
17+
[checked]="displayedDifficulties.includes(difficulty)" [disabled]="restrictToTutorialsFirst && !allTutorialsCompleted">
1818
<label>
1919
<span class="fa-4x fa-layers fa-fw" style="display: block; margin: 5px;">
2020
<svg [style.fill]="'url(#' + difficulty + ')'" class="svg-inline--fa fa-star fa-w-18 star-border" aria-hidden="true"
@@ -38,22 +38,22 @@
3838
</label>
3939
</mat-button-toggle>
4040

41-
<button id="btnToggleAllDifficulties" class="mat-button" (click)="toggleAllDifficulty()" [disabled]="!fullModeUnlocked && !allTutorialsCompleted">{{(this.toggledMajorityOfDifficulties ? "BTN_HIDE_ALL" : "BTN_SHOW_ALL") | translate}}</button>
41+
<button id="btnToggleAllDifficulties" class="mat-button" (click)="toggleAllDifficulty()" [disabled]="restrictToTutorialsFirst && !allTutorialsCompleted">{{(this.toggledMajorityOfDifficulties ? "BTN_HIDE_ALL" : "BTN_SHOW_ALL") | translate}}</button>
4242

43-
<mat-button-toggle (change)="toggleShowSolvedChallenges()" [checked]="showSolvedChallenges" [disabled]="!fullModeUnlocked && !allTutorialsCompleted">
43+
<mat-button-toggle (change)="toggleShowSolvedChallenges()" [checked]="showSolvedChallenges" [disabled]="restrictToTutorialsFirst && !allTutorialsCompleted">
4444
<i class="fa-2x fas fa-trophy" aria-hidden="true"></i> {{"BTN_SHOW_SOLVED" | translate}}
4545
</mat-button-toggle>
4646

4747
<mat-button-toggle id="btnToggleShowOnlyTutorialChallenges" (change)="toggleShowOnlyTutorialChallenges()"
48-
[checked]="showOnlyTutorialChallenges" [disabled]="!fullModeUnlocked && !allTutorialsCompleted"
49-
[matTooltip]="fullModeUnlocked || allTutorialsCompleted ? '' : ('INFO_FULL_CHALLENGE_MODE' | translate: {num: challenges.length})" matTooltipPosition="above">
48+
[checked]="showOnlyTutorialChallenges" [disabled]="restrictToTutorialsFirst && !allTutorialsCompleted"
49+
[matTooltip]="restrictToTutorialsFirst && !allTutorialsCompleted ? ('INFO_FULL_CHALLENGE_MODE' | translate: {num: challenges.length}) : ''" matTooltipPosition="above">
5050
<mat-icon>
5151
school
5252
</mat-icon>
5353
{{"BTN_SHOW_ONLY_TUTORIALS" | translate}}
5454
</mat-button-toggle>
5555

56-
<mat-button-toggle *ngIf="numDisabledChallenges > 0" (change)="toggleShowDisabledChallenges()" [checked]="showDisabledChallenges" [disabled]="!fullModeUnlocked && !allTutorialsCompleted">
56+
<mat-button-toggle *ngIf="numDisabledChallenges > 0" (change)="toggleShowDisabledChallenges()" [checked]="showDisabledChallenges" [disabled]="restrictToTutorialsFirst && !allTutorialsCompleted">
5757
<i class="fa-2x fas fa-exclamation-circle" aria-hidden="true"></i> {{"BTN_SHOW_UNAVAILABLE" | translate}}
5858
</mat-button-toggle>
5959

@@ -64,11 +64,11 @@
6464
<div class="category-container" fxLayout="row wrap">
6565
<mat-button-toggle class="category-toggle" appearance="legacy" *ngFor="let category of availableChallengeCategories"
6666
(change)="toggleShowChallengeCategory(category)"
67-
[checked]="displayedChallengeCategories.includes(category)" [disabled]="!fullModeUnlocked && !allTutorialsCompleted">
67+
[checked]="displayedChallengeCategories.includes(category)" [disabled]="restrictToTutorialsFirst && !allTutorialsCompleted">
6868
{{category}}
6969
</mat-button-toggle>
7070

71-
<button class="mat-button" (click)="toggleAllChallengeCategory()" [disabled]="!fullModeUnlocked && !allTutorialsCompleted">{{(this.toggledMajorityOfCategories ? "BTN_HIDE_ALL" : "BTN_SHOW_ALL") | translate}}</button>
71+
<button class="mat-button" (click)="toggleAllChallengeCategory()" [disabled]="restrictToTutorialsFirst && !allTutorialsCompleted">{{(this.toggledMajorityOfCategories ? "BTN_HIDE_ALL" : "BTN_SHOW_ALL") | translate}}</button>
7272
</div>
7373

7474
</mat-card>

‎frontend/src/app/score-board/score-board.component.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class ScoreBoardComponent implements OnInit {
3838
public numDisabledChallenges: number = 0
3939
public showDisabledChallenges: boolean = false
4040
public showOnlyTutorialChallenges: boolean = true
41-
public fullModeUnlocked: boolean = true
41+
public restrictToTutorialsFirst: boolean = false
4242
public allTutorialsCompleted: boolean = false
4343
public disabledEnv?: string
4444
public displayedColumns = ['name', 'difficulty', 'description', 'category', 'status']
@@ -72,7 +72,7 @@ export class ScoreBoardComponent implements OnInit {
7272
this.showContributionInfoBox = config.application.showGitHubLinks
7373
this.questionnaireUrl = config.application.social && config.application.social.questionnaireUrl
7474
this.appName = config.application.name
75-
this.fullModeUnlocked = config.challenges.isFullModeUnlocked
75+
this.restrictToTutorialsFirst = config.challenges.restrictToTutorialsFirst
7676
}, (err) => console.log(err))
7777

7878
this.challengeService.find({ sort: 'name' }).subscribe((challenges) => {
@@ -172,7 +172,7 @@ export class ScoreBoardComponent implements OnInit {
172172
calculateTutorialCompletion (challenges: Challenge[]) {
173173
this.allTutorialsCompleted = true
174174
for (let i = 0; i < challenges.length; i++) {
175-
if (!this.fullModeUnlocked && challenges[i].tutorialOrder && !challenges[i].disabledEnv) {
175+
if (this.restrictToTutorialsFirst && challenges[i].tutorialOrder && !challenges[i].disabledEnv) {
176176
this.allTutorialsCompleted = this.allTutorialsCompleted && challenges[i].solved
177177
}
178178
}

0 commit comments

Comments
 (0)
Please sign in to comment.