Skip to content

Mission editing slang #512

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c4fe884
Removed previous button on first question, added divider
ZiHawkEye Mar 24, 2019
15d8749
Yarn format
ZiHawkEye Mar 24, 2019
079b843
Changeded help description
ZiHawkEye Mar 24, 2019
4b074f9
Merge pull request #12 from source-academy/mission-editing
gerhean Mar 24, 2019
f09f97c
fix import for firefox
gerhean Mar 24, 2019
0547d1f
max width for globals
ZiHawkEye Mar 24, 2019
eeeac40
merge
ZiHawkEye Mar 24, 2019
19044bb
symbols aligned
ZiHawkEye Mar 24, 2019
0cf76f4
increase abstraction
gerhean Mar 24, 2019
a254845
Merge pull request #13 from source-academy/mission-editing
gerhean Mar 24, 2019
01ffb72
manage questions give warning
gerhean Mar 24, 2019
22b7d80
Merge branch 'missionEditing-slang' of https://github.com/gerhean/cad…
gerhean Mar 24, 2019
1138294
UI change for deployment tab
ZiHawkEye Mar 24, 2019
03bdaa9
merge changes
gerhean Mar 24, 2019
de9f70a
Merge pull request #15 from source-academy/mission-editing
gerhean Mar 24, 2019
fb1353d
fixed maxGrade and maxXP calculation
gerhean Mar 24, 2019
6a173f2
added local/global switch
gerhean Mar 25, 2019
a7ee16c
adjust mcq options
gerhean Mar 25, 2019
60a7f64
split question template tab
gerhean Mar 25, 2019
c1cb2a7
swap answer and solutionTemplate
gerhean Mar 25, 2019
7460f3c
add reading
gerhean Mar 25, 2019
6ffe9cb
add grading deployment
gerhean Mar 25, 2019
a0f1237
Merge pull request #16 from source-academy/mission-editing
gerhean Mar 25, 2019
05dd14a
clone question shift question added
ZiHawkEye Mar 25, 2019
8aeb9ba
Merge branch 'missionEditing-slang' of https://github.com/gerhean/cad…
ZiHawkEye Mar 25, 2019
ab2976d
Merge pull request #17 from ZiHawkEye/mission-editing
gerhean Mar 25, 2019
9dce47b
fixed symbol formating
gerhean Mar 25, 2019
c45734c
Merge branch 'missionEditing-slang' of https://github.com/gerhean/cad…
ZiHawkEye Mar 26, 2019
de75912
changed manage questions ui
ZiHawkEye Mar 26, 2019
74dbeda
yarn format
ZiHawkEye Mar 26, 2019
ffde4ee
added more overview options
gerhean Mar 26, 2019
47e7da6
add editing persist
gerhean Mar 26, 2019
32bfb6a
Merge pull request #18 from ZiHawkEye/mission-editing
gerhean Mar 27, 2019
695eb8b
Update ManageQuestionTab.tsx
gerhean Mar 27, 2019
1fe386c
Merge branch 'mission-editing' into missionEditing-slang
gerhean Mar 27, 2019
1fcf63f
Merge pull request #19 from source-academy/mission-editing
gerhean Mar 27, 2019
c5e1344
small updates
gerhean Mar 31, 2019
4aa49ee
temp remove editor functionalites
gerhean Apr 2, 2019
b52dd08
yarn format
gerhean Apr 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/assessment/assessmentShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export interface IMCQQuestion extends IQuestion {

export interface IQuestion {
answer: string | number | null;
editorValue?: string | null;
comment: string | null;
content: string;
id: number;
Expand Down
55 changes: 29 additions & 26 deletions src/components/incubator/EditingWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,15 @@ class AssessmentWorkspace extends React.Component<AssessmentWorkspaceProps, ISta
null,
() => {
const assessment = retrieveLocalAssessment()!;
this.handleRefreshLibrary();
this.setState({
assessment,
hasUnsavedChanges: false,
showResetOverlay: false,
originalMaxGrade: this.getMaxMarks('maxGrade'),
originalMaxXp: this.getMaxMarks('maxXp')
});
this.handleRefreshLibrary();
this.resetEditorValue();
},
{ minimal: false, intent: Intent.DANGER }
)}
Expand All @@ -248,24 +249,16 @@ class AssessmentWorkspace extends React.Component<AssessmentWorkspaceProps, ISta
this.props.storedAssessmentId !== assessmentId ||
this.props.storedQuestionId !== questionId
) {
const question = this.state.assessment!.questions[questionId];
const editorValue =
question.type === QuestionTypes.programming
? (question as IProgrammingQuestion).solutionTemplate || ''
: null;
this.resetEditorValue(false);
this.props.handleUpdateCurrentAssessmentId(assessmentId, questionId);
this.handleRefreshLibrary();
this.props.handleUpdateHasUnsavedChanges(false);
if (editorValue && !this.state.editorPersist) {
this.props.handleResetWorkspace({ editorValue });
this.props.handleEditorValueChange(editorValue);
}
if (this.state.hasUnsavedChanges) {
this.setState({
assessment: retrieveLocalAssessment(),
hasUnsavedChanges: false
});
}
this.handleRefreshLibrary();
}
}

