Skip to content

Commit ab2976d

Browse files
authored
Merge pull request #17 from ZiHawkEye/mission-editing
clone question shift question added
2 parents a0f1237 + 05dd14a commit ab2976d

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

src/components/incubator/editingWorkspaceSideContent/DeploymentTab.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,13 @@ export class DeploymentTab extends React.Component<IProps, { activeTab: number }
8080

8181
const globals = deployment.globals.map((symbol, i) => (
8282
<tr key={i}>
83-
<td className="col-xs-3" style={{ height: '2rem', width: '10rem', overflow: 'auto' }}>
84-
<div style={{ height: '2rem', width: '10rem', overflow: 'auto' }}>
83+
<td className="col-xs-3" style={{ width: '10rem' }}>
84+
<div style={{ width: '10rem' }}>
8585
{this.textareaContent(deploymentPath.concat(['globals', i, 0]))}
8686
</div>
8787
</td>
88-
<td className="col-xs-7" style={{ height: '2rem', width: '20rem', overflow: 'auto' }}>
89-
<div style={{ height: '2rem', width: '20rem', overflow: 'auto' }}>
90-
{this.globalValueTextareaContent(i)}
91-
</div>
88+
<td className="col-xs-7" style={{ width: '20rem' }}>
89+
<div style={{ width: '20rem' }}>{this.globalValueTextareaContent(i)}</div>
9290
</td>
9391
<td className="col-xs-2">
9492
{controlButton('Delete', IconNames.MINUS, this.handleGlobalDelete(i))}

src/components/incubator/editingWorkspaceSideContent/ManageQuestionTab.tsx

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ export class ManageQuestionTab extends React.Component<IProps, IState> {
4040
private manageQuestionTab = () => {
4141
return (
4242
<div>
43+
{controlButton(
44+
'Clone Current Question',
45+
IconNames.DOCUMENT,
46+
this.confirmSave(
47+
this.makeQuestion(() => this.props.assessment.questions[this.props.questionId])
48+
)
49+
)}
50+
<br />
4351
{controlButton(
4452
'Insert Programming Question',
4553
IconNames.FONT,
@@ -50,15 +58,43 @@ export class ManageQuestionTab extends React.Component<IProps, IState> {
5058
IconNames.CONFIRM,
5159
this.confirmSave(this.makeQuestion(mcqTemplate))
5260
)}
61+
<br />
5362
{controlButton(
5463
'Delete Current Question',
5564
IconNames.REMOVE,
56-
this.confirmSave(this.deleteQn)
65+
this.confirmSave(this.deleteQuestion)
66+
)}
67+
<br />
68+
{controlButton(
69+
'Shift Question Left',
70+
IconNames.CARET_LEFT,
71+
this.confirmSave(() => this.shiftQuestion(-1))
72+
)}
73+
{controlButton(
74+
'Shift Question Right',
75+
IconNames.CARET_RIGHT,
76+
this.confirmSave(() => this.shiftQuestion(1))
5777
)}
5878
</div>
5979
);
6080
};
6181

82+
private shiftQuestion = (dir: number) => {
83+
const assessment = this.props.assessment;
84+
const index = this.props.questionId;
85+
const question = assessment.questions[index];
86+
let questions = assessment.questions;
87+
questions = questions.slice(0, index).concat(questions.slice(index + 1));
88+
questions = questions
89+
.slice(0, index + dir)
90+
.concat([question])
91+
.concat(questions.slice(index + dir));
92+
assessment.questions = questions;
93+
// tslint:disable-next-line:no-console
94+
console.log(questions);
95+
this.props.updateAssessment(assessment);
96+
};
97+
6298
private makeQuestion = (template: () => any) => () => {
6399
const assessment = this.props.assessment;
64100
const index = this.props.questionId;
@@ -71,7 +107,7 @@ export class ManageQuestionTab extends React.Component<IProps, IState> {
71107
this.props.updateAssessment(assessment);
72108
};
73109

74-
private deleteQn = () => {
110+
private deleteQuestion = () => {
75111
const assessment = this.props.assessment;
76112
let questions = assessment.questions;
77113
const index = this.props.questionId;

0 commit comments

Comments
 (0)