-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: otter training - prepare training content
- Loading branch information
Showing
24 changed files
with
489 additions
and
40 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
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
28 changes: 28 additions & 0 deletions
28
apps/showcase/scripts/prepare-training-exercises/index.cjs
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,28 @@ | ||
const {readdir, readFile, writeFile} = require('node:fs/promises'); | ||
const {getFilesTree} = require('@o3r/training-tools'); | ||
const {dirname, join, resolve} = require('node:path'); | ||
const glob = require('globby'); | ||
|
||
/** | ||
* The purpose of this script is to generate the exercise and solution files for the code editor | ||
*/ | ||
|
||
void (async () => { | ||
const root = resolve(__dirname, '..', '..'); | ||
const files = await glob('src/assets/trainings/*-training/**/(exercise|solution)/**', {cwd: root, dot: true}); | ||
const paths = files.reduce((exercisePaths, file) => { | ||
const exerciseDirectory = dirname(file).match('(.*/(?:exercise|solution))')?.[0]; | ||
if (exerciseDirectory) { | ||
exercisePaths.add(exerciseDirectory); | ||
} | ||
return exercisePaths; | ||
}, new Set()); | ||
for (const folder of paths) { | ||
const filePath = join(root, folder); | ||
const exerciseStructure = await getFilesTree([{isDir: true, path: `${filePath}`}], {readdir, readFile}); | ||
const [_, commonPath, folderName] = folder.match('(.*)/(exercise|solution)'); | ||
const targetPath = join(commonPath, `${folderName}.json`); | ||
const content = JSON.stringify(exerciseStructure); | ||
await writeFile(targetPath, content); | ||
} | ||
})(); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './sdk-training.component'; |
4 changes: 4 additions & 0 deletions
4
apps/showcase/src/app/sdk-training/sdk-training.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,4 @@ | ||
o3r-training { | ||
// full visible height on the screen (with removal of the showcase header height of 4rem) | ||
height: calc(100vh - 4rem); | ||
} |
22 changes: 22 additions & 0 deletions
22
apps/showcase/src/app/sdk-training/sdk-training.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,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { SdkTrainingComponent } from './sdk-training.component'; | ||
|
||
describe('SdkTrainingComponent', () => { | ||
let component: SdkTrainingComponent; | ||
let fixture: ComponentFixture<SdkTrainingComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [SdkTrainingComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(SdkTrainingComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
apps/showcase/src/app/sdk-training/sdk-training.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,14 @@ | ||
import {ChangeDetectionStrategy, Component} from '@angular/core'; | ||
import {TrainingComponent} from '../../components'; | ||
|
||
@Component({ | ||
selector: 'o3r-sdk-training', | ||
standalone: true, | ||
imports: [ | ||
TrainingComponent | ||
], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
template: '<o3r-training [title]="\'SDK Training\'" [trainingPath]="\'trainings/sdk\'"></o3r-training>', | ||
styleUrls: ['./sdk-training.component.scss'] | ||
}) | ||
export class SdkTrainingComponent {} |
1 change: 1 addition & 0 deletions
1
apps/showcase/src/components/training/code-editor-control/code-editor-control.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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
code-editor-control { | ||
transition: min-height 100ms ease; | ||
|
||
&:has(.command-panel.d-none) { | ||
min-height: 3rem; | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export * from './code-editor-view/index'; | ||
export * from './training-step/index'; | ||
export * from './training.component'; |
46 changes: 46 additions & 0 deletions
46
apps/showcase/src/components/training/training.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,46 @@ | ||
@if (steps()[currentStepIndex()]; as currentStep){ | ||
<div class="mt-7 mb-3 d-flex justify-content-between"> | ||
<div class="align-self-center"> | ||
<h1 class="m-0">{{title()}}</h1> | ||
<div ngbDropdown class="mt-2"> | ||
<button type="button" class="btn btn-outline-primary" id="training-exercise-selection" ngbDropdownToggle> | ||
{{currentStep.description.title}} | ||
</button> | ||
<div ngbDropdownMenu aria-labelledby="training-exercise-selection"> | ||
@for (label of stepNames(); track label; let id = $index) { | ||
<button type="button" ngbDropdownItem class="dropdown-item" [class.active]="id === currentStepIndex()" (click)="setCurrentStep(id)"> | ||
{{label}} | ||
</button> | ||
} | ||
</div> | ||
</div> | ||
</div> | ||
<div class="align-self-center d-flex flex-wrap"> | ||
@if (currentStep.dynamicContent.project() || currentStep.dynamicContent.solutionProject()) { | ||
<button type="button" class="btn btn-outline-primary mb-2 mb-md-0 me-5" (click)="updateDisplayInstructions()"> | ||
{{showInstructions() ? 'Hide instructions' : 'Show instructions'}} | ||
</button> | ||
<button type="button" class="btn btn-outline-danger mb-2 mb-md-0 me-5" | ||
(click)="updateDisplaySolution()" | ||
[disabled]="!showSolution() && !currentStep.dynamicContent.solutionProject() || showSolution() && !currentStep.dynamicContent.project()" | ||
> | ||
{{showSolution() ? 'Show exercise' : 'Show solution'}} | ||
</button> | ||
} | ||
<div> | ||
<button type="button" class="btn btn-outline-secondary df-btn-icononly fa-chevron-left me-2" [disabled]="currentStepIndex() <= 0" | ||
(click)="setCurrentStep(currentStepIndex() - 1)"></button> | ||
<button type="button" class="btn btn-outline-secondary df-btn-icononly fa-chevron-right ms-2" [disabled]="currentStepIndex() >= steps().length - 1" | ||
(click)="setCurrentStep(currentStepIndex() + 1)"></button> | ||
</div> | ||
</div> | ||
</div> | ||
<o3r-training-step-pres | ||
class="flex-fill overflow-hidden mb-5" | ||
[class.constrained]="!!(currentStep.dynamicContent.solutionProject() || currentStep.dynamicContent.project())" | ||
[instructions]="showInstructions() ? currentStep.dynamicContent.htmlContent() : ''" | ||
[title]="currentStep.description.title" | ||
[project]="showSolution() ? currentStep.dynamicContent.solutionProject() : currentStep.dynamicContent.project()" | ||
[editorMode]="currentStep.description.filesConfiguration?.mode"> | ||
</o3r-training-step-pres> | ||
} |
8 changes: 8 additions & 0 deletions
8
apps/showcase/src/components/training/training.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,8 @@ | ||
:host { | ||
display: flex; | ||
flex-direction: column; | ||
|
||
&:not(:has(.constrained)) { | ||
height: 100% !important; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
apps/showcase/src/components/training/training.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,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { TrainingComponent } from './training.component'; | ||
|
||
describe('SdkTrainingComponent', () => { | ||
let component: TrainingComponent; | ||
let fixture: ComponentFixture<TrainingComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [TrainingComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(TrainingComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
Oops, something went wrong.