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

Commite78e5d3

Browse files
committed
add actions for levels/stages
1 parent6071ae2 commite78e5d3

File tree

5 files changed

+99
-40
lines changed

5 files changed

+99
-40
lines changed

‎src/editor/commands/index.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,6 @@ export const createCommands = ({ context, machine, storage, git, position }: Cre
8989
// TODO: use actual tutorial repo
9090
awaitPromise.all([git.gitSetupRemote(tutorial.meta.repo),storage.setTutorial(tutorial),storage.resetProgress()])
9191

92-
// TODO: refactor to allow client to call initialization
93-
constpos:CR.Position=awaitposition.getInitial(tutorial)
94-
95-
// eslint-disable-next-line
96-
const{ steps}=tutorial.data
97-
const{ setup}=steps[pos.stepId].actions
98-
awaitgit.gitLoadCommits(setup,dispatch)
9992
machine.send('TUTORIAL_LOADED')
10093
},
10194
[COMMANDS.TUTORIAL_SETUP]:async(tutorial:CR.Tutorial)=>{

‎src/state/actions/index.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,18 +158,34 @@ export default (dispatch: CR.EditorDispatch) => ({
158158
returnnextPosition
159159
},
160160
}),
161-
loadLevel(){
161+
loadLevel(context:CR.MachineContext):void{
162+
const{ data, position}=context
162163
console.log('loadLevel')
164+
console.log(position)
165+
const{ levels}=data
166+
constlevel=levels[position.levelId]
167+
168+
// run level setup if it exists
169+
if(level&&level.actions&&level.actions.setup){
170+
git.gitLoadCommits(level.actions.setup,dispatch)
171+
}
163172
},
164173
stageLoadNext(context:CR.MachineContext){
165174
console.log('stageLoadNext')
166175
const{ position}=context
167176
console.log(position)
168177
},
169178
loadStage(context:CR.MachineContext):void{
179+
const{ data, position}=context
170180
console.log('loadStage')
171-
const{ position}=context
172181
console.log(position)
182+
const{ stages}=data
183+
conststage=stages[position.levelId]
184+
185+
// run level setup if it exists
186+
if(stage&&stage.actions&&stage.actions.setup){
187+
git.gitLoadCommits(stage.actions.setup,dispatch)
188+
}
173189
},
174190
//@ts-ignore
175191
updatePosition:assign({

‎src/tutorials/basic.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ const basic: CR.Tutorial = {
6666
},
6767
actions:{
6868
setup:{
69-
commits:['430500f','8383061'],
69+
commits:['aab5f3d','8fa5ad5'],
7070
commands:['npm install'],
7171
files:['src/sum.js'],
7272
},
7373
solution:{
74-
commits:['abbe136'],
74+
commits:['abe3123'],
7575
},
7676
},
7777
hints:[],
@@ -83,11 +83,11 @@ const basic: CR.Tutorial = {
8383
},
8484
actions:{
8585
setup:{
86-
commits:['9cbb518'],
86+
commits:['0e01df8'],
8787
files:['src/multiply.js'],
8888
},
8989
solution:{
90-
commits:['5ae011f'],
90+
commits:['1b9a520'],
9191
},
9292
},
9393
hints:[],
@@ -99,11 +99,11 @@ const basic: CR.Tutorial = {
9999
},
100100
actions:{
101101
setup:{
102-
commits:['70c774c'],
102+
commits:['40802cf'],
103103
files:['src/divide.js'],
104104
},
105105
solution:{
106-
commits:['3180bed'],
106+
commits:['b321a3d'],
107107
},
108108
},
109109
hints:[],
@@ -115,11 +115,11 @@ const basic: CR.Tutorial = {
115115
},
116116
actions:{
117117
setup:{
118-
commits:['16d9699'],
118+
commits:['4db40b4'],
119119
files:['src/modulo.js'],
120120
},
121121
solution:{
122-
commits:['bbf8aa5']
122+
commits:['3580c9d']
123123
}
124124
}
125125
},
@@ -130,11 +130,11 @@ const basic: CR.Tutorial = {
130130
},
131131
actions:{
132132
setup:{
133-
commits:['683c8db'],
133+
commits:['abc1e2d'],
134134
files:['src/power.js'],
135135
},
136136
solution:{
137-
commits:['deaf3a8']
137+
commits:['5d28c25']
138138
}
139139
}
140140
},
@@ -145,11 +145,11 @@ const basic: CR.Tutorial = {
145145
},
146146
actions:{
147147
setup:{
148-
commits:['c539057'],
148+
commits:['d2c5827'],
149149
files:['src/hello.js'],
150150
},
151151
solution:{
152-
commits:['ab7d57b']
152+
commits:['f668bf7']
153153
}
154154
}
155155
},
@@ -160,11 +160,11 @@ const basic: CR.Tutorial = {
160160
},
161161
actions:{
162162
setup:{
163-
commits:['abe8404'],
163+
commits:['3aa0ccd'],
164164
files:['src/hello.js'],
165165
},
166166
solution:{
167-
commits:['6f40d18']
167+
commits:['9897785']
168168
}
169169
}
170170
},

