Skip to content

Commit

Permalink
Name onChange callback argument better
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremywiebe committed Aug 2, 2024
1 parent da01fd0 commit 0d45f3a
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions packages/perseus-editor/src/item-extras-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class ItemExtrasEditor extends React.Component<Props> {
label="Show calculator"
infoTip="Use the calculator when completing difficult calculations is NOT the intent of the question. DON’T use the calculator when testing the student’s ability to complete different types of computations."
checked={this.props.calculator}
onChange={(e) => {
onChange={(newCheckedState) => {
this.props.onChange({
calculator: e,
calculator: newCheckedState,
});
}}
/>
Expand All @@ -61,14 +61,16 @@ class ItemExtrasEditor extends React.Component<Props> {
label="Show financial calculator"
infoTip="This provides the student with the ability to view a financial calculator, e.g., for answering financial questions. Once checked, requires at least one of the three options below to be checked."
checked={this.shouldShowFinancialCalculatorOptions()}
onChange={(e) => {
onChange={(newCheckedState) => {
// If the financial calculator is unchecked,
// these need to be reset. All checked by
// default.
this.props.onChange({
financialCalculatorMonthlyPayment: e,
financialCalculatorTotalAmount: e,
financialCalculatorTimeToPayOff: e,
financialCalculatorMonthlyPayment:
newCheckedState,
financialCalculatorTotalAmount: newCheckedState,
financialCalculatorTimeToPayOff:
newCheckedState,
});
}}
/>
Expand All @@ -81,9 +83,10 @@ class ItemExtrasEditor extends React.Component<Props> {
checked={
this.props.financialCalculatorMonthlyPayment
}
onChange={(e) => {
onChange={(newCheckedState) => {
this.props.onChange({
financialCalculatorMonthlyPayment: e,
financialCalculatorMonthlyPayment:
newCheckedState,
});
}}
indent
Expand All @@ -94,9 +97,10 @@ class ItemExtrasEditor extends React.Component<Props> {
checked={
this.props.financialCalculatorTotalAmount
}
onChange={(e) => {
onChange={(newCheckedState) => {
this.props.onChange({
financialCalculatorTotalAmount: e,
financialCalculatorTotalAmount:
newCheckedState,

Check warning on line 103 in packages/perseus-editor/src/item-extras-editor.tsx

View check run for this annotation

Codecov / codecov/patch

packages/perseus-editor/src/item-extras-editor.tsx#L103

Added line #L103 was not covered by tests
});
}}
indent
Expand All @@ -107,9 +111,10 @@ class ItemExtrasEditor extends React.Component<Props> {
checked={
this.props.financialCalculatorTimeToPayOff
}
onChange={(e) => {
onChange={(newCheckedState) => {
this.props.onChange({
financialCalculatorTimeToPayOff: e,
financialCalculatorTimeToPayOff:
newCheckedState,

Check warning on line 117 in packages/perseus-editor/src/item-extras-editor.tsx

View check run for this annotation

Codecov / codecov/patch

packages/perseus-editor/src/item-extras-editor.tsx#L117

Added line #L117 was not covered by tests
});
}}
indent
Expand All @@ -121,9 +126,9 @@ class ItemExtrasEditor extends React.Component<Props> {
label="Show periodic table"
infoTip="This provides the student with the ability to view a periodic table of the elements, e.g., for answering chemistry questions."
checked={this.props.periodicTable}
onChange={(e) => {
onChange={(newCheckedState) => {
this.props.onChange({
periodicTable: e,
periodicTable: newCheckedState,
// If the periodic table is unchecked,
// this needs to be reset. If table is
// checked, it should already be false.
Expand All @@ -137,9 +142,9 @@ class ItemExtrasEditor extends React.Component<Props> {
label="Include key/legend with periodic table"
infoTip="Include a key for HS courses; omit for AP chemistry."
checked={this.props.periodicTableWithKey}
onChange={(e) => {
onChange={(newCheckedState) => {
this.props.onChange({
periodicTableWithKey: e,
periodicTableWithKey: newCheckedState,

Check warning on line 147 in packages/perseus-editor/src/item-extras-editor.tsx

View check run for this annotation

Codecov / codecov/patch

packages/perseus-editor/src/item-extras-editor.tsx#L147

Added line #L147 was not covered by tests
});
}}
indent
Expand All @@ -150,9 +155,9 @@ class ItemExtrasEditor extends React.Component<Props> {
label="Show z table (statistics)"
infoTip="This provides the student with the ability to view a table of critical values for the z distribution, e.g. for answering statistics questions."
checked={this.props.zTable}
onChange={(e) => {
onChange={(newCheckedState) => {
this.props.onChange({
zTable: e,
zTable: newCheckedState,

Check warning on line 160 in packages/perseus-editor/src/item-extras-editor.tsx

View check run for this annotation

Codecov / codecov/patch

packages/perseus-editor/src/item-extras-editor.tsx#L160

Added line #L160 was not covered by tests
});
}}
/>
Expand All @@ -161,9 +166,9 @@ class ItemExtrasEditor extends React.Component<Props> {
label="Show t table (statistics)"
infoTip="This provides the student with the ability to view a table of critical values for the Student's t distribution, e.g. for answering statistics questions."
checked={this.props.tTable}
onChange={(e) => {
onChange={(newCheckedState) => {
this.props.onChange({
tTable: e,
tTable: newCheckedState,

Check warning on line 171 in packages/perseus-editor/src/item-extras-editor.tsx

View check run for this annotation

Codecov / codecov/patch

packages/perseus-editor/src/item-extras-editor.tsx#L171

Added line #L171 was not covered by tests
});
}}
/>
Expand All @@ -172,9 +177,9 @@ class ItemExtrasEditor extends React.Component<Props> {
label="Show chi-squared table (statistics)"
infoTip="This provides the student with the ability to view a table of critical values for the chi-squared distribution, e.g. for answering statistics questions."
checked={this.props.chi2Table}
onChange={(e) => {
onChange={(newCheckedState) => {
this.props.onChange({
chi2Table: e,
chi2Table: newCheckedState,

Check warning on line 182 in packages/perseus-editor/src/item-extras-editor.tsx

View check run for this annotation

Codecov / codecov/patch

packages/perseus-editor/src/item-extras-editor.tsx#L182

Added line #L182 was not covered by tests
});
}}
/>
Expand All @@ -188,7 +193,7 @@ const ItemExtraCheckbox = (props: {
label: string;
infoTip: string;
checked: boolean;
onChange: (newState: boolean) => void;
onChange: (newCheckedState: boolean) => void;
indent?: boolean;
}) => (
<View style={[styles.checkbox, props.indent ? styles.indented : undefined]}>
Expand All @@ -199,7 +204,7 @@ const ItemExtraCheckbox = (props: {
</View>
}
checked={props.checked}
onChange={(newState) => props.onChange(newState)}
onChange={(newCheckedState) => props.onChange(newCheckedState)}
/>
</View>
);
Expand Down

0 comments on commit 0d45f3a

Please sign in to comment.