Skip to content

Commit

Permalink
Merge pull request #45429 from code-dot-org/staging
Browse files Browse the repository at this point in the history
DTT (Staging > Test) [robo-dtt]
  • Loading branch information
dmcavoy committed Mar 22, 2022
2 parents 2a698c6 + 2ed2858 commit f280d6c
Show file tree
Hide file tree
Showing 74 changed files with 2,760 additions and 454 deletions.
77 changes: 75 additions & 2 deletions apps/src/lib/levelbuilder/unit-editor/CloneLessonDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import BaseDialog from '@cdo/apps/templates/BaseDialog';
import Button from '@cdo/apps/templates/Button';
import DialogFooter from '@cdo/apps/templates/teacherDashboard/DialogFooter';

const LevelCopyText = {
deepCopy: 'Deep Copy',
shallowCopy: 'Shallow Copy'
};

export default class CloneLessonDialog extends Component {
static propTypes = {
lessonId: PropTypes.number,
Expand All @@ -13,6 +18,8 @@ export default class CloneLessonDialog extends Component {

defaultState = {
destinationUnit: '',
levelCopyType: 'deepCopy',
newLevelSuffix: '',
saving: false,
cloneFailed: false,
cloneSucceeded: false,
Expand All @@ -28,11 +35,14 @@ export default class CloneLessonDialog extends Component {
this.setState({saving: true});
const csrfContainer = document.querySelector('meta[name="csrf-token"]');
let success = false;
const newLevelSuffix =
this.state.levelCopyType === 'deepCopy' && this.state.newLevelSuffix;

return fetch(`/lessons/${this.props.lessonId}/clone`, {
method: 'POST',
body: JSON.stringify({
destinationUnitName: this.state.destinationUnit
destinationUnitName: this.state.destinationUnit,
newLevelSuffix
}),
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -60,6 +70,9 @@ export default class CloneLessonDialog extends Component {
};

render() {
const savable =
this.state.destinationUnit &&
(this.state.levelCopyType === 'shallowCopy' || this.state.newLevelSuffix);
return (
<BaseDialog
cancelText="Cancel"
Expand Down Expand Up @@ -103,6 +116,51 @@ export default class CloneLessonDialog extends Component {
onChange={e => this.setState({destinationUnit: e.target.value})}
/>
</label>
<label>
Level copy type:{' '}
<select
className="levelCopySelector"
value={this.state.levelCopyType}
style={styles.dropdown}
onChange={e => this.setState({levelCopyType: e.target.value})}
>
{Object.keys(LevelCopyText).map(type => (
<option key={type} value={type}>
{LevelCopyText[type]}
</option>
))}
</select>
</label>
<table style={styles.table}>
<tbody>
<tr>
<td style={styles.tableCell}>Deep Copy (recommended)</td>
<td style={styles.tableCell}>
Create a new copy of each level within the lesson.
</td>
</tr>
<tr>
<td style={styles.tableCell}>Shallow Copy</td>
<td style={styles.tableCell}>
Share existing levels with the original lesson. This can
lead to problems later, so be sure you want this before
proceeding with this option.
</td>
</tr>
</tbody>
</table>
{this.state.levelCopyType === 'deepCopy' && (
<label>
Suffix to add when copying levels:{' '}
<input
type="text"
value={this.state.newLevelSuffix}
onChange={e =>
this.setState({newLevelSuffix: e.target.value})
}
/>
</label>
)}
{this.state.saving && <i className="fa fa-spinner fa-spin" />}
</div>
)}
Expand All @@ -113,11 +171,26 @@ export default class CloneLessonDialog extends Component {
onClick={this.onCloneClick}
text={'Clone'}
color={'orange'}
disabled={this.state.saving}
disabled={this.state.saving || !savable}
id="clone-lesson-button"
/>
)}
</DialogFooter>
</BaseDialog>
);
}
}

const styles = {
dropdown: {
width: 200
},
table: {
border: 'none',
marginBottom: 10
},
tableCell: {
border: '1px solid black',
padding: 3
}
};
4 changes: 3 additions & 1 deletion apps/src/templates/teacherDashboard/shapes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ export const assignmentUnitShape = PropTypes.shape({
name: PropTypes.string.isRequired,
path: PropTypes.string.isRequired,
lesson_extras_available: PropTypes.bool.isRequired,
text_to_speech_enabled: PropTypes.bool.isRequired
text_to_speech_enabled: PropTypes.bool.isRequired,
position: PropTypes.number
});

export const assignmentCourseVersionShape = PropTypes.shape({
id: PropTypes.number.isRequired,
key: PropTypes.string.isRequired,
version_year: PropTypes.string.isRequired,
content_root_id: PropTypes.number.isRequired,
name: PropTypes.string.isRequired,
Expand Down
54 changes: 39 additions & 15 deletions apps/src/templates/teacherDashboard/teacherDashboardTestHelpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export const testSection = {
id: 11,
courseId: 29,
courseOfferingId: 2,
courseVersionId: 3,
scriptId: null,
name: 'my_section',
loginType: 'word',
Expand All @@ -12,10 +14,11 @@ export const testSection = {
studentCount: 10,
code: 'PMTKVH'
};

export const noStudentsSection = {
id: 11,
courseId: 29,
courseOfferingId: 2,
courseVersionId: 3,
scriptId: null,
name: 'my_section',
loginType: 'word',
Expand Down Expand Up @@ -91,6 +94,7 @@ export const courseOfferings = {
course_versions: {
1: {
id: 1,
key: '2017',
version_year: '2017',
content_root_id: 10,
name: 'Course A',
Expand All @@ -104,12 +108,14 @@ export const courseOfferings = {
id: 1,
name: 'Course A',
path: '/s/coursea-2017',
lesson_extras_available: true
lesson_extras_available: true,
position: null
}
}
},
2: {
id: 2,
key: '2018',
version_year: '2018',
content_root_id: 11,
name: 'Course A',
Expand All @@ -123,7 +129,8 @@ export const courseOfferings = {
id: 2,
name: 'Course A (2018)',
path: '/s/coursea-2018',
lesson_extras_available: true
lesson_extras_available: true,
position: null
}
}
}
Expand All @@ -137,7 +144,8 @@ export const courseOfferings = {
course_versions: {
3: {
id: 3,
version_year: '2017',
key: '2017',
version_year: "'17-'18",
content_root_id: 12,
name: 'CS Discoveries 2017',
path: '/courses/csd-2017',
Expand All @@ -151,20 +159,23 @@ export const courseOfferings = {
name: 'Unit 1',
path: '/s/csd1-2017',
lesson_extras_available: false,
text_to_speech_enabled: false
text_to_speech_enabled: false,
position: 1
},
4: {
id: 4,
name: 'Unit 2',
path: '/s/csd2-2017',
lesson_extras_available: false,
text_to_speech_enabled: false
text_to_speech_enabled: false,
position: 2
}
}
},
4: {
id: 4,
version_year: '2018',
key: '2018',
version_year: "'18-'19",
content_root_id: 13,
name: 'CS Discoveries 2018',
path: '/courses/csd-2018',
Expand All @@ -178,14 +189,16 @@ export const courseOfferings = {
name: 'Unit 1',
path: '/s/csd1-2018',
lesson_extras_available: false,
text_to_speech_enabled: false
text_to_speech_enabled: false,
position: 1
},
6: {
id: 6,
name: 'Unit 2',
path: '/s/csd2-2018',
lesson_extras_available: false,
text_to_speech_enabled: false
text_to_speech_enabled: false,
position: 2
}
}
}
Expand All @@ -199,6 +212,7 @@ export const courseOfferings = {
course_versions: {
5: {
id: 5,
key: '2022',
version_year: '2022',
content_root_id: 14,
name: 'CS A',
Expand All @@ -213,14 +227,16 @@ export const courseOfferings = {
name: 'Unit 1',
path: '/s/csa1-2022',
lesson_extras_available: false,
text_to_speech_enabled: false
text_to_speech_enabled: false,
position: 1
},
8: {
id: 8,
name: 'Unit 2',
path: '/s/csa2-2022',
lesson_extras_available: false,
text_to_speech_enabled: false
text_to_speech_enabled: false,
position: 2
}
}
}
Expand All @@ -234,6 +250,7 @@ export const courseOfferings = {
course_versions: {
6: {
id: 6,
key: 'unversioned',
version_year: 'unversioned',
content_root_id: 15,
name: 'Flappy',
Expand All @@ -248,7 +265,8 @@ export const courseOfferings = {
name: 'Flappy',
path: '/s/flappy',
lesson_extras_available: false,
text_to_speech_enabled: false
text_to_speech_enabled: false,
position: null
}
}
}
Expand All @@ -262,6 +280,7 @@ export const courseOfferings = {
course_versions: {
7: {
id: 7,
key: 'unversioned',
version_year: 'unversioned',
content_root_id: 16,
name: 'Hello World',
Expand All @@ -276,7 +295,8 @@ export const courseOfferings = {
name: 'Hello World',
path: '/s/hello-world',
lesson_extras_available: false,
text_to_speech_enabled: false
text_to_speech_enabled: false,
position: null
}
}
}
Expand All @@ -290,6 +310,7 @@ export const courseOfferings = {
course_versions: {
8: {
id: 8,
key: 'unversioned',
version_year: 'unversioned',
content_root_id: 17,
name: 'Poem Art',
Expand All @@ -304,7 +325,8 @@ export const courseOfferings = {
name: 'Poem Art',
path: '/s/poem-art',
lesson_extras_available: false,
text_to_speech_enabled: false
text_to_speech_enabled: false,
position: null
}
}
}
Expand All @@ -318,6 +340,7 @@ export const courseOfferings = {
course_versions: {
9: {
id: 9,
key: 'unversioned',
version_year: 'unversioned',
content_root_id: 18,
name: 'Artist',
Expand All @@ -332,7 +355,8 @@ export const courseOfferings = {
name: 'Artist',
path: '/s/artist',
lesson_extras_available: false,
text_to_speech_enabled: false
text_to_speech_enabled: false,
position: null
}
}
}
Expand Down

0 comments on commit f280d6c

Please sign in to comment.