Skip to content

Commit d59f4c9

Browse files
committed
Revert "Added Template Reset Feature"
This reverts commit 3c1457e.
1 parent 3c1457e commit d59f4c9

File tree

4 files changed

+14
-127
lines changed

4 files changed

+14
-127
lines changed

src/components/assessment/AssessmentWorkspace.tsx

Lines changed: 11 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
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'
112
import { IconNames } from '@blueprintjs/icons'
123
import * as React from 'react'
134

145
import { InterpreterOutput, IWorkspaceState } from '../../reducers/states'
156
import { beforeNow } from '../../utils/dateHelpers'
167
import { history } from '../../utils/history'
178
import { assessmentCategoryLink } from '../../utils/paramParseHelpers'
18-
import { controlButton } from '../commons'
199
import Markdown from '../commons/Markdown'
2010
import Workspace, { WorkspaceProps } from '../workspace'
2111
import { ControlBarProps } from '../workspace/ControlBar'
@@ -77,15 +67,13 @@ export type DispatchProps = {
7767

7868
class AssessmentWorkspace extends React.Component<
7969
AssessmentWorkspaceProps,
80-
{ showOverlay: boolean; showResetOverlay: boolean }
70+
{ showOverlay: boolean }
8171
> {
8272
public constructor(props: AssessmentWorkspaceProps) {
8373
super(props)
8474
this.state = {
85-
showOverlay: false,
86-
showResetOverlay: false
75+
showOverlay: false
8776
}
88-
this.props.handleEditorValueChange('')
8977
}
9078

9179
/**
@@ -98,20 +86,6 @@ class AssessmentWorkspace extends React.Component<
9886
if (this.props.questionId === 0 && this.props.notAttempted) {
9987
this.setState({ showOverlay: true })
10088
}
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-
}
11589
}
11690

11791
/**
@@ -145,53 +119,24 @@ class AssessmentWorkspace extends React.Component<
145119
</Card>
146120
</Dialog>
147121
)
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-
)
183122
/* If questionId is out of bounds, set it to the max. */
184123
const questionId =
185124
this.props.questionId >= this.props.assessment.questions.length
186125
? this.props.assessment.questions.length - 1
187126
: this.props.questionId
188127
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
189134
const workspaceProps: WorkspaceProps = {
190135
controlBarProps: this.controlBarProps(this.props, questionId),
191136
editorProps:
192137
question.type === QuestionTypes.programming
193138
? {
194-
editorValue: this.props.editorValue!,
139+
editorValue: editorValue!,
195140
handleEditorEval: this.props.handleEditorEval,
196141
handleEditorValueChange: this.props.handleEditorValueChange,
197142
handleUpdateHasUnsavedChanges: this.props.handleUpdateHasUnsavedChanges
@@ -220,7 +165,6 @@ class AssessmentWorkspace extends React.Component<
220165
return (
221166
<div className="WorkspaceParent pt-dark">
222167
{overlay}
223-
{resetOverlay}
224168
<Workspace {...workspaceProps} />
225169
</div>
226170
)
@@ -250,7 +194,7 @@ class AssessmentWorkspace extends React.Component<
250194
? question.answer !== null
251195
? ((question as IProgrammingQuestion).answer as string)
252196
: (question as IProgrammingQuestion).solutionTemplate
253-
: ''
197+
: null
254198
this.props.handleUpdateCurrentAssessmentId(assessmentId, questionId)
255199
this.props.handleResetWorkspace({ editorValue })
256200
this.props.handleClearContext(question.library)
@@ -341,9 +285,6 @@ class AssessmentWorkspace extends React.Component<
341285
this.props.assessment!.questions[questionId].id,
342286
this.props.editorValue!
343287
),
344-
onClickReset: () => {
345-
this.setState({ showResetOverlay: true })
346-
},
347288
questionProgress: [questionId + 1, this.props.assessment!.questions.length],
348289
sourceChapter: this.props.assessment!.questions[questionId].library.chapter
349290
}

src/components/assessment/__tests__/__snapshots__/AssessmentWorkspace.tsx.snap

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,6 @@ exports[`AssessmentWorkspace page with MCQ question renders correctly 1`] = `
1010
<Blueprint2.Button className=\\"assessment-briefing-button\\" onClick={[Function: onClick]} text=\\"Continue\\" />
1111
</Blueprint2.Card>
1212
</Blueprint2.Dialog>
13-
<Blueprint2.Dialog className=\\"assessment-reset\\" icon=\\"error\\" isCloseButtonShown={false} isOpen={false} title=\\"Confirmation: Reset editor?\\" canOutsideClickClose={true}>
14-
<div className=\\"pt-dialog-body\\">
15-
<Markdown content=\\"Are you sure you want to reset the template?\\" />
16-
<Markdown content=\\"*Note this will not affect the saved copy of your code, unless you save over it.*\\" />
17-
</div>
18-
<div className=\\"pt-dialog-footer\\">
19-
<Blueprint2.ButtonGroup>
20-
<Blueprint2.Button disabled={false} fill={false} intent=\\"none\\" minimal={false} className=\\"\\" onClick={[Function]}>
21-
Cancel
22-
</Blueprint2.Button>
23-
<Blueprint2.Button disabled={false} fill={false} intent=\\"danger\\" minimal={false} className=\\"\\" onClick={[Function]}>
24-
Confirm
25-
</Blueprint2.Button>
26-
</Blueprint2.ButtonGroup>
27-
</div>
28-
</Blueprint2.Dialog>
2913
<Workspace controlBarProps={{...}} editorProps={[undefined]} editorWidth=\\"50%\\" handleEditorWidthChange={[Function: handleEditorWidthChange]} handleSideContentHeightChange={[Function: handleSideContentHeightChange]} hasUnsavedChanges={false} mcqProps={{...}} sideContentHeight={[undefined]} sideContentProps={{...}} replProps={{...}} />
3014
</div>"
3115
`;
@@ -38,22 +22,6 @@ exports[`AssessmentWorkspace page with overdue assessment renders correctly 1`]
3822
<Blueprint2.Button className=\\"assessment-briefing-button\\" onClick={[Function: onClick]} text=\\"Continue\\" />
3923
</Blueprint2.Card>
4024
</Blueprint2.Dialog>
41-
<Blueprint2.Dialog className=\\"assessment-reset\\" icon=\\"error\\" isCloseButtonShown={false} isOpen={false} title=\\"Confirmation: Reset editor?\\" canOutsideClickClose={true}>
42-
<div className=\\"pt-dialog-body\\">
43-
<Markdown content=\\"Are you sure you want to reset the template?\\" />
44-
<Markdown content=\\"*Note this will not affect the saved copy of your code, unless you save over it.*\\" />
45-
</div>
46-
<div className=\\"pt-dialog-footer\\">
47-
<Blueprint2.ButtonGroup>
48-
<Blueprint2.Button disabled={false} fill={false} intent=\\"none\\" minimal={false} className=\\"\\" onClick={[Function]}>
49-
Cancel
50-
</Blueprint2.Button>
51-
<Blueprint2.Button disabled={false} fill={false} intent=\\"danger\\" minimal={false} className=\\"\\" onClick={[Function]}>
52-
Confirm
53-
</Blueprint2.Button>
54-
</Blueprint2.ButtonGroup>
55-
</div>
56-
</Blueprint2.Dialog>
5725
<Workspace controlBarProps={{...}} editorProps={{...}} editorWidth=\\"50%\\" handleEditorWidthChange={[Function: handleEditorWidthChange]} handleSideContentHeightChange={[Function: handleSideContentHeightChange]} hasUnsavedChanges={false} mcqProps={{...}} sideContentHeight={[undefined]} sideContentProps={{...}} replProps={{...}} />
5826
</div>"
5927
`;
@@ -66,22 +34,6 @@ exports[`AssessmentWorkspace page with programming question renders correctly 1`
6634
<Blueprint2.Button className=\\"assessment-briefing-button\\" onClick={[Function: onClick]} text=\\"Continue\\" />
6735
</Blueprint2.Card>
6836
</Blueprint2.Dialog>
69-
<Blueprint2.Dialog className=\\"assessment-reset\\" icon=\\"error\\" isCloseButtonShown={false} isOpen={false} title=\\"Confirmation: Reset editor?\\" canOutsideClickClose={true}>
70-
<div className=\\"pt-dialog-body\\">
71-
<Markdown content=\\"Are you sure you want to reset the template?\\" />
72-
<Markdown content=\\"*Note this will not affect the saved copy of your code, unless you save over it.*\\" />
73-
</div>
74-
<div className=\\"pt-dialog-footer\\">
75-
<Blueprint2.ButtonGroup>
76-
<Blueprint2.Button disabled={false} fill={false} intent=\\"none\\" minimal={false} className=\\"\\" onClick={[Function]}>
77-
Cancel
78-
</Blueprint2.Button>
79-
<Blueprint2.Button disabled={false} fill={false} intent=\\"danger\\" minimal={false} className=\\"\\" onClick={[Function]}>
80-
Confirm
81-
</Blueprint2.Button>
82-
</Blueprint2.ButtonGroup>
83-
</div>
84-
</Blueprint2.Dialog>
8537
<Workspace controlBarProps={{...}} editorProps={{...}} editorWidth=\\"50%\\" handleEditorWidthChange={[Function: handleEditorWidthChange]} handleSideContentHeightChange={[Function: handleSideContentHeightChange]} hasUnsavedChanges={false} mcqProps={{...}} sideContentHeight={[undefined]} sideContentProps={{...}} replProps={{...}} />
8638
</div>"
8739
`;

src/components/workspace/ControlBar.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export type ControlBarProps = {
3434
onClickPrevious?(): any
3535
onClickReturn?(): any
3636
onClickSave?(): any
37-
onClickReset?(): any
3837
}
3938

4039
interface IChapter {
@@ -60,8 +59,7 @@ class ControlBar extends React.PureComponent<ControlBarProps, {}> {
6059
hasShareButton: true,
6160
onClickNext: () => {},
6261
onClickPrevious: () => {},
63-
onClickSave: () => {},
64-
onClickReset: () => {}
62+
onClickSave: () => {}
6563
}
6664

6765
private shareInputElem: HTMLInputElement
@@ -129,13 +127,10 @@ class ControlBar extends React.PureComponent<ControlBarProps, {}> {
129127
this.props.hasChapterSelect && this.props.externalLibraryName !== undefined
130128
? externalSelect(this.props.externalLibraryName, this.props.handleExternalSelect!)
131129
: undefined
132-
const resetButton = this.props.hasSaveButton
133-
? controlButton('Reset', IconNames.REPEAT, this.props.onClickReset)
134-
: undefined
135130
return (
136131
<div className="ControlBar_editor pt-button-group">
137132
{this.props.isRunning ? stopButton : runButton} {saveButton}
138-
{shareButton} {chapterSelectButton} {externalSelectButton} {resetButton}
133+
{shareButton} {chapterSelectButton} {externalSelectButton}
139134
</div>
140135
)
141136
}

src/styles/_academy.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@
129129
}
130130
}
131131

132-
.betcha-dialog,
133-
.assessment-reset {
132+
.betcha-dialog {
134133
span.warning {
135134
font-weight: bold;
136135
color: firebrick;

0 commit comments

Comments
 (0)