Skip to content

Commit fb637cd

Browse files
authored
Mission editing slang (#517)
* Removed previous button on first question, added divider * Yarn format * Changeded help description * fix import for firefox * max width for globals * symbols aligned * increase abstraction removed numberRange from textArea Reduced save frequency of solutionTemplate * manage questions give warning * UI change for deployment tab * fixed maxGrade and maxXP calculation * added local/global switch * adjust mcq options * split question template tab added suggested answer editing * swap answer and solutionTemplate internal change * add reading * add grading deployment * clone question shift question added * fixed symbol formating * changed manage questions ui * yarn format * added more overview options * add editing persist * Update ManageQuestionTab.tsx * small updates editor value now saved * temp remove editor functionalites * yarn format * remove edit persist
1 parent 9cfa385 commit fb637cd

File tree

2 files changed

+12
-36
lines changed

2 files changed

+12
-36
lines changed

src/components/incubator/EditingWorkspace.tsx

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ interface IState {
8181
assessment: IAssessment | null;
8282
activeTab: number;
8383
editingMode: string;
84-
editorPersist: boolean;
8584
hasUnsavedChanges: boolean;
8685
showResetOverlay: boolean;
8786
originalMaxGrade: number;
@@ -95,7 +94,6 @@ class AssessmentWorkspace extends React.Component<AssessmentWorkspaceProps, ISta
9594
assessment: retrieveLocalAssessment(),
9695
activeTab: 0,
9796
editingMode: 'question',
98-
editorPersist: false,
9997
hasUnsavedChanges: false,
10098
showResetOverlay: false,
10199
originalMaxGrade: 0,
@@ -222,7 +220,6 @@ class AssessmentWorkspace extends React.Component<AssessmentWorkspaceProps, ISta
222220
originalMaxXp: this.getMaxMarks('maxXp')
223221
});
224222
this.handleRefreshLibrary();
225-
this.resetEditorValue();
226223
},
227224
{ minimal: false, intent: Intent.DANGER }
228225
)}
@@ -249,7 +246,7 @@ class AssessmentWorkspace extends React.Component<AssessmentWorkspaceProps, ISta
249246
this.props.storedAssessmentId !== assessmentId ||
250247
this.props.storedQuestionId !== questionId
251248
) {
252-
this.resetEditorValue(false);
249+
this.resetEditorValue();
253250
this.props.handleUpdateCurrentAssessmentId(assessmentId, questionId);
254251
this.props.handleUpdateHasUnsavedChanges(false);
255252
if (this.state.hasUnsavedChanges) {
@@ -284,22 +281,20 @@ class AssessmentWorkspace extends React.Component<AssessmentWorkspaceProps, ISta
284281
this.props.handleClearContext(library);
285282
};
286283

287-
private resetEditorValue = (checkPersist: boolean = true) => {
288-
if (checkPersist || !this.state.editorPersist) {
289-
const question: IQuestion = this.state.assessment!.questions[this.formatedQuestionId()];
290-
let editorValue: string;
291-
if (question.type === QuestionTypes.programming) {
292-
if (question.editorValue) {
293-
editorValue = question.editorValue;
294-
} else {
295-
editorValue = (question as IProgrammingQuestion).solutionTemplate as string;
296-
}
284+
private resetEditorValue = () => {
285+
const question: IQuestion = this.state.assessment!.questions[this.formatedQuestionId()];
286+
let editorValue: string;
287+
if (question.type === QuestionTypes.programming) {
288+
if (question.editorValue) {
289+
editorValue = question.editorValue;
297290
} else {
298-
editorValue = '//If you see this, this is a bug. Please report bug.';
291+
editorValue = (question as IProgrammingQuestion).solutionTemplate as string;
299292
}
300-
this.props.handleResetWorkspace({ editorValue });
301-
this.props.handleEditorValueChange(editorValue);
293+
} else {
294+
editorValue = '//If you see this, this is a bug. Please report bug.';
302295
}
296+
this.props.handleResetWorkspace({ editorValue });
297+
this.props.handleEditorValueChange(editorValue);
303298
};
304299

305300
private handleSave = () => {
@@ -374,12 +369,6 @@ class AssessmentWorkspace extends React.Component<AssessmentWorkspaceProps, ISta
374369
});
375370
};
376371

377-
// private toggleEditorPersist = () => {
378-
// this.setState({
379-
// editorPersist: !this.state.editorPersist
380-
// });
381-
// };
382-
383372
/** Pre-condition: IAssessment has been loaded */
384373
private sideContentProps: (p: AssessmentWorkspaceProps, q: number) => SideContentProps = (
385374
props: AssessmentWorkspaceProps,
@@ -565,8 +554,6 @@ class AssessmentWorkspace extends React.Component<AssessmentWorkspaceProps, ISta
565554
sourceChapter: this.state.assessment!.questions[questionId].library.chapter,
566555
editingMode: this.state.editingMode,
567556
toggleEditMode: this.toggleEditingMode
568-
// isEditorPersist: this.state.editorPersist,
569-
// handleToggleEditorPersist: this.toggleEditorPersist
570557
};
571558
};
572559
}

src/components/workspace/ControlBar.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ export type ControlBarProps = {
2626
handleReplEval: () => void;
2727
handleReplOutputClear: () => void;
2828
handleToggleEditorAutorun?: () => void;
29-
handleToggleEditorPersist?: () => void;
3029
hasChapterSelect: boolean;
3130
hasEditorAutorunButton: boolean;
3231
hasSaveButton: boolean;
3332
hasShareButton: boolean;
3433
hasUnsavedChanges?: boolean;
35-
isEditorPersist?: boolean;
3634
isEditorAutorun?: boolean;
3735
isRunning: boolean;
3836
editingMode?: string;
@@ -146,22 +144,13 @@ class ControlBar extends React.PureComponent<ControlBarProps, {}> {
146144
this.props.onClickReset !== null
147145
? controlButton('Reset', IconNames.REPEAT, this.props.onClickReset)
148146
: undefined;
149-
const editorPersistSwitch =
150-
this.props.handleToggleEditorPersist !== undefined
151-
? controlButton(
152-
'Editor Persistence ' + (this.props.isEditorPersist ? 'Enabled' : 'Disabled'),
153-
this.props.isEditorPersist ? IconNames.TICK : IconNames.CROSS,
154-
this.props.handleToggleEditorPersist
155-
)
156-
: undefined;
157147
return (
158148
<div className="ControlBar_editor pt-button-group">
159149
{this.props.isEditorAutorun ? undefined : this.props.isRunning ? stopButton : runButton}
160150
{saveButton}
161151
{shareButton} {chapterSelectButton} {externalSelectButton}
162152
{this.props.isEditorAutorun ? stopAutorunButton : startAutorunButton}
163153
{resetButton}
164-
{editorPersistSwitch}
165154
</div>
166155
);
167156
}

0 commit comments

Comments
 (0)