|
1 | | -import{machine}from'../../extension' |
2 | | -import{TutorialModel}from'../../services/tutorial' |
3 | | -import*asCRfrom'typings' |
4 | | -import*asGfrom'typings/graphql' |
5 | | - |
6 | | - |
7 | | -exportdefault(tutorialModel:TutorialModel,editorDispatch:CR.EditorDispatch)=>({ |
8 | | -createWebview(){ |
9 | | -editorDispatch('coderoad.open_webview') |
10 | | -}, |
11 | | -asyncnewOrContinue(){ |
12 | | -// verify that the user has an existing tutorial to continue |
13 | | -consthasExistingTutorial:boolean=awaittutorialModel.hasExisting() |
14 | | -machine.send(hasExistingTutorial ?'CONTINUE' :'NEW') |
15 | | -}, |
16 | | -testRunnerSetup(){ |
17 | | -constcodingLanguage:G.EnumCodingLanguage=tutorialModel.config.codingLanguage |
18 | | -editorDispatch('coderoad.test_runner_setup',codingLanguage) |
19 | | -}, |
20 | | -initializeNewTutorial:()=>{ |
21 | | -console.log('initializeNewTutorial') |
22 | | -}, |
23 | | -tutorialContinue(){ |
24 | | -console.log('tutorial continue') |
25 | | -}, |
26 | | -// tutorialContinue: assign({ |
27 | | -// // load initial data, progress & position |
28 | | -// data(): CR.TutorialData { |
29 | | -// console.log('ACTION: tutorialLoad.data') |
30 | | -// if (!currentTutorial) { |
31 | | -// throw new Error('No Tutorial loaded') |
32 | | -// } |
33 | | -// return currentTutorial.data |
34 | | -// }, |
35 | | -// progress(): CR.Progress { |
36 | | -// console.log('ACTION: tutorialLoad.progress') |
37 | | -// return currentProgress |
38 | | -// }, |
39 | | -// position(context: any): CR.Position { |
40 | | -// console.log('ACTION: tutorialLoad.position') |
41 | | -// if (!currentTutorial) { |
42 | | -// throw new Error('No Tutorial loaded') |
43 | | -// } |
44 | | -// const {data} = currentTutorial |
45 | | -// const position = calculatePosition({data, progress: currentProgress}) |
46 | | - |
47 | | -// console.log('position', position) |
48 | | -// return position |
49 | | -// }, |
50 | | -// }), |
51 | | -testStart(){ |
52 | | -editorDispatch('coderoad.run_test') |
53 | | -}, |
54 | | -testPass():void{ |
55 | | -editorDispatch('coderoad.test_pass') |
56 | | -// git.gitSaveCommit(tutorialModel.position) |
57 | | -}, |
58 | | -testFail(){ |
59 | | -editorDispatch('coderoad.test_fail') |
60 | | -}, |
61 | | -//@ts-ignore |
62 | | -progressUpdate(){ |
63 | | -tutorialModel.updateProgress() |
64 | | -tutorialModel.nextPosition() |
65 | | -}, |
66 | | - |
67 | | -// assign({ |
68 | | -// progress: (): CR.Progress => { |
69 | | - |
70 | | -// console.log('progress update') |
71 | | -// const {progress, position, data} = context |
72 | | -// const nextProgress = progress |
73 | | - |
74 | | -// nextProgress.steps[position.stepId] = true |
75 | | -// const {stepList} = data.stages[position.stageId] |
76 | | -// const stageComplete = stepList[stepList.length - 1] === position.stepId |
77 | | -// if (stageComplete) { |
78 | | -// nextProgress.stages[position.stageId] = true |
79 | | -// const {stageList} = data.levels[position.levelId] |
80 | | -// const levelComplete = stageList[stageList.length - 1] === position.stageId |
81 | | -// if (levelComplete) { |
82 | | -// nextProgress.levels[position.levelId] = true |
83 | | -// const {levelList} = data.summary |
84 | | -// const tutorialComplete = levelList[levelList.length - 1] === position.levelId |
85 | | -// if (tutorialComplete) { |
86 | | -// nextProgress.complete = true |
87 | | -// } |
88 | | -// } |
89 | | -// } |
90 | | -// console.log('progress update', nextProgress) |
91 | | -// storage.setProgress(nextProgress) |
92 | | -// return nextProgress |
93 | | -// }, |
94 | | -// }), |
95 | | -// stepLoadNext: assign({ |
96 | | -// position: (context: any): CR.Position => { |
97 | | -// const {data, position} = context |
98 | | -// const {stepList} = data.stages[position.stageId] |
99 | | -// const currentStepIndex = stepList.indexOf(position.stepId) |
100 | | - |
101 | | -// const nextStepId = currentStepIndex < stepList.length ? stepList[currentStepIndex + 1] : position.stepId |
102 | | - |
103 | | -// const nextPosition = { |
104 | | -// ...context.position, |
105 | | -// stepId: nextStepId, |
106 | | -// } |
107 | | - |
108 | | -// return nextPosition |
109 | | -// }, |
110 | | -// }), |
111 | | -loadLevel():void{ |
112 | | -tutorialModel.triggerCurrent('LEVEL') |
113 | | -}, |
114 | | -stageLoadNext(){ |
115 | | -console.log('stageLoadNext') |
116 | | -tutorialModel.nextPosition() |
117 | | -}, |
118 | | -loadStage():void{ |
119 | | -tutorialModel.triggerCurrent('STAGE') |
120 | | -}, |
121 | | -//@ts-ignore |
122 | | -// updatePosition: assign({ |
123 | | -// position: () => calculatePosition({ |
124 | | -// data: context.data, |
125 | | -// progress: context.progress, |
126 | | -// }), |
127 | | -// }), |
128 | | -stepLoadCommits():void{ |
129 | | -tutorialModel.triggerCurrent('STEP') |
130 | | -}, |
131 | | -}) |
| 1 | +// import {machine} from '../../extension' |
| 2 | +// import {cache} from '../../services/apollo' |
| 3 | +// import {editorDispatch} from '../../utils/vscode' |
| 4 | +// import * as CR from 'typings' |
| 5 | +// import * as G from 'typings/graphql' |
| 6 | +// import tutorialConfig from '../../services/apollo/queries/tutorialConfig' |
| 7 | + |
| 8 | + |
| 9 | +exportdefault{} |
| 10 | + |
| 11 | +// export default { |
| 12 | +// createWebview() { |
| 13 | +// editorDispatch('coderoad.open_webview') |
| 14 | +// }, |
| 15 | +// async newOrContinue() { |
| 16 | +// // verify that the user has an existing tutorial to continue |
| 17 | +// // const hasExistingTutorial: boolean = await tutorialModel.hasExisting() |
| 18 | +// // machine.send(hasExistingTutorial ? 'CONTINUE' : 'NEW') |
| 19 | +// }, |
| 20 | +// testRunnerSetup() { |
| 21 | +// const result = cache.readQuery({query: tutorialConfig}) |
| 22 | +// console.log('result', result) |
| 23 | +// // const codingLanguage: G.EnumCodingLanguage = result.data.codingLanguage |
| 24 | +// // editorDispatch('coderoad.test_runner_setup', codingLanguage) |
| 25 | +// }, |
| 26 | +// initializeNewTutorial: () => { |
| 27 | +// console.log('initializeNewTutorial') |
| 28 | +// }, |
| 29 | +// tutorialContinue() { |
| 30 | +// console.log('tutorial continue') |
| 31 | +// }, |
| 32 | +// testStart() { |
| 33 | +// editorDispatch('coderoad.run_test') |
| 34 | +// }, |
| 35 | +// testPass(): void { |
| 36 | +// editorDispatch('coderoad.test_pass') |
| 37 | +// // git.gitSaveCommit(tutorialModel.position) |
| 38 | +// }, |
| 39 | +// testFail() { |
| 40 | +// editorDispatch('coderoad.test_fail') |
| 41 | +// }, |
| 42 | +// //@ts-ignore |
| 43 | +// progressUpdate() { |
| 44 | +// // tutorialModel.updateProgress() |
| 45 | +// // tutorialModel.nextPosition() |
| 46 | +// }, |
| 47 | +// loadLevel(): void { |
| 48 | +// // tutorialModel.triggerCurrent('LEVEL') |
| 49 | +// }, |
| 50 | +// stageLoadNext() { |
| 51 | +// console.log('stageLoadNext') |
| 52 | +// // tutorialModel.nextPosition() |
| 53 | +// }, |
| 54 | +// loadStage(): void { |
| 55 | +// // tutorialModel.triggerCurrent('STAGE') |
| 56 | +// }, |
| 57 | +// stepLoadCommits(): void { |
| 58 | +// // tutorialModel.triggerCurrent('STEP') |
| 59 | +// }, |
| 60 | +// } |