‎typings/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ export interface TutorialLevel {
66
title:string
77
text:string
88
}
9+
actions?:{
10+
setup:TutorialAction
11+
}
912
}
1013

1114
exportinterfaceTutorialStage{
@@ -14,6 +17,9 @@ export interface TutorialStage {
1417
title:string
1518
text:string
1619
}
20+
actions?:{
21+
setup:TutorialAction
22+
}
1723
}
1824

1925
exportinterfaceTutorialHint{

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

Lines changed: 61 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import*asCRfrom'typings'
22

33
constbasic:CR.Tutorial={
4-
id:'tutorialId',
4+
id:'1',
55
meta:{
66
version:'0.1.0',
77
repo:'https://github.com/ShMcK/coderoad-tutorial-basic.git',
@@ -17,16 +17,23 @@ const basic: CR.Tutorial = {
1717
summary:{
1818
title:'Basic Test',
1919
description:'A basic coding skills example',
20-
levelList:['level1Id'],
20+
levelList:['level1Id','level2Id'],
2121
},
2222
levels:{
2323
level1Id:{
24-
stageList:['stage1Id'],
24+
stageList:['stage1Id','stage2Id'],
2525
content:{
26-
title:'Sum Level',
26+
title:'Operators',
2727
text:'A description of this stage',
2828
},
2929
},
30+
level2Id:{
31+
stageList:['a'],
32+
content:{
33+
title:'Logic',
34+
text:'Some basic logic in level 2'
35+
}
36+
}
3037
},
3138
stages:{
3239
stage1Id:{
@@ -42,7 +49,14 @@ const basic: CR.Tutorial = {
4249
title:'Second Stage',
4350
text:'Going into round 2'
4451
}
45-
}
52+
},
53+
a:{
54+
stepList:['a1','a2'],
55+
content:{
56+
title:'Part 1',
57+
text:'Going into round 1'
58+
}
59+
},
4660
},
4761
steps:{
4862
step1Id:{
@@ -52,12 +66,12 @@ const basic: CR.Tutorial = {
5266
},
5367
actions:{
5468
setup:{
55-
commits:['430500f','8383061'],
69+
commits:['aab5f3d','8fa5ad5'],
5670
commands:['npm install'],
5771
files:['src/sum.js'],
5872
},
5973
solution:{
60-
commits:['abbe136'],
74+
commits:['abe3123'],
6175
},
6276
},
6377
hints:[],
@@ -69,11 +83,11 @@ const basic: CR.Tutorial = {
6983
},
7084
actions:{
7185
setup:{
72-
commits:['9cbb518'],
86+
commits:['0e01df8'],
7387
files:['src/multiply.js'],
7488
},
7589
solution:{
76-
commits:['5ae011f'],
90+
commits:['1b9a520'],
7791
},
7892
},
7993
hints:[],
@@ -85,11 +99,11 @@ const basic: CR.Tutorial = {
8599
},
86100
actions:{
87101
setup:{
88-
commits:['70c774c'],
102+
commits:['40802cf'],
89103
files:['src/divide.js'],
90104
},
91105
solution:{
92-
commits:['3180bed'],
106+
commits:['b321a3d'],
93107
},
94108
},
95109
hints:[],
@@ -101,11 +115,11 @@ const basic: CR.Tutorial = {
101115
},
102116
actions:{
103117
setup:{
104-
commits:['16d9699'],
105-
files:[],
118+
commits:['4db40b4'],
119+
files:['src/modulo.js'],
106120
},
107121
solution:{
108-
commits:['bbf8aa5']
122+
commits:['3580c9d']
109123
}
110124
}
111125
},
@@ -116,11 +130,41 @@ const basic: CR.Tutorial = {
116130
},
117131
actions:{
118132
setup:{
119-
commits:['683c8db'],
120-
files:[],
133+
commits:['abc1e2d'],
134+
files:['src/power.js'],
135+
},
136+
solution:{
137+
commits:['5d28c25']
138+
}
139+
}
140+
},
141+
a1:{
142+
content:{
143+
title:'Hello',
144+
text:'Return the word "hello"'
145+
},
146+
actions:{
147+
setup:{
148+
commits:['d2c5827'],
149+
files:['src/hello.js'],
150+
},
151+
solution:{
152+
commits:['f668bf7']
153+
}
154+
}
155+
},
156+
a2:{
157+
content:{
158+
title:'Bye',
159+
text:'Return the word "bye"'
160+
},
161+
actions:{
162+
setup:{
163+
commits:['3aa0ccd'],
164+
files:['src/hello.js'],
121165
},
122166
solution:{
123-
commits:['deaf3a8']
167+
commits:['9897785']
124168
}
125169
}
126170
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp