Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb8cd7c4

Browse files
authored
Merge pull requestcoderoad#23 from ShMcK/feature/multi-stage
Feature/multi stage
2 parents7d89a43 +7c21cf1 commitb8cd7c4

File tree

10 files changed

+125
-77
lines changed

10 files changed

+125
-77
lines changed

‎TODO.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

‎src/state/actions/index.ts

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,24 @@ let currentProgress: CR.Progress = {
1414
complete:false,
1515
}
1616

17+
constcalculatePosition=({ data, progress}:{data:CR.TutorialData,progress:CR.Progress}):CR.Position=>{
18+
const{ levelList}=data.summary
19+
// take next incomplete level or the final step
20+
constlevelId=levelList.find((id:string)=>!progress.levels[id])||levelList[levelList.length-1]
21+
const{ stageList}=data.levels[levelId]
22+
conststageId=stageList.find((id:string)=>!progress.stages[id])||stageList[stageList.length-1]
23+
const{ stepList}=data.stages[stageId]
24+
conststepId=stepList.find((id:string)=>!progress.steps[id])||stepList[stepList.length-1]
25+
26+
constnextPosition:CR.Position={
27+
levelId,
28+
stageId,
29+
stepId,
30+
}
31+
32+
returnnextPosition
33+
}
34+
1735
exportdefault(dispatch:CR.EditorDispatch)=>({
1836
createWebview(){
1937
dispatch('coderoad.open_webview')
@@ -79,24 +97,9 @@ export default (dispatch: CR.EditorDispatch) => ({
7997
if(!currentTutorial){
8098
thrownewError('No Tutorial loaded')
8199
}
82-
83100
const{ data}=currentTutorial
101+
constposition=calculatePosition({ data,progress:currentProgress})
84102

85-
const{ levelList}=data.summary
86-
// take next incomplete level or the final step
87-
constlevelId=levelList.find((id:string)=>!currentProgress.levels[id])||levelList[levelList.length-1]
88-
const{ stageList}=data.levels[levelId]
89-
conststageId=stageList.find((id:string)=>!currentProgress.stages[id])||stageList[stageList.length-1]
90-
console.log('position stepList')
91-
console.log(data.stages[stageId])
92-
const{ stepList}=data.stages[stageId]
93-
conststepId=stepList.find((id:string)=>!currentProgress.steps[id])||stepList[stepList.length-1]
94-
95-
constposition={
96-
levelId,
97-
stageId,
98-
stepId,
99-
}
100103
console.log('position',position)
101104
returnposition
102105
},
@@ -113,6 +116,7 @@ export default (dispatch: CR.EditorDispatch) => ({
113116
//@ts-ignore
114117
progressUpdate:assign({
115118
progress:(context:CR.MachineContext):CR.Progress=>{
119+
console.log('progress update')
116120
const{ progress, position, data}=context
117121
constnextProgress=progress
118122

@@ -156,9 +160,23 @@ export default (dispatch: CR.EditorDispatch) => ({
156160
loadLevel(){
157161
console.log('loadLevel')
158162
},
159-
loadStage(){
163+
stageLoadNext(context:CR.MachineContext){
164+
console.log('stageLoadNext')
165+
const{ position}=context
166+
console.log(position)
167+
},
168+
loadStage(context:CR.MachineContext):void{
160169
console.log('loadStage')
170+
const{ position}=context
171+
console.log(position)
161172
},
173+
//@ts-ignore
174+
updatePosition:assign({
175+
position:(context:CR.MachineContext)=>calculatePosition({
176+
data:context.data,
177+
progress:context.progress,
178+
}),
179+
}),
162180
stepLoadCommits(context:CR.MachineContext):void{
163181
const{ data, position}=context
164182
const{ setup}=data.steps[position.stepId].actions

‎src/state/machine.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export const machine = (dispatch: CR.EditorDispatch) =>
101101
},
102102
},
103103
Stage:{
104-
onEntry:['loadStage'],
104+
onEntry:['loadStage','stepLoadCommits'],
105105
initial:'Normal',
106106
states:{
107107
Normal:{
@@ -148,7 +148,10 @@ export const machine = (dispatch: CR.EditorDispatch) =>
148148
},
149149
StageComplete:{
150150
on:{
151-
STAGE_NEXT:'#tutorial-load-next',
151+
STAGE_NEXT:{
152+
target:'#tutorial-load-next',
153+
actions:['updatePosition'],
154+
},
152155
},
153156
},
154157
},

‎src/tutorials/basic.ts

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const basic: CR.Tutorial = {
2121
},
2222
levels:{
2323
level1Id:{
24-
stageList:['stage1Id'],
24+
stageList:['stage1Id','stage2Id'],
2525
content:{
2626
title:'Sum Level',
2727
text:'A description of this stage',
@@ -36,12 +36,19 @@ const basic: CR.Tutorial = {
3636
text:'A description of this stage',
3737
},
3838
},
39+
stage2Id:{
40+
stepList:['1','2'],
41+
content:{
42+
title:'Second Stage',
43+
text:'Going into round 2'
44+
}
45+
}
3946
},
4047
steps:{
4148
step1Id:{
4249
content:{
4350
title:'Sum',
44-
text:'Write a function that adds two numbers together',
51+
text:'Write a function`add`that adds two numbers together',
4552
},
4653
actions:{
4754
setup:{
@@ -58,7 +65,7 @@ const basic: CR.Tutorial = {
5865
step2Id:{
5966
content:{
6067
title:'Multiply',
61-
text:'Write a function that multiplies two numbers together',
68+
text:'Write a function`multiply`that multiplies two numbers together',
6269
},
6370
actions:{
6471
setup:{
@@ -74,7 +81,7 @@ const basic: CR.Tutorial = {
7481
step3Id:{
7582
content:{
7683
title:'Divide',
77-
text:'Write a function that divides',
84+
text:'Write a function`divide`that divides',
7885
},
7986
actions:{
8087
setup:{
@@ -87,6 +94,36 @@ const basic: CR.Tutorial = {
8794
},
8895
hints:[],
8996
},
97+
1:{
98+
content:{
99+
title:'Modulo',
100+
text:'Modulo `%` it up'
101+
},
102+
actions:{
103+
setup:{
104+
commits:['16d9699'],
105+
files:['src/modulo.js'],
106+
},
107+
solution:{
108+
commits:['bbf8aa5']
109+
}
110+
}
111+
},
112+
2:{
113+
content:{
114+
title:'Power',
115+
text:'Power up with `**` powers'
116+
},
117+
actions:{
118+
setup:{
119+
commits:['683c8db'],
120+
files:['src/power.js'],
121+
},
122+
solution:{
123+
commits:['deaf3a8']
124+
}
125+
}
126+
},
90127
},
91128
},
92129
}

‎vsc-extension-quickstart.md

Lines changed: 0 additions & 41 deletions
This file was deleted.

‎web-app/src/components/Stage/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ interface Props {
2828
[stepId:string]:any// CC.Step
2929
}
3030
complete:boolean
31-
onNextStage():void
31+
onContinue():void
3232
}
3333

34-
constStage=({ stage, steps,onNextStage, complete}:Props)=>{
34+
constStage=({ stage, steps,onContinue, complete}:Props)=>{
3535
const{ stepList, content}=stage
3636
const{ title, text}=content
3737
// grab the active step
@@ -61,7 +61,7 @@ const Stage = ({ stage, steps, onNextStage, complete }: Props) => {
6161

6262
{complete&&(
6363
<divstyle={styles.options}>
64-
<ButtononClick={onNextStage}>Continue</Button>
64+
<ButtononClick={onContinue}>Continue</Button>
6565
</div>
6666
)}
6767
</div>

‎web-app/src/containers/Tutorial/StagePage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const StagePage = (props: PageProps) => {
1818

1919
conststageComplete=progress.stages[stageId]||false
2020

21-
constonNextStage=():void=>{
21+
constonContinue=():void=>{
2222
props.send('STAGE_NEXT')
2323
}
2424

@@ -35,7 +35,7 @@ const StagePage = (props: PageProps) => {
3535
},
3636
}
3737
}
38-
return<Stagestage={stage}steps={steps}onNextStage={onNextStage}complete={stageComplete}/>
38+
return<Stagestage={stage}steps={steps}onContinue={onContinue}complete={stageComplete}/>
3939
}
4040

4141
exportdefaultStagePage

‎web-app/src/containers/Tutorial/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const Tutorial = (props: Props) => {
1818
return(
1919
<Routerstate={props.state}>
2020
<Routepath="Tutorial.LoadNext">
21-
<LoadingPagetext="Loading Tutorial..."/>
21+
<LoadingPagetext="Loading..."/>
2222
</Route>
2323
<Routepath="Tutorial.Summary">
2424
<SummaryPagesend={send}/>

‎web-app/src/tutorials/basic.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ const basic: CR.Tutorial = {
3636
text:'A description of this stage',
3737
},
3838
},
39+
stage2Id:{
40+
stepList:['1','2'],
41+
content:{
42+
title:'Second Stage',
43+
text:'Going into round 2'
44+
}
45+
}
3946
},
4047
steps:{
4148
step1Id:{
@@ -87,6 +94,36 @@ const basic: CR.Tutorial = {
8794
},
8895
hints:[],
8996
},
97+
1:{
98+
content:{
99+
title:'Modulo',
100+
text:'Modulo `%` it up'
101+
},
102+
actions:{
103+
setup:{
104+
commits:['16d9699'],
105+
files:[],
106+
},
107+
solution:{
108+
commits:['bbf8aa5']
109+
}
110+
}
111+
},
112+
2:{
113+
content:{
114+
title:'Power',
115+
text:'Power up with `**` powers'
116+
},
117+
actions:{
118+
setup:{
119+
commits:['683c8db'],
120+
files:[],
121+
},
122+
solution:{
123+
commits:['deaf3a8']
124+
}
125+
}
126+
},
90127
},
91128
},
92129
}

‎web-app/stories/Stage.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ function someExample(a) {
5151
})}
5252
stage={object('stage',demo.data.stages.stage1Id)}
5353
complete={boolean('complete',false)}
54-
onNextStage={action('onNextStage')}
54+
onContinue={action('onContinue')}
5555
/>
5656
))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp