From 3c1457e07a276ebb8d8a9e3a0cae968688d40711 Mon Sep 17 00:00:00 2001 From: Shuming Date: Mon, 18 Feb 2019 21:14:07 +0800 Subject: [PATCH 1/4] Added Template Reset Feature --- .../assessment/AssessmentWorkspace.tsx | 81 ++++++++++++++++--- .../AssessmentWorkspace.tsx.snap | 48 +++++++++++ src/components/workspace/ControlBar.tsx | 9 ++- src/styles/_academy.scss | 3 +- 4 files changed, 127 insertions(+), 14 deletions(-) diff --git a/src/components/assessment/AssessmentWorkspace.tsx b/src/components/assessment/AssessmentWorkspace.tsx index 3bc08155e7..84bbbfecaf 100644 --- a/src/components/assessment/AssessmentWorkspace.tsx +++ b/src/components/assessment/AssessmentWorkspace.tsx @@ -1,4 +1,13 @@ -import { Button, Card, Dialog, NonIdealState, Spinner } from '@blueprintjs/core' +import { + Button, + ButtonGroup, + Card, + Classes, + Dialog, + Intent, + NonIdealState, + Spinner +} from '@blueprintjs/core' import { IconNames } from '@blueprintjs/icons' import * as React from 'react' @@ -6,6 +15,7 @@ import { InterpreterOutput, IWorkspaceState } from '../../reducers/states' import { beforeNow } from '../../utils/dateHelpers' import { history } from '../../utils/history' import { assessmentCategoryLink } from '../../utils/paramParseHelpers' +import { controlButton } from '../commons' import Markdown from '../commons/Markdown' import Workspace, { WorkspaceProps } from '../workspace' import { ControlBarProps } from '../workspace/ControlBar' @@ -67,13 +77,15 @@ export type DispatchProps = { class AssessmentWorkspace extends React.Component< AssessmentWorkspaceProps, - { showOverlay: boolean } + { showOverlay: boolean; showResetOverlay: boolean } > { public constructor(props: AssessmentWorkspaceProps) { super(props) this.state = { - showOverlay: false + showOverlay: false, + showResetOverlay: false } + this.props.handleEditorValueChange('') } /** @@ -86,6 +98,20 @@ class AssessmentWorkspace extends React.Component< if (this.props.questionId === 0 && this.props.notAttempted) { this.setState({ showOverlay: true }) } + if (this.props.assessment) { + const question: IQuestion = this.props.assessment.questions[ + this.props.questionId >= this.props.assessment.questions.length + ? this.props.assessment.questions.length - 1 + : this.props.questionId + ] + this.props.handleEditorValueChange( + question.type === QuestionTypes.programming + ? question.answer !== null + ? ((question as IProgrammingQuestion).answer as string) + : (question as IProgrammingQuestion).solutionTemplate + : '' + ) + } } /** @@ -119,24 +145,53 @@ class AssessmentWorkspace extends React.Component< ) + + const resetOverlay = ( + +
+ + +
+
+ + {controlButton('Cancel', null, () => this.setState({ showResetOverlay: false }), { + minimal: false + })} + {controlButton( + 'Confirm', + null, + () => { + this.setState({ showResetOverlay: false }) + this.props.handleEditorValueChange( + (this.props.assessment!.questions[questionId] as IProgrammingQuestion) + .solutionTemplate + ) + this.props.handleUpdateHasUnsavedChanges(true) + }, + { minimal: false, intent: Intent.DANGER } + )} + +
+
+ ) /* If questionId is out of bounds, set it to the max. */ const questionId = this.props.questionId >= this.props.assessment.questions.length ? this.props.assessment.questions.length - 1 : this.props.questionId const question: IQuestion = this.props.assessment.questions[questionId] - const editorValue = - question.type === QuestionTypes.programming - ? question.answer !== null - ? ((question as IProgrammingQuestion).answer as string) - : (question as IProgrammingQuestion).solutionTemplate - : null const workspaceProps: WorkspaceProps = { controlBarProps: this.controlBarProps(this.props, questionId), editorProps: question.type === QuestionTypes.programming ? { - editorValue: editorValue!, + editorValue: this.props.editorValue!, handleEditorEval: this.props.handleEditorEval, handleEditorValueChange: this.props.handleEditorValueChange, handleUpdateHasUnsavedChanges: this.props.handleUpdateHasUnsavedChanges @@ -165,6 +220,7 @@ class AssessmentWorkspace extends React.Component< return (
{overlay} + {resetOverlay}
) @@ -194,7 +250,7 @@ class AssessmentWorkspace extends React.Component< ? question.answer !== null ? ((question as IProgrammingQuestion).answer as string) : (question as IProgrammingQuestion).solutionTemplate - : null + : '' this.props.handleUpdateCurrentAssessmentId(assessmentId, questionId) this.props.handleResetWorkspace({ editorValue }) this.props.handleClearContext(question.library) @@ -285,6 +341,9 @@ class AssessmentWorkspace extends React.Component< this.props.assessment!.questions[questionId].id, this.props.editorValue! ), + onClickReset: () => { + this.setState({ showResetOverlay: true }) + }, questionProgress: [questionId + 1, this.props.assessment!.questions.length], sourceChapter: this.props.assessment!.questions[questionId].library.chapter } diff --git a/src/components/assessment/__tests__/__snapshots__/AssessmentWorkspace.tsx.snap b/src/components/assessment/__tests__/__snapshots__/AssessmentWorkspace.tsx.snap index dc954779c5..a3a3c8643e 100644 --- a/src/components/assessment/__tests__/__snapshots__/AssessmentWorkspace.tsx.snap +++ b/src/components/assessment/__tests__/__snapshots__/AssessmentWorkspace.tsx.snap @@ -10,6 +10,22 @@ exports[`AssessmentWorkspace page with MCQ question renders correctly 1`] = ` + +
+ + +
+
+ + + Cancel + + + Confirm + + +
+
" `; @@ -22,6 +38,22 @@ exports[`AssessmentWorkspace page with overdue assessment renders correctly 1`] + +
+ + +
+
+ + + Cancel + + + Confirm + + +
+
" `; @@ -34,6 +66,22 @@ exports[`AssessmentWorkspace page with programming question renders correctly 1` + +
+ + +
+
+ + + Cancel + + + Confirm + + +
+
" `; diff --git a/src/components/workspace/ControlBar.tsx b/src/components/workspace/ControlBar.tsx index 98c4f18176..56f3b4fb58 100644 --- a/src/components/workspace/ControlBar.tsx +++ b/src/components/workspace/ControlBar.tsx @@ -34,6 +34,7 @@ export type ControlBarProps = { onClickPrevious?(): any onClickReturn?(): any onClickSave?(): any + onClickReset?(): any } interface IChapter { @@ -59,7 +60,8 @@ class ControlBar extends React.PureComponent { hasShareButton: true, onClickNext: () => {}, onClickPrevious: () => {}, - onClickSave: () => {} + onClickSave: () => {}, + onClickReset: () => {} } private shareInputElem: HTMLInputElement @@ -127,10 +129,13 @@ class ControlBar extends React.PureComponent { this.props.hasChapterSelect && this.props.externalLibraryName !== undefined ? externalSelect(this.props.externalLibraryName, this.props.handleExternalSelect!) : undefined + const resetButton = this.props.hasSaveButton + ? controlButton('Reset', IconNames.REPEAT, this.props.onClickReset) + : undefined return (
{this.props.isRunning ? stopButton : runButton} {saveButton} - {shareButton} {chapterSelectButton} {externalSelectButton} + {shareButton} {chapterSelectButton} {externalSelectButton} {resetButton}
) } diff --git a/src/styles/_academy.scss b/src/styles/_academy.scss index e584891821..1905c06a4a 100644 --- a/src/styles/_academy.scss +++ b/src/styles/_academy.scss @@ -129,7 +129,8 @@ } } -.betcha-dialog { +.betcha-dialog, +.assessment-reset { span.warning { font-weight: bold; color: firebrick; From d59f4c9740742ca85cac1a5fe972155a85aea1f0 Mon Sep 17 00:00:00 2001 From: Shuming Date: Fri, 22 Feb 2019 11:47:03 +0800 Subject: [PATCH 2/4] Revert "Added Template Reset Feature" This reverts commit 3c1457e07a276ebb8d8a9e3a0cae968688d40711. --- .../assessment/AssessmentWorkspace.tsx | 81 +++---------------- .../AssessmentWorkspace.tsx.snap | 48 ----------- src/components/workspace/ControlBar.tsx | 9 +-- src/styles/_academy.scss | 3 +- 4 files changed, 14 insertions(+), 127 deletions(-) diff --git a/src/components/assessment/AssessmentWorkspace.tsx b/src/components/assessment/AssessmentWorkspace.tsx index 84bbbfecaf..3bc08155e7 100644 --- a/src/components/assessment/AssessmentWorkspace.tsx +++ b/src/components/assessment/AssessmentWorkspace.tsx @@ -1,13 +1,4 @@ -import { - Button, - ButtonGroup, - Card, - Classes, - Dialog, - Intent, - NonIdealState, - Spinner -} from '@blueprintjs/core' +import { Button, Card, Dialog, NonIdealState, Spinner } from '@blueprintjs/core' import { IconNames } from '@blueprintjs/icons' import * as React from 'react' @@ -15,7 +6,6 @@ import { InterpreterOutput, IWorkspaceState } from '../../reducers/states' import { beforeNow } from '../../utils/dateHelpers' import { history } from '../../utils/history' import { assessmentCategoryLink } from '../../utils/paramParseHelpers' -import { controlButton } from '../commons' import Markdown from '../commons/Markdown' import Workspace, { WorkspaceProps } from '../workspace' import { ControlBarProps } from '../workspace/ControlBar' @@ -77,15 +67,13 @@ export type DispatchProps = { class AssessmentWorkspace extends React.Component< AssessmentWorkspaceProps, - { showOverlay: boolean; showResetOverlay: boolean } + { showOverlay: boolean } > { public constructor(props: AssessmentWorkspaceProps) { super(props) this.state = { - showOverlay: false, - showResetOverlay: false + showOverlay: false } - this.props.handleEditorValueChange('') } /** @@ -98,20 +86,6 @@ class AssessmentWorkspace extends React.Component< if (this.props.questionId === 0 && this.props.notAttempted) { this.setState({ showOverlay: true }) } - if (this.props.assessment) { - const question: IQuestion = this.props.assessment.questions[ - this.props.questionId >= this.props.assessment.questions.length - ? this.props.assessment.questions.length - 1 - : this.props.questionId - ] - this.props.handleEditorValueChange( - question.type === QuestionTypes.programming - ? question.answer !== null - ? ((question as IProgrammingQuestion).answer as string) - : (question as IProgrammingQuestion).solutionTemplate - : '' - ) - } } /** @@ -145,53 +119,24 @@ class AssessmentWorkspace extends React.Component< ) - - const resetOverlay = ( - -
- - -
-
- - {controlButton('Cancel', null, () => this.setState({ showResetOverlay: false }), { - minimal: false - })} - {controlButton( - 'Confirm', - null, - () => { - this.setState({ showResetOverlay: false }) - this.props.handleEditorValueChange( - (this.props.assessment!.questions[questionId] as IProgrammingQuestion) - .solutionTemplate - ) - this.props.handleUpdateHasUnsavedChanges(true) - }, - { minimal: false, intent: Intent.DANGER } - )} - -
-
- ) /* If questionId is out of bounds, set it to the max. */ const questionId = this.props.questionId >= this.props.assessment.questions.length ? this.props.assessment.questions.length - 1 : this.props.questionId const question: IQuestion = this.props.assessment.questions[questionId] + const editorValue = + question.type === QuestionTypes.programming + ? question.answer !== null + ? ((question as IProgrammingQuestion).answer as string) + : (question as IProgrammingQuestion).solutionTemplate + : null const workspaceProps: WorkspaceProps = { controlBarProps: this.controlBarProps(this.props, questionId), editorProps: question.type === QuestionTypes.programming ? { - editorValue: this.props.editorValue!, + editorValue: editorValue!, handleEditorEval: this.props.handleEditorEval, handleEditorValueChange: this.props.handleEditorValueChange, handleUpdateHasUnsavedChanges: this.props.handleUpdateHasUnsavedChanges @@ -220,7 +165,6 @@ class AssessmentWorkspace extends React.Component< return (
{overlay} - {resetOverlay}
) @@ -250,7 +194,7 @@ class AssessmentWorkspace extends React.Component< ? question.answer !== null ? ((question as IProgrammingQuestion).answer as string) : (question as IProgrammingQuestion).solutionTemplate - : '' + : null this.props.handleUpdateCurrentAssessmentId(assessmentId, questionId) this.props.handleResetWorkspace({ editorValue }) this.props.handleClearContext(question.library) @@ -341,9 +285,6 @@ class AssessmentWorkspace extends React.Component< this.props.assessment!.questions[questionId].id, this.props.editorValue! ), - onClickReset: () => { - this.setState({ showResetOverlay: true }) - }, questionProgress: [questionId + 1, this.props.assessment!.questions.length], sourceChapter: this.props.assessment!.questions[questionId].library.chapter } diff --git a/src/components/assessment/__tests__/__snapshots__/AssessmentWorkspace.tsx.snap b/src/components/assessment/__tests__/__snapshots__/AssessmentWorkspace.tsx.snap index a3a3c8643e..dc954779c5 100644 --- a/src/components/assessment/__tests__/__snapshots__/AssessmentWorkspace.tsx.snap +++ b/src/components/assessment/__tests__/__snapshots__/AssessmentWorkspace.tsx.snap @@ -10,22 +10,6 @@ exports[`AssessmentWorkspace page with MCQ question renders correctly 1`] = ` - -
- - -
-
- - - Cancel - - - Confirm - - -
-
" `; @@ -38,22 +22,6 @@ exports[`AssessmentWorkspace page with overdue assessment renders correctly 1`] - -
- - -
-
- - - Cancel - - - Confirm - - -
-
" `; @@ -66,22 +34,6 @@ exports[`AssessmentWorkspace page with programming question renders correctly 1` - -
- - -
-
- - - Cancel - - - Confirm - - -
-
" `; diff --git a/src/components/workspace/ControlBar.tsx b/src/components/workspace/ControlBar.tsx index 56f3b4fb58..98c4f18176 100644 --- a/src/components/workspace/ControlBar.tsx +++ b/src/components/workspace/ControlBar.tsx @@ -34,7 +34,6 @@ export type ControlBarProps = { onClickPrevious?(): any onClickReturn?(): any onClickSave?(): any - onClickReset?(): any } interface IChapter { @@ -60,8 +59,7 @@ class ControlBar extends React.PureComponent { hasShareButton: true, onClickNext: () => {}, onClickPrevious: () => {}, - onClickSave: () => {}, - onClickReset: () => {} + onClickSave: () => {} } private shareInputElem: HTMLInputElement @@ -129,13 +127,10 @@ class ControlBar extends React.PureComponent { this.props.hasChapterSelect && this.props.externalLibraryName !== undefined ? externalSelect(this.props.externalLibraryName, this.props.handleExternalSelect!) : undefined - const resetButton = this.props.hasSaveButton - ? controlButton('Reset', IconNames.REPEAT, this.props.onClickReset) - : undefined return (
{this.props.isRunning ? stopButton : runButton} {saveButton} - {shareButton} {chapterSelectButton} {externalSelectButton} {resetButton} + {shareButton} {chapterSelectButton} {externalSelectButton}
) } diff --git a/src/styles/_academy.scss b/src/styles/_academy.scss index 1905c06a4a..e584891821 100644 --- a/src/styles/_academy.scss +++ b/src/styles/_academy.scss @@ -129,8 +129,7 @@ } } -.betcha-dialog, -.assessment-reset { +.betcha-dialog { span.warning { font-weight: bold; color: firebrick; From 2991432c6a376c1923a85344c764fc12de62feec Mon Sep 17 00:00:00 2001 From: Shuming Date: Fri, 22 Feb 2019 11:47:22 +0800 Subject: [PATCH 3/4] Revert "Revert "Added Template Reset Feature"" This reverts commit d59f4c9740742ca85cac1a5fe972155a85aea1f0. --- .../assessment/AssessmentWorkspace.tsx | 81 ++++++++++++++++--- .../AssessmentWorkspace.tsx.snap | 48 +++++++++++ src/components/workspace/ControlBar.tsx | 9 ++- src/styles/_academy.scss | 3 +- 4 files changed, 127 insertions(+), 14 deletions(-) diff --git a/src/components/assessment/AssessmentWorkspace.tsx b/src/components/assessment/AssessmentWorkspace.tsx index 3bc08155e7..84bbbfecaf 100644 --- a/src/components/assessment/AssessmentWorkspace.tsx +++ b/src/components/assessment/AssessmentWorkspace.tsx @@ -1,4 +1,13 @@ -import { Button, Card, Dialog, NonIdealState, Spinner } from '@blueprintjs/core' +import { + Button, + ButtonGroup, + Card, + Classes, + Dialog, + Intent, + NonIdealState, + Spinner +} from '@blueprintjs/core' import { IconNames } from '@blueprintjs/icons' import * as React from 'react' @@ -6,6 +15,7 @@ import { InterpreterOutput, IWorkspaceState } from '../../reducers/states' import { beforeNow } from '../../utils/dateHelpers' import { history } from '../../utils/history' import { assessmentCategoryLink } from '../../utils/paramParseHelpers' +import { controlButton } from '../commons' import Markdown from '../commons/Markdown' import Workspace, { WorkspaceProps } from '../workspace' import { ControlBarProps } from '../workspace/ControlBar' @@ -67,13 +77,15 @@ export type DispatchProps = { class AssessmentWorkspace extends React.Component< AssessmentWorkspaceProps, - { showOverlay: boolean } + { showOverlay: boolean; showResetOverlay: boolean } > { public constructor(props: AssessmentWorkspaceProps) { super(props) this.state = { - showOverlay: false + showOverlay: false, + showResetOverlay: false } + this.props.handleEditorValueChange('') } /** @@ -86,6 +98,20 @@ class AssessmentWorkspace extends React.Component< if (this.props.questionId === 0 && this.props.notAttempted) { this.setState({ showOverlay: true }) } + if (this.props.assessment) { + const question: IQuestion = this.props.assessment.questions[ + this.props.questionId >= this.props.assessment.questions.length + ? this.props.assessment.questions.length - 1 + : this.props.questionId + ] + this.props.handleEditorValueChange( + question.type === QuestionTypes.programming + ? question.answer !== null + ? ((question as IProgrammingQuestion).answer as string) + : (question as IProgrammingQuestion).solutionTemplate + : '' + ) + } } /** @@ -119,24 +145,53 @@ class AssessmentWorkspace extends React.Component< ) + + const resetOverlay = ( + +
+ + +
+
+ + {controlButton('Cancel', null, () => this.setState({ showResetOverlay: false }), { + minimal: false + })} + {controlButton( + 'Confirm', + null, + () => { + this.setState({ showResetOverlay: false }) + this.props.handleEditorValueChange( + (this.props.assessment!.questions[questionId] as IProgrammingQuestion) + .solutionTemplate + ) + this.props.handleUpdateHasUnsavedChanges(true) + }, + { minimal: false, intent: Intent.DANGER } + )} + +
+
+ ) /* If questionId is out of bounds, set it to the max. */ const questionId = this.props.questionId >= this.props.assessment.questions.length ? this.props.assessment.questions.length - 1 : this.props.questionId const question: IQuestion = this.props.assessment.questions[questionId] - const editorValue = - question.type === QuestionTypes.programming - ? question.answer !== null - ? ((question as IProgrammingQuestion).answer as string) - : (question as IProgrammingQuestion).solutionTemplate - : null const workspaceProps: WorkspaceProps = { controlBarProps: this.controlBarProps(this.props, questionId), editorProps: question.type === QuestionTypes.programming ? { - editorValue: editorValue!, + editorValue: this.props.editorValue!, handleEditorEval: this.props.handleEditorEval, handleEditorValueChange: this.props.handleEditorValueChange, handleUpdateHasUnsavedChanges: this.props.handleUpdateHasUnsavedChanges @@ -165,6 +220,7 @@ class AssessmentWorkspace extends React.Component< return (
{overlay} + {resetOverlay}
) @@ -194,7 +250,7 @@ class AssessmentWorkspace extends React.Component< ? question.answer !== null ? ((question as IProgrammingQuestion).answer as string) : (question as IProgrammingQuestion).solutionTemplate - : null + : '' this.props.handleUpdateCurrentAssessmentId(assessmentId, questionId) this.props.handleResetWorkspace({ editorValue }) this.props.handleClearContext(question.library) @@ -285,6 +341,9 @@ class AssessmentWorkspace extends React.Component< this.props.assessment!.questions[questionId].id, this.props.editorValue! ), + onClickReset: () => { + this.setState({ showResetOverlay: true }) + }, questionProgress: [questionId + 1, this.props.assessment!.questions.length], sourceChapter: this.props.assessment!.questions[questionId].library.chapter } diff --git a/src/components/assessment/__tests__/__snapshots__/AssessmentWorkspace.tsx.snap b/src/components/assessment/__tests__/__snapshots__/AssessmentWorkspace.tsx.snap index dc954779c5..a3a3c8643e 100644 --- a/src/components/assessment/__tests__/__snapshots__/AssessmentWorkspace.tsx.snap +++ b/src/components/assessment/__tests__/__snapshots__/AssessmentWorkspace.tsx.snap @@ -10,6 +10,22 @@ exports[`AssessmentWorkspace page with MCQ question renders correctly 1`] = ` + +
+ + +
+
+ + + Cancel + + + Confirm + + +
+
" `; @@ -22,6 +38,22 @@ exports[`AssessmentWorkspace page with overdue assessment renders correctly 1`] + +
+ + +
+
+ + + Cancel + + + Confirm + + +
+
" `; @@ -34,6 +66,22 @@ exports[`AssessmentWorkspace page with programming question renders correctly 1` + +
+ + +
+
+ + + Cancel + + + Confirm + + +
+
" `; diff --git a/src/components/workspace/ControlBar.tsx b/src/components/workspace/ControlBar.tsx index 98c4f18176..56f3b4fb58 100644 --- a/src/components/workspace/ControlBar.tsx +++ b/src/components/workspace/ControlBar.tsx @@ -34,6 +34,7 @@ export type ControlBarProps = { onClickPrevious?(): any onClickReturn?(): any onClickSave?(): any + onClickReset?(): any } interface IChapter { @@ -59,7 +60,8 @@ class ControlBar extends React.PureComponent { hasShareButton: true, onClickNext: () => {}, onClickPrevious: () => {}, - onClickSave: () => {} + onClickSave: () => {}, + onClickReset: () => {} } private shareInputElem: HTMLInputElement @@ -127,10 +129,13 @@ class ControlBar extends React.PureComponent { this.props.hasChapterSelect && this.props.externalLibraryName !== undefined ? externalSelect(this.props.externalLibraryName, this.props.handleExternalSelect!) : undefined + const resetButton = this.props.hasSaveButton + ? controlButton('Reset', IconNames.REPEAT, this.props.onClickReset) + : undefined return (
{this.props.isRunning ? stopButton : runButton} {saveButton} - {shareButton} {chapterSelectButton} {externalSelectButton} + {shareButton} {chapterSelectButton} {externalSelectButton} {resetButton}
) } diff --git a/src/styles/_academy.scss b/src/styles/_academy.scss index e584891821..1905c06a4a 100644 --- a/src/styles/_academy.scss +++ b/src/styles/_academy.scss @@ -129,7 +129,8 @@ } } -.betcha-dialog { +.betcha-dialog, +.assessment-reset { span.warning { font-weight: bold; color: firebrick; From afd545744bac8870ed5ae07529240eee6f5c6e79 Mon Sep 17 00:00:00 2001 From: Shuming Date: Wed, 10 Apr 2019 17:57:42 +0800 Subject: [PATCH 4/4] Resolved merge conflicts --- .../assessment/AssessmentWorkspace.tsx | 24 +++++++++---------- src/components/workspace/ControlBar.tsx | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/assessment/AssessmentWorkspace.tsx b/src/components/assessment/AssessmentWorkspace.tsx index 1052b08940..0cd778bd64 100644 --- a/src/components/assessment/AssessmentWorkspace.tsx +++ b/src/components/assessment/AssessmentWorkspace.tsx @@ -85,8 +85,8 @@ class AssessmentWorkspace extends React.Component< showOverlay: false, showResetOverlay: false }; - this.props.handleEditorValueChange('') - }; + this.props.handleEditorValueChange(''); + } /** * After mounting (either an older copy of the assessment @@ -103,14 +103,14 @@ class AssessmentWorkspace extends React.Component< this.props.questionId >= this.props.assessment.questions.length ? this.props.assessment.questions.length - 1 : this.props.questionId - ] + ]; this.props.handleEditorValueChange( question.type === QuestionTypes.programming ? question.answer !== null ? ((question as IProgrammingQuestion).answer as string) : (question as IProgrammingQuestion).solutionTemplate : '' - ) + ); } } @@ -144,7 +144,7 @@ class AssessmentWorkspace extends React.Component< /> - ) + ); const resetOverlay = ( { - this.setState({ showResetOverlay: false }) + this.setState({ showResetOverlay: false }); this.props.handleEditorValueChange( (this.props.assessment!.questions[questionId] as IProgrammingQuestion) .solutionTemplate - ) - this.props.handleUpdateHasUnsavedChanges(true) + ); + this.props.handleUpdateHasUnsavedChanges(true); }, { minimal: false, intent: Intent.DANGER } )} @@ -185,7 +185,7 @@ class AssessmentWorkspace extends React.Component< this.props.questionId >= this.props.assessment.questions.length ? this.props.assessment.questions.length - 1 : this.props.questionId; - const question: IQuestion = this.props.assessment.questions[questionId] + const question: IQuestion = this.props.assessment.questions[questionId]; const workspaceProps: WorkspaceProps = { controlBarProps: this.controlBarProps(this.props, questionId), editorProps: @@ -250,14 +250,14 @@ class AssessmentWorkspace extends React.Component< ? question.answer !== null ? ((question as IProgrammingQuestion).answer as string) : (question as IProgrammingQuestion).solutionTemplate - : '' + : ''; this.props.handleUpdateCurrentAssessmentId(assessmentId, questionId); this.props.handleResetWorkspace({ editorValue }); this.props.handleClearContext(question.library); this.props.handleUpdateHasUnsavedChanges(false); if (editorValue) { this.props.handleEditorValueChange(editorValue); - }; + } } } @@ -343,7 +343,7 @@ class AssessmentWorkspace extends React.Component< this.props.editorValue! ), onClickReset: () => { - this.setState({ showResetOverlay: true }) + this.setState({ showResetOverlay: true }); }, questionProgress: [questionId + 1, this.props.assessment!.questions.length], sourceChapter: this.props.assessment!.questions[questionId].library.chapter diff --git a/src/components/workspace/ControlBar.tsx b/src/components/workspace/ControlBar.tsx index 3bda47e38c..6b1be54a42 100644 --- a/src/components/workspace/ControlBar.tsx +++ b/src/components/workspace/ControlBar.tsx @@ -134,7 +134,7 @@ class ControlBar extends React.PureComponent { : undefined; const resetButton = this.props.hasSaveButton ? controlButton('Reset', IconNames.REPEAT, this.props.onClickReset) - : undefined + : undefined; const startAutorunButton = this.props.hasEditorAutorunButton ? controlButton('Autorun', IconNames.PLAY, this.props.handleToggleEditorAutorun) : undefined;