-
Notifications
You must be signed in to change notification settings - Fork 480
/
ChooseYourProgram.jsx
210 lines (194 loc) · 6.43 KB
/
ChooseYourProgram.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
import React from 'react';
import LabeledFormComponent from '../../form_components/LabeledFormComponent';
import {
PageLabels,
SectionHeaders,
TextFields
} from '@cdo/apps/generated/pd/teacher2021ApplicationConstants';
import {FormGroup, Row, Col} from 'react-bootstrap';
import {PROGRAM_CSD, PROGRAM_CSP} from './TeacherApplicationConstants';
export default class ChooseYourProgram extends LabeledFormComponent {
static labels = PageLabels.chooseYourProgram;
static associatedFields = [...Object.keys(PageLabels.chooseYourProgram)];
getNameForSelectedProgram() {
if (this.props.data.program === PROGRAM_CSD) {
return 'Discoveries';
} else if (this.props.data.program === PROGRAM_CSP) {
return 'Principles';
} else {
return 'Program';
}
}
render() {
// This should be kept consistent with the calculation logic in
// dashboard/app/models/pd/application/teacher2021_application.rb.
const csHowManyMinutes = parseInt(this.props.data.csHowManyMinutes, 10);
const csHowManyDaysPerWeek = parseInt(
this.props.data.csHowManyDaysPerWeek,
10
);
const csHowManyWeeksPerYear = parseInt(
this.props.data.csHowManyWeeksPerYear,
10
);
let courseHours = null;
if (
!isNaN(csHowManyMinutes) &&
!isNaN(csHowManyDaysPerWeek) &&
!isNaN(csHowManyWeeksPerYear)
) {
courseHours =
(csHowManyMinutes * csHowManyDaysPerWeek * csHowManyWeeksPerYear) / 60;
}
let courseNotes = null;
if (this.props.data.program && courseHours !== null) {
if (this.props.data.program.includes('Discoveries')) {
if (courseHours < 50) {
courseNotes = 'csd';
}
} else if (this.props.data.program.includes('Principles')) {
if (courseHours < 100) {
courseNotes = 'csp';
}
}
}
return (
<FormGroup>
<h3>Section 3: {SectionHeaders.chooseYourProgram}</h3>
{this.radioButtonsFor('program')}
{this.props.data.program === PROGRAM_CSD &&
this.checkBoxesFor('csdWhichGrades')}
{this.props.data.program === PROGRAM_CSP && (
<div>
{this.checkBoxesFor('cspWhichGrades')}
{this.radioButtonsFor('cspHowOffer')}
</div>
)}
<p>
<strong>Course hours =</strong> (number of minutes of one class){' '}
<strong> X </strong> (number of days per week the class will be
offered) <strong> X </strong> (number of weeks with the class)
</p>
<p>
Please provide information about your course implementation plans.{' '}
<a
href="https://docs.google.com/document/d/1DhvzoNElJcfGYLrp5sVnnqp0ShvsePUpp3JK7ihjFGM/edit"
target="_blank"
>
Click here
</a>{' '}
for guidance on our professional development recommendations depending
on the number of units you intend to teach.
</p>
<br />
{this.numberInputFor('csHowManyMinutes', {
style: {
width: '100px'
},
label: PageLabels.chooseYourProgram.csHowManyMinutes.replace(
'program',
this.getNameForSelectedProgram()
),
labelWidth: {md: 8},
controlWidth: {md: 4},
inlineControl: true
})}
{this.numberInputFor('csHowManyDaysPerWeek', {
style: {
width: '100px'
},
label: PageLabels.chooseYourProgram.csHowManyDaysPerWeek.replace(
'program',
this.getNameForSelectedProgram()
),
labelWidth: {md: 8},
controlWidth: {md: 4},
inlineControl: true
})}
{this.numberInputFor('csHowManyWeeksPerYear', {
style: {
width: '100px'
},
label: PageLabels.chooseYourProgram.csHowManyWeeksPerYear.replace(
'program',
this.getNameForSelectedProgram()
),
labelWidth: {md: 8},
controlWidth: {md: 4},
inlineControl: true
})}
{courseHours && (
<div style={{marginBottom: 30}}>
<Row>
<Col md={8}>
<div style={{textAlign: 'right'}}>
<strong>Course hours</strong>
</div>
</Col>
<Col md={4}>
<strong>{courseHours.toFixed(2)}</strong>
</Col>
</Row>
</div>
)}
{courseNotes === 'csp' && (
<p style={{color: 'red'}}>
Note: 50 or more hours of instruction per CS Principles section are
strongly recommended. We suggest checking with your school
administration to see if additional time can be allotted for this
course in 2020-21.
</p>
)}
{this.props.data.program === PROGRAM_CSD &&
this.checkBoxesFor('csdWhichUnits')}
{this.props.data.program === PROGRAM_CSP &&
this.checkBoxesFor('cspWhichUnits')}
{this.radioButtonsWithAdditionalTextFieldsFor('planToTeach', {
[TextFields.dontKnowIfIWillTeachExplain]: 'other'
})}
{this.radioButtonsWithAdditionalTextFieldsFor('replaceExisting', {
[TextFields.iDontKnowExplain]: 'other'
})}
{this.props.data.replaceExisting === 'Yes' &&
this.checkBoxesWithAdditionalTextFieldsFor('replaceWhichCourse', {
[TextFields.otherPleaseExplain]: 'other'
})}
</FormGroup>
);
}
/**
* @override
*/
static getDynamicallyRequiredFields(data) {
const requiredFields = [];
if (data.program === PROGRAM_CSD) {
requiredFields.push('csdWhichGrades', 'csdWhichUnits');
}
if (data.program === PROGRAM_CSP) {
requiredFields.push('cspWhichGrades', 'csdWhichUnits', 'cspHowOffer');
}
if (data.replaceExisting === 'Yes') {
requiredFields.push('replaceWhichCourse');
}
return requiredFields;
}
/**
* @override
*/
static processPageData(data) {
const changes = {};
if (data.program === PROGRAM_CSD) {
changes.cspWhichGrades = undefined;
changes.cspWhichUnits = undefined;
changes.cspHowOffer = undefined;
}
if (data.program === PROGRAM_CSP) {
changes.csdWhichGrades = undefined;
changes.csdWhichUnits = undefined;
}
if (data.replaceExisting !== 'Yes') {
changes.replaceWhichCourse = undefined;
}
return changes;
}
}