Skip to content
Prev Previous commit
Next Next commit
remove progress progress (progressing)
Signed-off-by: shmck <[email protected]>
  • Loading branch information
ShMcK committed Aug 1, 2020
commit 17e968f880bef82ad010b2aaa8bd231eadeda74a
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,8 @@ Adds a review page for viewing tutorial content. The review page should be espec
- Launch from URL fixes
- Move styles into a central theme
- Prevent multiple versions of CodeRoad from launching

### [0.13.0]

- Significant internal refactor to remove recording progress
- Admin mode to allow creators to jump between tutorial levels/steps during development
9 changes: 1 addition & 8 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const createCommands = ({ extensionPath, workspaceState }: CreateCommandP
onSuccess: (position: T.Position) => {
logger('test pass position', position)
// send test pass message back to client
webview.send({ type: 'TEST_PASS', payload: { position } })
webview.send({ type: 'TEST_PASS', payload: { position: { ...position, complete: true } } })
},
onFail: (position: T.Position, failSummary: T.TestFail): void => {
// send test fail message back to client with failure message
Expand Down Expand Up @@ -82,13 +82,6 @@ export const createCommands = ({ extensionPath, workspaceState }: CreateCommandP
subtasks,
callbacks,
}: { subtasks?: boolean; callbacks?: { onSuccess: () => void } } = {}) => {
logger('run test current', currentPosition)
// use stepId from client, or last set stepId
// const position: T.Position = {
// ...current,
// stepId: current && current.position.stepId?.length ? current.position.stepId : currentPosition.stepId,
// }
logger('currentPosition', currentPosition)
testRunner({ position: currentPosition, onSuccess: callbacks?.onSuccess, subtasks })
},
[COMMANDS.ENTER]: () => {
Expand Down
3 changes: 3 additions & 0 deletions web-app/src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import LoadingPage from './containers/Loading'
import StartPage from './containers/Start'
import SelectTutorialPage from './containers/SelectTutorial'
import TutorialPage from './containers/Tutorial'
import logger from './services/logger'

/*
* NOTE: due to a lack of URLs and a dependency on xstate
Expand All @@ -19,6 +20,8 @@ const Routes = () => {
return <ErrorView send={send} error={context.error} />
}

logger(`ROUTE: ${route}`)

return (
<Router route={route}>
{/* Setup */}
Expand Down
6 changes: 4 additions & 2 deletions web-app/src/services/state/actions/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export const updateStepPosition = assign({
const level: TT.Level = selectors.currentLevel(context)
const steps: TT.Step[] = level.steps

// final step but not completed
// final step now completed
if (steps[steps.length - 1].id === position.stepId) {
return { ...position, complete: false }
return { ...position, complete: true }
}

const stepIndex = steps.findIndex((s: TT.Step) => s.id === position.stepId)
Expand Down Expand Up @@ -75,6 +75,8 @@ export const loadNext = send(
export const stepNext = send(
(context: T.MachineContext): T.Action => {
const level: TT.Level = selectors.currentLevel(context)
console.log(`STEP_NEXT: ${JSON.stringify(context.position)}`)
console.log(`STEP NEXT LEVEL ${JSON.stringify(level)}`)
return getStepNext(context.position, level)
},
)
Expand Down
17 changes: 9 additions & 8 deletions web-app/src/services/state/actions/utils/stepNext.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const level: TT.Level = {
}

describe('stepNext', () => {
it('should LOAD_NEXT_STEP when there is another step and is complete', () => {
const position = { stepId: '1.1', levelId: '1', complete: true }
it('should LOAD_NEXT_STEP when there is another step', () => {
const position = { levelId: '1', stepId: '1.2', complete: false }
const result = getStepNext(position, level)
expect(result).toEqual({
type: 'LOAD_NEXT_STEP',
Expand All @@ -36,25 +36,26 @@ describe('stepNext', () => {
},
})
})
it('should LOAD_NEXT_STEP to the same step if not complete', () => {
const position = { stepId: '1.1', levelId: '1', complete: false }
it('should LOAD_NEXT_STEP when there is another step but no more', () => {
const position = { levelId: '1', stepId: '1.3', complete: false }
const result = getStepNext(position, level)
expect(result).toEqual({
type: 'LOAD_NEXT_STEP',
payload: {
step: level.steps[0],
step: level.steps[2],
},
})
})

it('should LEVEL_COMPLETE when there are no steps', () => {
const position = { stepId: '1.3', levelId: '1', complete: true }
const result = getStepNext(position, level)
const position = { levelId: '1', stepId: null, complete: false }
const result = getStepNext(position, { ...level, steps: [] })
expect(result).toEqual({
type: 'LEVEL_COMPLETE',
})
})
it('should LEVEL_COMPLETE when all steps are complete', () => {
const position = { stepId: '1.3', levelId: '1', complete: true }
const position = { levelId: '1', stepId: '1.3', complete: true }
const result = getStepNext(position, { ...level, steps: [] })
expect(result).toEqual({
type: 'LEVEL_COMPLETE',
Expand Down
20 changes: 7 additions & 13 deletions web-app/src/services/state/actions/utils/stepNext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@ import * as TT from 'typings/tutorial'
const getStepNext = (position: T.Position, level: TT.Level): T.Action => {
const { steps } = level

if (steps.length && position.stepId) {
if (steps.length) {
const stepIndex = steps.findIndex((s: TT.Step) => s.id === position.stepId)
const finalStep = stepIndex === steps.length - 1
// not final step, or final step but not complete
const hasNextStep = !finalStep

if (hasNextStep) {
const nextStep = steps[stepIndex + (position.complete ? 1 : 0)]
return {
type: 'LOAD_NEXT_STEP',
payload: {
step: nextStep,
},
}
const nextStep = steps[stepIndex]
return {
type: 'LOAD_NEXT_STEP',
payload: {
step: nextStep,
},
}
}
return {
Expand Down
2 changes: 1 addition & 1 deletion web-app/src/services/state/machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export const createMachine = (options: any) => {
},
},
LevelComplete: {
onExit: ['testClear'],
onExit: ['testClear', 'incrementLevel'],
on: {
NEXT_LEVEL: 'LoadNext',
KEY_PRESS_ENTER: 'LoadNext',
Expand Down