1
- import {
2
- Button ,
3
- ButtonGroup ,
4
- Card ,
5
- Classes ,
6
- Dialog ,
7
- Intent ,
8
- NonIdealState ,
9
- Spinner
10
- } from '@blueprintjs/core'
1
+ import { Button , Card , Dialog , NonIdealState , Spinner } from '@blueprintjs/core'
11
2
import { IconNames } from '@blueprintjs/icons'
12
3
import * as React from 'react'
13
4
14
5
import { InterpreterOutput , IWorkspaceState } from '../../reducers/states'
15
6
import { beforeNow } from '../../utils/dateHelpers'
16
7
import { history } from '../../utils/history'
17
8
import { assessmentCategoryLink } from '../../utils/paramParseHelpers'
18
- import { controlButton } from '../commons'
19
9
import Markdown from '../commons/Markdown'
20
10
import Workspace , { WorkspaceProps } from '../workspace'
21
11
import { ControlBarProps } from '../workspace/ControlBar'
@@ -77,15 +67,13 @@ export type DispatchProps = {
77
67
78
68
class AssessmentWorkspace extends React . Component <
79
69
AssessmentWorkspaceProps ,
80
- { showOverlay : boolean ; showResetOverlay : boolean }
70
+ { showOverlay : boolean }
81
71
> {
82
72
public constructor ( props : AssessmentWorkspaceProps ) {
83
73
super ( props )
84
74
this . state = {
85
- showOverlay : false ,
86
- showResetOverlay : false
75
+ showOverlay : false
87
76
}
88
- this . props . handleEditorValueChange ( '' )
89
77
}
90
78
91
79
/**
@@ -98,20 +86,6 @@ class AssessmentWorkspace extends React.Component<
98
86
if ( this . props . questionId === 0 && this . props . notAttempted ) {
99
87
this . setState ( { showOverlay : true } )
100
88
}
101
- if ( this . props . assessment ) {
102
- const question : IQuestion = this . props . assessment . questions [
103
- this . props . questionId >= this . props . assessment . questions . length
104
- ? this . props . assessment . questions . length - 1
105
- : this . props . questionId
106
- ]
107
- this . props . handleEditorValueChange (
108
- question . type === QuestionTypes . programming
109
- ? question . answer !== null
110
- ? ( ( question as IProgrammingQuestion ) . answer as string )
111
- : ( question as IProgrammingQuestion ) . solutionTemplate
112
- : ''
113
- )
114
- }
115
89
}
116
90
117
91
/**
@@ -145,53 +119,24 @@ class AssessmentWorkspace extends React.Component<
145
119
</ Card >
146
120
</ Dialog >
147
121
)
148
-
149
- const resetOverlay = (
150
- < Dialog
151
- className = "assessment-reset"
152
- icon = { IconNames . ERROR }
153
- isCloseButtonShown = { false }
154
- isOpen = { this . state . showResetOverlay }
155
- title = "Confirmation: Reset editor?"
156
- >
157
- < div className = { Classes . DIALOG_BODY } >
158
- < Markdown content = "Are you sure you want to reset the template?" />
159
- < Markdown content = "*Note this will not affect the saved copy of your code, unless you save over it.*" />
160
- </ div >
161
- < div className = { Classes . DIALOG_FOOTER } >
162
- < ButtonGroup >
163
- { controlButton ( 'Cancel' , null , ( ) => this . setState ( { showResetOverlay : false } ) , {
164
- minimal : false
165
- } ) }
166
- { controlButton (
167
- 'Confirm' ,
168
- null ,
169
- ( ) => {
170
- this . setState ( { showResetOverlay : false } )
171
- this . props . handleEditorValueChange (
172
- ( this . props . assessment ! . questions [ questionId ] as IProgrammingQuestion )
173
- . solutionTemplate
174
- )
175
- this . props . handleUpdateHasUnsavedChanges ( true )
176
- } ,
177
- { minimal : false , intent : Intent . DANGER }
178
- ) }
179
- </ ButtonGroup >
180
- </ div >
181
- </ Dialog >
182
- )
183
122
/* If questionId is out of bounds, set it to the max. */
184
123
const questionId =
185
124
this . props . questionId >= this . props . assessment . questions . length
186
125
? this . props . assessment . questions . length - 1
187
126
: this . props . questionId
188
127
const question : IQuestion = this . props . assessment . questions [ questionId ]
128
+ const editorValue =
129
+ question . type === QuestionTypes . programming
130
+ ? question . answer !== null
131
+ ? ( ( question as IProgrammingQuestion ) . answer as string )
132
+ : ( question as IProgrammingQuestion ) . solutionTemplate
133
+ : null
189
134
const workspaceProps : WorkspaceProps = {
190
135
controlBarProps : this . controlBarProps ( this . props , questionId ) ,
191
136
editorProps :
192
137
question . type === QuestionTypes . programming
193
138
? {
194
- editorValue : this . props . editorValue ! ,
139
+ editorValue : editorValue ! ,
195
140
handleEditorEval : this . props . handleEditorEval ,
196
141
handleEditorValueChange : this . props . handleEditorValueChange ,
197
142
handleUpdateHasUnsavedChanges : this . props . handleUpdateHasUnsavedChanges
@@ -220,7 +165,6 @@ class AssessmentWorkspace extends React.Component<
220
165
return (
221
166
< div className = "WorkspaceParent pt-dark" >
222
167
{ overlay }
223
- { resetOverlay }
224
168
< Workspace { ...workspaceProps } />
225
169
</ div >
226
170
)
@@ -250,7 +194,7 @@ class AssessmentWorkspace extends React.Component<
250
194
? question . answer !== null
251
195
? ( ( question as IProgrammingQuestion ) . answer as string )
252
196
: ( question as IProgrammingQuestion ) . solutionTemplate
253
- : ''
197
+ : null
254
198
this . props . handleUpdateCurrentAssessmentId ( assessmentId , questionId )
255
199
this . props . handleResetWorkspace ( { editorValue } )
256
200
this . props . handleClearContext ( question . library )
@@ -341,9 +285,6 @@ class AssessmentWorkspace extends React.Component<
341
285
this . props . assessment ! . questions [ questionId ] . id ,
342
286
this . props . editorValue !
343
287
) ,
344
- onClickReset : ( ) => {
345
- this . setState ( { showResetOverlay : true } )
346
- } ,
347
288
questionProgress : [ questionId + 1 , this . props . assessment ! . questions . length ] ,
348
289
sourceChapter : this . props . assessment ! . questions [ questionId ] . library . chapter
349
290
}
0 commit comments