@@ -32,6 +32,7 @@ export default {
3232 const canContinue = ! ! ( tutorial && progress && hasGit && hasGitRemote )
3333
3434 if ( canContinue ) {
35+ // continue
3536 currentTutorial = tutorial
3637 currentProgress = progress
3738 }
@@ -41,6 +42,7 @@ export default {
4142 async tutorialLaunch ( ) {
4243 // TODO: add selection of tutorial id
4344 const tutorial : CR . Tutorial = await api ( { resource : 'getTutorial' , params : { id : '1' } } )
45+ currentTutorial = tutorial
4446 console . log ( 'api' )
4547 console . log ( tutorial )
4648 vscode . commands . executeCommand ( 'coderoad.tutorial_launch' , tutorial )
@@ -49,6 +51,19 @@ export default {
4951 vscode . commands . executeCommand ( 'coderoad.tutorial_setup' , currentTutorial )
5052 vscode . commands . executeCommand ( 'coderoad.open_webview' , vscode . ViewColumn . Two )
5153 } ,
54+ initializeNewTutorial : assign ( {
55+ position : ( context : any ) : CR . Position => {
56+ const { data } = context
57+ const levelId = data . summary . levelList [ 0 ]
58+ const stageId = data . levels [ levelId ] . stageList [ 0 ]
59+ const stepId = data . stages [ stageId ] . stepList [ 0 ]
60+ return {
61+ levelId,
62+ stageId,
63+ stepId
64+ }
65+ }
66+ } ) ,
5267 tutorialContinue : assign ( {
5368 // load initial data, progress & position
5469 data ( ) : CR . TutorialData {
@@ -149,7 +164,22 @@ export default {
149164 return nextProgress
150165 }
151166 } ) ,
152- stepLoadNext ( ) {
153- console . log ( "LOAD NEXT STEP" )
167+ stepLoadNext : assign ( {
168+ position : ( context : any ) => {
169+ const { data, position } = context
170+ const { stepList } = data . stages [ position . stageId ]
171+ const currentStepIndex = stepList . indexOf ( position . stepId )
172+ const nextStepId = stepList [ currentStepIndex + 1 ]
173+ return {
174+ ...context . position ,
175+ stepId : nextStepId ,
176+ }
177+ }
178+ } ) ,
179+ loadLevel ( ) {
180+ console . log ( 'loadLevel' )
181+ } ,
182+ loadStage ( ) {
183+ console . log ( 'loadStage' )
154184 }
155185}
0 commit comments