Expand All @@ -291,22 +284,32 @@ class AssessmentWorkspace extends React.Component<AssessmentWorkspaceProps, ISta
this.props.handleClearContext(library);
};

private resetEditorValue = () => {
if (!this.state.editorPersist) {
private resetEditorValue = (checkPersist: boolean = true) => {
if (checkPersist || !this.state.editorPersist) {
const question: IQuestion = this.state.assessment!.questions[this.formatedQuestionId()];
const editorValue =
question.type === QuestionTypes.programming
? ((question as IProgrammingQuestion).solutionTemplate as string)
: '//If you see this, this is a bug. Please report bug.';
let editorValue: string;
if (question.type === QuestionTypes.programming) {
if (question.editorValue) {
editorValue = question.editorValue;
} else {
editorValue = (question as IProgrammingQuestion).solutionTemplate as string;
}
} else {
editorValue = '//If you see this, this is a bug. Please report bug.';
}
this.props.handleResetWorkspace({ editorValue });
this.props.handleEditorValueChange(editorValue);
}
};

private handleSave = () => {
const assessment = this.state.assessment!;
assessment.questions[this.formatedQuestionId()].editorValue = this.props.editorValue;
this.setState({
assessment,
hasUnsavedChanges: false
});
storeLocalAssessment(this.state.assessment!);
storeLocalAssessment(assessment);
// this.handleRefreshLibrary();
this.handleSaveGradeAndXp();
};
Expand Down Expand Up @@ -371,11 +374,11 @@ class AssessmentWorkspace extends React.Component<AssessmentWorkspaceProps, ISta
});
};

private toggleEditorPersist = () => {
this.setState({
editorPersist: !this.state.editorPersist
});
};
// private toggleEditorPersist = () => {
// this.setState({
// editorPersist: !this.state.editorPersist
// });
// };

/** Pre-condition: IAssessment has been loaded */
private sideContentProps: (p: AssessmentWorkspaceProps, q: number) => SideContentProps = (
Expand Down Expand Up @@ -561,9 +564,9 @@ class AssessmentWorkspace extends React.Component<AssessmentWorkspaceProps, ISta
questionProgress: [questionId + 1, this.state.assessment!.questions.length],
sourceChapter: this.state.assessment!.questions[questionId].library.chapter,
editingMode: this.state.editingMode,
toggleEditMode: this.toggleEditingMode,
isEditorPersist: this.state.editorPersist,
handleToggleEditorPersist: this.toggleEditorPersist
toggleEditMode: this.toggleEditingMode
// isEditorPersist: this.state.editorPersist,
// handleToggleEditorPersist: this.toggleEditorPersist
};
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,6 @@ export class ManageQuestionTab extends React.Component<IProps, IState> {
IconNames.CONFIRM,
this.confirmSave(this.makeQuestion(mcqTemplate, index))
)}
<br />
{index > 0
? controlButton(
'Shift Question Left',
IconNames.CARET_LEFT,
this.confirmSave(this.shiftQuestion(-1))
)
: undefined}
{index < this.props.assessment.questions.length - 1
? controlButton(
'Shift Question Right',
IconNames.CARET_RIGHT,
this.confirmSave(this.shiftQuestion(1))
)
: undefined}
</div>
);
};
Expand Down
8 changes: 6 additions & 2 deletions src/components/workspace/ControlBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class ControlBar extends React.PureComponent<ControlBarProps, {}> {
? controlButton('Reset', IconNames.REPEAT, this.props.onClickReset)
: undefined;
const editorPersistSwitch =
this.props.handleToggleEditorPersist !== null
this.props.handleToggleEditorPersist !== undefined
? controlButton(
'Editor Persistence ' + (this.props.isEditorPersist ? 'Enabled' : 'Disabled'),
this.props.isEditorPersist ? IconNames.TICK : IconNames.CROSS,
Expand Down Expand Up @@ -205,7 +205,11 @@ class ControlBar extends React.PureComponent<ControlBarProps, {}> {
' editing mode.'
}
>
{controlButton('Switch editing mode', IconNames.REFRESH, this.props.toggleEditMode)}
{controlButton(
this.props.editingMode + ' editing mode',
IconNames.REFRESH,
this.props.toggleEditMode
)}
</Tooltip>
) : (
undefined
Expand Down