@@ -83,19 +83,16 @@ export default {
8383if ( ! currentTutorial ) {
8484throw new Error ( 'No Tutorial loaded' )
8585}
86+
8687const { data} = currentTutorial
87- const levelId = data . summary . levelList . find ( ( id :string ) => ! currentProgress . levels [ id ] )
88- if ( ! levelId ) {
89- throw new Error ( 'No level found on position load' )
90- }
91- const stageId = data . levels [ levelId ] . stageList . find ( ( id :string ) => ! currentProgress . stages [ id ] )
92- if ( ! stageId ) {
93- throw new Error ( 'No stage found on position load' )
94- }
95- const stepId = data . stages [ stageId ] . stepList . find ( ( id :string ) => ! currentProgress . steps [ id ] )
96- if ( ! stepId ) {
97- throw new Error ( 'No step found on position load' )
98- }
88+
89+ const { levelList} = data . summary
90+ // take next incomplete level or the final step
91+ const levelId = levelList . find ( ( id :string ) => ! currentProgress . levels [ id ] ) || levelList [ levelList . length - 1 ]
92+ const { stageList} = data . levels [ levelId ]
93+ const stageId = stageList . find ( ( id :string ) => ! currentProgress . stages [ id ] ) || stageList [ stageList . length - 1 ]
94+ const { stepList} = data . stages [ stageId ]
95+ const stepId = stepList . find ( ( id :string ) => ! currentProgress . steps [ id ] ) || stepList [ stepList . length - 1 ]
9996
10097const position = {
10198 levelId,
@@ -181,7 +178,10 @@ export default {
181178const { data, position} = context
182179const { stepList} = data . stages [ position . stageId ]
183180const currentStepIndex = stepList . indexOf ( position . stepId )
184- const nextStepId = stepList [ currentStepIndex + 1 ]
181+
182+ const nextStepId = ( currentStepIndex < stepList . length )
183+ ?stepList [ currentStepIndex + 1 ]
184+ :position . stepId
185185
186186const nextPosition = {
187187 ...context . position ,