-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement tutorial mode for new score board
- Loading branch information
Showing
11 changed files
with
273 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...score-board-preview/components/tutorial-mode-warning/tutorial-mode-warning.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div | ||
*ngIf="tutorialModeActive" | ||
class="tutorial-mode-warning-container" | ||
> | ||
<mat-icon>school</mat-icon> | ||
<span class="tutorial-mode-warning-text"> | ||
{{ 'INFO_FULL_CHALLENGE_MODE' | translate: {num: allChallenges.length} }} | ||
</span> | ||
</div> | ||
|
13 changes: 13 additions & 0 deletions
13
...score-board-preview/components/tutorial-mode-warning/tutorial-mode-warning.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.tutorial-mode-warning-container { | ||
align-items: center; | ||
background-color: var(--theme-background-dark); | ||
border-radius: 4px; | ||
display: grid; | ||
grid-template-columns: min-content auto; | ||
margin-top: 24px; | ||
padding: 12px; | ||
} | ||
|
||
.tutorial-mode-warning-text { | ||
margin-left: 12px; | ||
} |
78 changes: 78 additions & 0 deletions
78
...re-board-preview/components/tutorial-mode-warning/tutorial-mode-warning.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing' | ||
|
||
import { TutorialModeWarningComponent } from './tutorial-mode-warning.component' | ||
import { TranslateModule } from '@ngx-translate/core' | ||
|
||
describe('TutorialModeWarningComponent', () => { | ||
let component: TutorialModeWarningComponent | ||
let fixture: ComponentFixture<TutorialModeWarningComponent> | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [TranslateModule.forRoot()], | ||
declarations: [TutorialModeWarningComponent] | ||
}).compileComponents() | ||
|
||
fixture = TestBed.createComponent(TutorialModeWarningComponent) | ||
component = fixture.componentInstance | ||
|
||
component.allChallenges = [ | ||
{ | ||
category: 'foobar', | ||
name: 'my name', | ||
tutorialOrder: 1, | ||
solved: false | ||
}, | ||
{ | ||
category: 'foobar', | ||
name: 'my name two', | ||
description: 'lorem ipsum', | ||
tutorialOrder: null, | ||
solved: false | ||
} | ||
] as any | ||
|
||
component.applicationConfig = { | ||
challenges: { | ||
restrictToTutorialsFirst: true | ||
} | ||
} as any | ||
|
||
fixture.detectChanges() | ||
}) | ||
|
||
it('should show warning when there are configured and unsolved tutorial challenges exist', () => { | ||
component.ngOnChanges() | ||
expect(component.tutorialModeActive).toBe(true) | ||
}) | ||
|
||
it('not show if tutorial is not configured', () => { | ||
component.applicationConfig = { | ||
challenges: { | ||
restrictToTutorialsFirst: false | ||
} | ||
} as any | ||
component.ngOnChanges() | ||
expect(component.tutorialModeActive).toBe(false) | ||
}) | ||
|
||
it('should not show warning when all tutorial mode challenges are solved', () => { | ||
component.allChallenges = [ | ||
{ | ||
category: 'foobar', | ||
name: 'my name', | ||
tutorialOrder: 1, | ||
solved: true | ||
}, | ||
{ | ||
category: 'foobar', | ||
name: 'my name two', | ||
description: 'lorem ipsum', | ||
tutorialOrder: null, | ||
solved: false | ||
} | ||
] as any | ||
component.ngOnChanges() | ||
expect(component.tutorialModeActive).toBe(false) | ||
}) | ||
}) |
31 changes: 31 additions & 0 deletions
31
...p/score-board-preview/components/tutorial-mode-warning/tutorial-mode-warning.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Component, Input, OnChanges } from '@angular/core' | ||
|
||
import { EnrichedChallenge } from '../../types/EnrichedChallenge' | ||
import { Config } from 'src/app/Services/configuration.service' | ||
|
||
@Component({ | ||
selector: 'tutorial-mode-warning', | ||
templateUrl: './tutorial-mode-warning.component.html', | ||
styleUrls: ['./tutorial-mode-warning.component.scss'] | ||
}) | ||
export class TutorialModeWarningComponent implements OnChanges { | ||
@Input() | ||
public allChallenges: EnrichedChallenge[] | ||
|
||
@Input() | ||
public applicationConfig: Config | null = null | ||
|
||
public tutorialModeActive: boolean | null = null | ||
|
||
ngOnChanges (): void { | ||
if (!this.applicationConfig?.challenges?.restrictToTutorialsFirst) { | ||
this.tutorialModeActive = false | ||
return | ||
} | ||
|
||
const allTutorialChallengesSolved = this.allChallenges | ||
.filter(challenge => challenge.tutorialOrder !== null) | ||
.every(challenge => challenge.solved) | ||
this.tutorialModeActive = !allTutorialChallengesSolved | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.